Fixes for tests regarding the evaluation functions

This commit is contained in:
Daniel Schick 2023-10-22 13:08:15 +02:00
parent 1f29aca6d0
commit 9c690a91b0
7 changed files with 60 additions and 33 deletions

View File

@ -92,11 +92,9 @@ namespace BreCalClient
{
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.Times.BerthInfo = this.textBoxBerthRemarks.Text.Trim();
this.Times.BerthId = (int?)this.comboBoxArrivalBerth.SelectedValue;
this.ShipcallModel.Shipcall.Draft = (float?)this.doubleUpDownDraft.Value;
this.ShipcallModel.Shipcall.TidalWindowFrom = this.datePickerTidalWindowFrom.Value;

View File

@ -89,10 +89,9 @@ namespace BreCalClient
{
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.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;

View File

@ -92,11 +92,9 @@ namespace BreCalClient
{
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.Times.BerthInfo = this.textBoxBerthRemarksArrival.Text.Trim();
this.Times.BerthId = (int?)this.comboBoxArrivalBerth.SelectedValue;
this.ShipcallModel.Shipcall.Draft = (float?)this.doubleUpDownDraft.Value;
this.ShipcallModel.Shipcall.TidalWindowFrom = this.datePickerTidalWindowFrom.Value;

View File

@ -507,10 +507,12 @@ namespace BreCalClient
}
}
#endregion
#region UpdateUI func
private void UpdateUI()
{
@ -542,6 +544,8 @@ namespace BreCalClient
}));
}
#endregion
#region control event handler
private async void Sc_EditRequested(ShipcallControl obj)
@ -558,6 +562,7 @@ namespace BreCalClient
try
{
obj.ShipcallControlModel.Shipcall?.Participants.Clear();
obj.ShipcallControlModel.UpdateTimesAssignments(this._api);
foreach(ParticipantAssignment pa in obj.ShipcallControlModel.AssignedParticipants.Values)
obj.ShipcallControlModel.Shipcall?.Participants.Add(pa);
await _api.ShipcallsPutAsync(obj.ShipcallControlModel.Shipcall);
@ -584,6 +589,7 @@ namespace BreCalClient
if(obj.ShipcallControlModel.Shipcall != null)
etc.CallType = (TypeEnum) obj.ShipcallControlModel.Shipcall.Type;
bool wasEdit = false;
if (times != null)
{
@ -654,12 +660,19 @@ namespace BreCalClient
{
editControl.Times = times;
wasEdit = true;
}
else
{
if(editControl.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY))
editControl.Times.ParticipantId = editControl.ShipcallModel.AssignedParticipants[ParticipantType.AGENCY].ParticipantId;
}
editControl.Times.ParticipantType = (int)ParticipantType.AGENCY;
if(editControl.ShowDialog() ?? false)
{
try
{
sc.ShipcallControlModel?.UpdateTimesAssignments(_api); // if the agent changed the assignment of the participant to another
// always try to be the agent, even if we are BSMD
if (editControl.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY))
{

View File

@ -48,24 +48,7 @@
<Label Grid.Column="1" FontSize="12" x:Name="labelShipName" Foreground="White" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}" VerticalAlignment="Stretch"
HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" PreviewMouseUp="Image_PreviewMouseUp"/>
<Grid Grid.Column="2" Background="{Binding Source={x:Static sets:Settings.Default}, Path=BG_COLOR}">
<Image Grid.Column="3" Margin="2" x:Name="imageEvaluation">
<Image.Style>
<Style TargetType="Image">
<Setter Property="Source" Value="{Binding NotFolderImage}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding LightMode}" Value="{x:Static db:ShipcallControlModel+TrafficLightMode.GREEN}">
<Setter Property="Source" Value="./Resources/check.png"/>
</DataTrigger>
<DataTrigger Binding="{Binding LightMode}" Value="{x:Static db:ShipcallControlModel+TrafficLightMode.RED}">
<Setter Property="Source" Value="./Resources/delete2.png"/>
</DataTrigger>
<DataTrigger Binding="{Binding LightMode}" Value="{x:Static db:ShipcallControlModel+TrafficLightMode.YELLOW}">
<Setter Property="Source" Value="./Resources/sign_warning.png"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Image.Style>
</Image>
<Image Grid.Column="3" Margin="2" x:Name="imageEvaluation" />
</Grid>
</Grid>
<Viewbox Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left">

View File

@ -151,6 +151,21 @@ namespace BreCalClient
break;
}
switch(this.ShipcallControlModel?.LightMode)
{
case ShipcallControlModel.TrafficLightMode.GREEN:
this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/check.png"));
break;
case ShipcallControlModel.TrafficLightMode.YELLOW:
this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/sign_warning.png"));
break;
case ShipcallControlModel.TrafficLightMode.RED:
this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/delete2.png"));
break;
default:
break;
}
if (this.ShipcallControlModel?.Shipcall?.Evaluation != null)
{
ShipcallControlModel.TrafficLightMode resultColor = (ShipcallControlModel.TrafficLightMode) (this.ShipcallControlModel?.Shipcall?.Evaluation ?? 0); // der nullable Operator hier ist so doof, die VS validation blickts einfach nicht
@ -280,6 +295,7 @@ namespace BreCalClient
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.textBlockTerminalRemarks.Text = times.Remarks;
if (this.ShipcallControlModel?.Shipcall?.Type != 1)

View File

@ -2,6 +2,7 @@
// Description: Container model for shipcall related info
//
using BreCalClient.misc.Api;
using BreCalClient.misc.Model;
using System;
using System.Collections.Generic;
@ -124,6 +125,25 @@ namespace BreCalClient
return false;
}
/// <summary>
/// After closing the edit shipcall or edit agency dialogs, the times assignments may have changed.
/// This function updates the assignments for existing times records accordingly and saves them.
/// </summary>
/// <param name="_api">API reference to PUT eidted times</param>
internal async void UpdateTimesAssignments(DefaultApi _api)
{
foreach (Extensions.ParticipantType participantType in this.AssignedParticipants.Keys)
{
Times? times = this.GetTimesForParticipantType(participantType);
if(times == null) continue;
if(times.ParticipantId != this.AssignedParticipants[participantType].ParticipantId)
{
times.ParticipantId = this.AssignedParticipants[participantType].ParticipantId;
await _api.TimesPutAsync(times);
}
}
}
#endregion
#region helper