コード例 #1
0
 private TimeSpanFrequency ApplyTimeRange(SchedulerModel model)
 {
     return(model.IsSingleLanch == false
                ? TimeSpanFrequency.StartOnce(model.cTimeConst.TimeOfDay)
                : new TimeSpanFrequency(model.SingleLanchPeriod,
                                        (RhythmByTime)
                                        Enum.Parse(typeof(RhythmByTime),
                                                   model.OccursEvery.ToString()),
                                        model.StartingAt.TimeOfDay, model.EndingAt.TimeOfDay));
 }
コード例 #2
0
ファイル: Sheduling.cs プロジェクト: morfeyka/gazprom-sync
        private static IEnumerable <string> AddTimeAddIns(TimeSpanFrequency frequency)
        {
            var addIns = new List <string>();

            if (frequency.IsSingleLanch)
            {
                addIns.Add(string.Format(DescriptionFormattingString, "в", frequency.StartingAt.ToString("T")));
            }
            else
            {
                addIns.Add(frequency.Period == 1
                               ? (frequency.OccursEvery == RhythmByTime.Hours ? @"каждый" : @"каждую")                //overEvery overEvery_w
                               : string.Format(DescriptionFormattingString, @"каждые", frequency.Period));            //overEvery(s)
                addIns.Add(DeclinableForTimes(frequency.OccursEvery, frequency.Period));
                addIns.Add(string.Format(DescriptionFormattingString, @"между", frequency.StartingAt.ToString("T"))); //betweenIn
                addIns.Add(string.Format(DescriptionFormattingString, @"и", frequency.EndingAt.ToString("T")));
            }
            addIns.Add(string.Format(DescriptionFormattingString, string.Empty, "."));
            return(addIns);
        }
コード例 #3
0
        private SchedulerModel LoadSheduling(SheduleFrequencyProperty sheduler)
        {
            SchedulerModel model = new SchedulerModel();

            switch (sheduler.Occurs)
            {
            case RhythmByDate.OneTime:
                model.cDate = _shaper.Frequency.DurationFrom.Add(sheduler.DailyFrequency.StartingAt);
                break;

            case RhythmByDate.Daily:
                model.DailyPeriod = sheduler.Period;
                break;

            case RhythmByDate.Weekly:
                model.WeeklyPeriod = sheduler.Period;
                List <DayOfWeek> recuring = ((WeeklyFrequency)sheduler).RecuringDays;
                model.Monday    = recuring.Contains(DayOfWeek.Monday);
                model.Tuesday   = recuring.Contains(DayOfWeek.Tuesday);
                model.Wednesday = recuring.Contains(DayOfWeek.Wednesday);
                model.Thursday  = recuring.Contains(DayOfWeek.Thursday);
                model.Friday    = recuring.Contains(DayOfWeek.Friday);
                model.Saturday  = recuring.Contains(DayOfWeek.Saturday);
                model.Sunday    = recuring.Contains(DayOfWeek.Sunday);
                break;

            case RhythmByDate.Monthly:
                model.MonthlyPeriod = model.tbxMonthNumFor = sheduler.Period;
                if (((MonthlyFrequency)sheduler).IsDefinedByDay)
                {
                    model.RblMonthDetail = false;
                    model.DayOffset      = ((MonthlyFrequency)sheduler).DayOffset;
                }
                else
                {
                    model.RblMonthDetail = true;
                    KeyValuePair <RhythmByWeek, DayOfWeek>?datePart = ((MonthlyFrequency)sheduler).DayOfWeek;
                    if (!datePart.HasValue)
                    {
                        return(model);
                    }
                    foreach (var item in model.WeekPartList)
                    {
                        item.Selected = item.Value == ((int)datePart.Value.Key).ToString();
                        if (item.Selected)
                        {
                            model.ddlWeekPart = ((int)datePart.Value.Key);
                        }
                    }
                    foreach (var item in model.DayOfWeekList)
                    {
                        item.Selected = item.Value == ((int)datePart.Value.Value).ToString();
                        if (item.Selected)
                        {
                            model.ddlWeeks = (int)datePart.Value.Value;
                        }
                    }
                }
                break;
            }
            foreach (var item in model.DateRhythmList)
            {
                item.Selected = item.Value == ((int)sheduler.Occurs).ToString();
                if (item.Selected)
                {
                    model.ddlDateRhythm = (int)sheduler.Occurs;
                }
            }
            TimeSpanFrequency daily = sheduler.DailyFrequency;

            if (daily.IsSingleLanch)
            {
                model.cTimeConst = DateTime.Now.Date.Add(daily.StartingAt);
            }
            else
            {
                model.IsSingleLanch = true;
                //foreach (ListItem item in  IsSingleLanch.Items)
                //{
                //    item.Selected = item.Value == @"1";
                //}
                foreach (var item in model.RhythmByTimeList)
                {
                    item.Selected = item.Value == ((int)daily.OccursEvery).ToString();
                    if (item.Selected)
                    {
                        model.OccursEvery = (int)daily.OccursEvery;
                    }
                }
                model.StartingAt        = new DateTime().Add(daily.StartingAt);
                model.EndingAt          = new DateTime().Add(daily.EndingAt);
                model.SingleLanchPeriod = daily.Period;
            }
            model.DurationFrom = sheduler.DurationFrom;
            if (!sheduler.IsInfinite)
            {
                //foreach (ListItem item in rblStopDetail.Items)
                //    item.Selected = item.Value == @"1";
                model.IsInfinite = false;
                model.DurationTo = sheduler.DurationTo;
            }
            else
            {
                model.IsInfinite = true;
            }
            return(model);
        }