private void OnElapsedTime(object source, ElapsedEventArgs e) { timer.Stop(); int h = Convert.ToInt32(ConfigurationManager.AppSettings["heureDuJour"].Split('h')[0]); int m = Convert.ToInt32(ConfigurationManager.AppSettings["heureDuJour"].Split('h')[1]); //Program.log(string.Format("It's {0}h{1}, not {2}h{3}.", DateTime.Now.Hour, DateTime.Now.Minute, h, m)); if ((DateTime.Now.Hour == h && DateTime.Now.Minute == m && DateTime.Now.Date > _lastDayDone.Date) || ConfigurationManager.AppSettings["debugMode"] == "true" ) { Program.Log(string.Format("It's time ! {0} as in config",ConfigurationManager.AppSettings["heureDuJour"] )); if(ConfigurationManager.AppSettings["debugMode"] == "true") Program.Log("(Service is in Debug mode)"); ServiceProcess mp = new ServiceProcess(); List<User> listNewUserDay = mp.RetrieveNewUsers(); Program.Log("User List : " + listNewUserDay.Count); UserDataService uDal = new UserDataService(); string path = ConfigurationManager.AppSettings["localCsvFilesDirectory"]; string csvfilePath = uDal.CreateCsvFileFtpFromList(path, listNewUserDay, "CSat"); //string csvCPlusfilePath = uDal.CreateCsvFileFtpFromList(path, listCanalPlus, "CPlus"); //string csvCSatfilePath = uDal.CreateCsvFileFtpFromList(path, listCanalSat, "CSat"); //Program.log(csvCPlusfilePath); //mp.PushFileFTP(csvCPlusfilePath, "cplus"); Program.Log(csvfilePath); mp.MailPerformancePushFileFTP(csvfilePath, "plus"); if(!_canTriggerSeveralTimesADay) _lastDayDone = DateTime.Now; } if (DateTime.Now.ToString("yyyyMMdd") == ConfigurationManager.AppSettings["finOperation"]) { // l'opé est terminée, on ne restart par le timer et il faudra désinstaller le service. //OnStop(); Program.Log("Stopping service, end Of Operation has been reached : " + ConfigurationManager.AppSettings["finOperation"]); return; } //Program.log("Timer restart."); timer.Start(); }