public void AddSchedule(ScheduledTime oTime) { //int iDay = (DateTime.Now.Date - oTime.StartDateTime).Days; int iDay = (oTime.StartDateTime.Date - DateTime.Now.Date).Days; //Check if startTime is in the past if (oTime.StartDateTime.Date < DateTime.Now.Date) { //Show only the hours that are visible today oTime.Duration = (oTime.StartDateTime + oTime.Duration) - DateTime.Now.Date; oTime.StartDateTime = DateTime.Now.Date; iDay = 0; } if (iDay < DaysVisible & iDay >= 0) { DayControl DC = (DayControl)stackPanel2.Children[iDay]; TimeSpan startTime = oTime.StartDateTime.TimeOfDay; TimeSpan endTime = oTime.StartDateTime.TimeOfDay + oTime.Duration; if (endTime.TotalHours > 24) { //Move it to next day endTime = new TimeSpan(24, 0, 0); AddSchedule(new ScheduledTime(new DateTime(oTime.StartDateTime.Year, oTime.StartDateTime.Month, oTime.StartDateTime.Day, 0, 0, 0).AddDays(1), (oTime.StartDateTime.TimeOfDay + oTime.Duration).Subtract(new TimeSpan(24, 0, 0)), oTime.color, oTime.Title, oTime.isLocal, oTime.ServiceWindowID, oTime.ServiceWindowType));; } if ((oTime.StartDateTime.Date - DateTime.Now.Date) <= new TimeSpan(DaysVisible, 0, 0, 0)) { DC.timeList.Add(new DayControl.timeRange(startTime, endTime, oTime.color, oTime.Title, oTime.isLocal, oTime.ServiceWindowID, oTime.ServiceWindowType)); } } }
private static void WeeklyTest() { IScheduledItem item = new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(1, 0, 0, 0, 0)); TestItem(item, new DateTime(2004, 1, 1), true, new DateTime(2004, 1, 5)); TestItem(item, new DateTime(2004, 1, 2), true, new DateTime(2004, 1, 5)); TestItem(item, new DateTime(2003, 12, 30), true, new DateTime(2004, 1, 5)); TestItem(item, new DateTime(2004, 1, 5), true, new DateTime(2004, 1, 5)); TestItem(item, new DateTime(2004, 1, 5), false, new DateTime(2004, 1, 12)); TestItem(item, new DateTime(2004, 1, 6), false, new DateTime(2004, 1, 12)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(0, 0, 0, 0, 0)), new DateTime(2004, 1, 1), true, new DateTime(2004, 1, 4)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(1, 0, 0, 0, 0)), new DateTime(2004, 1, 1), true, new DateTime(2004, 1, 5)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(2, 0, 0, 0, 0)), new DateTime(2004, 1, 1), true, new DateTime(2004, 1, 6)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(3, 0, 0, 0, 0)), new DateTime(2004, 1, 1), true, new DateTime(2004, 1, 7)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(4, 0, 0, 0, 0)), new DateTime(2004, 1, 1), true, new DateTime(2004, 1, 1)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(5, 0, 0, 0, 0)), new DateTime(2004, 1, 1), true, new DateTime(2004, 1, 2)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(6, 0, 0, 0, 0)), new DateTime(2004, 1, 1), true, new DateTime(2004, 1, 3)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(4, 0, 0, 0, 0)), new DateTime(2004, 1, 1), false, new DateTime(2004, 1, 8)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(0, 6, 34, 23, 0)), new DateTime(2004, 1, 1), true, new DateTime(2004, 1, 4, 6, 34, 23)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(0, 6, 34, 23, 0)), new DateTime(2004, 1, 4), true, new DateTime(2004, 1, 4, 6, 34, 23)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(0, 6, 34, 23, 0)), new DateTime(2004, 1, 4, 3, 0, 0), true, new DateTime(2004, 1, 4, 6, 34, 23)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(0, 6, 34, 23, 0)), new DateTime(2004, 1, 4, 6, 0, 0), true, new DateTime(2004, 1, 4, 6, 34, 23)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(0, 6, 34, 23, 0)), new DateTime(2004, 1, 4, 6, 33, 0), true, new DateTime(2004, 1, 4, 6, 34, 23)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(0, 6, 34, 23, 0)), new DateTime(2004, 1, 4, 6, 34, 0), true, new DateTime(2004, 1, 4, 6, 34, 23)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(0, 6, 34, 23, 0)), new DateTime(2004, 1, 4, 6, 34, 23), true, new DateTime(2004, 1, 4, 6, 34, 23)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(0, 6, 34, 23, 0)), new DateTime(2004, 1, 4, 6, 34, 23), false, new DateTime(2004, 1, 11, 6, 34, 23)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Weekly, new TimeSpan(0, 6, 34, 23, 0)), new DateTime(2004, 1, 4, 6, 34, 24), true, new DateTime(2004, 1, 11, 6, 34, 23)); }
protected override void OnStart(string[] args) { try { PublisherServiceMonitor._logger.Info((object)"BEGIN - OnStart"); this._timer = new ScheduleTimer(); this._timer.Error += new ExceptionEventHandler(this.OnScheduleError); ScheduledTime scheduledTime = new ScheduledTime(EventTimeBase.ByMinute, TimeSpan.FromMinutes(10.0)); List <CommandArgs> list = new List <CommandArgs>(); foreach (string str in this.GetUrls()) { list.Add(new CommandArgs() { PublisherServiceUrl = str }); PublisherServiceMonitor._logger.InfoFormat("Url '{0}' initialized.", (object)str); } this._timer.AddJob((IScheduledItem)scheduledTime, (Delegate) new ScheduledEventHandler(this.ExecuteCommand), new object[1] { (object)list }); this._timer.Start(); PublisherServiceMonitor._logger.Info((object)"END - OnStart"); } catch (Exception ex) { PublisherServiceMonitor._logger.Error((object)ex.Message, ex); } }
private static void DailyTest() { IScheduledItem item = new ScheduledTime(EventTimeIntervalEnum.Daily, new TimeSpan(0, 6, 0, 0, 0)); TestItem(item, new DateTime(2004, 1, 1), true, new DateTime(2004, 1, 1, 6, 0, 0)); TestItem(item, new DateTime(2004, 1, 1, 6, 0, 0), true, new DateTime(2004, 1, 1, 6, 0, 0)); TestItem(item, new DateTime(2004, 1, 1, 6, 1, 0), true, new DateTime(2004, 1, 2, 6, 0, 0)); TestItem(item, new DateTime(2004, 1, 1, 6, 0, 1), true, new DateTime(2004, 1, 2, 6, 0, 0)); TestItem(item, new DateTime(2004, 1, 1, 6, 0, 0, 1), true, new DateTime(2004, 1, 2, 6, 0, 0)); }
private static void HourlyTest() { IScheduledItem item = new ScheduledTime(EventTimeIntervalEnum.Hourly, TimeSpan.FromMinutes(20)); TestItem(item, new DateTime(2004, 1, 1), true, new DateTime(2004, 1, 1, 0, 20, 0)); TestItem(item, new DateTime(2004, 1, 1), false, new DateTime(2004, 1, 1, 0, 20, 0)); TestItem(item, new DateTime(2004, 1, 1, 0, 20, 0), true, new DateTime(2004, 1, 1, 0, 20, 0)); TestItem(item, new DateTime(2004, 1, 1, 0, 20, 0), false, new DateTime(2004, 1, 1, 1, 20, 0)); TestItem(item, new DateTime(2004, 1, 1, 0, 20, 1), true, new DateTime(2004, 1, 1, 1, 20, 0)); }
public void Remove(string profilename, string stroffset, string StrBase) { var sched = new ScheduledTime(StrBase, stroffset); var item2 = from TimerJob tjob in _List let schedvalue = tjob.Schedule as ScheduledTime where tjob.ProfileName == profilename && schedvalue.Base == sched.Base && schedvalue.Offset == sched.Offset select tjob; _List.Remove(item2.First()); }
private static void MonthlyTest() { IScheduledItem item = new ScheduledTime(EventTimeIntervalEnum.Monthly, new TimeSpan(0)); TestItem(item, new DateTime(2004, 1, 1), true, new DateTime(2004, 1, 1)); TestItem(item, new DateTime(2004, 1, 1), false, new DateTime(2004, 2, 1)); TestItem(item, new DateTime(2004, 1, 31), true, new DateTime(2004, 2, 1)); TestItem(item, new DateTime(2004, 1, 31), false, new DateTime(2004, 2, 1)); TestItem(item, new DateTime(2004, 1, 31, 23, 59, 59, 999), false, new DateTime(2004, 2, 1)); TestItem(item, new DateTime(2004, 1, 15), true, new DateTime(2004, 2, 1)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Monthly, new TimeSpan(1, 3, 2, 1, 0)), new DateTime(2004, 1, 1), true, new DateTime(2004, 1, 2, 3, 2, 1)); TestItem(new ScheduledTime(EventTimeIntervalEnum.Monthly, new TimeSpan(14, 0, 0, 0, 0)), new DateTime(2004, 1, 1), true, new DateTime(2004, 1, 15, 0, 0, 0)); }
public void ScheduleService() { try { //Initialize the Schedular Schedular = new Timer(new TimerCallback(SchedularCallback)); //Get the interval mode string mode = ConfigurationManager.AppSettings["Mode"].ToUpper(); string schedule = string.Empty; bool executeTask = true; //Get the current minute DateTime currentDate = DateTime.Now; DateTime tempDate = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day, currentDate.Hour, currentDate.Minute, 0, 0); switch (mode) { case "DAILY": if (tempDate != ScheduledTime) { //If Scheduled Time is passed set Schedule for the next day. if (DateTime.Now > this.ScheduledTime) { ScheduledTime = ScheduledTime.AddDays(1); } executeTask = false; } else { ScheduledTime = ScheduledTime.AddDays(1); } break; case "INTERVAL": //Get the Interval in Minutes from AppSettings. int intervalMinutes = Convert.ToInt32(ConfigurationManager.AppSettings["IntervalMinutes"]); if (intervalMinutes > 0) { if (tempDate != ScheduledTime) { if (tempDate > ScheduledTime) { ScheduledTime = ScheduledTime.AddDays(1); } executeTask = false; } else { //Set the Scheduled Time by adding the Interval to Current Time. ScheduledTime = tempDate.AddMinutes(intervalMinutes); //If Scheduled Time is passed set Schedule for the next Interval. if (DateTime.Now > ScheduledTime) { ScheduledTime = ScheduledTime.AddMinutes(intervalMinutes); } } } else { throw new Exception("El intervalo en minutos debe ser mayor a cero."); } break; default: throw new Exception("El modo definido no es válido."); } schedule = ScheduledTime.ToString("dd/MM/yyyy hh:mm:ss tt"); //Update Schedular ChangeSchedular(ScheduledTime); //Execute task //if (executeTask) PRINCIPAL(); //Save Log if (GuardaLog) { GuardaLogBitacora(((executeTask) ? "Proceso ejecutado! " : string.Empty) + "Próxima ejecución aproximada: " + schedule); } } catch (Exception ex) { ChangeSchedular(DateTime.Now.AddHours(1)); GuardaLogBitacora(ex.Message); } }
public bool Equals(FireteamSummary input) { if (input == null) { return(false); } return (( FireteamId == input.FireteamId || (FireteamId.Equals(input.FireteamId)) ) && ( GroupId == input.GroupId || (GroupId.Equals(input.GroupId)) ) && ( Platform == input.Platform || (Platform != null && Platform.Equals(input.Platform)) ) && ( ActivityType == input.ActivityType || (ActivityType.Equals(input.ActivityType)) ) && ( IsImmediate == input.IsImmediate || (IsImmediate != null && IsImmediate.Equals(input.IsImmediate)) ) && ( ScheduledTime == input.ScheduledTime || (ScheduledTime != null && ScheduledTime.Equals(input.ScheduledTime)) ) && ( OwnerMembershipId == input.OwnerMembershipId || (OwnerMembershipId.Equals(input.OwnerMembershipId)) ) && ( PlayerSlotCount == input.PlayerSlotCount || (PlayerSlotCount.Equals(input.PlayerSlotCount)) ) && ( AlternateSlotCount == input.AlternateSlotCount || (AlternateSlotCount.Equals(input.AlternateSlotCount)) ) && ( AvailablePlayerSlotCount == input.AvailablePlayerSlotCount || (AvailablePlayerSlotCount.Equals(input.AvailablePlayerSlotCount)) ) && ( AvailableAlternateSlotCount == input.AvailableAlternateSlotCount || (AvailableAlternateSlotCount.Equals(input.AvailableAlternateSlotCount)) ) && ( Title == input.Title || (Title != null && Title.Equals(input.Title)) ) && ( DateCreated == input.DateCreated || (DateCreated != null && DateCreated.Equals(input.DateCreated)) ) && ( DateModified == input.DateModified || (DateModified != null && DateModified.Equals(input.DateModified)) ) && ( IsPublic == input.IsPublic || (IsPublic != null && IsPublic.Equals(input.IsPublic)) ) && ( Locale == input.Locale || (Locale != null && Locale.Equals(input.Locale)) ) && ( IsValid == input.IsValid || (IsValid != null && IsValid.Equals(input.IsValid)) ) && ( DatePlayerModified == input.DatePlayerModified || (DatePlayerModified != null && DatePlayerModified.Equals(input.DatePlayerModified)) ) && ( TitleBeforeModeration == input.TitleBeforeModeration || (TitleBeforeModeration != null && TitleBeforeModeration.Equals(input.TitleBeforeModeration)) )); }
private static void MonitorThemeChanges() { #if UNITY_EDITOR_WIN registryMonitor?.Stop(); #elif UNITY_EDITOR_OSX appearanceMonitor?.Stop(); #endif timer?.Stop(); if (UserPreferences.IsEnabled) { if (UserPreferences.Mode == UserPreferences.AutoThemeMode.System) { #if UNITY_EDITOR_WIN // Windows: Watch system theme changes in registry registryMonitor = new RegistryMonitor(RegistryHive.CurrentUser, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"); registryMonitor.RegChanged += (sender, args) => SetEditorThemeFromSystemTheme(); registryMonitor.Start(); #elif UNITY_EDITOR_OSX // macOS appearanceMonitor = new AppearanceMonitor(); appearanceMonitor.AppearanceChanged += (sender, args) => { SetEditorThemeFromSystemTheme(); }; appearanceMonitor.Start(); #endif // Set current system theme on start/when enabled SetEditorThemeFromSystemTheme(); } else if (UserPreferences.Mode == UserPreferences.AutoThemeMode.Time) { var now = DateTime.Now.TimeOfDay; // Check current time and set theme if (UserPreferences.LightThemeTime < UserPreferences.DarkThemeTime) { if (now >= UserPreferences.LightThemeTime && now < UserPreferences.DarkThemeTime) { EditorThemeChanger.SetLightTheme(); } else { EditorThemeChanger.SetDarkTheme(); } } else { if (now < UserPreferences.LightThemeTime && now >= UserPreferences.DarkThemeTime) { EditorThemeChanger.SetDarkTheme(); } else { EditorThemeChanger.SetLightTheme(); } } // Schedule theme changes var lightThemeSchedule = new ScheduledTime(EventTimeBase.Daily, UserPreferences.LightThemeTime); var darkThemeSchedule = new ScheduledTime(EventTimeBase.Daily, UserPreferences.DarkThemeTime); timer = new ScheduleTimer(); timer.AddJob(lightThemeSchedule, new Action(EditorThemeChanger.SetLightTheme)); timer.AddJob(darkThemeSchedule, new Action(EditorThemeChanger.SetDarkTheme)); timer.Start(); } } }
public Agenda ParseSchedule() { var agenda = new Agenda(); var mode = configuration.GetSection("RunMode").GetChildren().ToDictionary(x => x.Key, y => y.Value); var downloadsPath = mode["Environment"] == "localhost" ? mode["AgendaPath"] : $"{hostingEnvironment.ContentRootPath}/../../downloads/"; var files = Directory.GetFiles(downloadsPath); if (files.Any()) { var scheduleFile = new FileInfo(files.First()); using (var excelPackage = new ExcelPackage(scheduleFile)) { if (excelPackage.Workbook.Worksheets.Any()) { var currentMonth = DateTime.Now.ToString("MMMM").ToLower(); var worksheet = excelPackage.Workbook.Worksheets.Single(x => x.Name.ToLower().Equals(currentMonth)); var rowCount = worksheet.Dimension.Rows; // Parse the whole schedule for (int rowIndex = 2; rowIndex <= rowCount; rowIndex++) { var nickname = worksheet.Cells[rowIndex, 1].Value; if (nickname == null) { break; } var scheduledTime = new ScheduledTime(); scheduledTime.EngineerNickname = nickname.ToString().Trim(); scheduledTime.From = DateTime.FromOADate((double)worksheet.Cells[rowIndex, 2].Value); scheduledTime.To = scheduledTime.From; //Todo extract time from 4th column var fromToHours = worksheet.Cells[rowIndex, 4].Value.ToString(); var timeOfDay = fromToHours.Split('-'); if (timeOfDay.Any(time => time.Contains("24:00"))) { timeOfDay[1] = "23:59"; } var startTime = DateTime.Parse(timeOfDay[0]); var endTime = DateTime.Parse(timeOfDay[1]); scheduledTime.From += startTime.TimeOfDay; scheduledTime.To += endTime.TimeOfDay; scheduledTime.Hours = (double)worksheet.Cells[rowIndex, 5].Value; agenda.Schedule.Add(scheduledTime); } // Parse all engineers for (int rowIndex = 2; rowIndex < rowCount; rowIndex++) { var engineerDetails = worksheet.Cells[rowIndex, 9].Value; if (engineerDetails == null) { continue; } var detailsParts = engineerDetails.ToString().Split('-'); var engineer = new Engineer(); engineer.Nickname = detailsParts[0].Trim(); engineer.Name = detailsParts[1].Trim(); engineer.Email = detailsParts[2].Trim(); agenda.Engineers.Add(engineer); } } } } return(agenda); }