n個のクライアントデータベースからデータを取得し、結果セットをXLS形式に変換して、クライアントが指定した間隔で対応する(クライアント固有の)FTPアカウントに送信するWindowsサービスを構築する必要があります。
別の言い方をすると、同じWindowsサービスが複数のデータベースに接続し、異なるFTPアカウントにファイルを送信し、接続されているクライアントDBに基づいて異なる間隔で実行されます。
私の質問は、複数のシナリオを柔軟に処理し、より構成可能になるように、どのように設計すればよいかということです。
この背後にある基本的な考え方は、新しいクライアントが同じサービスを要求したときに、将来的に実装時間を最小限に抑えることです。
個々のクライアントを個別のワーカースレッドに設定できる次のアイデアを検討しています。私はこのアプローチで何かがひどく間違っていることを知っていますが、最善の方法を理解できないようです。
部分的なコードは次のとおりです。
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
}
私が意味をなさない場合はお知らせください。まったく新しいアプローチを模索する用意があります。
コードサンプルが役立ちます。
よろしくお願いします!