diff --git a/src/BreCalClient/App.config b/src/BreCalClient/App.config
index 335a433..31f6f0a 100644
--- a/src/BreCalClient/App.config
+++ b/src/BreCalClient/App.config
@@ -86,6 +86,12 @@
+
+ 0
+
+
+ 0
+
\ No newline at end of file
diff --git a/src/BreCalClient/AppNotification.cs b/src/BreCalClient/AppNotification.cs
index 7a0f075..ed66f31 100644
--- a/src/BreCalClient/AppNotification.cs
+++ b/src/BreCalClient/AppNotification.cs
@@ -3,34 +3,70 @@
//
using System;
-using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
using ToastNotifications.Core;
+using BreCalClient.misc.Model;
namespace BreCalClient
{
internal class AppNotification
{
- private static Dictionary _notifications = new ();
+ private static Dictionary _notifications = new();
private readonly int _id;
-
+ private static ObservableCollection _notificationsCollection = new();
public AppNotification(int id)
{
_id = id;
}
+ #region Properties
+
public int Id { get { return _id; } }
+ public string? NotificationType
+ {
+ get; private set;
+ }
+
+ public string? NotificationDate
+ {
+ get; private set;
+ }
+
+ public string? Ship
+ {
+ get; private set;
+ }
+
+ public string? ShipcallType
+ {
+ get; private set;
+ }
+
+ public string? Berth
+ {
+ get; private set;
+ }
+
+ public string? ETA
+ {
+ get; private set;
+ }
+
+ public static ObservableCollection AppNotifications { get { return _notificationsCollection; } }
+
+ #endregion
+
#region internal statics
internal static void LoadFromSettings()
{
_notifications.Clear();
- // preload notifications that have been processed
+ // load notification ids that have been processed
foreach (string? notification_id in Properties.Settings.Default.Notifications)
{
if(Int32.TryParse(notification_id, out int result))
@@ -47,61 +83,61 @@ namespace BreCalClient
internal static bool UpdateNotifications(List notifications, System.Collections.Concurrent.ConcurrentDictionary currentShipcalls, ToastViewModel vm)
{
bool result = false;
+
foreach (BreCalClient.misc.Model.Notification notification in notifications)
{
- if(!_notifications.ContainsKey(notification.Id))
+ if (notification.ParticipantId.HasValue && notification.ParticipantId.Value != App.Participant.Id) // not meant for us
+ continue;
+
+ if (!currentShipcalls.ContainsKey(notification.ShipcallId)) // not one of our shipcalls (maybe for another port or filtered)
+ continue;
+
+ if (!_notificationsCollection.Where(x => x.Id == notification.Id).Any())
{
- _notifications.Add(notification.Id, new AppNotification(notification.Id));
+ AppNotification ap = new(notification.Id);
+ ap.NotificationType = notification.Type.ToString();
+ ap.Ship = currentShipcalls[notification.ShipcallId]?.Ship?.Name;
+ ap.ShipcallType = currentShipcalls[notification.ShipcallId]?.Shipcall?.Type.ToString();
+ ap.ETA = currentShipcalls[notification.ShipcallId]?.GetETAETD(true);
+ Times? agencyTimes = currentShipcalls[notification.ShipcallId]?.GetTimesForParticipantType(Extensions.ParticipantType.AGENCY);
+ ap.Berth = currentShipcalls[notification.ShipcallId]?.GetBerthText(agencyTimes);
- // filter if the notification concerns us
- if(notification.ParticipantId != null)
+ System.Diagnostics.Trace.WriteLine($"Notification {notification.Id} Type {notification.Type}");
+ MessageOptions options = new();
+ options.FontSize = 14;
+ options.ShowCloseButton = true;
+
+ switch(notification.Type) // TODO: Set toast color and icon
{
- if(App.Participant.Id == notification.ParticipantId)
- {
- result = true;
- }
- }
- else
- {
- // find out if this notification concerns us
- if(currentShipcalls.ContainsKey(notification.ShipcallId))
- {
- result = true;
- }
+ case misc.Model.NotificationType.TimeConflict:
+
+ break;
+ case misc.Model.NotificationType.TimeConflictResolved:
+
+ break;
+ case misc.Model.NotificationType.Assignment:
+
+ break;
+ case misc.Model.NotificationType.Next24h:
+
+ break;
+ case misc.Model.NotificationType.Unassigned:
+
+ break;
}
-
- if(result)
+
+ _notificationsCollection.Add(ap);
+
+ string toastText = $"{ap.Ship} ({ap.ShipcallType}) - {ap.ETA} - {ap.Berth}";
+
+ if (!_notifications.ContainsKey(notification.Id))
{
- System.Diagnostics.Trace.WriteLine($"Notification {notification.Id} Type {notification.Type}");
- MessageOptions options = new MessageOptions();
- options.FontSize = 14;
- options.ShowCloseButton = true;
- switch(notification.Type)
- {
- case misc.Model.NotificationType.TimeConflict:
-
- break;
- case misc.Model.NotificationType.TimeConflictResolved:
-
- break;
- case misc.Model.NotificationType.Assignment:
-
- break;
- case misc.Model.NotificationType.Next24h:
-
- break;
- case misc.Model.NotificationType.Unassigned:
-
- break;
- }
-
- string toastText = $"{currentShipcalls[notification.ShipcallId]?.Ship?.Name} ({currentShipcalls[notification.ShipcallId]?.Shipcall?.Type}) - {currentShipcalls[notification.ShipcallId]?.GetETAETD(true)} - {currentShipcalls[notification.ShipcallId]?.GetBerthText(null)}";
+ _notifications.Add(notification.Id, ap);
App.Current.Dispatcher.Invoke(() =>
{
vm.ShowInformation(toastText, options);
});
- }
-
+ }
}
}
return result;
diff --git a/src/BreCalClient/BreCalClient.csproj b/src/BreCalClient/BreCalClient.csproj
index 5ad9573..cd0a12e 100644
--- a/src/BreCalClient/BreCalClient.csproj
+++ b/src/BreCalClient/BreCalClient.csproj
@@ -26,6 +26,7 @@
+
@@ -84,6 +85,7 @@
+
diff --git a/src/BreCalClient/HistoryDialog.xaml.cs b/src/BreCalClient/HistoryDialog.xaml.cs
index ce6cb2b..f827de0 100644
--- a/src/BreCalClient/HistoryDialog.xaml.cs
+++ b/src/BreCalClient/HistoryDialog.xaml.cs
@@ -1,5 +1,5 @@
// Copyright (c) 2024- schick Informatik
-// Description: Window to show (complete) list of current shipcall histories
+// Description:
//
using BreCalClient.misc.Api;
diff --git a/src/BreCalClient/MainWindow.xaml b/src/BreCalClient/MainWindow.xaml
index dd169f8..f7f14eb 100644
--- a/src/BreCalClient/MainWindow.xaml
+++ b/src/BreCalClient/MainWindow.xaml
@@ -124,6 +124,8 @@
+
+
@@ -157,19 +159,25 @@
+
+
+
+
-
-
+
+
-
+
-
-
+
+
diff --git a/src/BreCalClient/MainWindow.xaml.cs b/src/BreCalClient/MainWindow.xaml.cs
index 23e109a..be19337 100644
--- a/src/BreCalClient/MainWindow.xaml.cs
+++ b/src/BreCalClient/MainWindow.xaml.cs
@@ -71,6 +71,7 @@ namespace BreCalClient
// private bool _filterChanged = false;
// private bool _sequenceChanged = false;
private HistoryDialog? _historyDialog;
+ private NotificationDialog? _notificationDialog;
#endregion
@@ -453,6 +454,21 @@ namespace BreCalClient
}
}
+ private void buttonNotifications_Click(object sender, RoutedEventArgs e)
+ {
+ if (_notificationDialog == null)
+ {
+ _notificationDialog = new NotificationDialog();
+ _notificationDialog.AppNotifications = AppNotification.AppNotifications;
+ _notificationDialog.Closed += (sender, e) => { this._notificationDialog = null; };
+ _notificationDialog.Show();
+ }
+ else
+ {
+ _notificationDialog.Activate();
+ }
+ }
+
private void buttonManualRefresh_Click(object sender, RoutedEventArgs e)
{
_refreshImmediately = true; // set flag to avoid timer loop termination
@@ -649,8 +665,11 @@ namespace BreCalClient
while (true)
{
Thread.Sleep(CHECK_NOTIFICATIONS_INTERVAL_SECONDS * 1000);
- List notifications = await _staticApi.NotificationsGetAsync();
- AppNotification.UpdateNotifications(notifications, _allShipcallsDict, _vm);
+ if (_loginResult?.NotifyPopup ?? false)
+ {
+ List notifications = await _staticApi.NotificationsGetAsync();
+ AppNotification.UpdateNotifications(notifications, _allShipcallsDict, _vm);
+ }
}
}
diff --git a/src/BreCalClient/NotificationDialog.xaml b/src/BreCalClient/NotificationDialog.xaml
new file mode 100644
index 0000000..799e732
--- /dev/null
+++ b/src/BreCalClient/NotificationDialog.xaml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/BreCalClient/NotificationDialog.xaml.cs b/src/BreCalClient/NotificationDialog.xaml.cs
new file mode 100644
index 0000000..f2d7871
--- /dev/null
+++ b/src/BreCalClient/NotificationDialog.xaml.cs
@@ -0,0 +1,44 @@
+// Copyright (c) 2024- schick Informatik
+// Description:
+//
+
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace BreCalClient
+{
+ ///
+ /// Interaction logic for NotificationDialog.xaml
+ ///
+ public partial class NotificationDialog : Window
+ {
+ public NotificationDialog()
+ {
+ InitializeComponent();
+ }
+
+ internal ObservableCollection? AppNotifications { get; set; }
+
+ private void buttonClose_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ this.dataGridNotifications.ItemsSource = AppNotifications;
+ }
+ }
+}
diff --git a/src/BreCalClient/Properties/Settings.Designer.cs b/src/BreCalClient/Properties/Settings.Designer.cs
index f24308d..c5b234b 100644
--- a/src/BreCalClient/Properties/Settings.Designer.cs
+++ b/src/BreCalClient/Properties/Settings.Designer.cs
@@ -237,5 +237,29 @@ namespace BreCalClient.Properties {
this["Notifications"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public double W5Top {
+ get {
+ return ((double)(this["W5Top"]));
+ }
+ set {
+ this["W5Top"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("0")]
+ public double W5Left {
+ get {
+ return ((double)(this["W5Left"]));
+ }
+ set {
+ this["W5Left"] = value;
+ }
+ }
}
}
diff --git a/src/BreCalClient/Properties/Settings.settings b/src/BreCalClient/Properties/Settings.settings
index 9f7c317..e7203cb 100644
--- a/src/BreCalClient/Properties/Settings.settings
+++ b/src/BreCalClient/Properties/Settings.settings
@@ -59,5 +59,11 @@
+
+ 0
+
+
+ 0
+
\ No newline at end of file
diff --git a/src/BreCalClient/Resources/Resources.Designer.cs b/src/BreCalClient/Resources/Resources.Designer.cs
index 334beb7..325574e 100644
--- a/src/BreCalClient/Resources/Resources.Designer.cs
+++ b/src/BreCalClient/Resources/Resources.Designer.cs
@@ -167,6 +167,16 @@ namespace BreCalClient.Resources {
}
}
+ ///
+ /// Looks up a localized resource of type System.Byte[].
+ ///
+ public static byte[] bell3 {
+ get {
+ object obj = ResourceManager.GetObject("bell3", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
+
///
/// Looks up a localized resource of type System.Byte[].
///
@@ -560,6 +570,15 @@ namespace BreCalClient.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Date.
+ ///
+ public static string textDate {
+ get {
+ return ResourceManager.GetString("textDate", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Delete.
///
@@ -1208,6 +1227,15 @@ namespace BreCalClient.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Shipcall.
+ ///
+ public static string textShipcall {
+ get {
+ return ResourceManager.GetString("textShipcall", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Ship length.
///
@@ -1244,6 +1272,15 @@ namespace BreCalClient.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Show notificiations.
+ ///
+ public static string textShowNotifications {
+ get {
+ return ResourceManager.GetString("textShowNotifications", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Sort order.
///
diff --git a/src/BreCalClient/Resources/Resources.de.resx b/src/BreCalClient/Resources/Resources.de.resx
index 183f264..eb6547f 100644
--- a/src/BreCalClient/Resources/Resources.de.resx
+++ b/src/BreCalClient/Resources/Resources.de.resx
@@ -565,4 +565,13 @@
Banner / Push Benachrichtigung in App
+
+ Datum
+
+
+ Anlauf
+
+
+ Benachrichtigungen anzeigen
+
\ No newline at end of file
diff --git a/src/BreCalClient/Resources/Resources.resx b/src/BreCalClient/Resources/Resources.resx
index 5ea32f5..cf96621 100644
--- a/src/BreCalClient/Resources/Resources.resx
+++ b/src/BreCalClient/Resources/Resources.resx
@@ -613,4 +613,16 @@
Notify by push notification in app
+
+ bell3.png;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ Date
+
+
+ Shipcall
+
+
+ Show notificiations
+
\ No newline at end of file
diff --git a/src/BreCalClient/Resources/bell3.png b/src/BreCalClient/Resources/bell3.png
new file mode 100644
index 0000000..ddc6a0e
Binary files /dev/null and b/src/BreCalClient/Resources/bell3.png differ