//public GetSequenceResponse GetSequence(GetSequenceRequest request) //{ // //TODO: добавить нормальную тестовую строку // string html = @"<!DOCTYPE html> // <html> // <head> // <meta charset=""utf-8"" /> // </head> // <body> // <div id=""schberlukiru""> // <div class=""schedule""><h4 class=""subtitle"">СЕДМИЦА 20-АЯ ПО ПЯТИДЕСЯТНИЦЕ</h4><div style=""margin - top:10px; "">[sign cat=""2""]<strong>16 октября 2017 г.<br/>ПОНЕДЕЛЬНИК<br/>Сщмч. Диони́сия Ареопаги́та, еп. Афи́нского.</strong></div><table border=0><tr><td>06.00 </td><td>Полунощница. Утреня. Часы.</td></tr><tr><td>08.00 </td><td>Божественная литургия.</td></tr><tr><td>17.30 </td><td>9-й час. Вечерня. Малое повечерие.</td></tr></table><div style=""margin - top:10px; "">[sign cat=""3""]<strong>17 октября 2017 г.<br/>ВТОРНИК<br/>Обре́тение мощей свтт. Гу́рия, архиеп. Казанского, и Варсоно́фия, еп. Тверского.</strong></div><table border=0><tr><td>06.00 </td><td>Полунощница. Утреня. Часы.</td></tr><tr><td>08.00 </td><td>Божественная литургия.</td></tr><tr><td>17.30 </td><td>9-й час. Вечерня. Малое повечерие.</td></tr></table><div style=""margin - top:10px; "">[sign cat=""3""]<strong>18 октября 2017 г.<br/>СРЕДА<br/>Свтт. Петра, Алекси́я, Ионы, Макария, Филиппа, Иова, Ермогена, Тихона, Петра, Филарета, Иннокентия и Макария, Московских и всея России чудотворцев.</strong></div><table border=0><tr><td>06.00 </td><td>Полунощница. Утреня. Часы.</td></tr><tr><td>08.00 </td><td>Божественная литургия.</td></tr><tr><td>17.30 </td><td>9-й час. Вечерня. Малое повечерие.</td></tr></table><div style=""margin - top:10px; "">[sign cat=""3""]<strong>19 октября 2017 г.<br/>ЧЕТВЕРГ<br/>Апостола Фомы́.</strong></div><table border=0><tr><td>06.00 </td><td>Полунощница. Утреня. Часы.</td></tr><tr><td>08.00 </td><td>Божественная литургия.</td></tr><tr><td>17.30 </td><td>9-й час. Вечерня. Малое повечерие.</td></tr></table><div style=""margin - top:10px; "">[sign cat=""2""]<strong>20 октября 2017 г.<br/>ПЯТНИЦА<br/>Мчч. Се́ргия и Ва́кха.</strong></div><table border=0><tr><td>06.00 </td><td>Полунощница. Утреня. Часы.</td></tr><tr><td>08.00 </td><td>Божественная литургия.</td></tr><tr><td>17.30 </td><td>9-й час. Вечерня. Малое повечерие.</td></tr></table><div style=""margin - top:10px; "">[sign cat=""1""]<strong>21 октября 2017 г.<br/>СУББОТА<br/>Прп. Пелагии.</strong></div><table border=0><tr><td>06.00 </td><td>Полунощница. Утреня. Часы.</td></tr><tr><td>08.00 </td><td>Божественная литургия.</td></tr><tr><td>16.00 </td><td>Всенощное бдение.</td></tr></table><div style=""margin - top:10px; "">[sign cat=""9""]<strong><span style=""color: #ff0000;"">22 октября 2017 г.<br/>ВОСКРЕСЕНЬЕ<br/>Неделя 20-ая по Пятидесятнице. Глас 3-й. Ап. Иа́кова Алфе́ева.</strong></span></div><table border=0><tr><td>08.40 </td><td>Часы 3-й и 6-й.</td></tr><tr><td>09.00 </td><td>Божественная литургия.</td></tr><tr><td>17.30 </td><td>9-й час. Вечерня. Малое повечерие.</td></tr></table></div><div class=""schedule""><h4 class=""subtitle"">СЕДМИЦА 21-АЯ ПО ПЯТИДЕСЯТНИЦЕ</h4><div style=""margin - top:10px; "">[sign cat=""3""]<strong>23 октября 2017 г.<br/>ПОНЕДЕЛЬНИК<br/>Прп. Амвро́сия О́птинского.</strong></div><table border=0><tr><td>06.00 </td><td>Полунощница. Утреня. Часы.</td></tr><tr><td>08.00 </td><td>Божественная литургия.</td></tr><tr><td>17.30 </td><td>9-й час. Вечерня. Малое повечерие.</td></tr></table><div style=""margin - top:10px; "">[sign cat=""3""]<strong>24 октября 2017 г.<br/>ВТОРНИК<br/>Собор преподобных О́птинских старцев.</strong></div><table border=0><tr><td>06.00 </td><td>Полунощница. Утреня. Часы.</td></tr><tr><td>08.00 </td><td>Божественная литургия.</td></tr><tr><td>17.30 </td><td>9-й час. Вечерня. Малое повечерие.</td></tr></table><div style=""margin - top:10px; "">[sign cat=""1""]<strong>25 октября 2017 г.<br/>СРЕДА<br/>Мчч. Про́ва, Тара́ха и Андрони́ка. Прп. Космы́, еп. Маиу́мского, творца канонов. </strong></div><table border=0><tr><td>06.00 </td><td>Полунощница. Утреня. Часы.</td></tr><tr><td>08.00 </td><td>Божественная литургия.</td></tr><tr><td>17.30 </td><td>9-й час. Вечерня. Малое повечерие.</td></tr></table><div style=""margin - top:10px; "">[sign cat=""3""]<strong>26 октября 2017 г.<br/>ЧЕТВЕРГ<br/>Иверской иконы Божией Матери.</strong></div><table border=0><tr><td>06.00 </td><td>Полунощница. Утреня. Часы.</td></tr><tr><td>08.00 </td><td>Божественная литургия.</td></tr><tr><td>17.30 </td><td>9-й час. Вечерня. Малое повечерие.</td></tr></table><div style=""margin - top:10px; "">[sign cat=""3""]<strong>27 октября 2017 г.<br/>ПЯТНИЦА<br/>Прп. Нико́лы Свято́ши, кн. Черни́говского.</strong></div><table border=0><tr><td>06.00 </td><td>Полунощница. Утреня. Часы.</td></tr><tr><td>08.00 </td><td>Божественная литургия.</td></tr><tr><td>17.30 </td><td>9-й час. Вечерня. Малое повечерие.</td></tr></table><div style=""margin - top:10px; "">[sign cat=""3""]<strong>28 октября 2017 г.<br/>СУББОТА<br/>Свт. Афана́сия исп., еп. Ковро́вского.</strong></div><table border=0><tr><td>06.00 </td><td>Полунощница. Утреня. Часы.</td></tr><tr><td>08.00 </td><td>Божественная литургия.</td></tr><tr><td>16.00 </td><td>Всенощное бдение.</td></tr></table><div style=""margin - top:10px; "">[sign cat=""9""]<strong><span style=""color: #ff0000;"">29 октября 2017 г.<br/>ВОСКРЕСЕНЬЕ<br/>Неделя 21-ая по Пятидесятнице. Глас 4-й. Мч. Ло́нгина со́тника, иже при Кресте́ Госпо́дни.</strong></span></div><table border=0><tr><td>08.40 </td><td>Часы 3-й и 6-й.</td></tr><tr><td>09.00 </td><td>Божественная литургия.</td></tr><tr><td>17.30 </td><td>9-й час. Вечерня. Малое повечерие.</td></tr></table></div> // </div> // </body> // </html>"; // GetSequenceResponse response = new GetSequenceResponse() { Sequence = html }; // return response; //} public GetSequenceResponse GetSequence(GetSequenceRequest request) { TypiconEntityService typService = new TypiconEntityService(_unitOfWork); GetTypiconEntityResponse resp = typService.GetTypiconEntity(request.TypiconId); TypiconEntity typicon = resp.TypiconEntity ?? throw new NullReferenceException("TypiconEntity"); GetScheduleWeekResponse weekResponse = CreateScheduleService().GetScheduleWeek(new GetScheduleWeekRequest() { Date = request.Date, Typicon = typicon, Handler = new ScheduleHandler(), Language = "cs-ru", CheckParameters = new CustomParamsCollection <IRuleCheckParameter>().SetModeParam(HandlingMode.AstronomicDay) }); _unitOfWork.SaveChanges(); HtmlInnerScheduleWeekViewer viewer = new HtmlInnerScheduleWeekViewer(); viewer.Execute(weekResponse.Week); GetSequenceResponse response = new GetSequenceResponse() { Sequence = viewer.ResultString }; return(response); }
private void InitializeIoC() { var container = new RegisterByContainer().Container; var unitOfWork = container.GetInstance <IUnitOfWork>(); var typiconEntityService = container.With(unitOfWork).GetInstance <ITypiconEntityService>(); GetTypiconEntityResponse response = typiconEntityService.GetTypiconEntity(1);// _unitOfWork.Repository<TypiconEntity>().Get(c => c.Name == "Типикон"); typiconEntity = response.TypiconEntity; var bookStorage = new BookStorage( container.With(unitOfWork).GetInstance <IEvangelionContext>(), container.With(unitOfWork).GetInstance <IApostolContext>(), container.With(unitOfWork).GetInstance <IOldTestamentContext>(), container.With(unitOfWork).GetInstance <IPsalterContext>(), container.With(unitOfWork).GetInstance <IOktoikhContext>(), container.With(unitOfWork).GetInstance <ITheotokionAppContext>(), container.With(unitOfWork).GetInstance <IEasterContext>(), container.With(unitOfWork).GetInstance <IKatavasiaContext>()); IRuleSerializerRoot serializerRoot = container.With(bookStorage).GetInstance <IRuleSerializerRoot>(); settingsFactory = new CustomRuleSettingsFactory(); scheduleService = container.With(settingsFactory).With(serializerRoot).GetInstance <IScheduleService>(); }
public void CommonRuleElement_SimplePassing() { //находим первый попавшийся MenologyRule EFUnitOfWork _unitOfWork = new EFUnitOfWork(); //BookStorage.Instance = BookStorageFactory.Create(); GetTypiconEntityResponse resp = new TypiconEntityService(_unitOfWork).GetTypiconEntity(1); TypiconEntity typiconEntity = resp.TypiconEntity; MenologyRule rule = typiconEntity.MenologyRules[0]; ServiceSequenceHandler handler = new ServiceSequenceHandler(); handler.Settings = new RuleHandlerSettings() { Language = LanguageSettingsFactory.Create("cs-ru"), Rule = rule, Date = DateTime.Today }; string folderPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData"); FileReader reader = new FileReader(folderPath); string xml = reader.Read("CommonRuleElement_Simple.xml"); var element = TestRuleSerializer.Deserialize <WorshipSequence>(xml); element.Interpret(handler); var model = handler.GetResult(); //WorshipSequenceViewModel model = new WorshipSequenceViewModel(element, handler); Assert.AreEqual(30, model.FirstOrDefault()?.Count); }
private void MigrateCommonRules(TypiconEntity typiconEntity) { Console.WriteLine("MigrateCommonRules()"); Timer timer = new Timer(); timer.Start(); string folderPath = Path.Combine(Properties.Settings.Default.FolderPath, typiconEntity.Name, "Common"); FileReader fileReader = new FileReader(folderPath); IEnumerable <(string name, string content)> files = fileReader.ReadAllFromDirectory(); foreach ((string name, string content)file in files) { CommonRule commonRule = new CommonRule() { Name = file.name, RuleDefinition = file.content, Owner = typiconEntity }; typiconEntity.CommonRules.Add(commonRule); } timer.Stop(); Console.WriteLine(timer.GetStringValue()); }
public void TypiconEntity_Delete() { EFUnitOfWork _unitOfWork = new EFUnitOfWork(); TypiconEntity typiconEntity = new TypiconEntity() { Name = "Устав для удаления" }; //typiconEntity.RulesFolder.AddFolder(new TypiconFolderEntity() //{ // Name = "Папка для удаления", // Owner = typiconEntity //}); _unitOfWork.Repository <TypiconEntity>().Insert(typiconEntity); _unitOfWork.SaveChanges(); _unitOfWork.Repository <TypiconEntity>().Delete(typiconEntity); _unitOfWork.SaveChanges(); Assert.Pass("Deleted."); }
/// <summary> /// Добавляет измененное правило. /// Вызывается из метода Execute класса ModificationsRuleHandler /// </summary> /// <param name="request"></param> public void AddModifiedRule(TypiconEntity typicon, ModificationsRuleRequest request) { ModifiedYear modifiedYear = typicon.ModifiedYears.FirstOrDefault(m => m.Year == request.Date.Year); if (modifiedYear == null) { modifiedYear = new ModifiedYear() { Year = request.Date.Year, TypiconEntity = typicon }; typicon.ModifiedYears.Add(modifiedYear); } //ModifiedRule modifiedYear.ModifiedRules.Add(new ModifiedRule() { Date = request.Date, RuleEntity = request.Caller, Priority = request.Priority, IsLastName = request.IsLastName, IsAddition = request.AsAddition, ShortName = request.ShortName, UseFullName = request.UseFullName }); }
private void SetStringCommonRules(YmnosStructure ymnosStructure, TypiconEntity typicon) { CommonRuleServiceRequest req = new CommonRuleServiceRequest() { RuleSerializer = Serializer }; //добавляем стихи к славнику и богородичну if (ymnosStructure.Doxastichon != null) { //слава req.Key = CommonRuleConstants.SlavaText; ymnosStructure.Doxastichon.Ymnis[0].Stihoi.Add(typicon.GetCommonRuleItemTextValue(req)); //и ныне if (ymnosStructure.Theotokion?.Count > 0) { req.Key = CommonRuleConstants.InyneText; ymnosStructure.Theotokion[0].Ymnis[0].Stihoi.Add(typicon.GetCommonRuleItemTextValue(req)); } } else { //слава и ныне if (ymnosStructure.Theotokion?.Count > 0) { req.Key = CommonRuleConstants.SlavaInyneText; ymnosStructure.Theotokion[0].Ymnis[0].Stihoi.Add(typicon.GetCommonRuleItemTextValue(req)); } } }
private void ReloadCommonRules(TypiconEntity typiconEntity, string folderPath) { folderPath = Path.Combine(folderPath, typiconEntity.Name, "Common"); FileReader fileReader = new FileReader(folderPath); IEnumerable <(string name, string content)> files = fileReader.ReadAllFromDirectory(); foreach ((string name, string content) in files) { CommonRule commonRule = typiconEntity.GetCommonRule(c => c.Name == name); if (commonRule == null) { commonRule = new CommonRule() { Name = name, RuleDefinition = content, Owner = typiconEntity }; typiconEntity.CommonRules.Add(commonRule); } else { commonRule.RuleDefinition = content; } } }
private void InitializeIoC() { var container = new RegisterByContainer().Container; _unitOfWork = container.GetInstance <IUnitOfWork>(); _typiconEntityService = container.With(_unitOfWork).GetInstance <ITypiconEntityService>(); GetTypiconEntityResponse response = _typiconEntityService.GetTypiconEntity(1);// _unitOfWork.Repository<TypiconEntity>().Get(c => c.Name == "Типикон"); _typiconEntity = response.TypiconEntity; _bookStorage = new BookStorage( container.With(_unitOfWork).GetInstance <IEvangelionContext>(), container.With(_unitOfWork).GetInstance <IApostolContext>(), container.With(_unitOfWork).GetInstance <IOldTestamentContext>(), container.With(_unitOfWork).GetInstance <IPsalterContext>(), container.With(_unitOfWork).GetInstance <IOktoikhContext>(), container.With(_unitOfWork).GetInstance <ITheotokionAppContext>(), container.With(_unitOfWork).GetInstance <IEasterContext>(), container.With(_unitOfWork).GetInstance <IKatavasiaContext>()); //EasterStorage.Instance.EasterDays = _unitOfWork.Repository<EasterItem>().GetAll().ToList(); IRuleSerializerRoot serializerRoot = container.With(_bookStorage).GetInstance <IRuleSerializerRoot>(); var settingsFactory = container.GetInstance <IRuleHandlerSettingsFactory>(); _scheduleService = container.With(settingsFactory).With(serializerRoot).GetInstance <IScheduleService>(); _docxTemplateService = container.With(_bookStorage.Oktoikh).GetInstance <IDocxTemplateService>(); }
public void TypiconEntity_FromDB() { EFUnitOfWork _unitOfWork = new EFUnitOfWork(); TypiconEntity typiconEntity = _unitOfWork.Repository <TypiconEntity>().Get(c => c.Name == "Типикон"); Assert.AreEqual(typiconEntity.Signs.Count, 16); }
protected bool IsAuthorizedToEdit(TypiconEntity typiconEntity) { var result = AuthorizationService.AuthorizeAsync( User, typiconEntity, TypiconOperations.Edit); return(result.Result.Succeeded); }
public void Typicon_TypiconEntity_ModifiedYear() { TypiconEntity typicon = new TypiconEntity(); ModifiedYear year = typicon.ModifiedYears.FirstOrDefault(c => c.Year == 2017); Assert.IsNull(year); }
protected async Task <bool> IsTypiconsAuthor(TypiconEntity typiconEntity) { var result = await _authorizationService.AuthorizeAsync( User as ClaimsPrincipal, typiconEntity, TypiconOperations.Delete); return(result.Succeeded); }
public void IsExists_Test() { EFUnitOfWork _unitOfWork = new EFUnitOfWork(); //BookStorage.Instance = BookStorageFactory.Create(); GetTypiconEntityResponse resp = new TypiconEntityService(_unitOfWork).GetTypiconEntity(1); TypiconEntity typiconEntity = resp.TypiconEntity; ServiceSequenceHandler handler = new ServiceSequenceHandler() { Settings = new RuleHandlerSettings() { Language = LanguageSettingsFactory.Create("cs-ru") } }; string folderPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData"); FileReader reader = new FileReader(folderPath); string xml = reader.Read("IsExists.xml"); //Дата --01-16 exists - false DateTime date = new DateTime(2017, 01, 16); MenologyRule rule = typiconEntity.GetMenologyRule(date); rule.RuleDefinition = xml; handler.Settings.Rule = rule; handler.Settings.DayWorships = rule.DayWorships; handler.Settings.Date = date; rule.GetRule(TestRuleSerializer.Root).Interpret(handler); var model = handler.GetResult(); //EktenisViewModel model = rule.GetRule<EktenisRule>(TestRuleSerializer.Root).CreateViewModel(handler) as EktenisViewModel; Assert.AreEqual(1, model.FirstOrDefault()?.Count); //Дата --02-09 exists - true date = new DateTime(2017, 02, 09); rule = typiconEntity.GetMenologyRule(date); rule.RuleDefinition = xml; handler.Settings.Rule = rule; handler.Settings.DayWorships = rule.DayWorships; handler.Settings.Date = date; rule.GetRule(TestRuleSerializer.Root).Interpret(handler); model = handler.GetResult(); //model = rule.GetRule<EktenisRule>(TestRuleSerializer.Root).CreateViewModel(handler) as EktenisViewModel; Assert.AreEqual(2, model.FirstOrDefault()?.Count); }
public void IsCelebrating_Test() { //находим первый попавшийся MenologyRule EFUnitOfWork _unitOfWork = new EFUnitOfWork(); //BookStorage.Instance = BookStorageFactory.Create(); GetTypiconEntityResponse resp = new TypiconEntityService(_unitOfWork).GetTypiconEntity(1); TypiconEntity typiconEntity = resp.TypiconEntity; ServiceSequenceHandler handler = new ServiceSequenceHandler() { Settings = new RuleHandlerSettings() { Language = LanguageSettingsFactory.Create("cs-ru"), Date = DateTime.Today } }; string folderPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData"); FileReader reader = new FileReader(folderPath); string xml = reader.Read("IsCelebrating_Simple.xml"); //Ektenis element = RuleFactory.CreateElement(xml) as Ektenis; //находим Праздничное правило MenologyRule rule = typiconEntity.GetMenologyRule(new DateTime(2017, 09, 28)); rule.RuleDefinition = xml; handler.Settings.Rule = rule; handler.Settings.DayWorships = rule.DayWorships; rule.GetRule(TestRuleSerializer.Root).Interpret(handler); var model = handler.GetResult(); //var model = rule.GetRule<EktenisRule>(TestRuleSerializer.Root).CreateViewModel(handler) as EktenisViewModel; Assert.AreEqual(3, model.FirstOrDefault()?.Count); //а теперь находим правило НЕ праздничное rule = typiconEntity.GetMenologyRule(new DateTime(2017, 10, 15)); rule.RuleDefinition = xml; handler.Settings.Rule = rule; handler.Settings.DayWorships = rule.DayWorships; handler.ClearResult(); rule.GetRule(TestRuleSerializer.Root).Interpret(handler); model = handler.GetResult(); //model = rule.GetRule<EktenisRule>(TestRuleSerializer.Root).CreateViewModel(handler) as EktenisViewModel; Assert.AreEqual(2, model.FirstOrDefault()?.Count); }
public TypiconEntity GetOwner() { TypiconEntity result = Owner; if ((result == null) && (Parent != null)) { return(Parent.GetOwner()); } return(result); }
private void MigrateKathismas(TypiconEntity typiconEntity) { Console.WriteLine("MigrateKathismas(TypiconEntity typiconEntity)"); string folder = Path.Combine(Properties.Settings.Default.FolderPath, @"Books\Psalter"); var context = new PsalterContext(_unitOfWork); var manager = new KathismasMigrationManager(context); manager.MigrateKathismas(new PsalterRuReader(folder, "cs-ru"), typiconEntity); }
public void DayServiceTest_Working() { EFUnitOfWork _unitOfWork = new EFUnitOfWork(); //BookStorage.Instance = BookStorageFactory.Create(); TypiconEntity typiconEntity = _unitOfWork.Repository <TypiconEntity>().Get(c => c.Name == "Типикон"); MenologyRule menologyRule = typiconEntity.GetMenologyRule(new DateTime(2017, 09, 28)); Assert.NotNull(menologyRule.GetRule(TestRuleSerializer.Root)); }
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); }
public void KathismasMigration_CS_RU_Full() { string folderPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\PsalterMigration"); var typicon = new TypiconEntity(); var manager = new KathismasMigrationManager(BookStorageFactory.Create().Psalter); manager.MigrateKathismas(new PsalterRuReader(folderPath, "cs-ru"), typicon); Assert.AreEqual(20, typicon.Kathismas.Count); }
public static TypiconEntity Create() { TypiconEntity typiconEntity = new TypiconEntity() { Name = "Типикон", Settings = new TypiconSettings() { DefaultLanguage = "cs-ru" } }; return(typiconEntity); }
/// <summary> /// Возвращает список измененных правил для конкретной даты /// </summary> /// <param name="date">Конкретная дата</param> /// <returns></returns> public static IEnumerable <ModifiedRule> GetModifiedRules(this TypiconEntity typicon, DateTime date, IRuleSerializerRoot serializer) { ModifiedYear modifiedYear = typicon.ModifiedYears.FirstOrDefault(m => m.Year == date.Year); if (modifiedYear == null) { modifiedYear = CreateModifiedYear(typicon, date, serializer); //typicon.ModifiedYears.Add(modifiedYear); //_unitOfWork.Commit(); } return(modifiedYear.ModifiedRules.Where(d => d.Date.Date == date.Date)); }
/// <summary> /// Возвращает список измененных правил для конкретной даты /// </summary> /// <param name="date">Конкретная дата</param> /// <returns></returns> public IEnumerable <ModifiedRule> GetModifiedRules(TypiconEntity typicon, DateTime date) { ModifiedYear modifiedYear = typicon.ModifiedYears.FirstOrDefault(m => m.Year == date.Year); if (modifiedYear == null) { modifiedYear = CreateModifiedYear(typicon, date); typicon.ModifiedYears.Add(modifiedYear); //_unitOfWork.Commit(); } return(modifiedYear.ModifiedRules.FindAll(d => d.Date.Date == date.Date)); }
private void Initialize(IUnitOfWork unitOfWork) { _unitOfWork = unitOfWork ?? throw new ArgumentNullException("unitOfWork"); _typiconEntity = _unitOfWork.Repository <TypiconEntity>().Get(c => c.Name == "Типикон"); if (_typiconEntity == null) { throw new NullReferenceException("TypiconEntity"); } var easterContext = new EasterFakeContext(new DateTime(2010, 4, 7)); _scheduleService = ScheduleServiceFactory.Create(_unitOfWork, easterContext); }
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 YmnosStructureRule_FromRealDB() { EFUnitOfWork _unitOfWork = new EFUnitOfWork(); //BookStorage.Instance = BookStorageFactory.Create(); GetTypiconEntityResponse resp = new TypiconEntityService(_unitOfWork).GetTypiconEntity(1); TypiconEntity typiconEntity = resp.TypiconEntity; ServiceSequenceHandler handler = new ServiceSequenceHandler() { Settings = new RuleHandlerSettings() { Language = LanguageSettingsFactory.Create("cs-ru") } }; string folderPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData"); FileReader reader = new FileReader(folderPath); string xml = reader.Read("YmnosStructureRuleTest.xml"); //Дата --11-09 exists - true DateTime date = new DateTime(2017, 11, 09); MenologyRule rule = typiconEntity.GetMenologyRule(date); rule.RuleDefinition = xml; handler.Settings.Rule = rule; handler.Settings.DayWorships = rule.DayWorships; handler.Settings.Date = date; var bookStorage = BookStorageFactory.Create(); OktoikhDay oktoikhDay = bookStorage.Oktoikh.Get(date); handler.Settings.OktoikhDay = oktoikhDay; rule.GetRule(TestRuleSerializer.Root).Interpret(handler); var model = handler.GetResult(); //SedalenRuleViewModel model = rule.GetRule<SedalenRule>(TestRuleSerializer.Root).CreateViewModel(handler) as SedalenRuleViewModel; Assert.AreEqual(3, rule.GetRule <SedalenRule>(TestRuleSerializer.Root).Structure.YmnosStructureCount); Assert.Pass(rule.GetRule <SedalenRule>(TestRuleSerializer.Root).Structure.YmnosStructureCount.ToString()); }
public void KanonasRule_FromDB() { EFUnitOfWork _unitOfWork = new EFUnitOfWork(); //BookStorage.Instance = BookStorageFactory.Create(); GetTypiconEntityResponse resp = new TypiconEntityService(_unitOfWork).GetTypiconEntity(1); TypiconEntity typiconEntity = resp.TypiconEntity; ServiceSequenceHandler handler = new ServiceSequenceHandler() { Settings = new RuleHandlerSettings() { Language = LanguageSettingsFactory.Create("cs-ru") } }; string folderPath = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData"); FileReader reader = new FileReader(folderPath); string xml = reader.Read("KanonasRuleTest.xml"); DateTime date = new DateTime(2017, 11, 11); MenologyRule rule = typiconEntity.GetMenologyRule(date); rule.RuleDefinition = xml; handler.Settings.Rule = rule; handler.Settings.DayWorships = rule.DayWorships; handler.Settings.Date = date; var bookStorage = BookStorageFactory.Create(); OktoikhDay oktoikhDay = bookStorage.Oktoikh.Get(date); handler.Settings.OktoikhDay = oktoikhDay; //rule.GetRule(TestRuleSerializer.Root).Interpret(handler); handler.ClearResult(); KanonasRule kanonasRule = rule.GetRule <KanonasRule>(TestRuleSerializer.Root); kanonasRule.Interpret(handler); Assert.AreEqual(4, kanonasRule.Kanones.Count()); //Assert.IsNotNull(kanonasRule.Sedalen); }
private TypiconVersion GetTypiconVersion() { var user = new User() { //Id = 2, }; var typicon = new TypiconEntity() { Owner = user, OwnerId = user.Id }; return(new TypiconVersion() { Typicon = typicon, //TypiconId = 2 }); }
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); }
private Result UpdateIsTemplateProperty(TypiconEntity found, bool isTemplate) { //находим черновик var draft = DbContext.Set <TypiconVersion>() .FirstOrDefault(c => c.TypiconId == found.Id && c.BDate == null && c.EDate == null); if (draft == null) { return(Result.Fail($"Версия черновика Устава с id={found.Id} не найдена.")); } if (draft.IsTemplate != isTemplate) { draft.IsTemplate = isTemplate; draft.IsModified = true; } return(Result.Ok()); }