public GetScheduleWeekResponse GetScheduleWeek(GetScheduleWeekRequest request) { ScheduleWeek week = new ScheduleWeek() { Name = ruleSerializer.BookStorage.Oktoikh.GetWeekName(request.Date, false) }; GetScheduleDayRequest dayRequest = new GetScheduleDayRequest() { Date = request.Date, Typicon = request.Typicon, Handler = request.Handler, Language = request.Language, ThrowExceptionIfInvalid = request.ThrowExceptionIfInvalid, ApplyParameters = request.ApplyParameters, CheckParameters = request.CheckParameters }; int i = 0; while (i < 7) { GetScheduleDayResponse dayResponse = GetScheduleDay(dayRequest); week.Days.Add(dayResponse.Day); dayRequest.Date = dayRequest.Date.AddDays(1); i++; } return(new GetScheduleWeekResponse() { Week = week }); }
public GetScheduleWeekResponse GetScheduleWeek(GetScheduleWeekRequest request) { OutputWeek week = new OutputWeek() { Name = nameComposer.GetWeekName(request.TypiconId, request.Date) }; GetScheduleDayRequest dayRequest = new GetScheduleDayRequest() { Date = request.Date, TypiconId = request.TypiconId, Handler = request.Handler, Language = request.Language, ThrowExceptionIfInvalid = request.ThrowExceptionIfInvalid, ApplyParameters = request.ApplyParameters, CheckParameters = request.CheckParameters }; int i = 0; while (i < 7) { GetScheduleDayResponse dayResponse = GetScheduleDay(dayRequest); week.Days.Add(dayResponse.Day); dayRequest.Date = dayRequest.Date.AddDays(1); i++; } return(new GetScheduleWeekResponse() { Week = week }); }
private void btnCustomRule_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtCustomRule.Text)) { return; } settingsFactory.CustomRule = txtCustomRule.Text; GetScheduleDayRequest request = new GetScheduleDayRequest() { Date = monthCalendarCustomRule.SelectionStart, Typicon = typiconEntity, Handler = new ServiceSequenceHandler(), Language = "cs-ru", //ApplyParameters = CustomParameters, //CheckParameters = new CustomParamsCollection<IRuleCheckParameter>().SetModeParam(HandlingMode.All) }; request.Handler.Settings.Language = LanguageSettingsFactory.Create("cs-ru"); GetScheduleDayResponse dayResponse = scheduleService.GetScheduleDay(request); TextScheduleDayViewer viewer = new TextScheduleDayViewer(); viewer.Execute(dayResponse.Day); webCustomRule.DocumentText = viewer.GetResult(); }
private void btnGetSequence_Click(object sender, EventArgs e) { //try //{ GetScheduleDayRequest request = new GetScheduleDayRequest() { Date = monthCalendarSequence.SelectionStart, Typicon = _typiconEntity, Handler = new ServiceSequenceHandler(), Language = "cs-ru", ApplyParameters = CustomParameters, CheckParameters = new CustomParamsCollection <IRuleCheckParameter>().SetModeParam(HandlingMode.All) }; request.Handler.Settings.Language = LanguageSettingsFactory.Create("cs-ru"); GetScheduleDayResponse dayResponse = _scheduleService.GetScheduleDay(request); TextScheduleDayViewer viewer = new TextScheduleDayViewer(); viewer.Execute(dayResponse.Day); txtSequence.Clear(); txtSequence.AppendText(viewer.GetResult()); //} //catch (Exception ex) //{ // txtSequence.Clear(); // txtSequence.AppendText(ex.Message); //} }
private void dateTimePickerTesting_ValueChanged(object sender, EventArgs e) { GetScheduleDayRequest dayRequest = new GetScheduleDayRequest() { Date = dateTimePickerTesting.Value, Typicon = _typiconEntity, Handler = new ScheduleHandler(), CheckParameters = new CustomParamsCollection <IRuleCheckParameter>().SetModeParam(HandlingMode.AstronomicDay) }; GetScheduleDayResponse dayResponse = _scheduleService.GetScheduleDay(dayRequest); _unitOfWork.SaveChanges(); textBoxTesting.Clear(); DateTime easter = _bookStorage.Easters.GetCurrentEaster(dateTimePickerTesting.Value.Year); int daysFromEaster = dateTimePickerTesting.Value.Subtract(easter).Days; textBoxTesting.AppendText(dayResponse.Day.Date.ToShortDateString() + Environment.NewLine); textBoxTesting.AppendText(dayResponse.Day.Name + ". " + daysFromEaster + " дней до Пасхи." + Environment.NewLine); foreach (WorshipRuleViewModel el in dayResponse.Day.Schedule) { string str = string.IsNullOrEmpty(el.Time) ? $"{el.Time} " : ""; str += $"{el.Name} {el.AdditionalName + Environment.NewLine}"; textBoxTesting.AppendText(str); } }
public ScheduleDay GetDay(DateTime date) { GetScheduleDayRequest request = new GetScheduleDayRequest() { Date = date, Typicon = _typiconEntity, Handler = new ScheduleHandler(), CheckParameters = new CustomParamsCollection <IRuleCheckParameter>().SetModeParam(HandlingMode.All) }; GetScheduleDayResponse response = _scheduleService.GetScheduleDay(request); return(response?.Day); }
public void BerlukiRu_ComparingRequests() { EFUnitOfWork _unitOfWork = new EFUnitOfWork(); //BookStorage.Instance = BookStorageFactory.Create(); TypiconEntity typiconEntity = _unitOfWork.Repository <TypiconEntity>().Get(c => c.Name == "Типикон"); DateTime date = new DateTime(2017, 9, 24); //сначала как в запросе в контроллере BerlukiRuController GetScheduleDayRequest dayRequest1 = new GetScheduleDayRequest() { Date = date, Handler = new ScheduleHandler(), Typicon = typiconEntity, CheckParameters = new CustomParamsCollection <IRuleCheckParameter>().SetModeParam(HandlingMode.AstronomicDay) }; ScheduleService scheduleService = ScheduleServiceFactory.Create(); GetScheduleDayResponse dayResponse1 = scheduleService.GetScheduleDay(dayRequest1); //теперь как TypiconController GetScheduleDayRequest dayRequest2 = new GetScheduleDayRequest() { Date = date, Typicon = typiconEntity, Handler = new ScheduleHandler(), CheckParameters = new CustomParamsCollection <IRuleCheckParameter>().SetModeParam(HandlingMode.AstronomicDay) }; GetScheduleDayResponse dayResponse2 = scheduleService.GetScheduleDay(dayRequest2); GetScheduleWeekRequest weekRequest = new GetScheduleWeekRequest() { Date = date, Typicon = typiconEntity, Handler = new ScheduleHandler(), CheckParameters = new CustomParamsCollection <IRuleCheckParameter>().SetModeParam(HandlingMode.AstronomicDay) }; GetScheduleWeekResponse weekResponse = scheduleService.GetScheduleWeek(weekRequest); Assert.AreEqual(dayResponse1.Day.Name, dayResponse2.Day.Name); Assert.AreEqual(dayResponse1.Day.Name, weekResponse.Week.Days.Last().Name); }
public void ServiceSequenceHandler_Working() { EFUnitOfWork _unitOfWork = new EFUnitOfWork(); //BookStorage.Instance = BookStorageFactory.Create(); TypiconEntity typiconEntity = _unitOfWork.Repository <TypiconEntity>().Get(c => c.Name == "Типикон"); GetScheduleDayRequest request = new GetScheduleDayRequest() { Date = new DateTime(2018, 5, 21),//DateTime.Today, Handler = new ServiceSequenceHandler(), Typicon = typiconEntity, CheckParameters = new CustomParamsCollection <IRuleCheckParameter>().SetModeParam(HandlingMode.AstronomicDay) }; ScheduleService scheduleService = ScheduleServiceFactory.Create(); GetScheduleDayResponse response = scheduleService.GetScheduleDay(request); }
public void ScheduleService_GetService() { EFUnitOfWork _unitOfWork = new EFUnitOfWork(); //BookStorage.Instance = BookStorageFactory.Create(); TypiconEntity typiconEntity = _unitOfWork.Repository <TypiconEntity>().Get(c => c.Name == "Типикон"); ScheduleHandler handler = new ScheduleHandler(); GetScheduleDayRequest request = new GetScheduleDayRequest() { Date = new DateTime(2018, 5, 21),//DateTime.Today, Handler = new ScheduleHandler(), Typicon = typiconEntity, CheckParameters = new CustomParamsCollection <IRuleCheckParameter>().SetModeParam(HandlingMode.AstronomicDay) }; ScheduleService scheduleService = ScheduleServiceFactory.Create(); GetScheduleDayResponse response = scheduleService.GetScheduleDay(request); _unitOfWork.SaveChanges(); Assert.AreEqual(3, response.Day.Schedule.Count); StringBuilder builder = new StringBuilder(); builder.AppendLine(response.Day.Date.ToShortDateString() + " " + response.Day.Name); foreach (WorshipRuleViewModel service in response.Day.Schedule) { builder.AppendLine(service.Time + " " + service.Name); } Assert.Pass(builder.ToString()); }