/// <summary>
        /// Возвращает полную информацию о периодическом опросе
        /// </summary>
        public static string Info(this PeriodicScan scan)
        {
            string type = scan.PeriodType ? "год." : "хв.";

            return($"Id:\t\t\t{scan.Id}\n" +
                   $"Назва:\t\t\t{scan.Title}\n" +
                   $"Період:\t\t\t{scan.Period} {type}\n" +
                   $"Останнє опитування:\t{scan.DateLastScanned?.ToString("dd.MM.yyyy HH:mm")}\n" +
                   $"Створено:\t\t{scan.DateCreated.ToString("dd.MM.yyyy HH:mm")}\n" +
                   $"Змінено:\t\t{scan.DateModified.ToString("dd.MM.yyyy HH:mm")}");
        }
        /// <summary>
        /// Возвращает текст для элемента дерева опросов
        /// </summary>
        public static string NodeTitle(this ScanBase scan)
        {
            PeriodicScan periodic = scan as PeriodicScan;

            if (periodic != null)
            {
                string type = periodic.PeriodType ? "год." : "хв.";
                return($"{periodic.Title} ({periodic.Period} {type})");
            }

            ScheduledScan scheduled = scan as ScheduledScan;

            if (scheduled != null)
            {
                string period = scheduled.Periods.Any()
                    ? $"({scheduled.Periods.FirstOrDefault()?.Period.ToString(@"hh\:mm")})"
                    : "";
                return($"{scheduled.Title} {period}");
            }

            return(string.Empty);
        }
Esempio n. 3
0
        public EditPeriodicScanForm()
        {
            InitializeComponent();

            Load += (sender, args) =>
            {
                if (!IsEdit)
                {
                    Scan = new PeriodicScan();
                    Text = TITLE_CREATE;
                    Icon = Resources.Add;
                }
                else
                {
                    Text              = TITLE_EDIT;
                    txtTitle.Text     = Scan.Title;
                    numPeriod.Value   = Scan.Period;
                    rbMinutes.Checked = !Scan.PeriodType;
                    rbHours.Checked   = Scan.PeriodType;
                    Icon              = Resources.PeriodicScan1;
                }
            };
        }