Example #1
0
        private ScheduleDay GetOrFillScheduleDay(GetRuleSettingsRequest request, TypiconEntity typicon,
                                                 ScheduleHandler handler, ScheduleDay scheduleDay = null)
        {
            //заполняем Правила и день Октоиха
            request.MenologyRule = typicon.GetMenologyRule(request.Date);

            int daysFromEaster = ruleSerializer.BookStorage.Easters.GetDaysFromCurrentEaster(request.Date);

            request.TriodionRule = typicon.GetTriodionRule(daysFromEaster);

            request.ModifiedRule = typicon.GetModifiedRuleHighestPriority(request.Date, ruleSerializer);
            request.OktoikhDay   = ruleSerializer.BookStorage.Oktoikh.Get(request.Date);

            //Формируем данные для обработки
            var settings = settingsFactory.Create(request);

            handler.Settings = settings;

            settings.Rule.GetRule(ruleSerializer).Interpret(handler);

            var container = handler.GetResult();

            if (scheduleDay == null)
            {
                //Sign sign = (settings.Rule is Sign s) ? s : GetTemplateSign(settings.Rule.Template);
                Sign sign = GetRootAdditionSign(settings);

                //Если settings.SignNumber определен в ModifiedRule, то назначаем его
                int signNumber = settings.SignNumber ?? (int)sign.Number;

                //if (request.Date.DayOfWeek == DayOfWeek.Sunday && sign.Priority > 3)
                //{
                //    //TODO: жесткая привязка к номеру знака воскресного дня
                //    signNumber = 8;// SignMigrator.GetOldId(k => k.Value.Name == "Воскресный день");
                //}

                scheduleDay = new ScheduleDay
                {
                    //задаем имя дню
                    Name       = nameComposer.Compose(settings, request.Date),
                    Date       = request.Date,
                    SignNumber = signNumber,
                    SignName   = sign.SignName[settings.Language.Name],
                };
            }

            //if (container != null)
            //{
            scheduleDay.Schedule.AddRange(container);
            //}

            return(scheduleDay);
        }
Example #2
0
        /// <summary>
        /// Вычисляет свойства для заполнения выходной формы
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        private OutputDayInfo GetOutputDayInfo(IScheduleDataCalculator dataCalculator, ScheduleDataCalculatorRequest request)
        {
            //Формируем данные для обработки
            var response = dataCalculator.Calculate(request);

            var outputDay = new OutputDay()
            {
                TypiconId = request.TypiconId,
                Date      = request.Date
            };

            if (response.Success)
            {
                //все удачно - собираем информацию

                var settings = response.Value.Settings;

                var brokenConstraints = GetBrokenConstraints(settings);

                _handler.Settings = settings;

                _handler.ClearResult();

                settings.RuleContainer.Interpret(_handler);

                var results = _handler.GetResults();

                var sign = response.Value.Rule.Template.GetPredefinedTemplate();

                outputDay.Header = new OutputDayHeader()
                {
                    //задаем имя дню
                    Name = _nameComposer.Compose(request.Date, response.Value.Rule.Template.Priority, settings.AllWorships),

                    PredefinedSignId = sign.Id,
                    //Если settings.PrintDayTemplate определен в ModifiedRule, то назначаем его
                    PrintDayTemplate = settings.PrintDayTemplate ?? sign.PrintTemplate
                };

                return(new OutputDayInfo(
                           outputDay,
                           settings.AllWorships,
                           results,
                           brokenConstraints));
            }
            else
            {
                //если response возвращается неудачный, то возвращаем "пустую" информацию
                return(new OutputDayInfo(
                           outputDay,
        private OutputDay GetOrFillScheduleDay(ScheduleDataCalculatorRequest request, ScheduleHandler handler, OutputDay scheduleDay = null)
        {
            //Формируем данные для обработки
            var response = dataCalculator.Calculate(request);

            var settings = response.Settings;

            handler.Settings = settings;

            settings.RuleContainer.Interpret(handler);

            var container = handler.GetResult();

            if (scheduleDay == null)
            {
                //Sign sign = (settings.Rule is Sign s) ? s : GetTemplateSign(settings.Rule.Template);
                var sign = GetPredefinedTemplate(response.Rule.Template);

                //Если settings.SignNumber определен в ModifiedRule, то назначаем его
                int signNumber = settings.SignNumber ?? sign.Number.Value;

                scheduleDay = new OutputDay
                {
                    //задаем имя дню
                    Name           = nameComposer.Compose(request.Date, response.Rule.Template.Priority, settings.AllWorships),
                    Date           = request.Date,
                    PredefinedSign = sign
                };
            }

            //if (container != null)
            //{
            scheduleDay.Worships.AddRange(container);
            //}

            return(scheduleDay);
        }