The project I'm working on requires certain accomplishments at a specific time. I am not sure what would be the best way to deal with this situation. The method should be able to withstand server restart / maintenance. And method calls must be programmatic.
I am considering moving along this path:
I could have a table in the database (or even a message queue) called TaskTable, which could have TaskID (PK), TaskName (varchar), TaskStatus (enumeration success, failed, scheduled) and TimeOfExecution. But I need a Windows service that periodically examines the database for any outstanding tasks. The problem I am facing is this: what am I using as a TaskName to save to the database? Class name? class and method name ToString? And how can I convert the string back and programmatically call method calls (I don't want to have a giant switch statement)? A typical task will look below. Thus, I could get the name of the task "SendIncompleteNotification" and the name of the class, to save it in the database, and programmatically when programmed again
public static Task<string> SendIncompleteNotification
{
get
{
return new Task<string>
(
a => Console.WriteLine("Sample Task")
, "This is a sample task which does nothing."
);
}
}
, /.
var type = ApplicationTask.SendIncompleteNotification.GetType();
//type.Name shows "Task`1" rather than SendIncompleteNotification
? !
:
, . , , /, . , , - , . db, .