protected override void OnStart(string[] args) { ReportLogger.AddMessage("CoreData Report Service", "Started"); coreDataReportTimer = new Timer(MILLISECONDS_IN_60_MINUTES); coreDataReportTimer.Enabled = true; coreDataReportTimer.Elapsed += coreDataReportTimer_Elapsed; checkTimer = new Timer(60000); checkTimer.Enabled = true; checkTimer.Elapsed += CheckTimerOnElapsed; }
public override bool Run() { if (DueToRun()) { ReportLogger.AddMessage("Trello", "Passed Due To Run."); ReportLogger reportLogger = new ReportLogger(Name); int stepId = reportLogger.AddStep(); try { ReportLogger.AddMessage("Trello", "Running"); List <TrelloList> lists = GetLists(key, token); //Returns list of ids etc in correct order as per on screen ReportLogger.AddMessage("Trello", "GetList"); Dictionary <string, string> contacts = Get.Contacts(); foreach (KeyValuePair <string, string> contact in contacts) { string message = Emailer.EmailContent(lists, contact.Value); Emailer.SendEmail(contact.Key, "LCTG - Daily Business Priorities", message, false, "*****@*****.**"); ReportLogger.AddMessage("Trello", "Email sent."); } reportLogger.EndStep(stepId); ReportLogger.AddMessage("Trello", "Completed"); } catch (Exception ex) { reportLogger.EndStep(stepId, ex); return(false); } reportLogger.EndLog(); return(true); } return(false); }
public override bool DueToRun() { if (QuedToRun) { QuedToRun = false; return(true); } //ReportLogger.AddMessage("Trello", "Due To Run"); ReadFromDb(); //ReportLogger.AddMessage("Trello", "ReadFrom Db() completed."); var dateTime = DateTime.Now; var timeSpan = dateTime - LastRun; //ReportLogger.AddMessage("Trello", "Check Timespan to see if it is due to run."); if (timeSpan.TotalMinutes >= 60 && dateTime.Hour == 7) { ReportLogger.AddMessage("Trello", "Due To Run."); LastRun = dateTime; return(true); } return(false); }
protected override void OnStop() { ReportLogger.AddMessage("CoreData Report Service", "Stopped"); }