Question

I have developed a Windows service in C# which has a functionality to send emails on a scheduled basis to the users. Now this service is to be deployed for a large number of clients (say, 50) who actually access the same server. Each client have a dedicated DB on this server, obviously. Hence, their configurations like the Database connection strings, schedule and time interval for running the service vary.

Please advise now:

  1. Is it a good practice to deploy the service per client ?(ie 50 services for 50 clients). Imagine the list of services in the Computer Management> Services

  2. I have now used a separate configuration file which is not a part of the project which therefore wouldn't require compilation. My service now reads from this config file where it is easy to make changes. What is the best method to manage configuration files, anyway?

I hope I will find some good suggestions for my very first question at stackoverflow. Thanks!

Was it helpful?

Solution

I don't think this is the right approach:

  • A windows service is always on. Within this service you need to implement a scheduling mechanism using something like Timer, if you need to then you can also implement a job engine within the windows service for clients to handle tasks for clients on different threads
  • I don't see why you need a separate database for each client. This is not the point of a database, usually you would use a single SQL Server instance and database to store all the data, and implement the table structure so that you can associate any given data record to a user.
  • Therefore I would not deploy a service per client, but a single service with a single database

As an aside, most visual studio .net projects (and certainly the windows service project) gives you the ability to use an app.config file (or web.config file for web projects) which is used for application configuration - this should be the first choice for having common configuration which shouldn't need recompliation to be changed. This is usually part of the project.

It is unlikely that, for this vague a question, you are going to get anyone to offer code samples or more than this. You should try things out for yourself based on these suggestions, and then ask specific questions that are not too vague (links provided to guidance on appropriate questions). Oh, and welcome to SO.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top