Ejemplo n.º 1
0
        public void Merge(OutputDayInfo dayInfo, ITypiconSerializer typiconSerializer)
        {
            //NextDayFirstWorship
            if (ScheduleResults.NextDayFirstWorship.Count > 0 &&
                dayInfo.ScheduleResults.DayBefore.FirstOrDefault() is OutputWorshipModel dayBefore)
            {
                ScheduleResults.NextDayFirstWorship.Reverse();
                //вставляем службы в первую службу следующего дня (daybefore), начиная с последних
                foreach (var worship in ScheduleResults.NextDayFirstWorship)
                {
                    dayBefore.ChildElements.InsertRange(0, worship.ChildElements);
                }
            }

            //DayBefore
            //ScheduleResults.ThisDay.AddRange(dayInfo.ScheduleResults.DayBefore);

            Day.AddWorships(dayInfo.ScheduleResults.DayBefore, typiconSerializer);

            _dayWorships.AddRange(dayInfo.DayWorships);

            //удаляем возможные дубликаты ссылок на тексты служб
            _dayWorships = _dayWorships.Distinct().ToList();

            //TODO: BrokenConstaints??
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Возвращает неделю
        /// </summary>
        /// <param name="typiconVersionId"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public IEnumerable <OutputDay> CreateWeek(CreateOutputWeekRequest req)
        {
            List <OutputDay> result = new List <OutputDay>();

            var dayReq = new CreateOutputDayRequest()
            {
                TypiconId        = req.TypiconId,
                TypiconVersionId = req.TypiconVersionId,
                HandlingMode     = HandlingMode.AstronomicDay
            };

            OutputDayInfo dayInfo = null;

            EachDayPerWeek.Perform(req.Date, date =>
            {
                dayReq.Date = date;

                var output = InnerCreate(dayReq, ref dayInfo, _dataCalculator);

                if (output != null)
                {
                    result.Add(output.Day);
                }
            });

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Используется для формирования customsequence
        /// </summary>
        /// <param name="dataCalculator"></param>
        /// <param name="req"></param>
        /// <returns></returns>
        public CreateOutputDayResponse Create(IScheduleDataCalculator dataCalculator, CreateOutputDayRequest req)
        {
            if (dataCalculator == null)
            {
                throw new ArgumentNullException(nameof(dataCalculator));
            }

            OutputDayInfo dayInfo = null;

            return(InnerCreate(req, ref dayInfo, dataCalculator));
        }
        protected override CreateOutputDayResponse InnerCreate(CreateOutputDayRequest req, ref OutputDayInfo dayInfo, IScheduleDataCalculator dataCalculator)
        {
            var exists = _dbContext.IsOutputDayExists(req.TypiconId, req.Date);

            if (!exists)
            {
                return(base.InnerCreate(req, ref dayInfo, dataCalculator));
            }
            else
            {
                dayInfo = null;

                return(default);
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="typiconId">Id Устава</param>
        /// <param name="typiconVersionId">Версия Устава</param>
        /// <param name="date"></param>
        /// <returns></returns>
        public CreateOutputDayResponse Create(CreateOutputDayRequest req)
        {
            OutputDayInfo dayInfo = null;

            return(InnerCreate(req, ref dayInfo, _dataCalculator));
        }
Ejemplo n.º 6
0
        protected virtual CreateOutputDayResponse InnerCreate(CreateOutputDayRequest req, ref OutputDayInfo dayInfo, IScheduleDataCalculator dataCalculator)
        {
            if (dayInfo == null)
            {
                //Формируем данные для обработки
                dayInfo = GetOutputDayInfo(dataCalculator, new ScheduleDataCalculatorRequest()
                {
                    TypiconId        = req.TypiconId,
                    TypiconVersionId = req.TypiconVersionId,
                    Date             = req.Date
                });
            }

            if (req.HandlingMode == HandlingMode.DayBefore ||
                req.HandlingMode == HandlingMode.All)
            {
                //добавляем DayBefore
                dayInfo.Day.AddWorships(dayInfo.ScheduleResults.DayBefore, _typiconSerializer);
            }

            if (req.HandlingMode == HandlingMode.ThisDay ||
                req.HandlingMode == HandlingMode.All ||
                req.HandlingMode == HandlingMode.AstronomicDay)
            {
                //добавляем ThisDay
                dayInfo.Day.AddWorships(dayInfo.ScheduleResults.ThisDay, _typiconSerializer);
            }

            var localDayInfo = dayInfo;

            //добавляем AstronomicDay
            if (req.HandlingMode == HandlingMode.AstronomicDay)
            {
                //Формируем данные для обработки от следующего дня
                dayInfo = GetOutputDayInfo(dataCalculator, new ScheduleDataCalculatorRequest()
                {
                    TypiconId        = req.TypiconId,
                    TypiconVersionId = req.TypiconVersionId,
                    Date             = req.Date.AddDays(1)
                });

                //складываем значения
                localDayInfo.Merge(dayInfo, _typiconSerializer);
            }

            //Добавить ссылки на службы
            localDayInfo.Day.OutputFormDayWorships = GetOutputDayDayWorships(localDayInfo.Day, localDayInfo.DayWorships);

            return(new CreateOutputDayResponse(localDayInfo.Day, localDayInfo.BrokenConstraints));
        }