diff --git a/misc/BreCalApi.cs b/misc/BreCalApi.cs
index f53e437..d4a06ed 100644
--- a/misc/BreCalApi.cs
+++ b/misc/BreCalApi.cs
@@ -1,7 +1,7 @@
//----------------------
//
-// Generated REST API Client Code Generator v1.8.4.0 on 29.09.2023 14:42:26
+// Generated REST API Client Code Generator v1.8.4.0 on 04.10.2023 07:39:32
// Using the tool OpenAPI Generator v7.0.0
//
//----------------------
@@ -51,6 +51,9 @@ using System.Threading.Tasks;
*/
namespace BreCalClient.misc.Api
{
+
+#pragma warning disable CS8073 // The result of the expression is always the same since a value of this type is never equal to 'null'
+
///
/// Represents a collection of functions to interact with the API endpoints
///
@@ -7632,5 +7635,8 @@ namespace BreCalClient.misc.Model
yield break;
}
}
+
+#pragma warning restore CS8073 // The result of the expression is always the same since a value of this type is never equal to 'null'
}
+
diff --git a/src/BreCalClient/App.config b/src/BreCalClient/App.config
index 9b96e2e..0800667 100644
--- a/src/BreCalClient/App.config
+++ b/src/BreCalClient/App.config
@@ -11,7 +11,7 @@
- https://brecal.bsmd-emswe.eu
+ https://brecaltest.bsmd-emswe.eu
#751D1F
diff --git a/src/BreCalClient/BreCalClient.csproj b/src/BreCalClient/BreCalClient.csproj
index 3c6b607..024ae43 100644
--- a/src/BreCalClient/BreCalClient.csproj
+++ b/src/BreCalClient/BreCalClient.csproj
@@ -8,8 +8,8 @@
True
BreCalClient.App
..\..\misc\brecal.snk
- 0.6.0.0
- 0.6.0.0
+ 0.7.0.0
+ 0.7.0.0
Bremen calling client
A Windows WPF client for the Bremen calling API.
containership.ico
diff --git a/src/BreCalClient/BreCalLists.cs b/src/BreCalClient/BreCalLists.cs
new file mode 100644
index 0000000..c8df918
--- /dev/null
+++ b/src/BreCalClient/BreCalLists.cs
@@ -0,0 +1,123 @@
+// Copyright (c) 2023 schick Informatik
+// Description: Static lists used everywhere
+//
+
+using BreCalClient.misc.Model;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+
+
+namespace BreCalClient
+{
+ public static class BreCalLists
+ {
+
+ #region Fields
+
+ private static readonly List aList = new();
+ private static readonly List mList = new();
+ private static readonly List pList = new();
+ private static readonly List tList = new();
+ private static readonly List terList = new();
+
+ private static List _berths = new();
+ private static List _participants = new();
+ private static List _ships = new();
+
+ private readonly static ConcurrentDictionary _shipLookupDict = new();
+ private readonly static ConcurrentDictionary _berthLookupDict = new();
+ private readonly static Dictionary _participantLookupDict = new();
+
+ #endregion
+
+ #region Properties
+
+ public static ConcurrentDictionary ShipLookupDict { get { return _shipLookupDict; } }
+
+ public static ConcurrentDictionary BerthLookupDict { get { return _berthLookupDict; } }
+
+ public static Dictionary ParticipantLookupDict { get { return _participantLookupDict; } }
+
+ ///
+ /// Participants that are agents
+ ///
+ public static List Participants_Agent { get { return aList; } }
+
+ ///
+ /// Participants that are mooring companies
+ ///
+ public static List Participants_Mooring { get { return mList; } }
+
+ ///
+ /// Participants that are pilots
+ ///
+ public static List Participants_Pilot { get { return pList; } }
+
+ ///
+ /// Participants that are tug shipping companies
+ ///
+ public static List Participants_Tug { get { return tList; } }
+
+ ///
+ /// Participants that are terminals
+ ///
+ public static List Participants_Terminal { get { return terList; } }
+
+ ///
+ /// All participants
+ ///
+ public static List Participants { get { return _participants; } }
+
+ ///
+ /// All berths
+ ///
+ public static List Berths { get { return _berths; } }
+
+ ///
+ /// All ships
+ ///
+ public static List Ships { get { return _ships; } }
+
+ #endregion
+
+ #region methods
+
+ internal static void InitializeParticipants(List participants)
+ {
+ _participants = participants;
+
+ aList.Clear();
+ mList.Clear();
+ pList.Clear();
+ tList.Clear();
+ terList.Clear();
+
+ foreach (Participant p in participants)
+ {
+ _participantLookupDict[p.Id] = p;
+ if (p.IsTypeFlagSet(Extensions.ParticipantType.AGENCY)) aList.Add(p);
+ if (p.IsTypeFlagSet(Extensions.ParticipantType.MOORING)) mList.Add(p);
+ if (p.IsTypeFlagSet(Extensions.ParticipantType.PILOT)) pList.Add(p);
+ if (p.IsTypeFlagSet(Extensions.ParticipantType.TUG)) tList.Add(p);
+ if (p.IsTypeFlagSet(Extensions.ParticipantType.TERMINAL)) terList.Add(p);
+ }
+ }
+
+ internal static void InitializeBerths(List berths)
+ {
+ foreach (var berth in berths)
+ _berthLookupDict[berth.Id] = berth;
+ _berths = berths;
+ }
+
+ internal static void InitializeShips(List ships)
+ {
+ foreach (var ship in ships)
+ _shipLookupDict[ship.Id] = ship;
+ _ships = ships;
+ }
+
+ #endregion
+
+ }
+}
diff --git a/src/BreCalClient/EditShipcallControl.xaml b/src/BreCalClient/EditShipcallControl.xaml
index 7138d90..dae9047 100644
--- a/src/BreCalClient/EditShipcallControl.xaml
+++ b/src/BreCalClient/EditShipcallControl.xaml
@@ -8,7 +8,7 @@
xmlns:db="clr-namespace:BreCalClient;assembly=BreCalClient"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
- Title="{x:Static p:Resources.textEditShipcall}" Height="466" Width="800" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico">
+ Title="{x:Static p:Resources.textEditShipcall}" Height="214" Width="800" Loaded="Window_Loaded" ResizeMode="NoResize" Icon="Resources/containership.ico">
@@ -26,135 +26,73 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/BreCalClient/EditShipcallControl.xaml.cs b/src/BreCalClient/EditShipcallControl.xaml.cs
index a823011..3c9ef71 100644
--- a/src/BreCalClient/EditShipcallControl.xaml.cs
+++ b/src/BreCalClient/EditShipcallControl.xaml.cs
@@ -26,21 +26,6 @@ namespace BreCalClient
public ShipcallControlModel ShipcallModel { get; set; } = new ();
- ///
- /// All participants
- ///
- public List Participants { get; set; } = new();
-
- ///
- /// All berths
- ///
- public List Berths { get; set; } = new();
-
- ///
- /// All ships
- ///
- public List Ships { get; set; } = new();
-
public Ship? SelectedShip {
get
{
@@ -54,32 +39,14 @@ namespace BreCalClient
private void Window_Loaded(object sender, RoutedEventArgs e)
{
- List aList = new();
- List mList = new();
- List pList = new();
- List tList = new();
- List terList = new();
+ this.comboBoxAgency.ItemsSource = BreCalLists.Participants_Agent;
- foreach(Participant p in Participants)
- {
- if (p.IsTypeFlagSet(Extensions.ParticipantType.AGENCY)) aList.Add(p);
- if (p.IsTypeFlagSet(Extensions.ParticipantType.MOORING)) mList.Add(p);
- if (p.IsTypeFlagSet(Extensions.ParticipantType.PILOT)) pList.Add(p);
- if (p.IsTypeFlagSet(Extensions.ParticipantType.TUG)) tList.Add(p);
- if (p.IsTypeFlagSet(Extensions.ParticipantType.TERMINAL)) terList.Add(p);
- }
-
- this.comboBoxAgency.ItemsSource = aList;
- this.comboBoxMooring.ItemsSource = mList;
- this.comboBoxPilot.ItemsSource = pList;
- this.comboBoxTug.ItemsSource = tList;
- this.comboBoxTerminal.ItemsSource = terList;
-
- this.comboBoxShip.ItemsSource = Ships;
+ this.comboBoxShip.ItemsSource = BreCalLists.Ships;
this.comboBoxCategories.ItemsSource = Enum.GetValues(typeof(Extensions.TypeEnum));
- this.comboBoxArrivalBerth.ItemsSource = this.Berths;
- this.comboBoxDepartureBerth.ItemsSource = this.Berths;
+ this.comboBoxArrivalBerth.ItemsSource = BreCalLists.Berths;
+ this.comboBoxDepartureBerth.ItemsSource = BreCalLists.Berths;
+ if (this.ShipcallModel.Shipcall == null) this.ShipcallModel.Shipcall = new();
this.CopyToControls();
this.EnableControls();
@@ -101,6 +68,21 @@ namespace BreCalClient
private void comboBoxShip_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
this.buttonOK.IsEnabled = this.comboBoxShip.SelectedItem != null;
+ if (this.comboBoxShip.SelectedItem != null)
+ {
+ Ship? ship = this.comboBoxShip.SelectedItem as Ship;
+ this.integerUpDownIMO.Value = ship?.Imo;
+ this.textBoxCallsign.Text = ship?.Callsign;
+ this.doubleUpDownLength.Value = ship?.Length;
+ this.doubleUpDownWidth.Value = ship?.Width;
+ }
+ else
+ {
+ this.integerUpDownIMO.Value = null;
+ this.textBoxCallsign.Text = string.Empty;
+ this.doubleUpDownLength.Value = null;
+ this.doubleUpDownWidth.Value = null;
+ }
}
private void comboBoxAgency_SelectionChanged(object sender, SelectionChangedEventArgs e)
@@ -116,31 +98,7 @@ namespace BreCalClient
{
this.comboBoxAgency.SelectedIndex = -1;
this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.AGENCY);
- }
-
- private void contextMenuItemClearMooring_Click(object sender, RoutedEventArgs e)
- {
- this.comboBoxMooring.SelectedIndex = -1;
- this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.MOORING);
- }
-
- private void contextMenuItemClearPilot_Click(object sender, RoutedEventArgs e)
- {
- this.comboBoxPilot.SelectedIndex = -1;
- this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.PILOT);
- }
-
- private void contextMenuItemClearTug_Click(object sender, RoutedEventArgs e)
- {
- this.comboBoxTug.SelectedIndex = -1;
- this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.TUG);
- }
-
- private void contextMenuItemClearTerminal_Click(object sender, RoutedEventArgs e)
- {
- this.comboBoxTerminal.SelectedIndex = -1;
- this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.TERMINAL);
- }
+ }
private void contextMenuItemArrivalBerth_Click(object sender, RoutedEventArgs e)
{
@@ -153,6 +111,31 @@ namespace BreCalClient
this.comboBoxDepartureBerth.SelectedIndex -= 1;
}
+ private void comboBoxCategories_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ TypeEnum? type = this.comboBoxCategories.SelectedItem as TypeEnum?;
+ if(type != null)
+ {
+ switch (type)
+ {
+ case TypeEnum.Incoming:
+ this.datePickerETA.IsEnabled = true;
+ this.datePickerETD.IsEnabled = false;
+ this.datePickerETD.Value = null;
+ break;
+ case TypeEnum.Outgoing:
+ this.datePickerETA.IsEnabled = false;
+ this.datePickerETD.IsEnabled = true;
+ this.datePickerETA.Value = null;
+ break;
+ case TypeEnum.Shifting:
+ this.datePickerETA.IsEnabled = true;
+ this.datePickerETD.IsEnabled = true;
+ break;
+ }
+ }
+ }
+
#endregion
#region private methods
@@ -162,30 +145,16 @@ namespace BreCalClient
if (this.ShipcallModel.Shipcall != null)
{
this.ShipcallModel.Shipcall.Type = (int)this.comboBoxCategories.SelectedItem;
- this.ShipcallModel.Shipcall.Eta = this.datePickerETA.Value ?? DateTime.Now;
- this.ShipcallModel.Shipcall.Voyage = this.textBoxVoyage.Text.Trim();
+ this.ShipcallModel.Shipcall.Eta = this.datePickerETA.Value ?? DateTime.Now;
this.ShipcallModel.Shipcall.Etd = this.datePickerETD.Value ?? DateTime.Now.AddDays(1);
- this.ShipcallModel.Shipcall.Anchored = this.checkBoxAnchored.IsChecked;
+
this.ShipcallModel.Shipcall.ShipId = ((Ship)this.comboBoxShip.SelectedItem).Id;
+ this.ShipcallModel.Ship = (Ship)this.comboBoxShip.SelectedItem;
this.ShipcallModel.Shipcall.ArrivalBerthId = (this.comboBoxArrivalBerth.SelectedItem != null) ? ((Berth)this.comboBoxArrivalBerth.SelectedItem).Id : null;
this.ShipcallModel.Shipcall.DepartureBerthId = (this.comboBoxDepartureBerth.SelectedItem != null) ? ((Berth)this.comboBoxDepartureBerth.SelectedItem).Id : null;
- this.ShipcallModel.Shipcall.Bunkering = this.checkBoxBunkering.IsChecked;
- this.ShipcallModel.Shipcall.Canceled = this.checkBoxCanceled.IsChecked;
- this.ShipcallModel.Shipcall.Draft = (float?)this.doubleUpDownDraft.Value;
- this.ShipcallModel.Shipcall.MooredLock = this.checkBoxMooredLock.IsChecked;
- this.ShipcallModel.Shipcall.RainSensitiveCargo = this.checkBoxRainsensitiveCargo.IsChecked;
- this.ShipcallModel.Shipcall.PilotRequired = this.checkBoxPilotRequired.IsChecked;
- this.ShipcallModel.Shipcall.ReplenishingLock = this.checkBoxReplenishingLock.IsChecked;
- this.ShipcallModel.Shipcall.ReplenishingTerminal = this.checkBoxReplenishingTerminal.IsChecked;
- this.ShipcallModel.Shipcall.RecommendedTugs = this.integerUpDownRecommendedTugs.Value;
- this.ShipcallModel.Shipcall.TidalWindowFrom = this.datePickerTidalWindowFrom.Value;
- this.ShipcallModel.Shipcall.TidalWindowTo = this.datePickerTidalWindowTo.Value;
- this.ShipcallModel.Shipcall.TugRequired = this.checkBoxTugRequired.IsChecked;
- if (this.comboBoxPierside.SelectedIndex >= 0)
- {
- this.ShipcallModel.Shipcall.PierSide = (this.comboBoxPierside.SelectedIndex == 0) ? true : false;
- }
-
+
+
+
// remove all and add selected participants
this.ShipcallModel.Shipcall.Participants.Clear();
this.ShipcallModel.AssignedParticipants.Clear();
@@ -197,31 +166,9 @@ namespace BreCalClient
this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.AGENCY] = participant;
}
- participant = (Participant?)this.comboBoxMooring.SelectedItem;
- if (participant != null)
- {
- this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
- this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.MOORING] = participant;
- }
- participant = (Participant?)this.comboBoxPilot.SelectedItem;
- if (participant != null)
- {
- this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
- this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.PILOT] = participant;
- }
- participant = (Participant?)this.comboBoxTerminal.SelectedItem;
- if (participant != null) {
- this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
- this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TERMINAL] = participant;
- }
- participant = (Participant?)this.comboBoxTug.SelectedItem;
- if (participant != null) {
- this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
- this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TUG] = participant;
- }
-
+
// BSMD and port authority are always added
- foreach (Participant p in Participants)
+ foreach (Participant p in BreCalLists.Participants)
{
if (p.Type == (int)Extensions.ParticipantType.PORT_ADMINISTRATION)
{
@@ -245,43 +192,17 @@ namespace BreCalClient
this.comboBoxCategories.SelectedItem = (Extensions.TypeEnum)this.ShipcallModel.Shipcall.Type;
if (this.ShipcallModel.Shipcall.Eta != DateTime.MinValue)
this.datePickerETA.Value = this.ShipcallModel.Shipcall.Eta;
- this.textBoxVoyage.Text = this.ShipcallModel.Shipcall.Voyage;
- this.datePickerETD.Value = this.ShipcallModel.Shipcall.Etd;
- this.checkBoxAnchored.IsChecked = this.ShipcallModel.Shipcall.Anchored;
+ // this.textBoxVoyage.Text = this.ShipcallModel.Shipcall.Voyage;
+ this.datePickerETD.Value = this.ShipcallModel.Shipcall.Etd;
this.comboBoxShip.SelectedValue = this.ShipcallModel.Shipcall.ShipId;
this.comboBoxArrivalBerth.SelectedValue = this.ShipcallModel.Shipcall.ArrivalBerthId;
this.comboBoxDepartureBerth.SelectedValue = this.ShipcallModel.Shipcall.DepartureBerthId;
- this.checkBoxBunkering.IsChecked = this.ShipcallModel.Shipcall.Bunkering;
- this.checkBoxCanceled.IsChecked = this.ShipcallModel.Shipcall.Canceled;
- this.doubleUpDownDraft.Value = this.ShipcallModel.Shipcall.Draft;
- this.checkBoxMooredLock.IsChecked = this.ShipcallModel.Shipcall.MooredLock;
-
- this.checkBoxRainsensitiveCargo.IsChecked = this.ShipcallModel.Shipcall.RainSensitiveCargo;
- this.checkBoxPilotRequired.IsChecked = this.ShipcallModel.Shipcall.PilotRequired;
- this.checkBoxReplenishingLock.IsChecked = this.ShipcallModel.Shipcall.ReplenishingLock;
- this.checkBoxReplenishingTerminal.IsChecked = this.ShipcallModel.Shipcall.ReplenishingTerminal;
- this.integerUpDownRecommendedTugs.Value = this.ShipcallModel.Shipcall.RecommendedTugs;
- this.datePickerTidalWindowFrom.Value = this.ShipcallModel.Shipcall.TidalWindowFrom;
- this.datePickerTidalWindowTo.Value = this.ShipcallModel.Shipcall.TidalWindowTo;
- this.checkBoxTugRequired.IsChecked = this.ShipcallModel.Shipcall.TugRequired;
- if (this.ShipcallModel.Shipcall.PierSide.HasValue)
- {
- if (this.ShipcallModel.Shipcall.PierSide.Value) this.comboBoxPierside.SelectedIndex = 0;
- else this.comboBoxPierside.SelectedIndex = 1;
- }
-
+
if (this.ShipcallModel.Shipcall.Participants == null) this.ShipcallModel.Shipcall.Participants = new();
- // Hier wird noch ein Problem vergessen: Wenn ein Participant mehrere Types gleichzeitig ist und es einen weitere Participant mit diesem Type gibt
- // müsste der "einzelne" Participant für die Rolle ausgewählt werden. (Angenommen ein Test-Teilnehmer hat "alle" Rollen..)
-
foreach (int participant_id in this.ShipcallModel.Shipcall.Participants)
{
if (((List)this.comboBoxAgency.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxAgency.SelectedValue = participant_id;
- if (((List)this.comboBoxMooring.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxMooring.SelectedValue = participant_id;
- if (((List)this.comboBoxPilot.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxPilot.SelectedValue = participant_id;
- if (((List)this.comboBoxTerminal.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTerminal.SelectedValue = participant_id;
- if (((List)this.comboBoxTug.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTug.SelectedValue = participant_id;
}
}
}
@@ -297,7 +218,7 @@ namespace BreCalClient
if (this.comboBoxAgency.SelectedIndex >= 0)
{
int agencyParticipantId = (int)this.comboBoxAgency.SelectedValue;
- Participant? p = this.Participants.Find(x => x.Id == agencyParticipantId);
+ Participant? p = BreCalLists.Participants.Find(x => x.Id == agencyParticipantId);
if (p != null)
{
if(p.IsFlagSet(ParticipantFlag.ALLOW_BSMD) && isBsmd)
@@ -310,30 +231,11 @@ namespace BreCalClient
this.comboBoxAgency.IsEnabled = isBsmd;
this.comboBoxArrivalBerth.IsEnabled = isBsmd || isAgency;
this.comboBoxCategories.IsEnabled = isBsmd;
- this.comboBoxDepartureBerth.IsEnabled = isBsmd || isAgency;
- this.checkBoxAnchored.IsEnabled = isAgency;
- this.checkBoxBunkering.IsEnabled = isAgency;
- this.checkBoxCanceled.IsEnabled = isBsmd || isAgency;
- this.checkBoxMooredLock.IsEnabled = isAgency;
- this.checkBoxPilotRequired.IsEnabled = isAgency;
- this.checkBoxRainsensitiveCargo.IsEnabled = isAgency;
- this.checkBoxReplenishingLock.IsEnabled = isAgency;
- this.checkBoxReplenishingTerminal.IsEnabled = isAgency;
- this.checkBoxTugRequired.IsEnabled = isAgency;
- this.comboBoxMooring.IsEnabled = isBsmd;
- this.comboBoxPierside.IsEnabled = isAgency;
- this.comboBoxPilot.IsEnabled = isAgency;
- this.comboBoxShip.IsEnabled = isBsmd;
- this.comboBoxMooring.IsEnabled = isAgency;
- this.comboBoxTerminal.IsEnabled = isAgency;
- this.comboBoxTug.IsEnabled = isAgency;
+ this.comboBoxDepartureBerth.IsEnabled = isBsmd || isAgency;
+ this.comboBoxShip.IsEnabled = isBsmd;
this.datePickerETA.IsEnabled = isAgency || isBsmd;
this.datePickerETD.IsEnabled = isAgency;
- this.textBoxVoyage.IsEnabled = isAgency;
- this.datePickerTidalWindowFrom.IsEnabled = isAgency;
- this.datePickerTidalWindowTo.IsEnabled = isAgency;
- this.integerUpDownRecommendedTugs.IsEnabled = isAgency;
- this.doubleUpDownDraft.IsEnabled = isAgency || isBsmd;
+
this.labelBSMDGranted.Visibility = editRightGrantedForBSMD ? Visibility.Visible : Visibility.Hidden;
}
diff --git a/src/BreCalClient/EditTimesAgencyIncomingControl.xaml b/src/BreCalClient/EditTimesAgencyIncomingControl.xaml
new file mode 100644
index 0000000..7898a06
--- /dev/null
+++ b/src/BreCalClient/EditTimesAgencyIncomingControl.xaml
@@ -0,0 +1,139 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs
new file mode 100644
index 0000000..968923f
--- /dev/null
+++ b/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs
@@ -0,0 +1,218 @@
+// Copyright (c) 2023 schick Informatik
+// Description: Input control for incoming shipcalls
+//
+
+using BreCalClient.misc.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
+
+namespace BreCalClient
+{
+ ///
+ /// Interaction logic for EditTimesAgencyIncomingControl.xaml
+ ///
+ public partial class EditTimesAgencyIncomingControl : Window, IEditShipcallTimesControl
+ {
+ #region Construction
+
+ public EditTimesAgencyIncomingControl()
+ {
+ InitializeComponent();
+ }
+
+ #endregion
+
+ #region Properties
+
+ public ShipcallControlModel ShipcallModel { get; set; } = new();
+
+ public Times Times { get; set; } = new();
+
+ #endregion
+
+ #region event handler
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxMooring.ItemsSource = BreCalLists.Participants_Mooring;
+ this.comboBoxPilot.ItemsSource = BreCalLists.Participants_Pilot;
+ this.comboBoxTug.ItemsSource = BreCalLists.Participants_Tug;
+ this.comboBoxTerminal.ItemsSource = BreCalLists.Participants_Terminal;
+
+ this.comboBoxArrivalBerth.ItemsSource = BreCalLists.Berths;
+ this.CopyToControls();
+ }
+
+ private void buttonOK_Click(object sender, RoutedEventArgs e)
+ {
+ this.CopyToModel();
+ this.DialogResult = true;
+ this.Close();
+ }
+
+ private void buttonCancel_Click(object sender, RoutedEventArgs e)
+ {
+ this.DialogResult = false;
+ this.Close();
+ }
+
+ #endregion
+
+ #region private methods
+
+ private void CopyToModel()
+ {
+ if (this.ShipcallModel.Shipcall != null)
+ {
+ this.Times.EtaBerth = this.datePickerETA.Value;
+
+ if (this.comboBoxPierside.SelectedIndex >= 0)
+ {
+ this.ShipcallModel.Shipcall.PierSide = (this.comboBoxPierside.SelectedIndex == 0) ? true : false;
+ }
+ this.Times.BerthInfo = this.textBoxBerthRemarks.Text.Trim();
+ if((this.comboBoxArrivalBerth.SelectedValue != null) && ((int?)this.comboBoxArrivalBerth.SelectedValue != this.ShipcallModel.Shipcall.ArrivalBerthId))
+ {
+ this.Times.BerthId = (int?)this.comboBoxArrivalBerth.SelectedValue;
+ }
+
+ this.ShipcallModel.Shipcall.Draft = (float?)this.doubleUpDownDraft.Value;
+ this.ShipcallModel.Shipcall.TidalWindowFrom = this.datePickerTidalWindowFrom.Value;
+ this.ShipcallModel.Shipcall.TidalWindowTo = this.datePickerTidalWindowTo.Value;
+ this.ShipcallModel.Shipcall.Canceled = this.checkBoxCanceled.IsChecked;
+
+ this.ShipcallModel.Shipcall.Anchored = this.checkBoxAnchored.IsChecked;
+ this.ShipcallModel.Shipcall.TugRequired = this.checkBoxTugRequired.IsChecked;
+ this.ShipcallModel.Shipcall.RecommendedTugs = this.integerUpDownRecommendedTugs.Value;
+ this.ShipcallModel.Shipcall.PilotRequired = this.checkBoxPilotRequired.IsChecked;
+ this.ShipcallModel.Shipcall.MooredLock = this.checkBoxMooredLock.IsChecked;
+ this.ShipcallModel.Shipcall.Bunkering = this.checkBoxBunkering.IsChecked;
+ this.ShipcallModel.Shipcall.ReplenishingTerminal = this.checkBoxReplenishingTerminal.IsChecked;
+ this.ShipcallModel.Shipcall.ReplenishingLock = this.checkBoxReplenishingLock.IsChecked;
+
+ if (!string.IsNullOrEmpty(this.textBoxRemarks.Text.Trim()))
+ this.Times.Remarks = this.textBoxRemarks.Text.Trim();
+
+ Participant? participant = (Participant?)this.comboBoxMooring.SelectedItem;
+ if (participant != null)
+ {
+ this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
+ this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.MOORING] = participant;
+ }
+ participant = (Participant?)this.comboBoxPilot.SelectedItem;
+ if (participant != null)
+ {
+ this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
+ this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.PILOT] = participant;
+ }
+ participant = (Participant?)this.comboBoxTerminal.SelectedItem;
+ if (participant != null)
+ {
+ this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
+ this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TERMINAL] = participant;
+ }
+ participant = (Participant?)this.comboBoxTug.SelectedItem;
+ if (participant != null)
+ {
+ this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
+ this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TUG] = participant;
+ }
+ }
+ }
+
+ private void CopyToControls()
+ {
+ if (this.ShipcallModel == null) return;
+ if (this.ShipcallModel.Shipcall != null)
+ {
+ if(this.Times.EtaBerth.HasValue)
+ {
+ this.datePickerETA.Value = this.Times.EtaBerth.Value;
+ }
+ else
+ {
+ // if not set through times use value of BSMD entry
+ if (this.ShipcallModel.Shipcall.Eta != DateTime.MinValue)
+ this.datePickerETA.Value = this.ShipcallModel.Shipcall.Eta;
+ }
+
+ if (Times.BerthId.HasValue)
+ this.comboBoxArrivalBerth.SelectedValue = Times.BerthId;
+ else if (this.ShipcallModel.Shipcall.ArrivalBerthId.HasValue)
+ this.comboBoxArrivalBerth.SelectedValue = this.ShipcallModel.Shipcall.ArrivalBerthId;
+
+ if (this.ShipcallModel.Shipcall.PierSide.HasValue)
+ {
+ if (this.ShipcallModel.Shipcall.PierSide.Value) this.comboBoxPierside.SelectedIndex = 0;
+ else this.comboBoxPierside.SelectedIndex = 1;
+ }
+ this.textBoxBerthRemarks.Text = this.Times.BerthInfo;
+ this.doubleUpDownDraft.Value = this.ShipcallModel.Shipcall.Draft;
+ this.datePickerTidalWindowFrom.Value = this.ShipcallModel.Shipcall.TidalWindowFrom;
+ this.datePickerTidalWindowTo.Value = this.ShipcallModel.Shipcall.TidalWindowTo;
+ this.checkBoxCanceled.IsChecked = this.ShipcallModel.Shipcall.Canceled;
+
+ this.checkBoxAnchored.IsChecked = this.ShipcallModel.Shipcall.Anchored;
+ this.checkBoxTugRequired.IsChecked = this.ShipcallModel.Shipcall.TugRequired;
+ this.integerUpDownRecommendedTugs.Value = this.ShipcallModel.Shipcall.RecommendedTugs;
+ this.checkBoxPilotRequired.IsChecked = this.ShipcallModel.Shipcall.PilotRequired;
+
+ this.checkBoxMooredLock.IsChecked = this.ShipcallModel.Shipcall.MooredLock;
+
+ this.checkBoxBunkering.IsChecked = this.ShipcallModel.Shipcall.Bunkering;
+ this.checkBoxReplenishingLock.IsChecked = this.ShipcallModel.Shipcall.ReplenishingLock;
+ this.checkBoxReplenishingTerminal.IsChecked = this.ShipcallModel.Shipcall.ReplenishingTerminal;
+
+ if(!string.IsNullOrEmpty(this.Times.Remarks))
+ this.textBoxRemarks.Text = this.Times.Remarks;
+
+ foreach (int participant_id in this.ShipcallModel.Shipcall.Participants)
+ {
+ if (((List)this.comboBoxMooring.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxMooring.SelectedValue = participant_id;
+ if (((List)this.comboBoxPilot.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxPilot.SelectedValue = participant_id;
+ if (((List)this.comboBoxTerminal.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTerminal.SelectedValue = participant_id;
+ if (((List)this.comboBoxTug.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTug.SelectedValue = participant_id;
+ }
+ }
+ }
+
+ #endregion
+
+ #region context menu handlers
+
+ private void contextMenuItemArrivalBerth_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxArrivalBerth.SelectedIndex = -1;
+ this.ShipcallModel.Berth = "";
+ }
+
+ private void contextMenuItemClearTug_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxTug.SelectedIndex = -1;
+ this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.TUG);
+ }
+
+ private void contextMenuItemClearPilot_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxPilot.SelectedIndex = -1;
+ this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.PILOT);
+ }
+
+ private void contextMenuItemClearMooring_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxMooring.SelectedIndex = -1;
+ this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.MOORING);
+ }
+
+ private void contextMenuItemClearTerminal_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxTerminal.SelectedIndex = -1;
+ this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.TERMINAL);
+ }
+
+ #endregion
+
+ }
+}
diff --git a/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml b/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml
new file mode 100644
index 0000000..2f41799
--- /dev/null
+++ b/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml
@@ -0,0 +1,129 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs
new file mode 100644
index 0000000..17ccaf1
--- /dev/null
+++ b/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs
@@ -0,0 +1,208 @@
+// Copyright (c) 2023 schick Informatik
+// Description: Input control for outgoing shipcalls
+//
+
+using BreCalClient.misc.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
+
+namespace BreCalClient
+{
+ ///
+ /// Interaction logic for EditTimesAgencyOutgoingControl.xaml
+ ///
+ public partial class EditTimesAgencyOutgoingControl : Window, IEditShipcallTimesControl
+ {
+
+ #region Construction
+
+ public EditTimesAgencyOutgoingControl()
+ {
+ InitializeComponent();
+ }
+
+ #endregion
+
+ #region Properties
+
+ public ShipcallControlModel ShipcallModel { get; set; } = new();
+
+ public Times Times { get; set; } = new();
+
+ #endregion
+
+ #region event handler
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxMooring.ItemsSource = BreCalLists.Participants_Mooring;
+ this.comboBoxPilot.ItemsSource = BreCalLists.Participants_Pilot;
+ this.comboBoxTug.ItemsSource = BreCalLists.Participants_Tug;
+ this.comboBoxTerminal.ItemsSource = BreCalLists.Participants_Terminal;
+
+ this.comboBoxDepartureBerth.ItemsSource = BreCalLists.Berths;
+ this.CopyToControls();
+ }
+
+ private void buttonOK_Click(object sender, RoutedEventArgs e)
+ {
+ this.CopyToModel();
+ this.DialogResult = true;
+ this.Close();
+ }
+
+ private void buttonCancel_Click(object sender, RoutedEventArgs e)
+ {
+ this.DialogResult = false;
+ this.Close();
+ }
+
+ #endregion
+
+ #region private methods
+
+ private void CopyToModel()
+ {
+ if (this.ShipcallModel.Shipcall != null)
+ {
+ this.Times.EtdBerth = this.datePickerETD.Value;
+ if (this.comboBoxPierside.SelectedIndex >= 0)
+ {
+ this.ShipcallModel.Shipcall.PierSide = (this.comboBoxPierside.SelectedIndex == 0) ? true : false;
+ }
+ if ((this.comboBoxDepartureBerth.SelectedValue != null) && ((int?)this.comboBoxDepartureBerth.SelectedValue != this.ShipcallModel.Shipcall.DepartureBerthId))
+ {
+ this.Times.BerthId = (int?)this.comboBoxDepartureBerth.SelectedValue;
+ }
+ this.Times.BerthInfo = this.textBoxBerthRemarks.Text.Trim();
+ this.ShipcallModel.Shipcall.Draft = (float?)this.doubleUpDownDraft.Value;
+ this.ShipcallModel.Shipcall.TidalWindowFrom = this.datePickerTidalWindowFrom.Value;
+ this.ShipcallModel.Shipcall.TidalWindowTo = this.datePickerTidalWindowTo.Value;
+ this.ShipcallModel.Shipcall.Canceled = this.checkBoxCanceled.IsChecked;
+
+ this.ShipcallModel.Shipcall.TugRequired = this.checkBoxTugRequired.IsChecked;
+ this.ShipcallModel.Shipcall.RecommendedTugs = this.integerUpDownRecommendedTugs.Value;
+ this.ShipcallModel.Shipcall.PilotRequired = this.checkBoxPilotRequired.IsChecked;
+ this.ShipcallModel.Shipcall.MooredLock = this.checkBoxMooredLock.IsChecked;
+ this.ShipcallModel.Shipcall.RainSensitiveCargo = this.checkBoxRainsensitiveCargo.IsChecked;
+ if(!string.IsNullOrEmpty(this.textBoxRemarks.Text.Trim()))
+ this.Times.Remarks = this.textBoxRemarks.Text.Trim();
+
+ Participant? participant = (Participant?)this.comboBoxMooring.SelectedItem;
+ if (participant != null)
+ {
+ this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
+ this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.MOORING] = participant;
+ }
+ participant = (Participant?)this.comboBoxPilot.SelectedItem;
+ if (participant != null)
+ {
+ this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
+ this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.PILOT] = participant;
+ }
+ participant = (Participant?)this.comboBoxTerminal.SelectedItem;
+ if (participant != null)
+ {
+ this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
+ this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TERMINAL] = participant;
+ }
+ participant = (Participant?)this.comboBoxTug.SelectedItem;
+ if (participant != null)
+ {
+ this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
+ this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TUG] = participant;
+ }
+ }
+ }
+
+ private void CopyToControls()
+ {
+ if (this.ShipcallModel == null) return;
+ if (this.ShipcallModel.Shipcall != null)
+ {
+ if (this.Times.EtdBerth.HasValue)
+ {
+ this.datePickerETD.Value = this.Times.EtdBerth.Value;
+ }
+ else
+ {
+ // if not set through times use value of BSMD entry
+ if (this.ShipcallModel.Shipcall.Etd != DateTime.MinValue)
+ this.datePickerETD.Value = this.ShipcallModel.Shipcall.Etd;
+ }
+
+ if (this.Times.BerthId.HasValue)
+ this.comboBoxDepartureBerth.SelectedValue = this.Times.BerthId;
+ else if (this.ShipcallModel.Shipcall.DepartureBerthId.HasValue)
+ this.comboBoxDepartureBerth.SelectedValue = this.ShipcallModel.Shipcall.DepartureBerthId;
+
+ if (this.ShipcallModel.Shipcall.PierSide.HasValue)
+ {
+ if (this.ShipcallModel.Shipcall.PierSide.Value) this.comboBoxPierside.SelectedIndex = 0;
+ else this.comboBoxPierside.SelectedIndex = 1;
+ }
+ this.textBoxBerthRemarks.Text = this.Times.BerthInfo;
+ this.doubleUpDownDraft.Value = this.ShipcallModel.Shipcall.Draft;
+ this.datePickerTidalWindowFrom.Value = this.ShipcallModel.Shipcall.TidalWindowFrom;
+ this.datePickerTidalWindowTo.Value = this.ShipcallModel.Shipcall.TidalWindowTo;
+ this.checkBoxCanceled.IsChecked = this.ShipcallModel.Shipcall.Canceled;
+
+ this.checkBoxTugRequired.IsChecked = this.ShipcallModel.Shipcall.TugRequired;
+ this.integerUpDownRecommendedTugs.Value = this.ShipcallModel.Shipcall.RecommendedTugs;
+ this.checkBoxPilotRequired.IsChecked = this.ShipcallModel.Shipcall.PilotRequired;
+
+ this.checkBoxMooredLock.IsChecked = this.ShipcallModel.Shipcall.MooredLock;
+ this.checkBoxRainsensitiveCargo.IsChecked = this.ShipcallModel.Shipcall.RainSensitiveCargo;
+ if(!string.IsNullOrEmpty(this.Times.Remarks))
+ this.textBoxRemarks.Text = this.Times.Remarks;
+
+ foreach (int participant_id in this.ShipcallModel.Shipcall.Participants)
+ {
+ if (((List)this.comboBoxMooring.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxMooring.SelectedValue = participant_id;
+ if (((List)this.comboBoxPilot.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxPilot.SelectedValue = participant_id;
+ if (((List)this.comboBoxTerminal.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTerminal.SelectedValue = participant_id;
+ if (((List)this.comboBoxTug.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTug.SelectedValue = participant_id;
+ }
+ }
+ }
+
+ #endregion
+
+ #region context menu handlers
+
+ private void contextMenuItemClearTug_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxTug.SelectedIndex = -1;
+ this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.TUG);
+ }
+
+ private void contextMenuItemClearPilot_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxPilot.SelectedIndex = -1;
+ this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.PILOT);
+ }
+
+ private void contextMenuItemClearMooring_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxMooring.SelectedIndex = -1;
+ this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.MOORING);
+ }
+
+ private void contextMenuItemDepartureBerth_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxDepartureBerth.SelectedIndex = -1;
+ this.ShipcallModel.Berth = "";
+ }
+
+ private void contextMenuItemClearTerminal_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxTerminal.SelectedIndex = -1;
+ this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.TERMINAL);
+ }
+
+ #endregion
+
+ }
+}
diff --git a/src/BreCalClient/EditTimesAgencyShiftingControl.xaml b/src/BreCalClient/EditTimesAgencyShiftingControl.xaml
new file mode 100644
index 0000000..fcf2af5
--- /dev/null
+++ b/src/BreCalClient/EditTimesAgencyShiftingControl.xaml
@@ -0,0 +1,153 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs
new file mode 100644
index 0000000..eaf3478
--- /dev/null
+++ b/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs
@@ -0,0 +1,231 @@
+// Copyright (c) 2023 schick Informatik
+// Description: Input control for shifting operations
+//
+
+using BreCalClient.misc.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows;
+
+namespace BreCalClient
+{
+ ///
+ /// Interaction logic for EditTimesAgencyShiftingControl.xaml
+ ///
+ public partial class EditTimesAgencyShiftingControl : Window, IEditShipcallTimesControl
+ {
+
+ #region Construction
+
+ public EditTimesAgencyShiftingControl()
+ {
+ InitializeComponent();
+ }
+
+ #endregion
+
+ #region Properties
+
+ public ShipcallControlModel ShipcallModel { get; set; } = new();
+
+ public Times Times { get; set; } = new();
+
+ #endregion
+
+ #region event handler
+
+ private void Window_Loaded(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxMooring.ItemsSource = BreCalLists.Participants_Mooring;
+ this.comboBoxPilot.ItemsSource = BreCalLists.Participants_Pilot;
+ this.comboBoxTug.ItemsSource = BreCalLists.Participants_Tug;
+ this.comboBoxTerminal.ItemsSource = BreCalLists.Participants_Terminal;
+
+ this.comboBoxDepartureBerth.ItemsSource = BreCalLists.Berths;
+ this.comboBoxArrivalBerth.ItemsSource = BreCalLists.Berths;
+ this.CopyToControls();
+ }
+
+ private void buttonOK_Click(object sender, RoutedEventArgs e)
+ {
+ this.CopyToModel();
+ this.DialogResult = true;
+ this.Close();
+ }
+
+ private void buttonCancel_Click(object sender, RoutedEventArgs e)
+ {
+ this.DialogResult = false;
+ this.Close();
+ }
+
+ #endregion
+
+ #region private methods
+
+ private void CopyToModel()
+ {
+ if (this.ShipcallModel.Shipcall != null)
+ {
+ this.Times.EtdBerth = this.datePickerETD.Value;
+ this.Times.EtaBerth = this.datePickerETA.Value;
+ this.ShipcallModel.Shipcall.DepartureBerthId = (int)this.comboBoxDepartureBerth.SelectedValue;
+ if (this.comboBoxPiersideArrival.SelectedIndex >= 0)
+ {
+ this.ShipcallModel.Shipcall.PierSide = (this.comboBoxPiersideArrival.SelectedIndex == 0) ? true : false;
+ }
+ this.Times.BerthInfo = this.textBoxBerthRemarksArrival.Text.Trim();
+ if ((this.comboBoxArrivalBerth.SelectedValue != null) && ((int?)this.comboBoxArrivalBerth.SelectedValue != this.ShipcallModel.Shipcall.ArrivalBerthId))
+ {
+ this.Times.BerthId = (int?)this.comboBoxArrivalBerth.SelectedValue;
+ }
+
+ this.ShipcallModel.Shipcall.Draft = (float?)this.doubleUpDownDraft.Value;
+ this.ShipcallModel.Shipcall.TidalWindowFrom = this.datePickerTidalWindowFrom.Value;
+ this.ShipcallModel.Shipcall.TidalWindowTo = this.datePickerTidalWindowTo.Value;
+ this.ShipcallModel.Shipcall.Canceled = this.checkBoxCanceled.IsChecked;
+
+
+ this.ShipcallModel.Shipcall.TugRequired = this.checkBoxTugRequired.IsChecked;
+ this.ShipcallModel.Shipcall.RecommendedTugs = this.integerUpDownRecommendedTugs.Value;
+ this.ShipcallModel.Shipcall.PilotRequired = this.checkBoxPilotRequired.IsChecked;
+ this.ShipcallModel.Shipcall.MooredLock = this.checkBoxMooredLock.IsChecked;
+ this.ShipcallModel.Shipcall.RainSensitiveCargo = this.checkBoxRainsensitiveCargo.IsChecked;
+ if(!string.IsNullOrEmpty(this.textBoxRemarks.Text.Trim()))
+ this.Times.Remarks = this.textBoxRemarks.Text.Trim();
+
+ Participant? participant = (Participant?)this.comboBoxMooring.SelectedItem;
+ if (participant != null)
+ {
+ this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
+ this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.MOORING] = participant;
+ }
+ participant = (Participant?)this.comboBoxPilot.SelectedItem;
+ if (participant != null)
+ {
+ this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
+ this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.PILOT] = participant;
+ }
+ participant = (Participant?)this.comboBoxTerminal.SelectedItem;
+ if (participant != null)
+ {
+ this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
+ this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TERMINAL] = participant;
+ }
+ participant = (Participant?)this.comboBoxTug.SelectedItem;
+ if (participant != null)
+ {
+ this.ShipcallModel.Shipcall.Participants.Add(participant.Id);
+ this.ShipcallModel.AssignedParticipants[Extensions.ParticipantType.TUG] = participant;
+ }
+ }
+ }
+
+ private void CopyToControls()
+ {
+ if (this.ShipcallModel == null) return;
+ if (this.ShipcallModel.Shipcall != null)
+ {
+ if (this.Times.EtaBerth.HasValue)
+ {
+ this.datePickerETA.Value = this.Times.EtaBerth.Value;
+ }
+ else
+ {
+ // if not set through times use value of BSMD entry
+ if (this.ShipcallModel.Shipcall.Eta != DateTime.MinValue)
+ this.datePickerETA.Value = this.ShipcallModel.Shipcall.Eta;
+ }
+ if(this.Times.EtdBerth.HasValue)
+ {
+ this.datePickerETD.Value = this.Times.EtdBerth.Value;
+ }
+ else
+ {
+ if (this.ShipcallModel.Shipcall.Etd != DateTime.MinValue)
+ this.datePickerETD.Value = this.ShipcallModel.Shipcall.Etd;
+ }
+
+ if (this.Times.BerthId.HasValue)
+ this.comboBoxArrivalBerth.SelectedValue = this.Times.BerthId;
+ else if (this.ShipcallModel.Shipcall.ArrivalBerthId.HasValue)
+ this.comboBoxArrivalBerth.SelectedValue = this.ShipcallModel.Shipcall.ArrivalBerthId;
+
+ if (this.ShipcallModel.Shipcall.DepartureBerthId.HasValue)
+ this.comboBoxDepartureBerth.SelectedValue = this.ShipcallModel.Shipcall.DepartureBerthId;
+
+ if (this.ShipcallModel.Shipcall.PierSide.HasValue)
+ {
+ if (this.ShipcallModel.Shipcall.PierSide.Value) this.comboBoxPiersideArrival.SelectedIndex = 0;
+ else this.comboBoxPiersideArrival.SelectedIndex = 1;
+ }
+ this.textBoxBerthRemarksArrival.Text = this.Times.BerthInfo;
+ this.doubleUpDownDraft.Value = this.ShipcallModel.Shipcall.Draft;
+ this.datePickerTidalWindowFrom.Value = this.ShipcallModel.Shipcall.TidalWindowFrom;
+ this.datePickerTidalWindowTo.Value = this.ShipcallModel.Shipcall.TidalWindowTo;
+ this.checkBoxCanceled.IsChecked = this.ShipcallModel.Shipcall.Canceled;
+
+ this.checkBoxTugRequired.IsChecked = this.ShipcallModel.Shipcall.TugRequired;
+ this.integerUpDownRecommendedTugs.Value = this.ShipcallModel.Shipcall.RecommendedTugs;
+ this.checkBoxPilotRequired.IsChecked = this.ShipcallModel.Shipcall.PilotRequired;
+
+ this.checkBoxMooredLock.IsChecked = this.ShipcallModel.Shipcall.MooredLock;
+ this.checkBoxRainsensitiveCargo.IsChecked = this.ShipcallModel.Shipcall.RainSensitiveCargo;
+ if(!string.IsNullOrEmpty(this.Times.Remarks))
+ this.textBoxRemarks.Text = this.Times.Remarks;
+
+ foreach (int participant_id in this.ShipcallModel.Shipcall.Participants)
+ {
+ if (((List)this.comboBoxMooring.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxMooring.SelectedValue = participant_id;
+ if (((List)this.comboBoxPilot.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxPilot.SelectedValue = participant_id;
+ if (((List)this.comboBoxTerminal.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTerminal.SelectedValue = participant_id;
+ if (((List)this.comboBoxTug.ItemsSource).Any(x => x.Id == participant_id)) this.comboBoxTug.SelectedValue = participant_id;
+ }
+ }
+ }
+
+ #endregion
+
+ #region context menu handlers
+
+ private void contextMenuItemDepartureBerth_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxDepartureBerth.SelectedIndex = -1;
+ this.ShipcallModel.Berth = "";
+ }
+
+ private void contextMenuItemArrivalBerth_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxArrivalBerth.SelectedIndex = -1;
+ this.ShipcallModel.Berth = "";
+ }
+
+ private void contextMenuItemClearTug_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxTug.SelectedIndex = -1;
+ this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.TUG);
+ }
+
+ private void contextMenuItemClearPilot_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxPilot.SelectedIndex = -1;
+ this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.PILOT);
+ }
+
+ private void contextMenuItemClearMooring_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxMooring.SelectedIndex = -1;
+ this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.MOORING);
+ }
+
+ private void contextMenuItemClearTerminal_Click(object sender, RoutedEventArgs e)
+ {
+ this.comboBoxTerminal.SelectedIndex = -1;
+ this.ShipcallModel.AssignedParticipants.Remove(Extensions.ParticipantType.TERMINAL);
+ }
+
+ #endregion
+
+ }
+}
diff --git a/src/BreCalClient/EditTimesTerminalControl.xaml.cs b/src/BreCalClient/EditTimesTerminalControl.xaml.cs
index cc7e277..1f626a1 100644
--- a/src/BreCalClient/EditTimesTerminalControl.xaml.cs
+++ b/src/BreCalClient/EditTimesTerminalControl.xaml.cs
@@ -3,19 +3,7 @@
//
using BreCalClient.misc.Model;
-using System;
-using System.Collections.Generic;
-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
{
@@ -31,9 +19,7 @@ namespace BreCalClient
#region Properties
- public Times Times { get; set; } = new();
-
- public List Berths { get; set; }
+ public Times Times { get; set; } = new();
#endregion
@@ -41,7 +27,7 @@ namespace BreCalClient
private void Window_Loaded(object sender, RoutedEventArgs e)
{
- this.comboBoxBerth.ItemsSource = this.Berths;
+ this.comboBoxBerth.ItemsSource = BreCalLists.Berths;
this.CopyToControls();
}
diff --git a/src/BreCalClient/IEditTimesControl.cs b/src/BreCalClient/IEditTimesControl.cs
index b4497f6..2c08ba7 100644
--- a/src/BreCalClient/IEditTimesControl.cs
+++ b/src/BreCalClient/IEditTimesControl.cs
@@ -1,9 +1,9 @@
-using BreCalClient.misc.Model;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+// Copyright (c) 2023 schick Informatik
+// Description: Interfaces to simplify dialog handling
+//
+
+using BreCalClient.misc.Model;
+
namespace BreCalClient
{
@@ -14,4 +14,10 @@ namespace BreCalClient
bool? ShowDialog();
}
+
+ internal interface IEditShipcallTimesControl : IEditTimesControl
+ {
+ ShipcallControlModel ShipcallModel { get; set; }
+ }
+
}
diff --git a/src/BreCalClient/MainWindow.xaml.cs b/src/BreCalClient/MainWindow.xaml.cs
index 61f6fe5..dc43dcc 100644
--- a/src/BreCalClient/MainWindow.xaml.cs
+++ b/src/BreCalClient/MainWindow.xaml.cs
@@ -2,18 +2,19 @@
// Description: Bremen calling main window
//
-using BreCalClient.misc.Api;
-using BreCalClient.misc.Client;
-using BreCalClient.misc.Model;
using System;
-using System.Collections.Concurrent;
using System.Collections.Generic;
-using System.Collections.ObjectModel;
using System.Diagnostics;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
+
+using log4net;
+
+using BreCalClient.misc.Api;
+using BreCalClient.misc.Client;
+using BreCalClient.misc.Model;
+
using static BreCalClient.Extensions;
namespace BreCalClient
@@ -23,33 +24,26 @@ namespace BreCalClient
///
public partial class MainWindow : Window
{
+ private readonly ILog _log = LogManager.GetLogger(typeof(MainWindow));
private const int SHIPCALL_UPDATE_INTERVAL_SECONDS = 30;
#region Fields
-
+ private Timer? _timer;
+ private Credentials? _credentials;
private readonly Dictionary _allShipcallsDict = new();
private readonly Dictionary _allShipCallsControlDict = new();
-
- private readonly List _visibleControlModels = new();
-
-
- private List _ships = new();
- private readonly ConcurrentDictionary _shipLookupDict = new();
- private List _berths = new();
- private readonly ConcurrentDictionary _berthLookupDict = new();
- private List _participants = new();
- private readonly Dictionary _participantLookupDict = new();
+ private readonly List _visibleControlModels = new();
private readonly DefaultApi _api;
- private readonly CancellationTokenSource _tokenSource = new();
+ private CancellationTokenSource _tokenSource = new();
private LoginResult? _loginResult;
private bool _refreshImmediately = false;
private bool? _showCanceled = null;
- private Extensions.SortOrder? _sortOrder;
+ private SortOrder? _sortOrder;
// private bool _filterChanged = false;
// private bool _sequenceChanged = false;
@@ -71,8 +65,8 @@ namespace BreCalClient
public MainWindow()
{
InitializeComponent();
- _api = new DefaultApi();
- _api.Configuration.ApiKeyPrefix["Authorization"] = "Bearer";
+ _api = new DefaultApi(Properties.Settings.Default.API_URL);
+ _api.Configuration.ApiKeyPrefix["Authorization"] = "Bearer";
}
#endregion
@@ -109,12 +103,11 @@ namespace BreCalClient
return;
}
- Credentials credentials = new(username: textUsername.Text.Trim(),
- password: textPassword.Password.Trim());
+ _credentials = new(username: textUsername.Text.Trim(), password: textPassword.Password.Trim());
try
{
- _loginResult = await _api.LoginPostAsync(credentials);
+ _loginResult = await _api.LoginPostAsync(_credentials);
if (_loginResult != null)
{
if (_loginResult.Id > 0)
@@ -122,7 +115,8 @@ namespace BreCalClient
this.busyIndicator.IsBusy = false;
this._api.Configuration.ApiKey["Authorization"] = _loginResult.Token;
this.LoadStaticLists();
- this.labelUsername.Text = $"{_loginResult.FirstName} {_loginResult.LastName}";
+ this.labelUsername.Text = $"{_loginResult.FirstName} {_loginResult.LastName}";
+ _timer = new Timer(RefreshToken, null, 4000000, Timeout.Infinite);
}
}
labelGeneralStatus.Text = $"Connection {ConnectionStatus.SUCCESSFUL}";
@@ -139,6 +133,29 @@ namespace BreCalClient
}
}
+ private void RefreshToken(object? state)
+ {
+ try
+ {
+ _loginResult = _api.LoginPost(_credentials);
+ if (_loginResult != null)
+ {
+ if (_loginResult.Id > 0)
+ {
+ this._api.Configuration.ApiKey["Authorization"] = _loginResult.Token;
+ }
+ }
+ else
+ {
+ _log.Error("Token refresh: Renewed login returned empty login result");
+ }
+ }
+ catch (Exception ex)
+ {
+ _log.ErrorFormat("Error refreshing token: {0}", ex.Message);
+ }
+ }
+
private void buttonExit_Click(object sender, RoutedEventArgs e)
{
this.Close();
@@ -146,12 +163,7 @@ namespace BreCalClient
private void buttonNew_Click(object sender, RoutedEventArgs e)
{
- EditShipcallControl esc = new()
- {
- Participants = this._participants,
- Ships = this._ships,
- Berths = this._berths
- };
+ EditShipcallControl esc = new();
if (esc.ShowDialog() ?? false)
{
@@ -234,28 +246,22 @@ namespace BreCalClient
private async void LoadStaticLists()
{
- this._berths = await _api.BerthsGetAsync();
- foreach(var berth in this._berths)
- _berthLookupDict[berth.Id] = berth;
- this.searchFilterControl.SetBerths(this._berths);
- this._ships = await _api.ShipsGetAsync();
- foreach(var ship in this._ships)
- _shipLookupDict[ship.Id] = ship;
- this._participants = await _api.ParticipantsGetAsync();
+ BreCalLists.InitializeBerths(await _api.BerthsGetAsync());
+ BreCalLists.InitializeShips(await _api.ShipsGetAsync());
+ BreCalLists.InitializeParticipants(await _api.ParticipantsGetAsync());
- List agencies = new();
- foreach (Participant participant in this._participants)
- {
- this._participantLookupDict[participant.Id] = participant;
+ this.searchFilterControl.SetBerths(BreCalLists.Berths);
+
+ foreach (Participant participant in BreCalLists.Participants)
+ {
if (_loginResult?.ParticipantId == participant.Id)
{
App.Participant = participant;
EnableControlsForParticipant();
- }
- if(participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY))
- agencies.Add(participant);
+ }
}
- this.searchFilterControl.SetAgencies(agencies);
+
+ this.searchFilterControl.SetAgencies(BreCalLists.Participants_Agent);
if (!string.IsNullOrEmpty(Properties.Settings.Default.FilterCriteria))
{
@@ -271,7 +277,13 @@ namespace BreCalClient
{
while (!_tokenSource.Token.IsCancellationRequested || _refreshImmediately)
{
- _refreshImmediately = false;
+
+ if (_refreshImmediately)
+ {
+ _refreshImmediately = false;
+ _tokenSource = new CancellationTokenSource();
+ }
+
List? shipcalls = null;
try
{
@@ -313,7 +325,7 @@ namespace BreCalClient
// update entry
_allShipcallsDict[shipcall.Id].Shipcall = shipcall;
_allShipcallsDict[shipcall.Id].Times = currentTimes;
- this.UpdateShipcall(_allShipcallsDict[shipcall.Id]);
+ UpdateShipcall(_allShipcallsDict[shipcall.Id]);
}
}
@@ -349,37 +361,36 @@ namespace BreCalClient
_allShipcallsDict[scm.Shipcall.Id] = scm;
Shipcall shipcall = scm.Shipcall;
- if (this._shipLookupDict.ContainsKey(shipcall.ShipId))
- scm.Ship = this._shipLookupDict[shipcall.ShipId];
- if (this._berthLookupDict.ContainsKey(shipcall.ArrivalBerthId ?? 0))
- scm.Berth = this._berthLookupDict[shipcall.ArrivalBerthId ?? 0].Name;
- scm.AssignParticipants(this._participants);
+ if (BreCalLists.ShipLookupDict.ContainsKey(shipcall.ShipId))
+ scm.Ship = BreCalLists.ShipLookupDict[shipcall.ShipId];
+ if (BreCalLists.BerthLookupDict.ContainsKey(shipcall.ArrivalBerthId ?? 0))
+ scm.Berth = BreCalLists.BerthLookupDict[shipcall.ArrivalBerthId ?? 0].Name;
+ scm.AssignParticipants(BreCalLists.Participants);
this.Dispatcher.Invoke(() =>
{
ShipcallControl sc = new()
{
Height = 120,
- ShipcallControlModel = scm,
- ParticipantDict = _participantLookupDict,
- Berths = _berths
+ ShipcallControlModel = scm
};
sc.EditTimesRequested += Sc_EditTimesRequested;
sc.EditRequested += Sc_EditRequested;
+ sc.EditAgencyRequested += Sc_EditAgencyRequested;
sc.RefreshData();
this._allShipCallsControlDict[scm.Shipcall.Id] = sc;
});
- }
+ }
- private void UpdateShipcall(ShipcallControlModel scm)
+ private static void UpdateShipcall(ShipcallControlModel scm)
{
if(scm.Shipcall == null) return;
Shipcall shipcall = scm.Shipcall;
- if (this._shipLookupDict.ContainsKey(shipcall.ShipId))
- scm.Ship = this._shipLookupDict[shipcall.ShipId];
- if (this._berthLookupDict.ContainsKey(shipcall.ArrivalBerthId ?? 0))
- scm.Berth = this._berthLookupDict[shipcall.ArrivalBerthId ?? 0].Name;
- scm.AssignParticipants(this._participants);
+ if (BreCalLists.ShipLookupDict.ContainsKey(shipcall.ShipId))
+ scm.Ship = BreCalLists.ShipLookupDict[shipcall.ShipId];
+ if (BreCalLists.BerthLookupDict.ContainsKey(shipcall.ArrivalBerthId ?? 0))
+ scm.Berth = BreCalLists.BerthLookupDict[shipcall.ArrivalBerthId ?? 0].Name;
+ scm.AssignParticipants(BreCalLists.Participants);
}
private void RemoveShipcall(int shipcallId)
@@ -413,42 +424,50 @@ namespace BreCalClient
if(sfm.Agencies.Count > 0 )
{
- this._visibleControlModels.RemoveAll(x => !sfm.Agencies.Contains((x.GetParticipantIdForType(Extensions.ParticipantType.AGENCY)) ?? -1));
+ _ = this._visibleControlModels.RemoveAll((x) =>
+ {
+ Participant? agency = x.GetParticipantForType(ParticipantType.AGENCY);
+ if(agency != null)
+ {
+ return !sfm.Agencies.Contains(agency.Id);
+ }
+ return true;
+ });
}
if(sfm.Categories.Count > 0 )
{
- this._visibleControlModels.RemoveAll(x => !sfm.Categories.Contains((x.Shipcall?.Type) ?? -1));
+ _ = this._visibleControlModels.RemoveAll(x => !sfm.Categories.Contains((x.Shipcall?.Type) ?? -1));
}
if(!string.IsNullOrEmpty(sfm.SearchString))
{
- this._visibleControlModels.RemoveAll(x => !x.ContainsRemarkText(sfm.SearchString));
+ _ = this._visibleControlModels.RemoveAll(x => !(x.ContainsRemarkText(sfm.SearchString) || (x.Ship?.Name.Contains(sfm.SearchString, StringComparison.InvariantCultureIgnoreCase) ?? false)));
}
if(sfm.ShipLengthTo != null)
{
- this._visibleControlModels.RemoveAll(x => x.Ship?.Length > sfm.ShipLengthTo);
+ _ = this._visibleControlModels.RemoveAll(x => x.Ship?.Length > sfm.ShipLengthTo);
}
if(sfm.ShipLengthFrom != null)
{
- this._visibleControlModels.RemoveAll(x => x.Ship?.Length < sfm.ShipLengthFrom);
+ _ = this._visibleControlModels.RemoveAll(x => x.Ship?.Length < sfm.ShipLengthFrom);
}
if(sfm.EtaFrom != null)
{
- this._visibleControlModels.RemoveAll(x => x.Shipcall?.Eta < sfm.EtaFrom);
+ _ = this._visibleControlModels.RemoveAll(x => x.Shipcall?.Eta < sfm.EtaFrom);
}
if(sfm.EtaTo != null)
{
- this._visibleControlModels.RemoveAll(x => x.Shipcall?.Eta > sfm.EtaTo);
+ _ = this._visibleControlModels.RemoveAll(x => x.Shipcall?.Eta > sfm.EtaTo);
}
if(!_showCanceled ?? true) // canceled calls are filtered by default
{
- this._visibleControlModels.RemoveAll(x => x.Shipcall?.Canceled ?? true);
+ _ = this._visibleControlModels.RemoveAll(x => x.Shipcall?.Canceled ?? false);
}
if (this._sortOrder != null)
@@ -507,10 +526,7 @@ namespace BreCalClient
{
EditShipcallControl esc = new()
{
- ShipcallModel = obj.ShipcallControlModel,
- Ships = _ships,
- Participants = _participants,
- Berths = _berths
+ ShipcallModel = obj.ShipcallControlModel
};
if(esc.ShowDialog() ?? false)
@@ -533,9 +549,7 @@ namespace BreCalClient
private async void Sc_EditTimesRequested(ShipcallControl obj, Times? times, Extensions.ParticipantType participantType)
{
// show a dialog that lets the user create / update times for the given shipcall
- IEditTimesControl etc = (participantType == ParticipantType.TERMINAL) ? new EditTimesTerminalControl() : new EditTimesControl();
- if (etc is EditTimesTerminalControl ettc)
- ettc.Berths = this._berths;
+ IEditTimesControl etc = (participantType == ParticipantType.TERMINAL) ? new EditTimesTerminalControl() : new EditTimesControl();
bool wasEdit = false;
if (times != null)
@@ -562,7 +576,8 @@ namespace BreCalClient
{
etc.Times.ShipcallId = obj.ShipcallControlModel.Shipcall.Id;
}
- await _api.TimesPostAsync(etc.Times);
+ Id apiResultId = await _api.TimesPostAsync(etc.Times);
+ etc.Times.Id = apiResultId.VarId;
obj.ShipcallControlModel?.Times.Add(etc.Times);
}
_refreshImmediately = true;
@@ -575,6 +590,66 @@ namespace BreCalClient
}
}
+ private async void Sc_EditAgencyRequested(ShipcallControl sc, Times? times)
+ {
+ IEditShipcallTimesControl? editControl = null;
+ switch(sc.ShipcallControlModel?.Shipcall?.Type)
+ {
+ case (int)TypeEnum.Incoming:
+ editControl = new EditTimesAgencyIncomingControl();
+ break;
+ case (int)TypeEnum.Outgoing:
+ editControl = new EditTimesAgencyOutgoingControl();
+ break;
+ case (int)TypeEnum.Shifting:
+ editControl = new EditTimesAgencyShiftingControl();
+ break;
+ }
+
+ if (editControl != null)
+ {
+ editControl.ShipcallModel = sc.ShipcallControlModel ?? new ShipcallControlModel();
+ bool wasEdit = false;
+ if (times != null)
+ {
+ editControl.Times = times;
+ wasEdit = true;
+ }
+ editControl.Times.ParticipantType = (int)ParticipantType.AGENCY;
+ if(editControl.ShowDialog() ?? false)
+ {
+ try
+ {
+ editControl.Times.ParticipantId = App.Participant.Id;
+
+ if (wasEdit)
+ {
+ await _api.TimesPutAsync(editControl.Times);
+ }
+ else
+ {
+ if ((sc.ShipcallControlModel != null) && (sc.ShipcallControlModel.Shipcall != null))
+ {
+ editControl.Times.ShipcallId = sc.ShipcallControlModel.Shipcall.Id;
+ }
+ Id resultAPI_Id = await _api.TimesPostAsync(editControl.Times);
+ editControl.Times.Id = resultAPI_Id.VarId;
+
+ sc.ShipcallControlModel?.Times.Add(editControl.Times);
+ }
+ await _api.ShipcallsPutAsync(editControl.ShipcallModel.Shipcall);
+ _refreshImmediately = true;
+ _tokenSource.Cancel();
+ }
+ catch(Exception ex)
+ {
+ ShowErrorDialog(ex.Message, "Error saving agency information");
+ }
+ }
+ }
+
+ }
+
#endregion
#region helper
diff --git a/src/BreCalClient/Properties/PublishProfiles/ClickOnceProfile.pubxml b/src/BreCalClient/Properties/PublishProfiles/ClickOnceProfile.pubxml
index a262fac..2adac28 100644
--- a/src/BreCalClient/Properties/PublishProfiles/ClickOnceProfile.pubxml
+++ b/src/BreCalClient/Properties/PublishProfiles/ClickOnceProfile.pubxml
@@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
0
- 0.6.0.0
+ 0.7.0.0
False
Release
True
diff --git a/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml b/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml
index db801ad..3894b6b 100644
--- a/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml
+++ b/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml
@@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
0
- 0.6.1.0
+ 0.7.0.0
False
Debug
True
diff --git a/src/BreCalClient/Resources/Resources.Designer.cs b/src/BreCalClient/Resources/Resources.Designer.cs
index ed9cb7c..5c8f167 100644
--- a/src/BreCalClient/Resources/Resources.Designer.cs
+++ b/src/BreCalClient/Resources/Resources.Designer.cs
@@ -460,6 +460,15 @@ namespace BreCalClient.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Incoming.
+ ///
+ public static string textIncoming {
+ get {
+ return ResourceManager.GetString("textIncoming", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Interval.
///
@@ -469,6 +478,15 @@ namespace BreCalClient.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Length.
+ ///
+ public static string textLength {
+ get {
+ return ResourceManager.GetString("textLength", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to L/W.
///
@@ -577,6 +595,15 @@ namespace BreCalClient.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Outgoing.
+ ///
+ public static string textOutgoing {
+ get {
+ return ResourceManager.GetString("textOutgoing", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Participants.
///
@@ -703,6 +730,33 @@ namespace BreCalClient.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Shifting.
+ ///
+ public static string textShifting {
+ get {
+ return ResourceManager.GetString("textShifting", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Shifting from.
+ ///
+ public static string textShiftingFrom {
+ get {
+ return ResourceManager.GetString("textShiftingFrom", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Shifting to.
+ ///
+ public static string textShiftingTo {
+ get {
+ return ResourceManager.GetString("textShiftingTo", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Ship.
///
@@ -820,6 +874,15 @@ namespace BreCalClient.Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Width.
+ ///
+ public static string textWidth {
+ get {
+ return ResourceManager.GetString("textWidth", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Zone entry.
///
diff --git a/src/BreCalClient/Resources/Resources.de.resx b/src/BreCalClient/Resources/Resources.de.resx
index 2cecb22..5606ede 100644
--- a/src/BreCalClient/Resources/Resources.de.resx
+++ b/src/BreCalClient/Resources/Resources.de.resx
@@ -236,7 +236,7 @@
Operation Start
- Festmacher in Schleuse
+ auch in Schleuse
Festmacher
@@ -385,4 +385,25 @@
Info
+
+ Einkommend
+
+
+ Ausgehend
+
+
+ Verholung
+
+
+ Länge
+
+
+ Verholung von
+
+
+ Verholung nach
+
+
+ Breite
+
\ No newline at end of file
diff --git a/src/BreCalClient/Resources/Resources.resx b/src/BreCalClient/Resources/Resources.resx
index 5477bcf..78c37b9 100644
--- a/src/BreCalClient/Resources/Resources.resx
+++ b/src/BreCalClient/Resources/Resources.resx
@@ -247,9 +247,15 @@
from
+
+ Incoming
+
Interval
+
+ Length
+
L/W
@@ -286,6 +292,9 @@
Operations start
+
+ Outgoing
+
Participants
@@ -328,6 +337,15 @@
Search
+
+ Shifting
+
+
+ Shifting from
+
+
+ Shifting to
+
Ship
@@ -367,6 +385,9 @@
Voyage
+
+ Width
+
Zone entry
diff --git a/src/BreCalClient/ShipcallControl.xaml b/src/BreCalClient/ShipcallControl.xaml
index 0f21e42..7f2d80c 100644
--- a/src/BreCalClient/ShipcallControl.xaml
+++ b/src/BreCalClient/ShipcallControl.xaml
@@ -118,6 +118,7 @@
+
@@ -139,6 +140,7 @@
+
@@ -159,6 +161,7 @@
+
@@ -180,6 +183,7 @@
+
@@ -201,6 +205,7 @@
+
@@ -219,10 +224,11 @@
-
+
+
diff --git a/src/BreCalClient/ShipcallControl.xaml.cs b/src/BreCalClient/ShipcallControl.xaml.cs
index ca2e298..c9839f4 100644
--- a/src/BreCalClient/ShipcallControl.xaml.cs
+++ b/src/BreCalClient/ShipcallControl.xaml.cs
@@ -4,8 +4,6 @@
using BreCalClient.misc.Model;
using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
@@ -19,6 +17,16 @@ namespace BreCalClient
///
public partial class ShipcallControl : UserControl
{
+ #region Fields
+
+ Participant? _agency;
+ Participant? _pilot;
+ Participant? _mooring;
+ Participant? _terminal;
+ Participant? _tug;
+ Participant? _port_administration;
+
+ #endregion
#region Construction
@@ -33,6 +41,8 @@ namespace BreCalClient
public event Action? EditRequested;
+ public event Action? EditAgencyRequested;
+
internal event Action? EditTimesRequested;
#endregion
@@ -42,17 +52,7 @@ namespace BreCalClient
///
/// this is our datasource
///
- public ShipcallControlModel? ShipcallControlModel { get; set; }
-
- ///
- /// these are all participants (currently loaded)
- ///
- public Dictionary? ParticipantDict { get; set; }
-
- ///
- /// For berth name lookup
- ///
- public List? Berths {get; set;}
+ public ShipcallControlModel? ShipcallControlModel { get; set; }
#endregion
@@ -63,57 +63,69 @@ namespace BreCalClient
if (this.ShipcallControlModel == null) return;
string agentName = "";
string? name;
- name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.AGENCY);
+ _agency = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.AGENCY);
+ name = _agency?.Name;
if (name != null) agentName = name;
this.labelAgent.Content = name ?? "- / -";
- name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.MOORING);
+ _mooring = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.MOORING);
+ name = _mooring?.Name;
this.labelMooring.Content = name ?? "- / -";
- name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.PILOT);
+ _pilot = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.PILOT);
+ name = _pilot?.Name;
this.labelPilot.Content = name ?? "- / - ";
- name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.TUG);
+ _tug = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.TUG);
+ name = _tug?.Name;
this.labelTug.Content = name ?? "- / - ";
- name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.PORT_ADMINISTRATION);
+ _port_administration = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.PORT_ADMINISTRATION);
+ name = _port_administration?.Name;
this.labelPortAuthority.Content = name ?? "- / - ";
- name = this.ShipcallControlModel.GetParticipantNameForType(Extensions.ParticipantType.TERMINAL);
+ _terminal = this.ShipcallControlModel.GetParticipantForType(Extensions.ParticipantType.TERMINAL);
+ name = _terminal?.Name;
this.labelTerminal.Content = name ?? "- / - ";
- if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TERMINAL) && (App.Participant.Id == this.ShipcallControlModel.GetParticipantIdForType(Extensions.ParticipantType.TERMINAL)))
+ if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TERMINAL) && (App.Participant.Id == _terminal?.Id))
{
this.labelTerminal.FontWeight = FontWeights.Bold;
this.labelTerminal.Foreground = Brushes.LightYellow;
}
- if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PILOT) && (App.Participant.Id == this.ShipcallControlModel.GetParticipantIdForType(Extensions.ParticipantType.PILOT)))
+
+ if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PILOT) && (App.Participant.Id == _pilot?.Id))
{
this.labelPilot.FontWeight = FontWeights.Bold;
this.labelPilot.Foreground = Brushes.LightYellow;
}
- if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY) && (App.Participant.Id == this.ShipcallControlModel.GetParticipantIdForType(Extensions.ParticipantType.AGENCY)))
+
+ if((App.Participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY) && (App.Participant.Id == _agency?.Id)) ||
+ (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.BSMD) && (_agency != null) && _agency.IsFlagSet(Extensions.ParticipantFlag.ALLOW_BSMD)))
{
this.labelAgent.FontWeight = FontWeights.Bold;
this.labelAgent.Foreground = Brushes.LightYellow;
}
- if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.MOORING) && (App.Participant.Id == this.ShipcallControlModel.GetParticipantIdForType(Extensions.ParticipantType.MOORING)))
+
+ if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.MOORING) && (App.Participant.Id == _mooring?.Id))
{
this.labelMooring.FontWeight = FontWeights.Bold;
this.labelMooring.Foreground = Brushes.LightYellow;
}
- if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION) && (App.Participant.Id == this.ShipcallControlModel.GetParticipantIdForType(Extensions.ParticipantType.PORT_ADMINISTRATION)))
+
+ if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION) && (App.Participant.Id == _port_administration?.Id))
{
this.labelPortAuthority.FontWeight = FontWeights.Bold;
this.labelPortAuthority.Foreground = Brushes.LightYellow;
}
- if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TUG) && (App.Participant.Id == this.ShipcallControlModel.GetParticipantIdForType(Extensions.ParticipantType.TUG)))
+
+ if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TUG) && (App.Participant.Id == _tug?.Id))
{
this.labelTug.FontWeight = FontWeights.Bold;
this.labelTug.Foreground = Brushes.LightYellow;
}
- if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.BSMD) ||
- (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY) && (App.Participant.Id == this.ShipcallControlModel.GetParticipantIdForType(Extensions.ParticipantType.AGENCY))))
+
+ if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.BSMD))
{
this.labelShipName.FontWeight = FontWeights.Bold;
this.labelShipName.Foreground = Brushes.LightYellow;
@@ -151,56 +163,75 @@ namespace BreCalClient
this.textBlockLengthWidth.Text = $"{this.ShipcallControlModel?.Ship?.Length} / {this.ShipcallControlModel?.Ship?.Width}";
this.textBlockAgency.Text = agentName.TruncateDots(10);
- if (this.ParticipantDict != null)
+
+ if (this.ShipcallControlModel != null)
{
- if (this.ShipcallControlModel != null)
+ foreach (Times times in this.ShipcallControlModel.Times)
{
- foreach (Times times in this.ShipcallControlModel.Times)
- {
- if (times.ParticipantType == (int)Extensions.ParticipantType.AGENCY)
- {
- this.labelAgencyETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
- this.labelAgencyETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
- this.textBlockAgencyRemarks.Text = times.Remarks;
- }
- if (times.ParticipantType == (int) Extensions.ParticipantType.MOORING)
- {
- this.labelMooringETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
- this.labelMooringETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
- this.textBlockMooringRemarks.Text = times.Remarks;
- }
- if (times.ParticipantType == (int)Extensions.ParticipantType.PORT_ADMINISTRATION)
- {
- this.labelPortAuthorityETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
- this.labelPortAuthorityETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
- this.textBlockPortAuthorityRemarks.Text = times.Remarks;
- }
- if (times.ParticipantType == (int)Extensions.ParticipantType.PILOT)
- {
- this.labelPilotETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
- this.labelPilotETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
- this.textBlockPilotRemarks.Text = times.Remarks;
- }
- if (times.ParticipantType == (int)Extensions.ParticipantType.TUG)
- {
- this.labelTugETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
- this.labelTugETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
- this.textBlockTugRemarks.Text = times.Remarks;
- }
- if (times.ParticipantType == (int)Extensions.ParticipantType.TERMINAL)
- {
- if (this.Berths != null)
- {
- Berth? berth = this.Berths.Find((x) => x.Id == times.BerthId);
- this.labelTerminalBerth.Content = (berth != null) ? berth.Name : "";
- }
- this.labelOperationsStart.Content = times.OperationsStart.HasValue ? times.OperationsStart.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
- this.labelOperationsEnd.Content = times.OperationsEnd.HasValue ? times.OperationsEnd.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
- this.textBlockTerminalRemarks.Text = times.Remarks;
- }
+ string? berthText = null;
+ if ((BreCalLists.Berths != null) && times.BerthId.HasValue)
+ {
+ Berth? berth = BreCalLists.Berths.Find((x) => x.Id == times.BerthId);
+ berthText = berth?.Name;
}
+ if(berthText == null)
+ {
+ if (this.ShipcallControlModel.Shipcall?.Type == (int) Extensions.TypeEnum.Outgoing)
+ {
+ Berth? berth = BreCalLists.Berths?.Find((x) => x.Id == this.ShipcallControlModel.Shipcall?.DepartureBerthId);
+ berthText = berth?.Name;
+ }
+ else
+ {
+ Berth? berth = BreCalLists.Berths?.Find((x) => x.Id == this.ShipcallControlModel.Shipcall?.ArrivalBerthId);
+ berthText = berth?.Name;
+ }
+ }
+
+ if (times.ParticipantType == (int)Extensions.ParticipantType.AGENCY)
+ {
+ this.labelAgencyBerth.Content = berthText;
+ this.labelAgencyETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
+ this.labelAgencyETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
+ this.textBlockAgencyRemarks.Text = times.Remarks;
+ }
+ if (times.ParticipantType == (int) Extensions.ParticipantType.MOORING)
+ {
+ this.labelMooringBerth.Content = berthText;
+ this.labelMooringETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
+ this.labelMooringETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
+ this.textBlockMooringRemarks.Text = times.Remarks;
+ }
+ if (times.ParticipantType == (int)Extensions.ParticipantType.PORT_ADMINISTRATION)
+ {
+ this.labelPortAuthorityBerth.Content = berthText;
+ this.labelPortAuthorityETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
+ this.labelPortAuthorityETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
+ this.textBlockPortAuthorityRemarks.Text = times.Remarks;
+ }
+ if (times.ParticipantType == (int)Extensions.ParticipantType.PILOT)
+ {
+ this.labelPilotBerth.Content = berthText;
+ this.labelPilotETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
+ this.labelPilotETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
+ this.textBlockPilotRemarks.Text = times.Remarks;
+ }
+ if (times.ParticipantType == (int)Extensions.ParticipantType.TUG)
+ {
+ this.labelTugBerth.Content = berthText;
+ this.labelTugETA.Content = times.EtaBerth.HasValue ? times.EtaBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
+ this.labelTugETD.Content = times.EtdBerth.HasValue ? times.EtdBerth.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
+ this.textBlockTugRemarks.Text = times.Remarks;
+ }
+ if (times.ParticipantType == (int)Extensions.ParticipantType.TERMINAL)
+ {
+ this.labelTerminalBerth.Content = berthText;
+ this.labelOperationsStart.Content = times.OperationsStart.HasValue ? times.OperationsStart.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
+ this.labelOperationsEnd.Content = times.OperationsEnd.HasValue ? times.OperationsEnd.Value.ToString("dd.MM.yyyy HH:mm") : "- / -";
+ this.textBlockTerminalRemarks.Text = times.Remarks;
+ }
}
- }
+ }
}
#endregion
@@ -214,8 +245,7 @@ namespace BreCalClient
private void buttonEditShipcall_Click(object? sender, RoutedEventArgs? e)
{
- if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.BSMD) ||
- (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY) && (App.Participant.Id == this.ShipcallControlModel?.GetParticipantIdForType(Extensions.ParticipantType.AGENCY))))
+ if(App.Participant.IsTypeFlagSet(Extensions.ParticipantType.BSMD))
this.EditRequested?.Invoke(this);
}
@@ -226,15 +256,17 @@ namespace BreCalClient
private void labelAgent_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
- if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY) && (App.Participant.Id == this.ShipcallControlModel?.GetParticipantIdForType(Extensions.ParticipantType.AGENCY)))
+ if ((App.Participant.IsTypeFlagSet(Extensions.ParticipantType.AGENCY) && (App.Participant.Id == _agency?.Id)) ||
+ (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.BSMD) && (_agency != null) && _agency.IsFlagSet(Extensions.ParticipantFlag.ALLOW_BSMD)))
{
- this.EditRequested?.Invoke(this);
+ Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.AGENCY);
+ this.EditAgencyRequested?.Invoke(this, times);
}
}
private void labelMooring_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
- if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.MOORING) && (App.Participant.Id == this.ShipcallControlModel?.GetParticipantIdForType(Extensions.ParticipantType.MOORING)))
+ if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.MOORING) && (App.Participant.Id == _mooring?.Id))
{
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.MOORING);
this.EditTimesRequested?.Invoke(this, times, Extensions.ParticipantType.MOORING);
@@ -243,7 +275,7 @@ namespace BreCalClient
private void labelPortAuthority_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
- if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION) && (App.Participant.Id == this.ShipcallControlModel?.GetParticipantIdForType(Extensions.ParticipantType.PORT_ADMINISTRATION)))
+ if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PORT_ADMINISTRATION) && (App.Participant.Id == _port_administration?.Id))
{
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.PORT_ADMINISTRATION);
this.EditTimesRequested?.Invoke(this, times, Extensions.ParticipantType.PORT_ADMINISTRATION);
@@ -252,7 +284,7 @@ namespace BreCalClient
private void labelPilot_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
- if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PILOT) && (App.Participant.Id == this.ShipcallControlModel?.GetParticipantIdForType(Extensions.ParticipantType.PILOT)))
+ if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.PILOT) && (App.Participant.Id == _pilot?.Id))
{
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.PILOT);
this.EditTimesRequested?.Invoke(this, times, Extensions.ParticipantType.PILOT);
@@ -261,7 +293,7 @@ namespace BreCalClient
private void labelTug_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
- if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TUG) && (App.Participant.Id == this.ShipcallControlModel?.GetParticipantIdForType(Extensions.ParticipantType.TUG)))
+ if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TUG) && (App.Participant.Id == _tug?.Id))
{
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.TUG);
this.EditTimesRequested?.Invoke(this, times, Extensions.ParticipantType.TUG);
@@ -270,7 +302,7 @@ namespace BreCalClient
private void labelTerminal_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
- if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TERMINAL) && (App.Participant.Id == this.ShipcallControlModel?.GetParticipantIdForType(Extensions.ParticipantType.TERMINAL)))
+ if (App.Participant.IsTypeFlagSet(Extensions.ParticipantType.TERMINAL) && (App.Participant.Id == _terminal?.Id))
{
Times? times = this.ShipcallControlModel?.GetTimesForParticipantType(Extensions.ParticipantType.TERMINAL);
this.EditTimesRequested?.Invoke(this, times, Extensions.ParticipantType.TERMINAL);
diff --git a/src/BreCalClient/ShipcallControlModel.cs b/src/BreCalClient/ShipcallControlModel.cs
index 0d39601..36857e3 100644
--- a/src/BreCalClient/ShipcallControlModel.cs
+++ b/src/BreCalClient/ShipcallControlModel.cs
@@ -109,6 +109,18 @@ namespace BreCalClient
if ((times.ParticipantId == participantId) && (times.ParticipantType == (int) type))
return times;
}
+ if(type == Extensions.ParticipantType.AGENCY)
+ {
+ // if I am BSMD and no agency entry was found this means we are editing the agency entry
+ if(App.Participant.Type == (int) Extensions.ParticipantType.BSMD)
+ {
+ foreach(Times times in this.Times)
+ {
+ if ((times.ParticipantId == App.Participant.Id) && (times.ParticipantType == (int) Extensions.ParticipantType.AGENCY))
+ return times;
+ }
+ }
+ }
}
return null;
}
@@ -131,25 +143,15 @@ namespace BreCalClient
#region helper
- internal string? GetParticipantNameForType(Extensions.ParticipantType participantType)
+ internal Participant? GetParticipantForType(Extensions.ParticipantType participantType)
{
foreach(Participant p in AssignedParticipants.Values)
{
if (p.IsTypeFlagSet(participantType))
- return p.Name;
+ return p;
}
return null;
- }
-
- internal int? GetParticipantIdForType(Extensions.ParticipantType participantType)
- {
- foreach(Participant p in AssignedParticipants.Values)
- {
- if(p.IsTypeFlagSet(participantType))
- return p.Id;
- }
- return null;
- }
+ }
private bool IsFlagSet(StatusFlags flag)
{
diff --git a/src/server/BreCal/impl/login.py b/src/server/BreCal/impl/login.py
index cef9e4c..c8c7e8d 100644
--- a/src/server/BreCal/impl/login.py
+++ b/src/server/BreCal/impl/login.py
@@ -28,7 +28,7 @@ def GetUser(options):
"user_name": data[0].user_name,
"user_phone": data[0].user_phone
}
- token = jwt_handler.generate_jwt(payload=result, lifetime=60) # generate token valid 60 mins
+ token = jwt_handler.generate_jwt(payload=result, lifetime=120) # generate token valid 60 mins
result["token"] = token # add token to user data
return json.dumps(result), 200, {'Content-Type': 'application/json; charset=utf-8'}
diff --git a/src/server/BreCal/impl/times.py b/src/server/BreCal/impl/times.py
index def3cfe..9792a88 100644
--- a/src/server/BreCal/impl/times.py
+++ b/src/server/BreCal/impl/times.py
@@ -124,10 +124,11 @@ def PutTimes(schemaModel):
pooledConnection.close()
- if affected_rows == 1:
- return json.dumps({"id" : schemaModel["id"]}), 200, {'Content-Type': 'application/json; charset=utf-8'}
+ # if affected_rows == 1: # this doesn't work as expected
- return json.dumps("no such record"), 404, {'Content-Type': 'application/json; charset=utf-8'}
+ return json.dumps({"id" : schemaModel["id"]}), 200, {'Content-Type': 'application/json; charset=utf-8'}
+
+ # return json.dumps("no such record"), 404, {'Content-Type': 'application/json; charset=utf-8'}
except Exception as ex:
logging.error(ex)
diff --git a/src/server/BreCal/schemas/model.py b/src/server/BreCal/schemas/model.py
index b1f1300..9f77a34 100644
--- a/src/server/BreCal/schemas/model.py
+++ b/src/server/BreCal/schemas/model.py
@@ -161,11 +161,11 @@ class UserSchema(Schema):
super().__init__(unknown=None)
pass
id = fields.Int(required=True)
- first_name = fields.Str(required=False)
- last_name = fields.Str(required=False)
- user_phone = fields.Str(required=False)
- old_password = fields.Str(required=False)
- new_password = fields.Str(required=False)
+ first_name = fields.Str(Required=False, allow_none=True)
+ last_name = fields.Str(required=False, allow_none=True)
+ user_phone = fields.Str(required=False, allow_none=True)
+ old_password = fields.Str(required=False, allow_none=True)
+ new_password = fields.Str(required=False, allow_none=True)
@dataclass
class Times: