我必须构建一个从n个客户端数据库获取数据的Windows服务,将结果集转换为XLS格式并将其发送到客户端的相应(客户端特定)FTP帐户指定的时间间隔,用于多个客户端数据库和FTP帐户的通用Windows服务
下面是放置它的另一种方式: 相同的Windows服务将连接到多个数据库,将文件发送到不同的FTP帐户,并根据连接到的客户端数据库以不同的时间间隔运行。
我的问题是,我应该如何设计它,以便它可以灵活处理多个场景并且更具可配置性。
这个背后的基本思想是最大限度地减少新客户端要求相同服务时的实施时间。
我正在考虑以下想法,其中可以将单个客户端设置为单独的工作线程。我知道这种方法有些严重错误,但似乎无法找出最佳方法。
这里的部分代码:
private static void Main(string[] args)
{
// Initialize the first worker thread.
NewUserThread newUserThread = new NewUserThread();
// Specify properties of this worker thread.
newUserThread.Name = "New User Check";
newUserThread.Delay = 0;
newUserThread.Interval = 2 * 60 * 1000;
// Initialize the second worker thread.
UserUpdateThread userUpdateThread = new UserUpdateThread();
// Specify properties of this worker thread.
userUpdateThread.Name = "User Update Check";
userUpdateThread.Delay = 30 * 1000;
userUpdateThread.Interval= 5 * 60 * 1000;
// Initialize the first Windows service objects.
WindowsService userCheckService = new WindowsService();
userCheckService.ServiceName = UserCheckServiceName;
// Initialize the second Windows service objects.
WindowsService emailService = new WindowsService();
emailService.ServiceName = EmailServiceName;
// Add services to an array.
ServiceBase[] services = new ServiceBase[]
{
userCheckService,
emailService,
};
// Launch services.
SendFiles("Launching services...");
Run(services, args);
}
internal static void (string message, params object[] args)
{
// Call to DB
// Convert dataset to XLS
// Send to FTP
}
让我知道,如果我没有做任何意义,我很开放,探索一种全新的方法。
代码示例将有所帮助。
非常感谢!
嗨,首席,由于我必须履行的项目的一些要求,我无法使用此设置,但我觉得这是一个很好的体系结构,我会记住另一个项目。 +1 – Learner 2013-02-20 18:47:04