completely reload core after copy operation

This commit is contained in:
Daniel Schick 2024-07-23 08:48:27 +02:00
parent 1947c30010
commit f9f8980e09
2 changed files with 46 additions and 40 deletions

View File

@ -31,7 +31,7 @@ namespace ENI2
private readonly List<MessageGroup> _listBoxList = new List<MessageGroup>();
private List<Message> _messages;
private readonly Dictionary<string, DetailBaseControl> controlCache = new Dictionary<string, DetailBaseControl>();
// private readonly Dictionary<Message.NotificationClass, string> messageClassControlDict = new Dictionary<Message.NotificationClass, string>();
// private readonly Dictionary<Message.NotificationClass, string> messageClassControlDict = new Dictionary<Message.NotificationClass, string>();
private readonly object messageListLock = new object();
private readonly HighlightService highlightService = new HighlightService();
@ -65,7 +65,7 @@ namespace ENI2
get
{
// Bedingung:
// wenn in einer Meldeklasse zwar Daten vorhanden sind, eingespielt durch Excel import oder
// wenn in einer Meldeklasse zwar Daten vorhanden sind, eingespielt durch Excel import oder
// Handeingabe, diese aber NICHT gesendet wurden.
// TODO: Hier wird noch ein Flag benötigt, dass die erfolgte Anzeige des Warndialogs speichert
List<string> result = new List<string>();
@ -74,7 +74,7 @@ namespace ENI2
{
if (((aMessage.InternalStatus == Message.BSMDStatus.UPDATED) ||
(aMessage.InternalStatus == Message.BSMDStatus.SAVED)) && // ||
// (aMessage.InternalStatus == Message.BSMDStatus.EXCEL)) &&
// (aMessage.InternalStatus == Message.BSMDStatus.EXCEL)) &&
!aMessage.UnsentMessageWarningShown)
{
aMessage.UnsentMessageWarningShown = true;
@ -82,7 +82,7 @@ namespace ENI2
result.Add(aMessage.MessageNotificationClassDisplay);
}
}
return result;
}
}
@ -140,7 +140,7 @@ namespace ENI2
shipNameLabel.Text = aCore.Shipname;
shipEMailLabel.Text = aCore.HerbergEmailContactReportingVessel;
displayIdLabel.Text = aCore.DisplayId;
// Listbox befüllen
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textOverview, MessageGroupControlType = typeof(OverViewDetailControl), ImagePath = "Resources/documents.png" });
@ -153,7 +153,7 @@ namespace ENI2
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textMDH, MessageGroupControlType = typeof(MaritimeHealthDeclarationDetailControl), ImagePath = "Resources/medical_bag.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textDepartureNotification, MessageGroupControlType = typeof(DepartureNotificationDetailControl), ImagePath = "Resources/arrow_up_right_green.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textShipData, MessageGroupControlType = typeof(ShipDataDetailControl), ImagePath = "Resources/containership.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textBorderPolice, MessageGroupControlType = typeof(BorderPoliceDetailControl), ImagePath = "Resources/policeman_german.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textBorderPolice, MessageGroupControlType = typeof(BorderPoliceDetailControl), ImagePath = "Resources/policeman_german.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textDGArrival, MessageGroupControlType = typeof(DangerousGoodsDetailControl), ImagePath = "Resources/sign_warning_radiation.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textDGDeparture, MessageGroupControlType = typeof(DangerousGoodsDetailControl), ImagePath = "Resources/sign_warning_radiation.png" });
this._listBoxList.Add(new MessageGroup() { MessageGroupName = Properties.Resources.textTowage, MessageGroupControlType = typeof(TowageDetailControl), ImagePath = "Resources/ship2.png" });
@ -264,7 +264,7 @@ namespace ENI2
detailControl.SetEnabled(isEnabled);
if (!isEnabled && (detailControl is OverViewDetailControl control) && !(Core.Cancelled ?? false))
control.ShowLockedBy(this.LockedBy);
control.ShowLockedBy(this.LockedBy);
controlCache.Add(mg.MessageGroupName, detailControl);
this.buttonSave.Visibility = Visibility.Hidden;
@ -298,7 +298,7 @@ namespace ENI2
MessageCore newCore = new MessageCore();
cdd.NewCore = newCore;
cdd.OldCore = this.Core;
cdd.Closed += (senderDialog, closeArgs) =>
{
CopyDeclarationDialog closedDialog = senderDialog as CopyDeclarationDialog;
@ -331,19 +331,19 @@ namespace ENI2
if(existingCore != null)
{
if(MessageBox.Show(Properties.Resources.textDeclarationAlreadyExists, Properties.Resources.textCaptionExists,
if(MessageBox.Show(Properties.Resources.textDeclarationAlreadyExists, Properties.Resources.textCaptionExists,
MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK)
{
List<Message> existingMessages = DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).GetMessagesForCore(existingCore, DBManager.MessageLoad.ALL);
foreach(Message existingMessage in existingMessages)
{
if((existingMessage.InternalStatus == Message.BSMDStatus.SENT) &&
if((existingMessage.InternalStatus == Message.BSMDStatus.SENT) &&
(existingMessage.MessageNotificationClass != Message.NotificationClass.VISIT) &&
(existingMessage.MessageNotificationClass != Message.NotificationClass.TRANSIT))
{
MessageBox.Show(Properties.Resources.textMessagesAlreadySent, Properties.Resources.textCaptionError, MessageBoxButton.OK, MessageBoxImage.Stop);
return;
}
}
}
// delete all existing data of core
@ -357,7 +357,7 @@ namespace ENI2
// Bearbeitungsinformationen für bestehende ID-Beantragung beibehalten, falls bereits vorhanden
if(existingCore.IsTransit &&
(existingMessage.MessageNotificationClass == Message.NotificationClass.TRANSIT) &&
(existingMessage.MessageNotificationClass == Message.NotificationClass.TRANSIT) &&
(existingMessage.InternalStatus == Message.BSMDStatus.CONFIRMED))
{
skipCopyTransit = true;
@ -389,7 +389,7 @@ namespace ENI2
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(newCore);
// Meldeklassen für neuen Anlauf erzeugen
// Meldeklassen für neuen Anlauf erzeugen
List<Message> newMessages = new List<Message>();
foreach (Message oldMessage in this._messages)
{
@ -417,6 +417,7 @@ namespace ENI2
newMessage.SaveElements();
}
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).LoadXtraData(newCore); // reload data from DB and set all rel properites
this.OnOpenNewCoreRequested(newCore);
}
};
@ -427,7 +428,7 @@ namespace ENI2
{
this.LockedByOtherUser = true; // fake flag
// clear existing controls
// clear existing controls
this.detailView.Children.Clear();
this.controlCache.Clear();
@ -444,7 +445,7 @@ namespace ENI2
private void buttonSave_Click(object sender, RoutedEventArgs e)
{
MessageBoxResult result = MessageBox.Show(Properties.Resources.textQuestionSavePage, Properties.Resources.textConfirmation,
MessageBoxResult result = MessageBox.Show(Properties.Resources.textQuestionSavePage, Properties.Resources.textConfirmation,
MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
@ -495,7 +496,7 @@ namespace ENI2
if(message.MessageNotificationClass == Message.NotificationClass.ATA)
{
DetailBaseControl currentControl = this.detailView.Children[0] as DetailBaseControl;
DetailBaseControl currentControl = this.detailView.Children[0] as DetailBaseControl;
// ggf. hat sich die Ticketnr geändert..
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(currentControl.Core);
}
@ -512,7 +513,7 @@ namespace ENI2
private void buttonSaveAll_Click(object sender, RoutedEventArgs e)
{
MessageBoxResult result = MessageBox.Show(Properties.Resources.textQuestionSaveAll, Properties.Resources.textConfirmation,
MessageBoxResult result = MessageBox.Show(Properties.Resources.textQuestionSaveAll, Properties.Resources.textConfirmation,
MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
@ -708,16 +709,16 @@ namespace ENI2
{
vViolations = new List<MessageViolation>();
vErrors = new List<MessageError>();
// TODO: clear highlighting
Util.UIHelper.SetBusyState();
RuleEngine ruleEngine = new RuleEngine();
foreach (Message aMessage in _messages)
{
{
if (!aMessage.EvaluateForValidation(this.Core.IsTransit)) continue;
List<MessageError> errors = new List<MessageError>();
List<MessageViolation> violations = new List<MessageViolation>();
ruleEngine.ValidateMessage(aMessage, out errors, out violations);
@ -793,7 +794,7 @@ namespace ENI2
#region CREW/PAS Schengen Plausibility
// Wir können davon ausgehen, dass bei allen Unterelementen die Flags gleich gesetzt sind. Das wird im Import und BorderPoliceDetailControl sichergestellt.
// Wir können davon ausgehen, dass bei allen Unterelementen die Flags gleich gesetzt sind. Das wird im Import und BorderPoliceDetailControl sichergestellt.
if(crewaMessage.Elements.Count > 0)
{
@ -802,7 +803,7 @@ namespace ENI2
if (!((crewaFirst.NotificationPAX ?? false) || crewaIsSchengen)) // mindestens eins der beiden
{
vErrors.Add(RuleEngine.CreateError(ValidationCode.V181, "Pax / Schengen: one must be set", null, Properties.Resources.textOverview, null, "CREWA")); ;
}
}
}
if (crewdMessage != null)
@ -814,7 +815,7 @@ namespace ENI2
if (!((crewdFirst.NotificationPAX ?? false) || crewdIsSchengen)) // mindestens eins der beiden
{
vErrors.Add(RuleEngine.CreateError(ValidationCode.V181, "Pax / Schengen: one must be set", null, Properties.Resources.textOverview, null, "CREWD")); ;
}
}
}
}
@ -826,7 +827,7 @@ namespace ENI2
if (!(pasIsPAX || pasIsSchengen)) // mindestens eins der beiden
{
vErrors.Add(RuleEngine.CreateError (ValidationCode.V201, "Pax / Schengen: one must be set", null, Properties.Resources.textOverview, null, "PASA"));
}
}
}
if (pasdMessage != null)
@ -839,7 +840,7 @@ namespace ENI2
if (!(pasdIsPAX || pasdIsSchengen)) // mindestens eins der beiden
{
vErrors.Add(RuleEngine.CreateError(ValidationCode.V201, "Pax / Schengen: one must be set", null, Properties.Resources.textOverview, null, "PASD"));
}
}
}
}
@ -855,7 +856,7 @@ namespace ENI2
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.NO_PAX, "No PAX set (PASA > 12)", null, Properties.Resources.textOverview, null, "PASA");
vViolations.Add(mv);
}
if((crewaMessage != null) && (crewaMessage.Elements.Count > 0))
{
CREW firstCREW = crewaMessage.Elements[0] as CREW;
@ -897,8 +898,8 @@ namespace ENI2
crewaMessage.ViolationList.Remove(mv);
}
if(crewdMessage != null)
{
if(crewdMessage != null)
{
MessageViolation mvd = crewdMessage.ViolationList.Find((x) => x.PropertyName.Equals("Effects") && (x.ViolationCode == (int)ValidationCode.TRUNCATE));
if ((mvd != null) && !Core.IsDK)
crewdMessage.ViolationList.Remove(mvd);
@ -1043,7 +1044,7 @@ namespace ENI2
{
if (poc30d.PortOfCallLast30DaysDateOfDeparture.HasValue && !poc30d.PortOfCallLast30DaysLocode.IsNullOrEmpty())
{
if((poc30d.PortOfCallLast30DaysDateOfDeparture.Value.Date == l10c.PortFacilityDateOfDeparture.Value.Date) &&
if((poc30d.PortOfCallLast30DaysDateOfDeparture.Value.Date == l10c.PortFacilityDateOfDeparture.Value.Date) &&
poc30d.PortOfCallLast30DaysLocode.Equals(l10c.PortFacilityPortLoCode, StringComparison.OrdinalIgnoreCase))
{
matchIsFound = true;
@ -1098,7 +1099,7 @@ namespace ENI2
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.LIST_EMPTY, "No entry for SERV found", null, "SERV service provider", null, "SERV");
mv.MessageGroupName = Properties.Resources.textPortNotification;
vViolations.Add(mv);
}
}
}
#endregion
@ -1154,8 +1155,8 @@ namespace ENI2
this._errorListDialog.Loaded += (o, e) => this._errorListDialog.RefreshVisible = true;
this._errorListDialog.ErrorSelected += _errorListDialog_ErrorSelected;
this._errorListDialog.RefreshClicked += _errorListDialog_RefreshClicked;
this._errorListDialog.Show();
}
this._errorListDialog.Show();
}
else
{
this._errorListDialog.BringUp();
@ -1167,12 +1168,12 @@ namespace ENI2
{
if(this._violationListDialog == null)
{
this._violationListDialog = new ViolationListDialog();
this._violationListDialog = new ViolationListDialog();
this._violationListDialog.Closed += (o, e) => this._violationListDialog = null;
this._violationListDialog.Loaded += (o, e) => this._violationListDialog.RefreshVisible = true;
this._violationListDialog.ViolationSelected += _errorListDialog_ErrorSelected;
this._violationListDialog.RefreshClicked += _errorListDialog_RefreshClicked;
this._violationListDialog.Show();
this._violationListDialog.Show();
}
else
{

View File

@ -295,12 +295,7 @@ namespace bsmd.database
List<MessageCore> result = new List<MessageCore>();
foreach (MessageCore core in cores.Cast<MessageCore>())
{
this.LoadCustomer(core);
this.LoadSTATShipName(core);
this.LoadETA_ETD(core);
this.LoadATA(core);
this.LoadATD(core);
this.LoadNumberSent(core);
LoadXtraData(core);
result.Add(core);
}
@ -310,6 +305,16 @@ namespace bsmd.database
return result;
}
public void LoadXtraData(MessageCore core)
{
this.LoadCustomer(core);
this.LoadSTATShipName(core);
this.LoadETA_ETD(core);
this.LoadATA(core);
this.LoadATD(core);
this.LoadNumberSent(core);
}
/// <summary>
/// Lädt MessageCore (=Schiffsanlauf) einer EU-NOAD Nachricht vom Fleettracker / Herberg
/// </summary>