private void RecalculateSchedule() { if (updating) { return; } Schedule = new Dictionary <string, string>(); DateTime?nextRunOnClient = null; DateTime?nextRunOnServer = null; if (radioButtonHourly.Checked && int.TryParse(comboBoxMin.SelectedItem.ToString(), out int min)) { SubText = FormattedSchedule = string.Format(Messages.HOURLY_SCHEDULE_FORMAT, min); nextRunOnClient = VMSS.GetHourlyDate(DateTime.Now, min); if (_serverTimeInfo.HasValue) { nextRunOnServer = HelpersGUI.RoundToNearestQuarter(nextRunOnClient.Value - _serverTimeInfo.Value.ServerClientTimeZoneDiff); Schedule["min"] = nextRunOnServer.Value.Minute.ToString(); } } else if (radioButtonDaily.Checked) { SubText = FormattedSchedule = string.Format(Messages.DAILY_SCHEDULE_FORMAT, HelpersGUI.DateTimeToString(dateTimePickerDaily.Value, Messages.DATEFORMAT_HM, true)); nextRunOnClient = VMSS.GetDailyDate(DateTime.Now, dateTimePickerDaily.Value.Minute, dateTimePickerDaily.Value.Hour); if (_serverTimeInfo.HasValue) { nextRunOnServer = HelpersGUI.RoundToNearestQuarter(nextRunOnClient.Value - _serverTimeInfo.Value.ServerClientTimeZoneDiff); Schedule["hour"] = nextRunOnServer.Value.Hour.ToString(); Schedule["min"] = nextRunOnServer.Value.Minute.ToString(); } } else if (radioButtonWeekly.Checked && daysWeekCheckboxes.AnySelected()) { var days = daysWeekCheckboxes.SelectedDays; var longString = string.Join(", ", days.Select(d => HelpersGUI.DayOfWeekToString(d))); var shortString = string.Join(", ", days.Select(d => HelpersGUI.DayOfWeekToShortString(d))); FormattedSchedule = string.Format(Messages.WEEKLY_SCHEDULE_FORMAT, HelpersGUI.DateTimeToString(dateTimePickerWeekly.Value, Messages.DATEFORMAT_HM, true), longString); SubText = string.Format(Messages.WEEKLY_SCHEDULE_FORMAT, HelpersGUI.DateTimeToString(dateTimePickerWeekly.Value, Messages.DATEFORMAT_HM, true), shortString); var nextClientRuns = VMSS.GetWeeklyDates(DateTime.Now, dateTimePickerWeekly.Value.Minute, dateTimePickerWeekly.Value.Hour, days); if (_serverTimeInfo.HasValue && nextClientRuns.Count > 0) { nextRunOnClient = nextClientRuns[0]; var nextServerRuns = nextClientRuns.Select(n => HelpersGUI.RoundToNearestQuarter(n - _serverTimeInfo.Value.ServerClientTimeZoneDiff)).ToList(); nextRunOnServer = nextServerRuns[0]; Schedule["hour"] = nextRunOnServer.Value.Hour.ToString(); Schedule["min"] = nextRunOnServer.Value.Minute.ToString(); Schedule["days"] = string.Join(",", nextServerRuns.Select(n => n.DayOfWeek.ToString())).ToLower(); } } if (string.IsNullOrEmpty(FormattedSchedule)) { FormattedSchedule = Messages.UNKNOWN; } if (string.IsNullOrEmpty(SubText)) { SubText = Messages.UNKNOWN; } RefreshTime(nextRunOnServer, nextRunOnClient); OnPageUpdated(); if (Populated != null) { Populated(); } }