连接我的组件? [英] Connect my components?

查看:60
本文介绍了连接我的组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时会将大文件放入我们公司Internet上的Windows文件夹中,无论何时,都应将其插入数据库中的临时表中。



数据库将按计划使用登台表。 Oracle数据库位于UNIX端,文件位于Windows端。



我尝试过:



(1)我大部分时间都在C#中实现了一个Windows服务,该服务在给定XML配置文件的情况下持续监视文件夹的更改,并且



(2)如果给出了文件名和相同的XML配置文件,我已经完成了一个使用Managed Oracle Client的高效导入器。



问题:



如何使用最佳实践连接这两个组件?我希望(1)调用(2)为每个文件生成一个单独的线程。那么我使用线程,背景工作者还是任务?



我喜欢在新的大文件更改完毕后触发事件的想法。



我喜欢订阅这个活动并用这些知识做任何你喜欢的事情。



但是我想保持简单。

解决方案

有几种方法,但最好的做法是我似乎 WCF (Windows Communication Foundation)。

如果您的组件在同一台机器上,命名管道将是我认为最有效的。

这是一个命名管道示例: WCF教程 - 基本进程间通信 - Tech.pro [ ^ ]

您可以在这里找到更多样本: Windows Communication Foundation(WCF)示例 [ ^ ]

这里有一个关于CodeProject的例子:一个简单的样本:WCF服务 [ ^ ]

Occasionally a large file is dropped into a Windows folder on our corporate Internet, and whenever it is, it should be inserted into a staging table in the database.

The database will consume the staging table on a schedule. The Oracle database is on the UNIX side, and the files are on the Windows side.

What I have tried:

(1) I have mostly finished implementing a Windows service in C# which continuously watches the folder for changes given an XML config file, and

(2) I have finished implementing an efficient importer which uses the Managed Oracle Client if it is given the file name and the same XML config file.

Question:

How do I connect the two components using best practices? I want to have (1) call (2) spawning a separate thread for each file. So do I use Threading, Background Workers, or Tasks?

I like the idea of an event which fires when a new large file has finished changing.

I like the idea of subscribing to this event and doing whatever you like with that knowledge.

Yet I want to keep it simple.

解决方案

There are several ways, but best practice to me seems WCF (Windows Communication Foundation).
If your components are on the same machine, named pipes would be the most efficient I think.
Here is a named pipe example: WCF Tutorial - Basic Interprocess Communication - Tech.pro[^]
You can find more samples here: Windows Communication Foundation (WCF) Samples[^]
And an example on CodeProject here: A Simple Sample: WCF Service[^]


这篇关于连接我的组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆