Checkin Laptop nach Bremen Sept.19

This commit is contained in:
Daniel Schick 2019-09-13 12:19:29 +00:00
parent ed5457c6af
commit ea3bb0ddc4
12 changed files with 181 additions and 53 deletions

View File

@ -57,6 +57,39 @@ namespace ENI2
get { return this.buttonSave.Visibility == Visibility.Visible; } // schwach aber es wird's tun get { return this.buttonSave.Visibility == Visibility.Visible; } // schwach aber es wird's tun
} }
public bool HasUnsentMessages
{
get
{
// Bedingung:
// wenn in einer Meldeklasse zwar Daten vorhanden sind, eingespielt durch Excel import oder
// Handeingabe, diese aber NICHT gesendet wurden.
foreach (Message aMessage in _messages)
{
if ((aMessage.InternalStatus == Message.BSMDStatus.UPDATED) ||
(aMessage.InternalStatus == Message.BSMDStatus.SAVED) ||
(aMessage.InternalStatus == Message.BSMDStatus.EXCEL))
return true;
}
return false;
}
}
public bool HasUnConfirmedMessages
{
get
{
foreach(Message aMessage in _messages)
{
if ((aMessage.InternalStatus == Message.BSMDStatus.SENT) ||
(aMessage.InternalStatus == Message.BSMDStatus.TOSEND))
return true;
}
return false;
}
}
#endregion #endregion
#region Construction #region Construction
@ -231,7 +264,6 @@ namespace ENI2
existingCore = DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).GetMessageCoreByVisitId(newCore.VisitId); existingCore = DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).GetMessageCoreByVisitId(newCore.VisitId);
} }
bool skipCopyTransit = false; bool skipCopyTransit = false;
bool skipCopyVisit = false; bool skipCopyVisit = false;
@ -302,6 +334,20 @@ namespace ENI2
if (skipCopyTransit && (oldMessage.MessageNotificationClass == Message.NotificationClass.TRANSIT)) continue; if (skipCopyTransit && (oldMessage.MessageNotificationClass == Message.NotificationClass.TRANSIT)) continue;
if (skipCopyVisit && (oldMessage.MessageNotificationClass == Message.NotificationClass.VISIT)) continue; if (skipCopyVisit && (oldMessage.MessageNotificationClass == Message.NotificationClass.VISIT)) continue;
// 10.9.19: bestimmte Meldeklassen nicht kopieren. Muss getestet werden, ob hier
// stattdessen "Leer"-Messages erzeugt werden müssen
if (oldMessage.MessageNotificationClass == Message.NotificationClass.ATA) continue;
if (oldMessage.MessageNotificationClass == Message.NotificationClass.ATD) continue;
if (oldMessage.MessageNotificationClass == Message.NotificationClass.NOA_NOD) continue;
bool isAndienKlasse = ((oldMessage.MessageNotificationClass == Message.NotificationClass.AGNT) ||
(oldMessage.MessageNotificationClass == Message.NotificationClass.STAT) ||
(oldMessage.MessageNotificationClass == Message.NotificationClass.INFO) ||
(oldMessage.MessageNotificationClass == Message.NotificationClass.HAZA) ||
(oldMessage.MessageNotificationClass == Message.NotificationClass.HAZD));
if (!cdd.CopyAll && !isAndienKlasse) continue;
Message newMessage = oldMessage.Clone() as Message; Message newMessage = oldMessage.Clone() as Message;
newMessage.MessageCore = newCore; newMessage.MessageCore = newCore;
newMessage.MessageCoreId = newCore.Id; newMessage.MessageCoreId = newCore.Id;
@ -366,9 +412,12 @@ namespace ENI2
{ {
if (message.IsDirty || message.IsNew) if (message.IsDirty || message.IsNew)
{ {
if ((message.Status == Message.MessageStatus.ACCEPTED) && if ((message.Status == Message.MessageStatus.ACCEPTED) &&
((message.InternalStatus == Message.BSMDStatus.CONFIRMED) || (message.InternalStatus == Message.BSMDStatus.VIOLATION))) ((message.InternalStatus == Message.BSMDStatus.CONFIRMED) || (message.InternalStatus == Message.BSMDStatus.VIOLATION)))
message.InternalStatus = Message.BSMDStatus.UPDATED; message.InternalStatus = Message.BSMDStatus.UPDATED;
else
message.InternalStatus = Message.BSMDStatus.SAVED;
string userName = "?"; string userName = "?";
if(App.UserId.HasValue && DBManager.Instance.GetReportingPartyDict().ContainsKey(App.UserId.Value)) if(App.UserId.HasValue && DBManager.Instance.GetReportingPartyDict().ContainsKey(App.UserId.Value))
{ {
@ -377,24 +426,8 @@ namespace ENI2
message.ChangedBy = string.Format("{0} at {1}", userName, DateTime.Now); message.ChangedBy = string.Format("{0} at {1}", userName, DateTime.Now);
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(message); DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(message);
//if (message.MessageNotificationClass == Message.NotificationClass.CREW) message.SaveElements();
//{
// foreach(CREW crew in message.Elements)
// {
// if (crew.IsNew || crew.IsDirty) DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(crew);
// }
//}
//else if (message.MessageNotificationClass == Message.NotificationClass.PAS)
//{
// foreach(PAS pas in message.Elements)
// {
// if(pas.IsNew || pas.IsDirty) DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(pas);
// }
//}
//else
//{
message.SaveElements();
//}
message.IsDirty = false; message.IsDirty = false;
if(message.MessageNotificationClass == Message.NotificationClass.ATA) if(message.MessageNotificationClass == Message.NotificationClass.ATA)

View File

@ -8,7 +8,7 @@
xmlns:p="clr-namespace:ENI2.Properties" xmlns:p="clr-namespace:ENI2.Properties"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d" mc:Ignorable="d"
Title="{x:Static p:Resources.textCopyDeclaration}" Height="270" Width="440" WindowStyle="SingleBorderWindow" Background="AliceBlue" ResizeMode="NoResize" Icon="/ENI2;component/Resources/id_cards.ico"> Title="{x:Static p:Resources.textCopyDeclaration}" Height="326" Width="440" WindowStyle="SingleBorderWindow" Background="AliceBlue" ResizeMode="NoResize" Icon="/ENI2;component/Resources/id_cards.ico">
<Grid Margin="5"> <Grid Margin="5">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="28" /> <RowDefinition Height="28" />
@ -17,6 +17,8 @@
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="28" /> <RowDefinition Height="28" />
<RowDefinition Height="28" />
<RowDefinition Height="28" />
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" /> <ColumnDefinition Width="1*" />
@ -29,6 +31,7 @@
<Label Name="labelPoC" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textPortCall}" /> <Label Name="labelPoC" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textPortCall}" />
<Label Name="labelETA" Grid.Row="4" Grid.Column="0" Content="ETA" /> <Label Name="labelETA" Grid.Row="4" Grid.Column="0" Content="ETA" />
<Label Name="labelHIS" Grid.Row="5" Grid.Column="0" Content="HIS" /> <Label Name="labelHIS" Grid.Row="5" Grid.Column="0" Content="HIS" />
<Label Name="labelCopy" Grid.Row="6" Grid.Column="0" Content="Copy" />
<TextBox Name="textBoxVisitTransitId" Margin="2" Grid.Row="0" Grid.Column="1" TextChanged="textBoxVisitTransitId_TextChanged" VerticalContentAlignment="Center"/> <TextBox Name="textBoxVisitTransitId" Margin="2" Grid.Row="0" Grid.Column="1" TextChanged="textBoxVisitTransitId_TextChanged" VerticalContentAlignment="Center"/>
<Image Grid.Row="0" Grid.Column="2" Name="okCheckMark" Source="pack://application:,,,/Resources/check.png" Margin="2" Visibility="Hidden" /> <Image Grid.Row="0" Grid.Column="2" Name="okCheckMark" Source="pack://application:,,,/Resources/check.png" Margin="2" Visibility="Hidden" />
<xctk:DoubleUpDown x:Name="doubleUpDownIMO" Margin="2" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" <xctk:DoubleUpDown x:Name="doubleUpDownIMO" Margin="2" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2"
@ -65,6 +68,14 @@
</DatePicker.BlackoutDates> </DatePicker.BlackoutDates>
</DatePicker> </DatePicker>
<ComboBox Name="comboBoxInitialHIS" Grid.Row="5" Grid.Column="1" Margin="2" Grid.ColumnSpan="2" DisplayMemberPath="Value" SelectedValuePath="Key" SelectionChanged="comboBoxInitialHIS_SelectionChanged"/> <ComboBox Name="comboBoxInitialHIS" Grid.Row="5" Grid.Column="1" Margin="2" Grid.ColumnSpan="2" DisplayMemberPath="Value" SelectedValuePath="Key" SelectionChanged="comboBoxInitialHIS_SelectionChanged"/>
<StackPanel Orientation="Horizontal" Grid.Row="6" Grid.Column="1">
<RadioButton GroupName="copy" IsChecked="True" Name="radioButtonCopyAll" Margin="2" VerticalAlignment="Center"/>
<Label Content="All" />
</StackPanel>
<StackPanel Orientation="Horizontal" Grid.Row="7" Grid.Column="1">
<RadioButton GroupName="copy" IsChecked="False" Name="radioButtonCopyASIHH" Margin="2" VerticalAlignment="Center"/>
<Label Content="AGNT/STAT/INFO/HAZA/HAZD" />
</StackPanel>
</Grid> </Grid>
</enictrl:EditWindowBase> </enictrl:EditWindowBase>

View File

@ -23,31 +23,7 @@ namespace ENI2.EditControls
{ {
InitializeComponent(); InitializeComponent();
Loaded += CopyDeclarationDialog_Loaded; Loaded += CopyDeclarationDialog_Loaded;
} }
private void CopyDeclarationDialog_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
this.OKClicked += VisitIdDialog_OKClicked;
List<KeyValuePair<bsmd.database.Message.NSWProvider, string>> comboDataSource = new List<KeyValuePair<bsmd.database.Message.NSWProvider, string>>()
{
new KeyValuePair<bsmd.database.Message.NSWProvider, string>( Message.NSWProvider.DBH, "DBH live" ),
new KeyValuePair<bsmd.database.Message.NSWProvider, string>( Message.NSWProvider.DBH_TEST, "DBH Testsystem" ),
new KeyValuePair<bsmd.database.Message.NSWProvider, string>( Message.NSWProvider.DUDR, "HIS-Nord live" ),
new KeyValuePair<bsmd.database.Message.NSWProvider, string>( Message.NSWProvider.DUDR_TEST, "HIS-Nord Testsystem" )
};
this.comboBoxInitialHIS.ItemsSource = comboDataSource;
this.comboBoxInitialHIS.SelectedIndex = 2;
this.EnableOK(false);
this.locodePoC.PropertyChanged += LocodePoC_PropertyChanged;
if (!this.OldCore.IMO.IsNullOrEmpty()) this.doubleUpDownIMO.Value = Double.Parse(this.OldCore.IMO);
if (!this.OldCore.ENI.IsNullOrEmpty()) this.doubleUpDownENI.Value = Double.Parse(this.OldCore.ENI);
if (!this.OldCore.PoC.IsNullOrEmpty()) this.locodePoC.LocodeValue = this.OldCore.PoC;
if (this.OldCore.ETA.HasValue) this.datePickerETA.SelectedDate = this.OldCore.ETA;
}
#region Properties #region Properties
@ -57,6 +33,8 @@ namespace ENI2.EditControls
public bool IsOK { get { return this._isOK; } } public bool IsOK { get { return this._isOK; } }
public bool CopyAll { get { return this.radioButtonCopyAll.IsChecked ?? false; } }
#endregion #endregion
#region completion logic #region completion logic
@ -93,6 +71,30 @@ namespace ENI2.EditControls
#region event handler #region event handler
private void CopyDeclarationDialog_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
this.OKClicked += VisitIdDialog_OKClicked;
List<KeyValuePair<bsmd.database.Message.NSWProvider, string>> comboDataSource = new List<KeyValuePair<bsmd.database.Message.NSWProvider, string>>()
{
new KeyValuePair<bsmd.database.Message.NSWProvider, string>( Message.NSWProvider.DBH, "DBH live" ),
new KeyValuePair<bsmd.database.Message.NSWProvider, string>( Message.NSWProvider.DBH_TEST, "DBH Testsystem" ),
new KeyValuePair<bsmd.database.Message.NSWProvider, string>( Message.NSWProvider.DUDR, "HIS-Nord live" ),
new KeyValuePair<bsmd.database.Message.NSWProvider, string>( Message.NSWProvider.DUDR_TEST, "HIS-Nord Testsystem" )
};
this.comboBoxInitialHIS.ItemsSource = comboDataSource;
this.comboBoxInitialHIS.SelectedIndex = 2;
this.EnableOK(false);
this.locodePoC.PropertyChanged += LocodePoC_PropertyChanged;
if (!this.OldCore.IMO.IsNullOrEmpty()) this.doubleUpDownIMO.Value = Double.Parse(this.OldCore.IMO);
if (!this.OldCore.ENI.IsNullOrEmpty()) this.doubleUpDownENI.Value = Double.Parse(this.OldCore.ENI);
if (!this.OldCore.PoC.IsNullOrEmpty()) this.locodePoC.LocodeValue = this.OldCore.PoC;
if (this.OldCore.ETA.HasValue) this.datePickerETA.SelectedDate = this.OldCore.ETA;
}
private void LocodePoC_PropertyChanged(object sender, PropertyChangedEventArgs e) private void LocodePoC_PropertyChanged(object sender, PropertyChangedEventArgs e)
{ {
this.CheckComplete(); this.CheckComplete();

View File

@ -159,6 +159,21 @@ namespace ENI2
e.Cancel = true; e.Cancel = true;
} }
// Test for unsent messages
if (!e.Cancel && drc.HasUnsentMessages)
{
if (MessageBox.Show(Properties.Resources.textConfirmUnsentMessages, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
e.Cancel = true;
}
// Test for unconfirmed messages
if(!e.Cancel && drc.HasUnConfirmedMessages)
{
if (MessageBox.Show(Properties.Resources.textConfirmUnconfirmedMessages, Properties.Resources.textConfirmation, MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No) == MessageBoxResult.No)
e.Cancel = true;
}
if (!e.Cancel) if (!e.Cancel)
{ {
if (lockedCores.ContainsKey(tabItem)) if (lockedCores.ContainsKey(tabItem))

View File

@ -1370,6 +1370,24 @@ namespace ENI2.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to Unconfirmed messages! Do you want to close anyway?.
/// </summary>
public static string textConfirmUnconfirmedMessages {
get {
return ResourceManager.GetString("textConfirmUnconfirmedMessages", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Unsent messages! Do you want to close anyway?.
/// </summary>
public static string textConfirmUnsentMessages {
get {
return ResourceManager.GetString("textConfirmUnsentMessages", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Unsaved changes! Do you want to close anyway?. /// Looks up a localized string similar to Unsaved changes! Do you want to close anyway?.
/// </summary> /// </summary>

View File

@ -1525,6 +1525,12 @@
<data name="textConfirmWithoutSaving" xml:space="preserve"> <data name="textConfirmWithoutSaving" xml:space="preserve">
<value>Unsaved changes! Do you want to close anyway?</value> <value>Unsaved changes! Do you want to close anyway?</value>
</data> </data>
<data name="textConfirmUnsentMessages" xml:space="preserve">
<value>Unsent messages! Do you want to close anyway?</value>
</data>
<data name="textConfirmUnconfirmedMessages" xml:space="preserve">
<value>Unconfirmed messages! Do you want to close anyway?</value>
</data>
<data name="textUnsavedChangesSendAnyWay" xml:space="preserve"> <data name="textUnsavedChangesSendAnyWay" xml:space="preserve">
<value>Some messages have unsaved changes. Send anyway?</value> <value>Some messages have unsaved changes. Send anyway?</value>
</data> </data>

Binary file not shown.

View File

@ -30,7 +30,7 @@ namespace bsmd.ExcelReadService
{ {
this.EventLog.Source = this.ServiceName; this.EventLog.Source = this.ServiceName;
this.EventLog.Log = "Application"; this.EventLog.Log = "Application";
this.Init(args); this.Init();
this.EventLog.WriteEntry("NSW Excel Read Service started.", EventLogEntryType.Information); this.EventLog.WriteEntry("NSW Excel Read Service started.", EventLogEntryType.Information);
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
@ -40,7 +40,7 @@ namespace bsmd.ExcelReadService
this.DoOnce(); this.DoOnce();
} }
private void Init(string[] args) private void Init()
{ {
this._timer = new Timer this._timer = new Timer
{ {

View File

@ -22,8 +22,6 @@ namespace bsmd.ExcelReadService
internal static bool ProcessSheet(ExcelReader reader, out string readMessage, out MessageCore messageCore) internal static bool ProcessSheet(ExcelReader reader, out string readMessage, out MessageCore messageCore)
{ {
readMessage = "ok";
messageCore = Util.LookupMessageCore(reader, out readMessage); messageCore = Util.LookupMessageCore(reader, out readMessage);
if (messageCore == null) return false; // cannot work with this sheet or create one if (messageCore == null) return false; // cannot work with this sheet or create one
@ -138,6 +136,7 @@ namespace bsmd.ExcelReadService
foreach (Message message in messages) foreach (Message message in messages)
{ {
message.CreatedBy = "EXCEL"; message.CreatedBy = "EXCEL";
message.InternalStatus = Message.BSMDStatus.EXCEL;
DBManager.Instance.Save(message); DBManager.Instance.Save(message);
message.SaveElements(); message.SaveElements();
} }
@ -2590,7 +2589,7 @@ namespace bsmd.ExcelReadService
// lookup using field values // lookup using field values
MessageCore result = null; MessageCore result = null;
DateTime? eta = null; DateTime? eta = null;
string poc = null; string poc;
string imo = null; string imo = null;
message = string.Empty; message = string.Empty;
bool isTransit = false; bool isTransit = false;
@ -2708,9 +2707,11 @@ namespace bsmd.ExcelReadService
imo = reader.ReadText("Visit.IMONumber"); imo = reader.ReadText("Visit.IMONumber");
reader.Conf.ConfirmText("Visit.IMONumber", imo, imo.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK); reader.Conf.ConfirmText("Visit.IMONumber", imo, imo.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
if ((imo.Length > 0) && !bsmd.database.Util.IsIMOValid(imo))
reader.Conf.ConfirmText("Visit.IMONumber", imo, ExcelReader.ReadState.WARN);
// ETA // ETA
if(poc != null) if (poc != null)
eta = reader.ReadDateTime("NOA_NOD.ETADateToPortOfCall", "NOA_NOD.ETATimeToPortOfCall"); eta = reader.ReadDateTime("NOA_NOD.ETADateToPortOfCall", "NOA_NOD.ETATimeToPortOfCall");
if ((imo != null) && (eta.HasValue) && (poc != null)) if ((imo != null) && (eta.HasValue) && (poc != null))
@ -2795,6 +2796,11 @@ namespace bsmd.ExcelReadService
result.IMO = result.IMO.Substring(0, 7); result.IMO = result.IMO.Substring(0, 7);
} }
if((result.IMO.Length == 7) && !bsmd.database.Util.IsIMOValid(result.IMO))
{
_log.WarnFormat("IMO {0} possibly invalid (checksum number violation)", result.IMO);
}
if(visitTransitId != null) if(visitTransitId != null)
{ {
if (bsmd.database.Util.IsTransitId(visitTransitId)) if (bsmd.database.Util.IsTransitId(visitTransitId))

View File

@ -157,7 +157,9 @@ namespace bsmd.database
SUSPENDED = 8, SUSPENDED = 8,
IN_USE, IN_USE,
UPDATED, UPDATED,
REPORT // nur für diese Meldeklasse einen PDF Report erzeugen (geht danach wieder auf PREPARE) REPORT, // nur für diese Meldeklasse einen PDF Report erzeugen (geht danach wieder auf PREPARE)
SAVED, // veränderte Meldeklasse wird im ENI gespeichert
EXCEL // Meldeklasse wurde in Excel befüllt
} }
/// <summary> /// <summary>

View File

@ -227,6 +227,41 @@ namespace bsmd.database
return null; return null;
} }
public static bool IsIMOValid(string imoAsString)
{
if (imoAsString.IsNullOrEmpty()) return false;
string actualIMO = null;
if(imoAsString.Length == 10)
{
if (imoAsString.Substring(0, 3).Equals("imo", StringComparison.OrdinalIgnoreCase))
actualIMO = imoAsString.Substring(3);
}
if (imoAsString.Length == 7)
actualIMO = imoAsString;
if ((actualIMO != null) && Int32.TryParse(actualIMO, out int _))
{
/* The integrity of an IMO number can be verified using its check digit. This is done by multiplying
* each of the first six digits by a factor of 2 to 7 corresponding to their position from right
* to left. The rightmost digit of this sum is the check digit.
* For example, for IMO 9074729: (9×7) + (0×6) + (7×5) + (4×4) + (7×3) + (2×2) = 139
*/
int sum = 0;
for (int i = 0, multiplier = 7; i < 6; i++, multiplier--)
{
sum += (Convert.ToInt32(actualIMO[i]) * multiplier);
}
int lastdigit = sum % 10; // letzte Stelle
if (Convert.ToInt32(actualIMO[6]) == lastdigit)
return true;
}
return false;
}
#region CoordinateTransformation #region CoordinateTransformation
public static double NSWToDecimalDegrees(int nswCoordinate) public static double NSWToDecimalDegrees(int nswCoordinate)

Binary file not shown.