Skip to content

Commit

Permalink
Merge pull request #10 from MattMofDoom/dev
Browse files Browse the repository at this point in the history
Fix issues with AbstractApiHolidays class
  • Loading branch information
MattMofDoom authored Jun 14, 2021
2 parents 4aed18e + 115772b commit dcb4838
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 39 deletions.
66 changes: 34 additions & 32 deletions Seq.App.EventTimeout/Classes/AbstractApiHolidays.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ namespace Seq.App.EventTimeout.Classes
/// <summary>
/// AbstractAPI Holidays API format
/// </summary>
public abstract class AbstractApiHolidays
// ReSharper disable once ClassNeverInstantiated.Global
public class AbstractApiHolidays
{
/// <summary>
/// AbstractAPI Holidays API format
Expand All @@ -26,56 +27,57 @@ public abstract class AbstractApiHolidays
/// <param name="date_day"></param>
/// <param name="week_day"></param>
// ReSharper disable InconsistentNaming
protected AbstractApiHolidays(string name, string name_local, string language, string description,
// ReSharper disable once ArrangeTypeMemberModifiers
public AbstractApiHolidays(string name, string name_local, string language, string description,
string country,
string location, string type, string date, string date_year, string date_month, string date_day,
string week_day)
{
this.name = name;
this.name_local = name_local;
this.language = language;
this.description = description;
this.location = location;
if (this.location.Contains(" - "))
Locations = this.location
.Substring(this.location.IndexOf(" - ", StringComparison.Ordinal) + 3,
this.location.Length - this.location.IndexOf(" - ", StringComparison.Ordinal) - 3)
Name = name;
Name_Local = name_local;
Language = language;
Description = description;
Location = location;
if (Location.Contains(" - "))
Locations = Location
.Substring(Location.IndexOf(" - ", StringComparison.Ordinal) + 3,
Location.Length - Location.IndexOf(" - ", StringComparison.Ordinal) - 3)
.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries).Select(t => t.Trim()).ToList();
else
Locations = this.location.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries)
Locations = Location.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries)
.Select(t => t.Trim())
.ToList();

this.country = country;
this.type = type;
this.date = date;
this.date_year = date_year;
this.date_month = date_month;
this.date_day = date_day;
this.week_day = week_day;
LocalStart = DateTime.ParseExact(this.date, "M/d/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None);
Country = country;
Type = type;
Date = date;
DateYear = date_year;
DateMonth = date_month;
DateDay = date_day;
WeekDay = week_day;
LocalStart = DateTime.ParseExact(Date, "M/d/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None);
UtcStart = LocalStart.ToUniversalTime();
UtcEnd = LocalStart.AddDays(1).ToUniversalTime();
}

// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedAutoPropertyAccessor.Local
// ReSharper disable UnusedAutoPropertyAccessor.Global
public string name { get; }
public string name_local { get; }
public string language { get; }
public string description { get; }
public string country { get; }
public string location { get; }
public string Name { get; }
public string Name_Local { get; }
public string Language { get; }
public string Description { get; }
public string Country { get; }
public string Location { get; }
public List<string> Locations { get; }
public string type { get; }
public string Type { get; }
public DateTime LocalStart { get; }
public DateTime UtcStart { get; }
public DateTime UtcEnd { get; }
public string date { get; }
public string date_year { get; }
public string date_month { get; }
public string date_day { get; }
public string week_day { get; }
public string Date { get; }
public string DateYear { get; }
public string DateMonth { get; }
public string DateDay { get; }
public string WeekDay { get; }
}
}
4 changes: 2 additions & 2 deletions Seq.App.EventTimeout/Classes/Holidays.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static List<AbstractApiHolidays> ValidateHolidays(IEnumerable<AbstractApi
if (holidayMatch.Count > 0)
// ReSharper disable once UnusedVariable
foreach (var match in holidayMatch.Where(match =>
holiday.type.IndexOf(match, StringComparison.OrdinalIgnoreCase) >= 0))
holiday.Type.IndexOf(match, StringComparison.OrdinalIgnoreCase) >= 0))
hasType = true;

if (localeMatch.Count > 0)
Expand All @@ -58,7 +58,7 @@ public static List<AbstractApiHolidays> ValidateHolidays(IEnumerable<AbstractApi
0))
hasRegion = true;

if (!includeBank && holiday.name.IndexOf("Bank Holiday", StringComparison.OrdinalIgnoreCase) >= 0)
if (!includeBank && holiday.Name.IndexOf("Bank Holiday", StringComparison.OrdinalIgnoreCase) >= 0)
isBank = true;

if (!includeWeekends && (holiday.LocalStart.DayOfWeek == DayOfWeek.Sunday ||
Expand Down
8 changes: 4 additions & 4 deletions Seq.App.EventTimeout/EventTimeoutReactor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -816,17 +816,17 @@ private void RetrieveHolidays(DateTime localDate, DateTime utcDate)
foreach (var holiday in result)
LogEvent(LogEventLevel.Debug,
"Holiday Name: {Name}, Local Name {LocalName}, Start {LocalStart}, Start UTC {Start}, End UTC {End}, Type {Type}, Location string {Location}, Locations parsed {Locations} ...",
holiday.name, holiday.name_local, holiday.LocalStart, holiday.UtcStart, holiday.UtcEnd,
holiday.type, holiday.location, holiday.Locations.ToArray());
holiday.Name, holiday.Name_Local, holiday.LocalStart, holiday.UtcStart, holiday.UtcEnd,
holiday.Type, holiday.Location, holiday.Locations.ToArray());
}

LogEvent(LogEventLevel.Debug, "Holidays retrieved and validated {holidayCount} ...",
_holidays.Count);
foreach (var holiday in _holidays)
LogEvent(LogEventLevel.Debug,
"Holiday Name: {Name}, Local Name {LocalName}, Start {LocalStart}, Start UTC {Start}, End UTC {End}, Type {Type}, Location string {Location}, Locations parsed {Locations} ...",
holiday.name, holiday.name_local, holiday.LocalStart, holiday.UtcStart, holiday.UtcEnd,
holiday.type, holiday.location, holiday.Locations.ToArray());
holiday.Name, holiday.Name_Local, holiday.LocalStart, holiday.UtcStart, holiday.UtcEnd,
holiday.Type, holiday.Location, holiday.Locations.ToArray());

_isUpdating = false;
if (!_isShowtime) UtcRollover(utcDate, true);
Expand Down
2 changes: 1 addition & 1 deletion Seq.App.EventTimeout/Seq.App.EventTimeout.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Copyright></Copyright>
<VersionSuffix>$([System.DateTime]::UtcNow.ToString(mmff))</VersionSuffix>
<!--<AssemblyVersion>1.2.3.0</AssemblyVersion>-->
<Version>1.4.0</Version>
<Version>1.4.2</Version>
<AssemblyVersion Condition=" '$(VersionSuffix)' == '' ">$(Version).1</AssemblyVersion>
<AssemblyVersion Condition=" '$(VersionSuffix)' != '' ">$(Version).$(VersionSuffix)</AssemblyVersion>
<FileVersion Condition=" '$(VersionSuffix)' == '' ">$(Version).0</FileVersion>
Expand Down

0 comments on commit dcb4838

Please sign in to comment.