From c1b4affb20a9fb415409e4d01fdd2fe433c1f9bf Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Fri, 28 Jun 2024 10:47:27 +0200 Subject: [PATCH] Filter shipcalls that have ata set and ata is more than 2 hours in the past --- src/BreCalClient/MainWindow.xaml.cs | 31 +++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/BreCalClient/MainWindow.xaml.cs b/src/BreCalClient/MainWindow.xaml.cs index c564a67..ee8826e 100644 --- a/src/BreCalClient/MainWindow.xaml.cs +++ b/src/BreCalClient/MainWindow.xaml.cs @@ -640,7 +640,7 @@ namespace BreCalClient // first add everything this._visibleControlModels.AddRange(_allShipcallsDict.Values); - // now remove elements whose filter criteria are met + // now remove elements whose filter criteria are met if(sfm.Berths.Count > 0 ) { @@ -745,7 +745,34 @@ namespace BreCalClient _ = this._visibleControlModels.RemoveAll(x => x.Shipcall?.Canceled ?? false); } - switch(this._sortOrder) + // special Basti case: Wenn das ATA / ATD eingetragen ist und schon 2 Stunden in der Vergangenheit liegt + if (searchPastDays <= 3) + { + _ = this._visibleControlModels.RemoveAll(x => + { + Times? mooringTimes = x.GetTimesForParticipantType(ParticipantType.MOORING); + if (mooringTimes != null) + { + switch (x.Shipcall?.Type) + { + case ShipcallType.Arrival: + if (mooringTimes.Ata.HasValue && ((DateTime.Now - mooringTimes.Ata.Value).TotalHours > 2)) + return true; + break; + + default: + if (mooringTimes.Atd.HasValue && ((DateTime.Now - mooringTimes.Atd.Value).TotalHours > 2)) + return true; + break; + } + } + + return false; + }); + } + + + switch (this._sortOrder) { case Extensions.SortOrder.SHIP_NAME: this._visibleControlModels.Sort((x, y) => { if (x.Ship == null) return 0; if (y.Ship == null) return 0; return x.Ship.Name.CompareTo(y.Ship.Name); });