Scenario:
- Read files from different servers. Each server provide files with different format, extension and data.
- The reading process is periodically different for each server (per minute, hour, weekly, monthly).
- There should be config file (or whatever) to set the configuration related to “File format”, “File extension”, “Server credentials”.
My Implementation:
I wrote an application to read these different files depending on configuration set as follow:
interface IServer
{
// Common implementation
}
[ServerPath("anyLocation")]
[FileDelimiter(",")]
[FileSearchPattern("*.txt")]
class Server2 : IServer
{
// Specific implementation
}
[ServerPath("anyLocation")]
[FileDelimiter("|")]
[FileSearchPattern("*.csv")]
class Server1 : IServer
{
// Specific implementation
}
Questions:
- Should I use a windows service to run this app?
- The settings I set as attributes should exists as settings accessible to the user, How to do?
- Most importantly, I don’t know if I should use a separate service for each server, taking into consideration that reading time may interfere (what happen in that case?). I still prefer to have a single service.
I wouldn’t create a windows service for this kind of problem.
Create a simple console application that accepts a commend line parameter to specify the desired target (server) and read the according configuration from a simple App.config instead of hardcoding it into your app.
Run your console app useing Scheduled Tasks – this will give you fine grained scheduling control, built in monitoring and error tracking without any additional code.