private Dictionary <int, string> BuildDays()
        {
            Dictionary <int, string> days = new Dictionary <int, string>();

            foreach (var dayOfWeek in Enum.GetValues(typeof(DayOfWeek)))
            {
                days.Add((int)dayOfWeek, HelpersGUI.DayOfWeekToString((DayOfWeek)dayOfWeek, true));
            }
            return(days);
        }
Example #2
0
 public string GetScheduleDescription(HealthCheckSettings healthCheckSettings)
 {
     {
         var time = new DateTime(1900, 1, 1, healthCheckSettings.TimeOfDay, 0, 0);
         return(healthCheckSettings.Status == HealthCheckStatus.Enabled
             ? string.Format(Messages.HEALTHCHECK_SCHEDULE_DESCRIPTION, healthCheckSettings.IntervalInWeeks,
                             HelpersGUI.DayOfWeekToString(healthCheckSettings.DayOfWeek, true),
                             HelpersGUI.DateTimeToString(time, Messages.DATEFORMAT_HM, true))
             : string.Empty);
     }
 }
Example #3
0
        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();
            }
        }