I am looking for a solution following best practices to simply periodically validate database entries against some business logic. For instance, I have the database with employees, and another table with incoming calls. My service should periodically run the validation task (or tasks, it might be a lot of business rules), which checks if we have missed call(s) for employee in "calls" table and sends a message to assigned employee.
My first thoughts was:
- Create some JobManager, which has such methods: "RegisterJob", "UnregisterJob", "ExecuteJob"
- Create "JobHandler" which takes job result and decides what to do (e.g. send a message in case missed call found.
- Create and implement "IJob" interface, which takes all the logic inside.
But, I think it is some kind of very simple and rough solution. Maybe, there are some better ideas?
-
1For C#, consider a library such as Quartz.NET, or even just the built-in Windows scheduler. Related question on SO: stackoverflow.com/questions/13788488/…Ben Cottrell– Ben Cottrell2017年08月05日 18:25:48 +00:00Commented Aug 5, 2017 at 18:25
1 Answer 1
Write a program that queries the DB and does the things it needs to do. Run it as a scheduled task using the tools provided by the target operating system.
Job done.
Don't write your own scheduler. Don't write your own message queue or "processing engine" or other junk.
Don't clutter it up with IJobSchedulerManagerFactoryMockDataControllerProvider
nonsense. If anything beyond the basics are required they will become apparent as you solve the problem at hand. Do that first.
-
Initially it was my plan, but due to requirements, we need to do it using WindowsService only.Alex– Alex2017年08月07日 09:39:47 +00:00Commented Aug 7, 2017 at 9:39
-
Simple and clear. Windows is full of managing tools that you can handle using .NET. There is no need of rewritting them.MartinS– MartinS2017年08月08日 12:10:15 +00:00Commented Aug 8, 2017 at 12:10
-
@Alex The answer provided is applicable to windows services as well; you use a timer within the service. But watch out for threading issues depending on the timer you use. The advice to stick with something simple is always sound. Expand your design in the future at the point you need that expansion.Frank Hileman– Frank Hileman2017年08月10日 22:44:09 +00:00Commented Aug 10, 2017 at 22:44
Explore related questions
See similar questions with these tags.