Skip to content

Commit

Permalink
Replaced GermanHolidayImporter with generic ExcelImporter
Browse files Browse the repository at this point in the history
  • Loading branch information
axunonb committed Dec 12, 2020
1 parent c9a59dd commit 1961ab0
Show file tree
Hide file tree
Showing 5 changed files with 168 additions and 11 deletions.
159 changes: 159 additions & 0 deletions TournamentManager/TournamentManager/Assets/Holidays.A-Indoor.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
<?xml version='1.0' encoding="UTF-8" standalone='yes'?>
<!-- element names are not case sensitive -->
<!-- Do NOT supply PublicHolidayStateIds for federal public holidays -->
<!-- Name and Type are required elements except for Remove action -->
<!-- THIS IMPORT FILE IS OBSOLETE - DO NOT USE -->
<Holidays>
<!-- Permanente Holidays in Augsburg and Volleyball League Augsburg -->
<Holiday action="replace" id="AugsburgerFriedensfest">
<Type>Public</Type>
<Name>Augsburger Friedensfest</Name
<PublicHolidayStateIds>
<StateId>Bayern</StateId>
</PublicHolidayStateIds>
</Holiday>
<Holiday action="replace" id="HeiligerAbend">
<Type>Custom</Type>
<Name>Heiliger Abend</Name>
</Holiday>
<Holiday action="replace" id="RosenMontag">
<Type>Custom</Type>
<Name>Rosenmontag</Name>
</Holiday>
<Holiday action="replace" id="FaschingsDienstag">
<Type>Custom</Type>
<Name>Faschingsdienstag</Name>
</Holiday>
<Holiday action="replace" id="Silvester">
<Type>Custom</Type>
<Name>Silvester</Name>
</Holiday>
<!-- School Holiday in Bavaria For School Year 2019/20 -->
<Holiday action="merge">
<Type>School</Type>
<DateFrom>2019-10-28</DateFrom>
<DateTo>2019-10-31</DateTo>
<Name>Herbstferien</Name>
<PublicHolidayStateIds>
<StateId>Bayern</StateId>
</PublicHolidayStateIds>
</Holiday>
<Holiday action="merge">
<Type>School</Type>
<DateFrom>2019-11-20</DateFrom>
<DateTo>2019-11-20</DateTo>
<Name>Herbstferien</Name>
<PublicHolidayStateIds>
<StateId>Bayern</StateId>
</PublicHolidayStateIds>
</Holiday>
<Holiday action="merge">
<Type>School</Type>
<DateFrom>2019-12-23</DateFrom>
<DateTo>2020-01-04</DateTo>
<Name>Weihnachtsferien</Name>
<PublicHolidayStateIds>
<StateId>Bayern</StateId>
</PublicHolidayStateIds>
</Holiday>
<Holiday action="merge">
<Type>School</Type>
<DateFrom>2020-02-24</DateFrom>
<DateTo>2020-02-28</DateTo>
<Name>Winterferien</Name>
<PublicHolidayStateIds>
<StateId>Bayern</StateId>
</PublicHolidayStateIds>
</Holiday>
<Holiday action="merge">
<Type>School</Type>
<DateFrom>2020-04-06</DateFrom>
<DateTo>2020-04-18</DateTo>
<Name>Osterferien</Name>
<PublicHolidayStateIds>
<StateId>Bayern</StateId>
</PublicHolidayStateIds>
</Holiday>
<Holiday action="merge">
<Type>School</Type>
<DateFrom>2020-06-02</DateFrom>
<DateTo>2020-06-13</DateTo>
<Name>Pfingstferien</Name>
<PublicHolidayStateIds>
<StateId>Bayern</StateId>
</PublicHolidayStateIds>
</Holiday>
<Holiday action="merge">
<Type>School</Type>
<DateFrom>2020-07-27</DateFrom>
<DateTo>2020-09-07</DateTo>
<Name>Sommerferien</Name>
<PublicHolidayStateIds>
<StateId>Bayern</StateId>
</PublicHolidayStateIds>
</Holiday>
<!-- School Holiday in Bavaria For School Year 2020/21 -->
<Holiday action="merge">
<Type>School</Type>
<DateFrom>2020-10-31</DateFrom>
<DateTo>2020-11-06</DateTo>
<Name>Herbstferien</Name>
<PublicHolidayStateIds>
<StateId>Bayern</StateId>
</PublicHolidayStateIds>
</Holiday>
<Holiday action="merge">
<Type>School</Type>
<DateFrom>2020-11-18</DateFrom>
<DateTo>2020-11-18</DateTo>
<Name>Herbstferien</Name>
<PublicHolidayStateIds>
<StateId>Bayern</StateId>
</PublicHolidayStateIds>
</Holiday>
<Holiday action="merge">
<Type>School</Type>
<DateFrom>2020-12-23</DateFrom>
<DateTo>2021-01-09</DateTo>
<Name>Weihnachtsferien</Name>
<PublicHolidayStateIds>
<StateId>Bayern</StateId>
</PublicHolidayStateIds>
</Holiday>
<Holiday action="merge">
<Type>School</Type>
<DateFrom>2021-02-15</DateFrom>
<DateTo>2021-02-19</DateTo>
<Name>Winterferien</Name>
<PublicHolidayStateIds>
<StateId>Bayern</StateId>
</PublicHolidayStateIds>
</Holiday>
<Holiday action="merge">
<Type>School</Type>
<DateFrom>2021-03-29</DateFrom>
<DateTo>2021-04-10</DateTo>
<Name>Osterferien</Name>
<PublicHolidayStateIds>
<StateId>Bayern</StateId>
</PublicHolidayStateIds>
</Holiday>
<Holiday action="merge">
<Type>School</Type>
<DateFrom>2021-05-25</DateFrom>
<DateTo>2021-06-04</DateTo>
<Name>Pfingstferien</Name>
<PublicHolidayStateIds>
<StateId>Bayern</StateId>
</PublicHolidayStateIds>
</Holiday>
<Holiday action="merge">
<Type>School</Type>
<DateFrom>2021-07-30</DateFrom>
<DateTo>2021-09-13</DateTo>
<Name>Sommerferien</Name>
<PublicHolidayStateIds>
<StateId>Bayern</StateId>
</PublicHolidayStateIds>
</Holiday>
</Holidays>
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class InternetCalendarImporter
/// <param name="iCalendarString"></param>
/// <param name="defaultTimeZoneId">The time zone to use, if it is not included in the start and end date/time of the event.</param>
/// <param name="dateLimits">The lower and upper UTC date limit to import.</param>
/// <returns></returns>
/// <returns>Return an <see cref="EntityCollection"/> of type <see cref="ExcludeMatchDateEntity"/> with imported dates.</returns>
public EntityCollection<ExcludeMatchDateEntity> Import(string iCalendarString, string defaultTimeZoneId, DateTimePeriod dateLimits)
{
var iCal = Ical.Net.Calendar.Load(iCalendarString);
Expand All @@ -30,7 +30,7 @@ public EntityCollection<ExcludeMatchDateEntity> Import(string iCalendarString, s
/// <param name="encoding">The <seealso cref="System.Text.Encoding"/> to use.</param>
/// <param name="defaultTimeZoneId">The time zone to use, if it is not included in the start and end date/time of the event.</param>
/// <param name="dateLimits">The lower and upper UTC date limit to import.</param>
/// <returns></returns>
/// <returns>Return an <see cref="EntityCollection"/> of type <see cref="ExcludeMatchDateEntity"/> with imported dates.</returns>
public EntityCollection<ExcludeMatchDateEntity> Import(Stream iCalendarStream, System.Text.Encoding encoding, string defaultTimeZoneId, DateTimePeriod dateLimits)
{
var iCal = Ical.Net.Calendar.Load(new StreamReader(iCalendarStream, encoding));
Expand Down
14 changes: 6 additions & 8 deletions TournamentManager/TournamentManager/Plan/MatchPlanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,10 @@ private async Task LoadEntitiesAsync(CancellationToken cancellationToken)
/// Generates dates which are excluded for the tournament with <see cref="OrganizationContext.MatchPlanTournamentId"/>
/// and saves them to persistent storage. Existing entries for the tournament are removed.
/// </summary>
/// <param name="specialHolidaysXmlFile"></param>
/// <param name="holidayFilter"></param>
/// <param name="excelImportFile"></param>
/// <param name="cancellationToken"></param>
/// <returns></returns>
public async Task GenerateExcludedDates(string specialHolidaysXmlFile,
Predicate<Axuno.Tools.GermanHoliday> holidayFilter, CancellationToken cancellationToken)
public async Task GenerateExcludedDates(string excelImportFile, CancellationToken cancellationToken)
{
if (!AreEntitiesLoaded) await LoadEntitiesAsync(cancellationToken);

Expand All @@ -81,10 +79,10 @@ await _appDb.GenericRepository.DeleteEntitiesDirectlyAsync(typeof(ExcludeMatchDa
cancellationToken);

var excludedDates = new EntityCollection<ExcludeMatchDateEntity>(
new Importers.ExcludedDates.GermanHolidayImporter(_timeZoneConverter,
_loggerFactory.CreateLogger<Importers.ExcludedDates.GermanHolidayImporter>()).Import(
specialHolidaysXmlFile,
new DateTimePeriod(minDate, maxDate), holidayFilter));
new TournamentManager.Importers.ExcludedDates.ExcelImporter(
_timeZoneConverter,
_loggerFactory.CreateLogger<Importers.ExcludedDates.ExcelImporter>())
.Import(excelImportFile, new DateTimePeriod(minDate, maxDate)));

foreach (var excludeMatchDateEntity in excludedDates)
excludeMatchDateEntity.TournamentId = _organizationContext.MatchPlanTournamentId;
Expand Down

0 comments on commit 1961ab0

Please sign in to comment.