Merge branch 'bugfix/validation_feedback' into release/1.5.0

This commit is contained in:
Daniel Schick 2024-09-12 09:43:45 +02:00
commit 82969c8726
18 changed files with 766 additions and 1673 deletions

File diff suppressed because it is too large Load Diff

View File

@ -943,12 +943,21 @@ components:
type: integer type: integer
Error: Error:
type: object type: object
required: description: Structure returned when invalid data (bad request) is created.
- message
properties: properties:
message: message:
description: A human readable error message description: A human readable error message
type: string type: string
errors:
description: A list of errors
type: array
items:
type: string
valid_data:
description: A dictionary of valid data
type: object
required:
- message
ShipcallType: ShipcallType:
type: string type: string
enum: enum:

View File

@ -8,8 +8,8 @@
<SignAssembly>True</SignAssembly> <SignAssembly>True</SignAssembly>
<StartupObject>BreCalClient.App</StartupObject> <StartupObject>BreCalClient.App</StartupObject>
<AssemblyOriginatorKeyFile>..\..\misc\brecal.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\..\misc\brecal.snk</AssemblyOriginatorKeyFile>
<AssemblyVersion>1.5.0.1</AssemblyVersion> <AssemblyVersion>1.5.0.4</AssemblyVersion>
<FileVersion>1.5.0.1</FileVersion> <FileVersion>1.5.0.4</FileVersion>
<Title>Bremen calling client</Title> <Title>Bremen calling client</Title>
<Description>A Windows WPF client for the Bremen calling API.</Description> <Description>A Windows WPF client for the Bremen calling API.</Description>
<ApplicationIcon>containership.ico</ApplicationIcon> <ApplicationIcon>containership.ico</ApplicationIcon>

View File

@ -41,8 +41,8 @@ namespace BreCalClient
} }
this.Ship.Imo = this.integerUpDownIMO.Value; this.Ship.Imo = this.integerUpDownIMO.Value;
this.Ship.Callsign = this.textBoxCallsign.Text.ToUpper().Trim(); this.Ship.Callsign = this.textBoxCallsign.Text.ToUpper().Trim();
this.Ship.Length = (float?) this.doubleUpDownLength.Value; this.Ship.Length = this.doubleUpDownLength.Value;
this.Ship.Width = (float?) this.doubleUpDownWidth.Value; this.Ship.Width = this.doubleUpDownWidth.Value;
this.DialogResult = true; this.DialogResult = true;
this.Close(); this.Close();

View File

@ -205,15 +205,23 @@ namespace BreCalClient
case ShipcallType.Departure: case ShipcallType.Departure:
isEnabled &= this.comboBoxDepartureBerth.SelectedItem != null; isEnabled &= this.comboBoxDepartureBerth.SelectedItem != null;
isEnabled &= this.datePickerETD.Value.HasValue; isEnabled &= this.datePickerETD.Value.HasValue;
if(this.datePickerETD.Value.HasValue)
isEnabled &= (this.datePickerETD.Value.Value > DateTime.Now);
break; break;
case ShipcallType.Arrival: case ShipcallType.Arrival:
isEnabled &= this.comboBoxArrivalBerth.SelectedItem != null; isEnabled &= this.comboBoxArrivalBerth.SelectedItem != null;
isEnabled &= this.datePickerETA.Value.HasValue; isEnabled &= this.datePickerETA.Value.HasValue;
if(this.datePickerETA.Value.HasValue)
isEnabled &= (this.datePickerETA.Value.Value > DateTime.Now);
break; break;
case ShipcallType.Shifting: case ShipcallType.Shifting:
isEnabled &= ((this.comboBoxDepartureBerth.SelectedItem != null) && (this.comboBoxArrivalBerth.SelectedItem != null)); isEnabled &= ((this.comboBoxDepartureBerth.SelectedItem != null) && (this.comboBoxArrivalBerth.SelectedItem != null));
isEnabled &= this.datePickerETD.Value.HasValue; isEnabled &= this.datePickerETD.Value.HasValue;
isEnabled &= this.datePickerETA.Value.HasValue; isEnabled &= this.datePickerETA.Value.HasValue;
if (this.datePickerETD.Value.HasValue)
isEnabled &= (this.datePickerETD.Value.Value > DateTime.Now);
if (this.datePickerETA.Value.HasValue)
isEnabled &= (this.datePickerETA.Value.Value > DateTime.Now);
break; break;
} }
} }

View File

@ -4,6 +4,7 @@
using BreCalClient.misc.Model; using BreCalClient.misc.Model;
using System; using System;
using System.Runtime.Serialization;
using System.Windows; using System.Windows;
using static BreCalClient.Extensions; using static BreCalClient.Extensions;
@ -70,9 +71,16 @@ namespace BreCalClient
private void buttonOK_Click(object sender, RoutedEventArgs e) private void buttonOK_Click(object sender, RoutedEventArgs e)
{ {
this.CopyToModel(); if (!CheckValues(out string message))
this.DialogResult = true; {
this.Close(); MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
}
else
{
this.CopyToModel();
this.DialogResult = true;
this.Close();
}
} }
private void buttonCancel_Click(object sender, RoutedEventArgs e) private void buttonCancel_Click(object sender, RoutedEventArgs e)
@ -85,6 +93,49 @@ namespace BreCalClient
#region private methods #region private methods
private bool CheckValues(out string message)
{
message = "";
if (this.datePickerETA.Value.HasValue && (this.datePickerETA.Value.Value < DateTime.Now) && (this.datePickerETA_End.Value == null))
{
message = BreCalClient.Resources.Resources.textETAInThePast;
return false;
}
if(this.datePickerETA_End.Value.HasValue && this.datePickerETA_End.Value < DateTime.Now)
{
message = BreCalClient.Resources.Resources.textETAInThePast;
return false;
}
if(this.datePickerETA.Value.HasValue && this.datePickerETA_End.Value.HasValue && this.datePickerETA.Value > this.datePickerETA_End.Value)
{
message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue;
return false;
}
if (this.datePickerTidalWindowFrom.Value.HasValue && (this.datePickerTidalWindowFrom.Value.Value < DateTime.Now) && (this.datePickerTidalWindowTo.Value == null))
{
message = BreCalClient.Resources.Resources.textTideTimesInThePast;
return false;
}
if (this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowTo.Value < DateTime.Now)
{
message = BreCalClient.Resources.Resources.textTideTimesInThePast;
return false;
}
if (this.datePickerTidalWindowFrom.Value.HasValue && this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowFrom.Value > this.datePickerTidalWindowTo.Value)
{
message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue;
return false;
}
return true;
}
private void CopyToModel() private void CopyToModel()
{ {
if (this.ShipcallModel.Shipcall != null) if (this.ShipcallModel.Shipcall != null)

View File

@ -80,9 +80,16 @@ namespace BreCalClient
private void buttonOK_Click(object sender, RoutedEventArgs e) private void buttonOK_Click(object sender, RoutedEventArgs e)
{ {
this.CopyToModel(); if (!CheckValues(out string message))
this.DialogResult = true; {
this.Close(); System.Windows.MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
}
else
{
this.CopyToModel();
this.DialogResult = true;
this.Close();
}
} }
private void buttonCancel_Click(object sender, RoutedEventArgs e) private void buttonCancel_Click(object sender, RoutedEventArgs e)
@ -95,6 +102,50 @@ namespace BreCalClient
#region private methods #region private methods
private bool CheckValues(out string message)
{
message = "";
if (this.datePickerETD.Value.HasValue && (this.datePickerETD.Value.Value < DateTime.Now) && (this.datePickerETD_End.Value == null))
{
message = BreCalClient.Resources.Resources.textETDInThePast;
return false;
}
if (this.datePickerETD_End.Value.HasValue && this.datePickerETD_End.Value < DateTime.Now)
{
message = BreCalClient.Resources.Resources.textETDInThePast;
return false;
}
if (this.datePickerETD.Value.HasValue && this.datePickerETD_End.Value.HasValue && this.datePickerETD.Value > this.datePickerETD_End.Value)
{
message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue;
return false;
}
if (this.datePickerTidalWindowFrom.Value.HasValue && (this.datePickerTidalWindowFrom.Value.Value < DateTime.Now) && (this.datePickerTidalWindowTo.Value == null))
{
message = BreCalClient.Resources.Resources.textTideTimesInThePast;
return false;
}
if (this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowTo.Value < DateTime.Now)
{
message = BreCalClient.Resources.Resources.textTideTimesInThePast;
return false;
}
if (this.datePickerTidalWindowFrom.Value.HasValue && this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowFrom.Value > this.datePickerTidalWindowTo.Value)
{
message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue;
return false;
}
return true;
}
private void CopyToModel() private void CopyToModel()
{ {
if (this.ShipcallModel.Shipcall != null) if (this.ShipcallModel.Shipcall != null)

View File

@ -71,9 +71,16 @@ namespace BreCalClient
private void buttonOK_Click(object sender, RoutedEventArgs e) private void buttonOK_Click(object sender, RoutedEventArgs e)
{ {
this.CopyToModel(); if (!CheckValues(out string message))
this.DialogResult = true; {
this.Close(); System.Windows.MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
}
else
{
this.CopyToModel();
this.DialogResult = true;
this.Close();
}
} }
private void buttonCancel_Click(object sender, RoutedEventArgs e) private void buttonCancel_Click(object sender, RoutedEventArgs e)
@ -86,6 +93,67 @@ namespace BreCalClient
#region private methods #region private methods
private bool CheckValues(out string message)
{
message = "";
if (this.datePickerETA.Value.HasValue && (this.datePickerETA.Value.Value < DateTime.Now) && (this.datePickerETA_End.Value == null))
{
message = BreCalClient.Resources.Resources.textETAInThePast;
return false;
}
if (this.datePickerETA_End.Value.HasValue && this.datePickerETA_End.Value < DateTime.Now)
{
message = BreCalClient.Resources.Resources.textETAInThePast;
return false;
}
if (this.datePickerETA.Value.HasValue && this.datePickerETA_End.Value.HasValue && this.datePickerETA.Value > this.datePickerETA_End.Value)
{
message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue;
return false;
}
if (this.datePickerETD.Value.HasValue && (this.datePickerETD.Value.Value < DateTime.Now) && (this.datePickerETD_End.Value == null))
{
message = BreCalClient.Resources.Resources.textETDInThePast;
return false;
}
if (this.datePickerETD_End.Value.HasValue && this.datePickerETD_End.Value < DateTime.Now)
{
message = BreCalClient.Resources.Resources.textETDInThePast;
return false;
}
if (this.datePickerETD.Value.HasValue && this.datePickerETD_End.Value.HasValue && this.datePickerETD.Value > this.datePickerETD_End.Value)
{
message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue;
return false;
}
if (this.datePickerTidalWindowFrom.Value.HasValue && (this.datePickerTidalWindowFrom.Value.Value < DateTime.Now) && (this.datePickerTidalWindowTo.Value == null))
{
message = BreCalClient.Resources.Resources.textTideTimesInThePast;
return false;
}
if (this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowTo.Value < DateTime.Now)
{
message = BreCalClient.Resources.Resources.textTideTimesInThePast;
return false;
}
if (this.datePickerTidalWindowFrom.Value.HasValue && this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowFrom.Value > this.datePickerTidalWindowTo.Value)
{
message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue;
return false;
}
return true;
}
private void CopyToModel() private void CopyToModel()
{ {
if (this.ShipcallModel.Shipcall != null) if (this.ShipcallModel.Shipcall != null)

View File

@ -44,7 +44,7 @@
<ColumnDefinition Width=".5*" /> <ColumnDefinition Width=".5*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<local:DateTimePickerExt IsEnabled="False" Grid.Row="0" Grid.Column="0" Margin="4,2,0,2" x:Name="datePickerETABerth" Format="Custom" FormatString="dd.MM. yyyy HH:mm"> <local:DateTimePickerExt IsEnabled="False" Grid.Row="0" Grid.Column="0" Margin="2" x:Name="datePickerETABerth" Format="Custom" FormatString="dd.MM. yyyy HH:mm">
<xctk:DateTimePicker.ContextMenu> <xctk:DateTimePicker.ContextMenu>
<ContextMenu> <ContextMenu>
<MenuItem Header="{x:Static p:Resources.textClearValue}" Name="contextMenuItemClearETA" Click="contextMenuItemClearETA_Click" > <MenuItem Header="{x:Static p:Resources.textClearValue}" Name="contextMenuItemClearETA" Click="contextMenuItemClearETA_Click" >

View File

@ -46,9 +46,16 @@ namespace BreCalClient
private void buttonOK_Click(object sender, RoutedEventArgs e) private void buttonOK_Click(object sender, RoutedEventArgs e)
{ {
this.CopyToModel(); if (!CheckValues(out string message))
this.DialogResult = true; {
this.Close(); System.Windows.MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
}
else
{
this.CopyToModel();
this.DialogResult = true;
this.Close();
}
} }
private void buttonCancel_Click(object sender, RoutedEventArgs e) private void buttonCancel_Click(object sender, RoutedEventArgs e)
@ -85,6 +92,44 @@ namespace BreCalClient
#region private methods #region private methods
private bool CheckValues(out string message)
{
message = "";
if (this.datePickerETABerth.Value.HasValue && (this.datePickerETABerth.Value.Value < DateTime.Now) && (this.datePickerETABerth_End.Value == null))
{
message = BreCalClient.Resources.Resources.textETAInThePast;
return false;
}
if (this.datePickerETABerth_End.Value.HasValue && this.datePickerETABerth_End.Value < DateTime.Now)
{
message = BreCalClient.Resources.Resources.textETAInThePast;
return false;
}
if (this.datePickerETABerth.Value.HasValue && this.datePickerETABerth_End.Value.HasValue && this.datePickerETABerth.Value > this.datePickerETABerth_End.Value)
{
message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue;
return false;
}
if (this.datePickerLockTime.Value.HasValue && (this.datePickerLockTime.Value.Value < DateTime.Now))
{
message = BreCalClient.Resources.Resources.textLockTimeInThePast;
return false;
}
if (this.datePickerZoneEntry.Value.HasValue && this.datePickerZoneEntry.Value < DateTime.Now)
{
message = BreCalClient.Resources.Resources.textZoneEntryInThePast;
return false;
}
return true;
}
private void CopyToModel() private void CopyToModel()
{ {
this.Times.Remarks = this.textBoxRemarks.Text.Trim().Truncate(512); this.Times.Remarks = this.textBoxRemarks.Text.Trim().Truncate(512);

View File

@ -3,6 +3,7 @@
// //
using BreCalClient.misc.Model; using BreCalClient.misc.Model;
using System;
using System.Windows; using System.Windows;
namespace BreCalClient namespace BreCalClient
@ -61,9 +62,16 @@ namespace BreCalClient
private void buttonOK_Click(object sender, RoutedEventArgs e) private void buttonOK_Click(object sender, RoutedEventArgs e)
{ {
this.CopyToModel(); if (!CheckValues(out string message))
this.DialogResult = true; {
this.Close(); System.Windows.MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
}
else
{
this.CopyToModel();
this.DialogResult = true;
this.Close();
}
} }
private void buttonCancel_Click(object sender, RoutedEventArgs e) private void buttonCancel_Click(object sender, RoutedEventArgs e)
@ -95,6 +103,50 @@ namespace BreCalClient
#region private methods #region private methods
private bool CheckValues(out string message)
{
message = "";
if (this.datePickerOperationStart.Value.HasValue && (this.datePickerOperationStart.Value.Value < DateTime.Now) && (this.datePickerOperationStart_End.Value == null))
{
message = BreCalClient.Resources.Resources.textOperationStartInThePast;
return false;
}
if (this.datePickerOperationStart_End.Value.HasValue && this.datePickerOperationStart_End.Value < DateTime.Now)
{
message = BreCalClient.Resources.Resources.textOperationStartInThePast;
return false;
}
if (this.datePickerOperationStart.Value.HasValue && this.datePickerOperationStart_End.Value.HasValue && this.datePickerOperationStart.Value > this.datePickerOperationStart_End.Value)
{
message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue;
return false;
}
if (this.datePickerOperationEnd.Value.HasValue && (this.datePickerOperationEnd.Value.Value < DateTime.Now) && (this.datePickerOperationEnd_End.Value == null))
{
message = BreCalClient.Resources.Resources.textOperationEndInThePast;
return false;
}
if (this.datePickerOperationEnd_End.Value.HasValue && this.datePickerOperationEnd_End.Value < DateTime.Now)
{
message = BreCalClient.Resources.Resources.textOperationEndInThePast;
return false;
}
if (this.datePickerOperationEnd.Value.HasValue && this.datePickerOperationEnd_End.Value.HasValue && this.datePickerOperationEnd.Value > this.datePickerOperationEnd_End.Value)
{
message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue;
return false;
}
return true;
}
private void CopyToModel() private void CopyToModel()
{ {
this.Times.PierSide = this.comboBoxPierside.SelectedIndex switch this.Times.PierSide = this.comboBoxPierside.SelectedIndex switch

View File

@ -337,7 +337,7 @@ namespace BreCalClient
{ {
this.Dispatcher.Invoke(new Action(() => this.Dispatcher.Invoke(new Action(() =>
{ {
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); ShowErrorDialog(ex.Message, "Error saving user information");
})); }));
} }
} }
@ -899,7 +899,10 @@ namespace BreCalClient
try try
{ {
obj.ShipcallControlModel.Shipcall?.Participants.Clear(); obj.ShipcallControlModel.Shipcall?.Participants.Clear();
obj.ShipcallControlModel.UpdateTimesAssignments(this._timesApi); if(! await obj.ShipcallControlModel.UpdateTimesAssignments(this._timesApi))
{
ShowErrorDialog(obj.ShipcallControlModel.LastErrorMessage, "Update assignments error");
}
foreach(ParticipantAssignment pa in obj.ShipcallControlModel.AssignedParticipants.Values) foreach(ParticipantAssignment pa in obj.ShipcallControlModel.AssignedParticipants.Values)
obj.ShipcallControlModel.Shipcall?.Participants.Add(pa); obj.ShipcallControlModel.Shipcall?.Participants.Add(pa);
await _shipcallApi.ShipcallUpdateAsync(obj.ShipcallControlModel.Shipcall); await _shipcallApi.ShipcallUpdateAsync(obj.ShipcallControlModel.Shipcall);
@ -1011,7 +1014,13 @@ namespace BreCalClient
{ {
try try
{ {
sc.ShipcallControlModel?.UpdateTimesAssignments(_timesApi); // if the agent changed the assignment of the participant to another if (sc.ShipcallControlModel != null)
{
if (!await sc.ShipcallControlModel.UpdateTimesAssignments(_timesApi)) // if the agent changed the assignment of the participant to another
{
ShowErrorDialog(sc.ShipcallControlModel.LastErrorMessage, "Error updating times assignment");
}
}
// always try to be the agent, even if we are BSMD // always try to be the agent, even if we are BSMD
if (editControl.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY)) if (editControl.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY))
@ -1064,6 +1073,7 @@ namespace BreCalClient
// Error calling ShipcallUpdate: {\"message\": \"PUT Requests for shipcalls can only be issued by an assigned AGENCY or BSMD users // Error calling ShipcallUpdate: {\"message\": \"PUT Requests for shipcalls can only be issued by an assigned AGENCY or BSMD users
// (if the special-flag is enabled). Assigned Agency: ShipcallParticipantMap(id=628, shipcall_id=115, participant_id=10, // (if the special-flag is enabled). Assigned Agency: ShipcallParticipantMap(id=628, shipcall_id=115, participant_id=10,
// type=8, created=datetime.datetime(2024, 8, 28, 15, 13, 14), modified=None) with Flags: 42\"} // type=8, created=datetime.datetime(2024, 8, 28, 15, 13, 14), modified=None) with Flags: 42\"}
Match m = Regex.Match(message, "\\{(.*)\\}"); Match m = Regex.Match(message, "\\{(.*)\\}");
if ((m != null) && m.Success) if ((m != null) && m.Success)
{ {
@ -1072,21 +1082,15 @@ namespace BreCalClient
dynamic? msg = JsonConvert.DeserializeObject(m.Value); dynamic? msg = JsonConvert.DeserializeObject(m.Value);
if (msg != null) if (msg != null)
{ {
if (msg.message != null) if (msg.error_field != null)
{ {
caption = $"{caption}: {msg.message}"; caption = $"{caption}: {msg.error_field}";
} }
if((msg.errors != null) && msg.errors.Count > 0) if(msg.error_description != null)
{ {
message = ""; message = msg.error_description;
foreach(string error in msg.errors) }
{
message += error;
message += Environment.NewLine;
}
}
} }
} }
catch (Exception) { } catch (Exception) { }

View File

@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<ApplicationRevision>0</ApplicationRevision> <ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.5.0.1</ApplicationVersion> <ApplicationVersion>1.5.0.4</ApplicationVersion>
<BootstrapperEnabled>True</BootstrapperEnabled> <BootstrapperEnabled>True</BootstrapperEnabled>
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
<CreateDesktopShortcut>True</CreateDesktopShortcut> <CreateDesktopShortcut>True</CreateDesktopShortcut>

View File

@ -389,6 +389,15 @@ namespace BreCalClient.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Both tide times are required.
/// </summary>
public static string textBothTideTimesNecessary {
get {
return ResourceManager.GetString("textBothTideTimesNecessary", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to BSMD right to edit granted. /// Looks up a localized string similar to BSMD right to edit granted.
/// </summary> /// </summary>
@ -623,6 +632,15 @@ namespace BreCalClient.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Some interval end times are before start times.
/// </summary>
public static string textEndValueBeforeStartValue {
get {
return ResourceManager.GetString("textEndValueBeforeStartValue", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Ship / remark. /// Looks up a localized string similar to Ship / remark.
/// </summary> /// </summary>
@ -632,6 +650,15 @@ namespace BreCalClient.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Error.
/// </summary>
public static string textError {
get {
return ResourceManager.GetString("textError", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to ETA berth. /// Looks up a localized string similar to ETA berth.
/// </summary> /// </summary>
@ -641,6 +668,15 @@ namespace BreCalClient.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to ETA value is in the past.
/// </summary>
public static string textETAInThePast {
get {
return ResourceManager.GetString("textETAInThePast", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to ETD berth. /// Looks up a localized string similar to ETD berth.
/// </summary> /// </summary>
@ -650,6 +686,15 @@ namespace BreCalClient.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to ETD value is in the past.
/// </summary>
public static string textETDInThePast {
get {
return ResourceManager.GetString("textETDInThePast", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Exit. /// Looks up a localized string similar to Exit.
/// </summary> /// </summary>
@ -740,6 +785,15 @@ namespace BreCalClient.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Lock time is in the past.
/// </summary>
public static string textLockTimeInThePast {
get {
return ResourceManager.GetString("textLockTimeInThePast", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Login. /// Looks up a localized string similar to Login.
/// </summary> /// </summary>
@ -830,6 +884,15 @@ namespace BreCalClient.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Operation end is in the past.
/// </summary>
public static string textOperationEndInThePast {
get {
return ResourceManager.GetString("textOperationEndInThePast", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Operations end. /// Looks up a localized string similar to Operations end.
/// </summary> /// </summary>
@ -848,6 +911,15 @@ namespace BreCalClient.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Operation start is in the past.
/// </summary>
public static string textOperationStartInThePast {
get {
return ResourceManager.GetString("textOperationStartInThePast", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Outgoing. /// Looks up a localized string similar to Outgoing.
/// </summary> /// </summary>
@ -1145,6 +1217,15 @@ namespace BreCalClient.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Times for the tide window are in the past.
/// </summary>
public static string textTideTimesInThePast {
get {
return ResourceManager.GetString("textTideTimesInThePast", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Timestamp. /// Looks up a localized string similar to Timestamp.
/// </summary> /// </summary>
@ -1262,6 +1343,15 @@ namespace BreCalClient.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Warning.
/// </summary>
public static string textWarning {
get {
return ResourceManager.GetString("textWarning", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Width. /// Looks up a localized string similar to Width.
/// </summary> /// </summary>
@ -1280,6 +1370,15 @@ namespace BreCalClient.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Zone entry time is in the past.
/// </summary>
public static string textZoneEntryInThePast {
get {
return ResourceManager.GetString("textZoneEntryInThePast", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Zone entry. /// Looks up a localized string similar to Zone entry.
/// </summary> /// </summary>

View File

@ -508,4 +508,37 @@
<data name="textClearAll" xml:space="preserve"> <data name="textClearAll" xml:space="preserve">
<value>Alle Eintragungen zurücksetzen?</value> <value>Alle Eintragungen zurücksetzen?</value>
</data> </data>
<data name="textBothTideTimesNecessary" xml:space="preserve">
<value>Beide Tidenzeiten sollten angegeben werden (von - bis)</value>
</data>
<data name="textEndValueBeforeStartValue" xml:space="preserve">
<value>Endzeit liegt vor Startzeit</value>
</data>
<data name="textError" xml:space="preserve">
<value>Error</value>
</data>
<data name="textETAInThePast" xml:space="preserve">
<value>Zeitpunkt ETA liegt in der Vergangenheit</value>
</data>
<data name="textETDInThePast" xml:space="preserve">
<value>Zeitpunkt ETD liegt in der Vergangenheit</value>
</data>
<data name="textLockTimeInThePast" xml:space="preserve">
<value>Schleusenzeit liegt in der Vergangenheit</value>
</data>
<data name="textOperationEndInThePast" xml:space="preserve">
<value>Operation Endzeit liegt in der Vergangenheit</value>
</data>
<data name="textOperationStartInThePast" xml:space="preserve">
<value>Operation Startzeit liegt in der Vergangenheit</value>
</data>
<data name="textTideTimesInThePast" xml:space="preserve">
<value>Tidenzeit liegt in der Vergangenheit</value>
</data>
<data name="textWarning" xml:space="preserve">
<value>Warnung</value>
</data>
<data name="textZoneEntryInThePast" xml:space="preserve">
<value>Zeit Reviereintritt liegt in der Vergangenheit</value>
</data>
</root> </root>

View File

@ -214,6 +214,9 @@
<data name="textBerths" xml:space="preserve"> <data name="textBerths" xml:space="preserve">
<value>Berths</value> <value>Berths</value>
</data> </data>
<data name="textBothTideTimesNecessary" xml:space="preserve">
<value>Both tide times are required</value>
</data>
<data name="textBSMDGranted" xml:space="preserve"> <data name="textBSMDGranted" xml:space="preserve">
<value>BSMD right to edit granted</value> <value>BSMD right to edit granted</value>
</data> </data>
@ -292,15 +295,27 @@
<data name="textEmail" xml:space="preserve"> <data name="textEmail" xml:space="preserve">
<value>E-mail</value> <value>E-mail</value>
</data> </data>
<data name="textEndValueBeforeStartValue" xml:space="preserve">
<value>Some interval end times are before start times</value>
</data>
<data name="textEnterKeyword" xml:space="preserve"> <data name="textEnterKeyword" xml:space="preserve">
<value>Ship / remark</value> <value>Ship / remark</value>
</data> </data>
<data name="textError" xml:space="preserve">
<value>Error</value>
</data>
<data name="textETABerth" xml:space="preserve"> <data name="textETABerth" xml:space="preserve">
<value>ETA berth</value> <value>ETA berth</value>
</data> </data>
<data name="textETAInThePast" xml:space="preserve">
<value>ETA value is in the past</value>
</data>
<data name="textETDBerth" xml:space="preserve"> <data name="textETDBerth" xml:space="preserve">
<value>ETD berth</value> <value>ETD berth</value>
</data> </data>
<data name="textETDInThePast" xml:space="preserve">
<value>ETD value is in the past</value>
</data>
<data name="textExit" xml:space="preserve"> <data name="textExit" xml:space="preserve">
<value>Exit</value> <value>Exit</value>
</data> </data>
@ -331,6 +346,9 @@
<data name="textLockTime" xml:space="preserve"> <data name="textLockTime" xml:space="preserve">
<value>Lock time</value> <value>Lock time</value>
</data> </data>
<data name="textLockTimeInThePast" xml:space="preserve">
<value>Lock time is in the past</value>
</data>
<data name="textLogin" xml:space="preserve"> <data name="textLogin" xml:space="preserve">
<value>Login</value> <value>Login</value>
</data> </data>
@ -361,12 +379,18 @@
<data name="textOperation" xml:space="preserve"> <data name="textOperation" xml:space="preserve">
<value>Operation</value> <value>Operation</value>
</data> </data>
<data name="textOperationEndInThePast" xml:space="preserve">
<value>Operation end is in the past</value>
</data>
<data name="textOperationsEnd" xml:space="preserve"> <data name="textOperationsEnd" xml:space="preserve">
<value>Operations end</value> <value>Operations end</value>
</data> </data>
<data name="textOperationsStart" xml:space="preserve"> <data name="textOperationsStart" xml:space="preserve">
<value>Operations start</value> <value>Operations start</value>
</data> </data>
<data name="textOperationStartInThePast" xml:space="preserve">
<value>Operation start is in the past</value>
</data>
<data name="textOutgoing" xml:space="preserve"> <data name="textOutgoing" xml:space="preserve">
<value>Outgoing</value> <value>Outgoing</value>
</data> </data>
@ -466,6 +490,9 @@
<data name="textTidalWindow" xml:space="preserve"> <data name="textTidalWindow" xml:space="preserve">
<value>Tidal window</value> <value>Tidal window</value>
</data> </data>
<data name="textTideTimesInThePast" xml:space="preserve">
<value>Times for the tide window are in the past</value>
</data>
<data name="textTimestamp" xml:space="preserve"> <data name="textTimestamp" xml:space="preserve">
<value>Timestamp</value> <value>Timestamp</value>
</data> </data>
@ -505,12 +532,18 @@
<data name="textVoyage" xml:space="preserve"> <data name="textVoyage" xml:space="preserve">
<value>Voyage</value> <value>Voyage</value>
</data> </data>
<data name="textWarning" xml:space="preserve">
<value>Warning</value>
</data>
<data name="textWidth" xml:space="preserve"> <data name="textWidth" xml:space="preserve">
<value>Width</value> <value>Width</value>
</data> </data>
<data name="textWrongCredentials" xml:space="preserve"> <data name="textWrongCredentials" xml:space="preserve">
<value>Wrong username or password</value> <value>Wrong username or password</value>
</data> </data>
<data name="textZoneEntryInThePast" xml:space="preserve">
<value>Zone entry time is in the past</value>
</data>
<data name="textZoneEntryTime" xml:space="preserve"> <data name="textZoneEntryTime" xml:space="preserve">
<value>Zone entry</value> <value>Zone entry</value>
</data> </data>

View File

@ -49,8 +49,15 @@ namespace BreCalClient
{ {
if (!shipmodel.Ship.Deleted) if (!shipmodel.Ship.Deleted)
{ {
if (this.ShipApi != null) try
await this.ShipApi.ShipDeleteAsync(shipmodel.Ship.Id); {
if (this.ShipApi != null)
await this.ShipApi.ShipDeleteAsync(shipmodel.Ship.Id);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
BreCalLists.Ships.Remove(shipmodel); // remove from "selectable" ships BreCalLists.Ships.Remove(shipmodel); // remove from "selectable" ships
shipmodel.Ship.Deleted = true; // set deleted marker on working instance shipmodel.Ship.Deleted = true; // set deleted marker on working instance
this.dataGridShips.ItemsSource = null; this.dataGridShips.ItemsSource = null;

View File

@ -6,6 +6,7 @@ using BreCalClient.misc.Api;
using BreCalClient.misc.Model; using BreCalClient.misc.Model;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks;
namespace BreCalClient namespace BreCalClient
{ {
@ -38,6 +39,8 @@ namespace BreCalClient
public string? Berth { get; set; } public string? Berth { get; set; }
public string LastErrorMessage { get; private set; } = "";
internal Dictionary<Extensions.ParticipantType, ParticipantAssignment> AssignedParticipants { get; } = new(); internal Dictionary<Extensions.ParticipantType, ParticipantAssignment> AssignedParticipants { get; } = new();
public List<Times> Times { get; set; } = new(); public List<Times> Times { get; set; } = new();
@ -247,8 +250,9 @@ namespace BreCalClient
/// This function updates the assignments for existing times records accordingly and saves them. /// This function updates the assignments for existing times records accordingly and saves them.
/// </summary> /// </summary>
/// <param name="_api">API reference to PUT eidted times</param> /// <param name="_api">API reference to PUT eidted times</param>
internal async void UpdateTimesAssignments(TimesApi api) internal async Task<bool> UpdateTimesAssignments(TimesApi api)
{ {
foreach (Extensions.ParticipantType participantType in this.AssignedParticipants.Keys) foreach (Extensions.ParticipantType participantType in this.AssignedParticipants.Keys)
{ {
Times? times = this.GetTimesForParticipantType(participantType); Times? times = this.GetTimesForParticipantType(participantType);
@ -256,7 +260,15 @@ namespace BreCalClient
if(times.ParticipantId != this.AssignedParticipants[participantType].ParticipantId) if(times.ParticipantId != this.AssignedParticipants[participantType].ParticipantId)
{ {
times.ParticipantId = this.AssignedParticipants[participantType].ParticipantId; times.ParticipantId = this.AssignedParticipants[participantType].ParticipantId;
await api.TimesUpdateAsync(times); try
{
await api.TimesUpdateAsync(times);
}
catch (Exception ex)
{
LastErrorMessage = ex.Message;
return false;
}
} }
} }
@ -283,9 +295,18 @@ namespace BreCalClient
foreach(Times times in deleteTimes) foreach(Times times in deleteTimes)
{ {
api.TimesDelete(times.Id); try
this.Times.Remove(times); {
api.TimesDelete(times.Id);
this.Times.Remove(times);
}
catch (Exception ex)
{
LastErrorMessage = ex.Message;
return false;
}
} }
return true;
} }
#endregion #endregion