From 1961ab0ca065a3f32545575c1f68ae0788d46cba Mon Sep 17 00:00:00 2001 From: Norbert Bietsch Date: Sat, 12 Dec 2020 20:08:06 +0100 Subject: [PATCH] Replaced GermanHolidayImporter with generic ExcelImporter --- .../{ExludedDates.xlsx => ExcludedDates.xlsx} | Bin .../Assets/Holidays.A-Indoor.config | 159 ++++++++++++++++++ .../ExcludedDates/GermanHolidayImporter.cs | 2 +- .../ExcludedDates/InternetCalendarImporter.cs | 4 +- .../TournamentManager/Plan/MatchPlanner.cs | 14 +- 5 files changed, 168 insertions(+), 11 deletions(-) rename TournamentManager/TournamentManager/Assets/{ExludedDates.xlsx => ExcludedDates.xlsx} (100%) create mode 100644 TournamentManager/TournamentManager/Assets/Holidays.A-Indoor.config diff --git a/TournamentManager/TournamentManager/Assets/ExludedDates.xlsx b/TournamentManager/TournamentManager/Assets/ExcludedDates.xlsx similarity index 100% rename from TournamentManager/TournamentManager/Assets/ExludedDates.xlsx rename to TournamentManager/TournamentManager/Assets/ExcludedDates.xlsx diff --git a/TournamentManager/TournamentManager/Assets/Holidays.A-Indoor.config b/TournamentManager/TournamentManager/Assets/Holidays.A-Indoor.config new file mode 100644 index 00000000..c63c7414 --- /dev/null +++ b/TournamentManager/TournamentManager/Assets/Holidays.A-Indoor.config @@ -0,0 +1,159 @@ + + + + + + + + + Public + Augsburger Friedensfest´ + + Bayern + + + + Custom + Heiliger Abend + + + Custom + Rosenmontag + + + Custom + Faschingsdienstag + + + Custom + Silvester + + + + School + 2019-10-28 + 2019-10-31 + Herbstferien + + Bayern + + + + School + 2019-11-20 + 2019-11-20 + Herbstferien + + Bayern + + + + School + 2019-12-23 + 2020-01-04 + Weihnachtsferien + + Bayern + + + + School + 2020-02-24 + 2020-02-28 + Winterferien + + Bayern + + + + School + 2020-04-06 + 2020-04-18 + Osterferien + + Bayern + + + + School + 2020-06-02 + 2020-06-13 + Pfingstferien + + Bayern + + + + School + 2020-07-27 + 2020-09-07 + Sommerferien + + Bayern + + + + + School + 2020-10-31 + 2020-11-06 + Herbstferien + + Bayern + + + + School + 2020-11-18 + 2020-11-18 + Herbstferien + + Bayern + + + + School + 2020-12-23 + 2021-01-09 + Weihnachtsferien + + Bayern + + + + School + 2021-02-15 + 2021-02-19 + Winterferien + + Bayern + + + + School + 2021-03-29 + 2021-04-10 + Osterferien + + Bayern + + + + School + 2021-05-25 + 2021-06-04 + Pfingstferien + + Bayern + + + + School + 2021-07-30 + 2021-09-13 + Sommerferien + + Bayern + + + diff --git a/TournamentManager/TournamentManager/Importers/ExcludedDates/GermanHolidayImporter.cs b/TournamentManager/TournamentManager/Importers/ExcludedDates/GermanHolidayImporter.cs index 41507b8a..bea774d0 100644 --- a/TournamentManager/TournamentManager/Importers/ExcludedDates/GermanHolidayImporter.cs +++ b/TournamentManager/TournamentManager/Importers/ExcludedDates/GermanHolidayImporter.cs @@ -6,7 +6,7 @@ namespace TournamentManager.Importers.ExcludedDates { - [Obsolete("User ExcelImporter instead")] + [Obsolete("User ExcelImporter instead", true)] public class GermanHolidayImporter { private readonly Axuno.Tools.DateAndTime.TimeZoneConverter _timeZoneConverter; diff --git a/TournamentManager/TournamentManager/Importers/ExcludedDates/InternetCalendarImporter.cs b/TournamentManager/TournamentManager/Importers/ExcludedDates/InternetCalendarImporter.cs index d5ecee76..aaf32cbe 100644 --- a/TournamentManager/TournamentManager/Importers/ExcludedDates/InternetCalendarImporter.cs +++ b/TournamentManager/TournamentManager/Importers/ExcludedDates/InternetCalendarImporter.cs @@ -15,7 +15,7 @@ public class InternetCalendarImporter /// /// The time zone to use, if it is not included in the start and end date/time of the event. /// The lower and upper UTC date limit to import. - /// + /// Return an of type with imported dates. public EntityCollection Import(string iCalendarString, string defaultTimeZoneId, DateTimePeriod dateLimits) { var iCal = Ical.Net.Calendar.Load(iCalendarString); @@ -30,7 +30,7 @@ public EntityCollection Import(string iCalendarString, s /// The to use. /// The time zone to use, if it is not included in the start and end date/time of the event. /// The lower and upper UTC date limit to import. - /// + /// Return an of type with imported dates. public EntityCollection Import(Stream iCalendarStream, System.Text.Encoding encoding, string defaultTimeZoneId, DateTimePeriod dateLimits) { var iCal = Ical.Net.Calendar.Load(new StreamReader(iCalendarStream, encoding)); diff --git a/TournamentManager/TournamentManager/Plan/MatchPlanner.cs b/TournamentManager/TournamentManager/Plan/MatchPlanner.cs index 415fce76..44788c1a 100644 --- a/TournamentManager/TournamentManager/Plan/MatchPlanner.cs +++ b/TournamentManager/TournamentManager/Plan/MatchPlanner.cs @@ -58,12 +58,10 @@ private async Task LoadEntitiesAsync(CancellationToken cancellationToken) /// Generates dates which are excluded for the tournament with /// and saves them to persistent storage. Existing entries for the tournament are removed. /// - /// - /// + /// /// /// - public async Task GenerateExcludedDates(string specialHolidaysXmlFile, - Predicate holidayFilter, CancellationToken cancellationToken) + public async Task GenerateExcludedDates(string excelImportFile, CancellationToken cancellationToken) { if (!AreEntitiesLoaded) await LoadEntitiesAsync(cancellationToken); @@ -81,10 +79,10 @@ await _appDb.GenericRepository.DeleteEntitiesDirectlyAsync(typeof(ExcludeMatchDa cancellationToken); var excludedDates = new EntityCollection( - new Importers.ExcludedDates.GermanHolidayImporter(_timeZoneConverter, - _loggerFactory.CreateLogger()).Import( - specialHolidaysXmlFile, - new DateTimePeriod(minDate, maxDate), holidayFilter)); + new TournamentManager.Importers.ExcludedDates.ExcelImporter( + _timeZoneConverter, + _loggerFactory.CreateLogger()) + .Import(excelImportFile, new DateTimePeriod(minDate, maxDate))); foreach (var excludeMatchDateEntity in excludedDates) excludeMatchDateEntity.TournamentId = _organizationContext.MatchPlanTournamentId;