diff --git a/AIS/LS100PortProxy/MultiplexManager.cs b/AIS/LS100PortProxy/MultiplexManager.cs
index e21e967a..3af54ac3 100644
--- a/AIS/LS100PortProxy/MultiplexManager.cs
+++ b/AIS/LS100PortProxy/MultiplexManager.cs
@@ -112,20 +112,24 @@ namespace LS100PortProxy
{ // Accept a connection
try
{
- Socket socket = _serverSocket.Accept();
+ Socket socket = _serverSocket.Accept();
ConnectionInfo connection = new ConnectionInfo();
connection.Socket = socket; // Create the thread for the receives.
connection.Thread = new Thread(ProcessConnection);
connection.Thread.IsBackground = true;
- connection.Thread.Start(connection);
+ connection.Thread.Start(connection);
// Store the socket
lock (_connections)
_connections.Add(connection);
_log.InfoFormat("new connection from {0}, total connections: {1}", socket.RemoteEndPoint.ToString(), _connections.Count);
}
- catch (SocketException) { /* tu was */ }
+ catch (SocketException ex)
+ { /* tu was? */
+ _log.WarnFormat("Exception on server socket:{0}", ex.Message);
+ }
Thread.Sleep(250);
}
+ _log.Info("Server connection closed");
this._serverSocket.Close();
}
@@ -169,13 +173,24 @@ namespace LS100PortProxy
aChunk = null;
}
}
+ else if(connection.Socket.Poll(500, SelectMode.SelectError)) {
+ _log.WarnFormat("This Socket has an error, breaking the " +
+ "forever loop");
+ lock (_connections)
+ {
+ connection.chunks.Clear();
+ }
+ break;
+ }
else
{
+ _log.WarnFormat("something has happened with this consumer connection, breaking the forever loop");
// dump queue in this case, packets cannot be sent..
lock (_connections)
{
connection.chunks.Clear();
}
+ break;
}
Thread.Sleep(50);
@@ -230,7 +245,11 @@ namespace LS100PortProxy
{
try
{
- if ((this.client == null) || !this.client.Connected) this.ConnectClient();
+ if ((this.client == null) || !this.client.Connected)
+ {
+ this.ConnectClient();
+ }
+
if ((this.client != null) && this.client.Connected && this.clientStream.CanRead)
{
while (this.clientStream.CanRead && !this.shouldStop)
@@ -304,8 +323,11 @@ namespace LS100PortProxy
Thread.Sleep(60000); // 60 Sekunden warten und neu verbinden
}
}
- if(this.client != null)
+ if (this.client != null)
+ {
+ _log.Info("closing client connection");
this.client.Close();
+ }
}
}
}
diff --git a/AIS/SQL/readme.txt b/AIS/SQL/readme.txt
new file mode 100644
index 00000000..d65ebc37
--- /dev/null
+++ b/AIS/SQL/readme.txt
@@ -0,0 +1,5 @@
+Anmeldeinformationen auf 192.168.2.3 (SMWET01)
+
+user id "shipinfo" PW "baffi123" DB "schiffsmeldedienst"
+user id "mkuehn" PW "baffi1234" DB "schiffsmeldedienst"
+user id "mkuehn" PW "baffi1234" DB "dgzrsSQL"
diff --git a/AIS/bsmd.AISService/AIS/AIS.cs b/AIS/bsmd.AISService/AIS/AIS.cs
index 47d85a2c..1a2222eb 100644
--- a/AIS/bsmd.AISService/AIS/AIS.cs
+++ b/AIS/bsmd.AISService/AIS/AIS.cs
@@ -83,6 +83,8 @@ namespace bsmd.AISService.AIS
set { this.station = value; }
}
+ public bool IsNew { get; set; }
+
#endregion
#region abstract method signatures
@@ -166,6 +168,8 @@ namespace bsmd.AISService.AIS
break;
}
+ if (result != null) result.IsNew = true;
+
return result;
}
diff --git a/AIS/bsmd.AISService/AIS/AIS_Configuration.cs b/AIS/bsmd.AISService/AIS/AIS_Configuration.cs
index 53fb5a4f..f92dca4e 100644
--- a/AIS/bsmd.AISService/AIS/AIS_Configuration.cs
+++ b/AIS/bsmd.AISService/AIS/AIS_Configuration.cs
@@ -84,6 +84,11 @@ namespace bsmd.AISService.AIS
///
public string LogfilePath { get; set; }
+ ///
+ /// Delete positions after this many days
+ ///
+ public int PurgeDays { get; set; } = 30;
+
///
/// outputs assembly version
///
diff --git a/AIS/bsmd.AISService/AIS/AIS_PosReport.cs b/AIS/bsmd.AISService/AIS/AIS_PosReport.cs
index 9d3e4c0c..f1f00fc4 100644
--- a/AIS/bsmd.AISService/AIS/AIS_PosReport.cs
+++ b/AIS/bsmd.AISService/AIS/AIS_PosReport.cs
@@ -112,7 +112,6 @@ namespace bsmd.AISService.AIS
public int CommState { get { return this.commstate; } }
-
#endregion
#region static methods
diff --git a/AIS/bsmd.AISService/AIS/AIS_QueueManager.cs b/AIS/bsmd.AISService/AIS/AIS_QueueManager.cs
index 49d8f35d..bf69c4f7 100644
--- a/AIS/bsmd.AISService/AIS/AIS_QueueManager.cs
+++ b/AIS/bsmd.AISService/AIS/AIS_QueueManager.cs
@@ -27,6 +27,7 @@ public class AIS_QueueManager
private List telnetHandlerList = new List();
private List dbUpdateQueue = new List();
private System.Timers.Timer dbUpdateTimer = new System.Timers.Timer();
+
private bool isStarted = false;
private Mutex dbSingleMutex = new Mutex();
@@ -55,6 +56,7 @@ public class AIS_QueueManager
AIS_Target.dbUpdateInterval = new TimeSpan(0, 0, configuration.DBMinPosReportTimeDifference);
this.dbUpdateTimer.Interval = configuration.DBUpdateInterval;
this.dbUpdateTimer.Elapsed += new ElapsedEventHandler(dbUpdateTimer_Elapsed);
+
}
#endregion
@@ -210,12 +212,12 @@ public class AIS_QueueManager
protected void OnAISQueueChanged(AIS_Target target)
{
- if (this.AISQueueChanged != null) this.AISQueueChanged(target);
+ this.AISQueueChanged?.Invoke(target);
}
protected void OnDBUpdateRequired(AIS_Target target)
{
- if (this.DBUpdateRequired != null) this.DBUpdateRequired(target);
+ this.DBUpdateRequired?.Invoke(target);
}
#endregion
diff --git a/AIS/bsmd.AISService/AIS/AIS_StaticData.cs b/AIS/bsmd.AISService/AIS/AIS_StaticData.cs
index 36735efd..b91b8c4f 100644
--- a/AIS/bsmd.AISService/AIS/AIS_StaticData.cs
+++ b/AIS/bsmd.AISService/AIS/AIS_StaticData.cs
@@ -157,84 +157,92 @@ namespace bsmd.AISService.AIS
{
BitArray bits = AIS.DecodeBinary(this.data);
Status result = Status.OK;
-
- try
+ if (bits.Count < 424)
{
- int type = AIS.GetInt(bits, 0, 5);
- if (type != 5)
- {
- result = Status.ILLEGAL_ARGUMENT;
- }
- else
- {
- this.userId = AIS.GetInt(bits, 6, 37);
- this.ais_version = AIS.GetInt(bits, 38, 39);
- this.imoNumber = AIS.GetInt(bits, 40, 69);
-
- StringBuilder sb_callsign = new StringBuilder(7);
- for (int i = 0; i < 7; i++)
- {
- int cval = AIS.GetInt(bits, 70 + (6 * i), 75 + (6 * i));
- char ch = AIS.GetAISChar(cval);
- if (ch == '@') ch = ' ';
- sb_callsign.Append(ch);
- }
- this.callsign = sb_callsign.ToString().Trim();
-
- StringBuilder sb_name = new StringBuilder(20);
- for (int i = 0; i < 20; i++)
- {
- int cval = AIS.GetInt(bits, 112 + (6 * i), 117 + (6 * i));
- char ch = AIS.GetAISChar(cval);
- if (ch == '@') ch = ' ';
- sb_name.Append(ch);
- }
- this.name = sb_name.ToString().Trim();
-
- this.shiptype = AIS.GetInt(bits, 232, 239);
- this.dimension = AIS.GetInt(bits, 240, 269);
- this.a = AIS.GetInt(bits, 240, 248);
- this.b = AIS.GetInt(bits, 249, 257);
- this.c = AIS.GetInt(bits, 258, 263);
- this.d = AIS.GetInt(bits, 264, 269);
- this.typeofdevice = AIS.GetInt(bits, 270, 273);
- this.etamonth = AIS.GetInt(bits, 274, 277);
- this.etaday = AIS.GetInt(bits, 278, 282);
- this.etahour = AIS.GetInt(bits, 283, 287);
- this.etaminute = AIS.GetInt(bits, 288, 293);
- try
- {
- if ((this.etahour < 24) && (this.etaday > 0) && (this.etaminute < 60) && (this.etamonth > 0))
- {
- this.eta = new DateTime(DateTime.Now.Year, this.etamonth, this.etaday, this.etahour, this.etaminute, 0);
- }
- }
- catch(Exception e) {
- _log.WarnFormat("ETA timestamp creation failed: {0}", e.Message);
- }
- this.maxpresetstaticdraught = AIS.GetInt(bits, 294, 301);
-
- StringBuilder sb_destination = new StringBuilder(20);
- for (int i = 0; i < 20; i++)
- {
- int cval = AIS.GetInt(bits, 302 + (6 * i), 307 + (6 * i));
- char ch = AIS.GetAISChar(cval);
- if (ch == '@') ch = ' ';
- sb_destination.Append(ch);
- }
- this.destination = sb_destination.ToString().Trim();
-
- this.dte = AIS.GetInt(bits, 422, 422);
- this.spare = AIS.GetInt(bits, 423, 423);
-
- }
- }
- catch (Exception e)
- {
- _log.WarnFormat("Error decoding AIS static data: {0}", e.Message);
+ _log.WarnFormat("AISStaticData truncated: {0}/424", bits.Count);
result = Status.PARSE_ERROR;
}
+ else
+ {
+ try
+ {
+ int type = AIS.GetInt(bits, 0, 5);
+ if (type != 5)
+ {
+ result = Status.ILLEGAL_ARGUMENT;
+ }
+ else
+ {
+ this.userId = AIS.GetInt(bits, 6, 37);
+ this.ais_version = AIS.GetInt(bits, 38, 39);
+ this.imoNumber = AIS.GetInt(bits, 40, 69);
+
+ StringBuilder sb_callsign = new StringBuilder(7);
+ for (int i = 0; i < 7; i++)
+ {
+ int cval = AIS.GetInt(bits, 70 + (6 * i), 75 + (6 * i));
+ char ch = AIS.GetAISChar(cval);
+ if (ch == '@') ch = ' ';
+ sb_callsign.Append(ch);
+ }
+ this.callsign = sb_callsign.ToString().Trim();
+
+ StringBuilder sb_name = new StringBuilder(20);
+ for (int i = 0; i < 20; i++)
+ {
+ int cval = AIS.GetInt(bits, 112 + (6 * i), 117 + (6 * i));
+ char ch = AIS.GetAISChar(cval);
+ if (ch == '@') ch = ' ';
+ sb_name.Append(ch);
+ }
+ this.name = sb_name.ToString().Trim();
+
+ this.shiptype = AIS.GetInt(bits, 232, 239);
+ this.dimension = AIS.GetInt(bits, 240, 269);
+ this.a = AIS.GetInt(bits, 240, 248);
+ this.b = AIS.GetInt(bits, 249, 257);
+ this.c = AIS.GetInt(bits, 258, 263);
+ this.d = AIS.GetInt(bits, 264, 269);
+ this.typeofdevice = AIS.GetInt(bits, 270, 273);
+ this.etamonth = AIS.GetInt(bits, 274, 277);
+ this.etaday = AIS.GetInt(bits, 278, 282);
+ this.etahour = AIS.GetInt(bits, 283, 287);
+ this.etaminute = AIS.GetInt(bits, 288, 293);
+ try
+ {
+ if ((this.etahour < 24) && (this.etaday > 0) && (this.etaminute < 60) && (this.etamonth > 0))
+ {
+ this.eta = new DateTime(DateTime.Now.Year, this.etamonth, this.etaday, this.etahour, this.etaminute, 0);
+ }
+ }
+ catch (Exception e)
+ {
+ _log.WarnFormat("ETA timestamp creation failed: {0}", e.Message);
+ }
+ this.maxpresetstaticdraught = AIS.GetInt(bits, 294, 301);
+
+ StringBuilder sb_destination = new StringBuilder(20);
+ for (int i = 0; i < 20; i++)
+ {
+ int cval = AIS.GetInt(bits, 302 + (6 * i), 307 + (6 * i));
+ char ch = AIS.GetAISChar(cval);
+ if (ch == '@') break; //ch = ' '; // alles nach einem @ nicht mehr beachten
+ sb_destination.Append(ch);
+ }
+ this.destination = sb_destination.ToString().Trim();
+
+ this.dte = AIS.GetInt(bits, 422, 422);
+ this.spare = AIS.GetInt(bits, 423, 423);
+
+ }
+ }
+ catch (Exception e)
+ {
+ _log.WarnFormat("Error decoding AIS static data: {0}", e.Message);
+ result = Status.PARSE_ERROR;
+ }
+ }
return result;
}
diff --git a/AIS/bsmd.AISService/AIS/AIS_Telnet.cs b/AIS/bsmd.AISService/AIS/AIS_Telnet.cs
index 753bb27d..6c3226e5 100644
--- a/AIS/bsmd.AISService/AIS/AIS_Telnet.cs
+++ b/AIS/bsmd.AISService/AIS/AIS_Telnet.cs
@@ -121,6 +121,8 @@ namespace bsmd.AISService.AIS
_log.Info("closing inactive TcpClient");
this.lastRead = DateTime.Now; // reset timer
}
+
+ System.Threading.Thread.Sleep(250); // wait a bit
}
return result;
diff --git a/AIS/bsmd.AISService/AIS/TelnetDataHandler.cs b/AIS/bsmd.AISService/AIS/TelnetDataHandler.cs
index 047d4d82..e14877a1 100644
--- a/AIS/bsmd.AISService/AIS/TelnetDataHandler.cs
+++ b/AIS/bsmd.AISService/AIS/TelnetDataHandler.cs
@@ -107,7 +107,7 @@ namespace bsmd.AISService.AIS
var line = frame.GetFileLineNumber();
_log.WarnFormat("Exception in telnet reader thread: {0}, top frame ln {1}", ex.Message, line);
}
- Thread.Sleep(100);
+ // Thread.Sleep(100);
}
aisTelnet.Close();
}
diff --git a/AIS/bsmd.AISService/AISService.cs b/AIS/bsmd.AISService/AISService.cs
index 96bbdb75..22a4db27 100644
--- a/AIS/bsmd.AISService/AISService.cs
+++ b/AIS/bsmd.AISService/AISService.cs
@@ -1,16 +1,11 @@
// Copyright (c) 2008-2018 schick Informatik
-// Description:
+// Description: Windows Service Main File
//
using System;
using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
using System.Diagnostics;
-using System.Linq;
using System.ServiceProcess;
-using System.Text;
-using System.Threading.Tasks;
using bsmd.AISService.AIS;
using bsmd.AISService.DB;
diff --git a/AIS/bsmd.AISService/App.config b/AIS/bsmd.AISService/App.config
index 4a686434..a61fdc41 100644
--- a/AIS/bsmd.AISService/App.config
+++ b/AIS/bsmd.AISService/App.config
@@ -37,6 +37,9 @@
+
+ 30
+
\ No newline at end of file
diff --git a/AIS/bsmd.AISService/DB/AISPosReport.cs b/AIS/bsmd.AISService/DB/AISPosReport.cs
index 6d05d842..4bd1fbc5 100644
--- a/AIS/bsmd.AISService/DB/AISPosReport.cs
+++ b/AIS/bsmd.AISService/DB/AISPosReport.cs
@@ -3,15 +3,12 @@
//
using System;
-using System.Diagnostics;
-using System.Collections.Generic;
-using System.Text;
using bsmd.AISService.AIS;
using log4net;
namespace bsmd.AISService.DB
-{
+{
internal class AISPosReport : AISBaseEntity {
private static ILog _log = LogManager.GetLogger(typeof(AISPosReport));
@@ -23,12 +20,12 @@ namespace bsmd.AISService.DB
/// id of insert operation (to update hotposition table)
public static Guid? Save(AIS_Target target, DBConnector con, AISStation aisStation)
{
- if (target.LastPosReport == null) return null;
-
+ if (target.LastPosReport == null) return null;
+
if (target.LastPosReport is AIS_PosReport)
{
// Trace.WriteLine("saving class A pos report");
- AIS_PosReport pr = target.LastPosReport as AIS_PosReport;
+ AIS_PosReport pr = target.LastPosReport as AIS_PosReport;
if (aisStation != null)
{
@@ -37,12 +34,15 @@ namespace bsmd.AISService.DB
aisStation.OnAir = true;
}
+ if (!pr.IsNew) return pr.Id;
+
string query = string.Format("INSERT INTO aisposreport (Id, MMSI, NavStatus, ROT, COG, SOG, Accuracy, Longitude, Latitude, Heading, Timestamp, Reserved, Spare, Raim, CommState, AISStationId) VALUES ('{0}', {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, '{10}', {11},{12},{13},{14},'{15}')",
pr.Id, pr.MMSI, pr.NavStatusVal, pr.ROTVal, pr.COGVal, pr.SOGVal, pr.Accuracy,
pr.LongitudeVal, pr.LatitudeVal, pr.TrueHeading ?? 511, pr.DBTimestamp, pr.Reserved, pr.Spare, pr.Raim, pr.CommState,
(aisStation != null) ? aisStation.Id : Guid.Empty);
con.ExecuteNonQuery(query);
+ pr.IsNew = false;
return pr.Id;
}
@@ -50,15 +50,19 @@ namespace bsmd.AISService.DB
if (target.LastPosReport is AIS_ClassB)
{
// Trace.WriteLine("saving class B pos report");
- AIS_ClassB pr = target.LastPosReport as AIS_ClassB;
+ AIS_ClassB pr = target.LastPosReport as AIS_ClassB;
+
aisStation.UpdateWithPositionReport(pr.MMSI, pr.Latitude, pr.Longitude, pr.Timestamp);
+ if (!pr.IsNew) return pr.Id;
+
string query = string.Format("INSERT INTO aisposreport (Id, MMSI, NavStatus, ROT, COG, SOG, Accuracy, Longitude, Latitude, Heading, Timestamp, Reserved, Spare, Raim, CommState, AISStationId) VALUES ('{0}', {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, '{10}', {11}, {12}, {13}, {14}, '{15}')",
pr.Id, pr.MMSI, 0, 0, pr.CogVal, pr.SogVal, 0, pr.LongitudeVal, pr.LatitudeVal,
pr.TrueHeading ?? 511, pr.DBTimestamp, pr.Reserved, pr.Spare, pr.Raim, pr.CommState, (aisStation != null) ? aisStation.Id : Guid.Empty);
con.ExecuteNonQuery(query);
-
+ pr.IsNew = false;
+
return pr.Id;
}
@@ -74,6 +78,11 @@ namespace bsmd.AISService.DB
return null;
}
+ public static int ClearPosReports(DBConnector con, int olderThanDays)
+ {
+ string query = string.Format("DELETE FROM aisposreport WHERE[Timestamp] < DATEADD(day, -{0}, GETDATE())", olderThanDays);
+ return con.ExecuteNonQuery(query);
+ }
}
}
diff --git a/AIS/bsmd.AISService/Program.cs b/AIS/bsmd.AISService/Program.cs
index 916a639f..b29cbd16 100644
--- a/AIS/bsmd.AISService/Program.cs
+++ b/AIS/bsmd.AISService/Program.cs
@@ -45,7 +45,7 @@ namespace bsmd.AISService
return 1;
}
}
- else if(Debugger.IsAttached)
+ else if(Debugger.IsAttached) // wenn man "live" profilern will muss man hier immer rein
{
AISService aisService = new AISService();
aisService.DebugStart();
diff --git a/AIS/bsmd.AISService/Properties/AssemblyInfo.cs b/AIS/bsmd.AISService/Properties/AssemblyInfo.cs
index 27dbd0ff..c9e1f08c 100644
--- a/AIS/bsmd.AISService/Properties/AssemblyInfo.cs
+++ b/AIS/bsmd.AISService/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyVersion("1.2.0.0")]
+[assembly: AssemblyFileVersion("1.2.0.0")]
diff --git a/AIS/bsmd.AISService/Properties/Settings.Designer.cs b/AIS/bsmd.AISService/Properties/Settings.Designer.cs
index d3648523..23101add 100644
--- a/AIS/bsmd.AISService/Properties/Settings.Designer.cs
+++ b/AIS/bsmd.AISService/Properties/Settings.Designer.cs
@@ -12,7 +12,7 @@ namespace bsmd.AISService.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.6.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@@ -31,5 +31,14 @@ namespace bsmd.AISService.Properties {
return ((string)(this["ConnectionString"]));
}
}
+
+ [global::System.Configuration.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("30")]
+ public int PurgeInterval {
+ get {
+ return ((int)(this["PurgeInterval"]));
+ }
+ }
}
}
diff --git a/AIS/bsmd.AISService/Properties/Settings.settings b/AIS/bsmd.AISService/Properties/Settings.settings
index ef60b87c..427e4b17 100644
--- a/AIS/bsmd.AISService/Properties/Settings.settings
+++ b/AIS/bsmd.AISService/Properties/Settings.settings
@@ -5,5 +5,8 @@
+
+ 30
+
\ No newline at end of file
diff --git a/AIS/bsmd.AISService/ais_config.xml b/AIS/bsmd.AISService/ais_config.xml
index 42481a80..1fb320ca 100644
--- a/AIS/bsmd.AISService/ais_config.xml
+++ b/AIS/bsmd.AISService/ais_config.xml
@@ -20,4 +20,5 @@
120
120
20
+ 30
\ No newline at end of file
diff --git a/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs
index 29b5c588..cd5c4178 100644
--- a/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs
@@ -26,13 +26,13 @@ namespace ENI2
#region Fields
private MessageCore _core;
- private List _listBoxList = new List();
+ private readonly List _listBoxList = new List();
private List _messages;
- private Dictionary controlCache = new Dictionary();
- private Dictionary messageClassControlDict = new Dictionary();
+ private readonly Dictionary controlCache = new Dictionary();
+ private readonly Dictionary messageClassControlDict = new Dictionary();
private Guid userId = Guid.NewGuid(); // remove THIS!!
- private object messageListLock = new object();
- private HighlightService highlightService = new HighlightService();
+ private readonly object messageListLock = new object();
+ private readonly HighlightService highlightService = new HighlightService();
// Referenzen für Fehler/Violation Dialoge (können, müssen aber nicht offen bleiben)
protected ErrorListDialog _errorListDialog = null;
@@ -54,7 +54,7 @@ namespace ENI2
public bool HasUnsavedChanges
{
- 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
}
#endregion
@@ -260,10 +260,6 @@ namespace ENI2
foreach (Message existingMessage in existingMessages)
{
- if (existingMessage is ISublistContainer)
- {
- ((ISublistContainer)existingMessage).DeleteElements();
- }
// Bearbeitungsinformationen für bestehende ID-Beantragung beibehalten, falls bereits vorhanden
@@ -283,6 +279,11 @@ namespace ENI2
continue;
}
+ if (existingMessage is ISublistContainer sublistContainer)
+ {
+ (sublistContainer).DeleteElements();
+ }
+
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Delete(existingMessage);
}
@@ -290,7 +291,7 @@ namespace ENI2
else
{
return;
- }
+ }
}
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(newCore);
@@ -343,21 +344,20 @@ namespace ENI2
Util.UIHelper.SetBusyState();
- DetailBaseControl currentControl = this.detailView.Children[0] as DetailBaseControl;
- if (currentControl != null)
+ if (this.detailView.Children[0] is DetailBaseControl currentControl)
{
foreach (Message message in currentControl.ControlMessages)
{
- this.SaveMessage(message);
+ this.SaveMessage(message);
}
this.buttonSave.Visibility = Visibility.Hidden;
- if(currentControl is OverViewDetailControl)
+ if (currentControl is OverViewDetailControl)
{
// ggf. hat sich die Ticketnr geändert..
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(currentControl.Core);
}
- }
+ }
}
this.DetailControl_RequestReload();
@@ -498,12 +498,10 @@ namespace ENI2
private void DetailControl_RequestSendValidation()
{
- List violationList = null;
- List errorList = null;
- this.Validate(false, out violationList, out errorList);
+ this.Validate(false, out List violationList, out List errorList);
- foreach(Message aMessage in this._messages)
+ foreach (Message aMessage in this._messages)
{
if(aMessage.InternalStatus == Message.BSMDStatus.TOSEND)
{
@@ -577,9 +575,7 @@ namespace ENI2
private void DetailControl_RequestValidate()
{
- List errorList = null;
- List violationList = null;
- this.Validate(true, out violationList, out errorList);
+ this.Validate(true, out List violationList, out List errorList);
}
private void Validate(bool showMessages, out List vViolations, out List vErrors)
@@ -659,8 +655,8 @@ namespace ENI2
if(this._errorListDialog == null)
{
this._errorListDialog = new ErrorListDialog();
- this._errorListDialog.Closed += (o, e) => { this._errorListDialog = null; };
- this._errorListDialog.Loaded += (o, e) => { this._errorListDialog.RefreshVisible = true; };
+ this._errorListDialog.Closed += (o, e) => this._errorListDialog = null;
+ this._errorListDialog.Loaded += (o, e) => this._errorListDialog.RefreshVisible = true;
this._errorListDialog.ErrorSelected += _errorListDialog_ErrorSelected;
this._errorListDialog.RefreshClicked += _errorListDialog_RefreshClicked;
this._errorListDialog.IsModal = false;
@@ -674,8 +670,8 @@ namespace ENI2
if(this._violationListDialog == null)
{
this._violationListDialog = new ViolationListDialog();
- this._violationListDialog.Closed += (o, e) => { this._violationListDialog = null; };
- this._violationListDialog.Loaded += (o, e) => { this._violationListDialog.RefreshVisible = true; };
+ 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.IsModal = false;
diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs
index b351e734..f5a238b3 100644
--- a/ENI-2/ENI2/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs
@@ -78,9 +78,11 @@ namespace ENI2.DetailViewControls
bpol = this._bpolMessage.Elements[0] as BPOL;
if (bpol == null)
{
- bpol = new BPOL();
- bpol.MessageCore = this.Core;
- bpol.MessageHeader = this._bpolMessage;
+ bpol = new BPOL
+ {
+ MessageCore = this.Core,
+ MessageHeader = this._bpolMessage
+ };
_bpolMessage.Elements.Add(bpol);
}
@@ -148,8 +150,10 @@ namespace ENI2.DetailViewControls
private void DataGridPortOfItinerary_CreateRequested()
{
- EditPortOfItineraryDialog epid = new EditPortOfItineraryDialog();
- epid.PortOfItinerary = new PortOfItinerary();
+ EditPortOfItineraryDialog epid = new EditPortOfItineraryDialog
+ {
+ PortOfItinerary = new PortOfItinerary()
+ };
epid.PortOfItinerary.Identifier = PortOfItinerary.GetNewIdentifier(this._bpol.PortOfItineraries);
epid.PortOfItinerary.BPOL = this._bpol;
@@ -159,9 +163,11 @@ namespace ENI2.DetailViewControls
if(!this._bpol.PortOfItineraries.Contains(epid.PortOfItinerary))
this._bpol.PortOfItineraries.Add(epid.PortOfItinerary);
this.dataGridPortOfItinerary.Items.Refresh();
- epid.PortOfItinerary = new PortOfItinerary();
- epid.PortOfItinerary.BPOL = _bpol;
- epid.PortOfItinerary.Identifier = PortOfItinerary.GetNewIdentifier(this._bpol.PortOfItineraries);
+ epid.PortOfItinerary = new PortOfItinerary
+ {
+ BPOL = _bpol,
+ Identifier = PortOfItinerary.GetNewIdentifier(this._bpol.PortOfItineraries)
+ };
this.SublistElementChanged(Message.NotificationClass.BPOL);
};
@@ -176,8 +182,7 @@ namespace ENI2.DetailViewControls
private void DataGridPortOfItinerary_DeleteRequested(DatabaseEntity obj)
{
- PortOfItinerary poi = obj as PortOfItinerary;
- if (poi != null)
+ if (obj is PortOfItinerary poi)
{
// are you sure dialog is in base class
_bpol.PortOfItineraries.Remove(poi);
@@ -190,8 +195,10 @@ namespace ENI2.DetailViewControls
private void DataGridPortOfItinerary_EditRequested(DatabaseEntity obj)
{
- EditPortOfItineraryDialog epid = new EditPortOfItineraryDialog();
- epid.PortOfItinerary = obj as PortOfItinerary;
+ EditPortOfItineraryDialog epid = new EditPortOfItineraryDialog
+ {
+ PortOfItinerary = obj as PortOfItinerary
+ };
epid.AddClicked += () =>
{
@@ -199,9 +206,11 @@ namespace ENI2.DetailViewControls
if(!_bpol.PortOfItineraries.Contains(epid.PortOfItinerary))
_bpol.PortOfItineraries.Add(epid.PortOfItinerary);
this.dataGridPortOfItinerary.Items.Refresh();
- epid.PortOfItinerary = new PortOfItinerary();
- epid.PortOfItinerary.BPOL = this._bpol;
- epid.PortOfItinerary.Identifier = PortOfItinerary.GetNewIdentifier(this._bpol.PortOfItineraries);
+ epid.PortOfItinerary = new PortOfItinerary
+ {
+ BPOL = this._bpol,
+ Identifier = PortOfItinerary.GetNewIdentifier(this._bpol.PortOfItineraries)
+ };
this.SublistElementChanged(Message.NotificationClass.BPOL);
};
@@ -231,17 +240,19 @@ namespace ENI2.DetailViewControls
{
foreach (LastTenPortFacilitiesCalled l10fc in _sec.LastTenPortFacilitesCalled)
{
- if (l10fc.PortFacilityDateOfDeparture.HasValue &&
- ((DateTime.Now - l10fc.PortFacilityDateOfDeparture.Value).TotalDays < 31))
+ //if (l10fc.PortFacilityDateOfDeparture.HasValue &&
+ //((DateTime.Now - l10fc.PortFacilityDateOfDeparture.Value).TotalDays < 31))
+ //{
+ PortOfItinerary poi = new PortOfItinerary
{
- PortOfItinerary poi = new PortOfItinerary();
- poi.Identifier = PortOfItinerary.GetNewIdentifier(this._bpol.PortOfItineraries);
- poi.BPOL = this._bpol;
- poi.PortOfItineraryETA = l10fc.PortFacilityDateOfArrival;
- poi.PortOfItineraryLocode = l10fc.PortFacilityPortLoCode;
- poi.PortOfItineraryName = l10fc.PortFacilityPortName;
- this._bpol.PortOfItineraries.Add(poi);
- }
+ Identifier = PortOfItinerary.GetNewIdentifier(this._bpol.PortOfItineraries),
+ BPOL = this._bpol,
+ PortOfItineraryETA = l10fc.PortFacilityDateOfArrival,
+ PortOfItineraryLocode = l10fc.PortFacilityPortLoCode,
+ PortOfItineraryName = l10fc.PortFacilityPortName
+ };
+ this._bpol.PortOfItineraries.Add(poi);
+ //}
}
if (this._bpol.PortOfItineraries.Count > 0)
{
@@ -258,8 +269,10 @@ namespace ENI2.DetailViewControls
private void DataGridPassengerList_CreateRequested()
{
- EditPASDialog epd = new EditPASDialog();
- epd.PAS = new PAS();
+ EditPASDialog epd = new EditPASDialog
+ {
+ PAS = new PAS()
+ };
epd.PAS.Identifier = PAS.GetNewIdentifier(_pasMessage.Elements);
epd.PAS.MessageHeader = this._pasMessage;
@@ -269,9 +282,11 @@ namespace ENI2.DetailViewControls
if(!this._pasMessage.Elements.Contains(epd.PAS))
this._pasMessage.Elements.Add(epd.PAS);
this.dataGridPassengerList.Items.Refresh();
- epd.PAS = new PAS();
- epd.PAS.MessageHeader = this._pasMessage;
- epd.PAS.Identifier = PAS.GetNewIdentifier(_pasMessage.Elements);
+ epd.PAS = new PAS
+ {
+ MessageHeader = this._pasMessage,
+ Identifier = PAS.GetNewIdentifier(_pasMessage.Elements)
+ };
this.SublistElementChanged(Message.NotificationClass.PAS);
};
@@ -286,12 +301,11 @@ namespace ENI2.DetailViewControls
private void DataGridPassengerList_DeleteRequested(DatabaseEntity obj)
{
- PAS pas = obj as PAS;
- if (pas != null)
+ if (obj is PAS pas)
{
// are you sure dialog is in base class
_pasMessage.Elements.Remove(pas);
- DBManager.Instance.Delete(pas);
+ DBManager.Instance.Delete(pas);
}
}
@@ -304,8 +318,10 @@ namespace ENI2.DetailViewControls
private void DataGridPassengerList_EditRequested(DatabaseEntity obj)
{
- EditPASDialog epd = new EditPASDialog();
- epd.PAS = obj as PAS;
+ EditPASDialog epd = new EditPASDialog
+ {
+ PAS = obj as PAS
+ };
epd.AddClicked += () =>
{
@@ -313,9 +329,11 @@ namespace ENI2.DetailViewControls
if(!_pasMessage.Elements.Contains(epd.PAS))
_pasMessage.Elements.Add(epd.PAS);
this.dataGridPassengerList.Items.Refresh();
- epd.PAS = new PAS();
- epd.PAS.Identifier = PAS.GetNewIdentifier(_pasMessage.Elements);
- epd.PAS.MessageHeader = _pasMessage;
+ epd.PAS = new PAS
+ {
+ Identifier = PAS.GetNewIdentifier(_pasMessage.Elements),
+ MessageHeader = _pasMessage
+ };
this.SublistElementChanged(Message.NotificationClass.PAS);
};
@@ -340,8 +358,10 @@ namespace ENI2.DetailViewControls
private void DataGridCrewList_CreateRequested()
{
- EditCREWDialog ecd = new EditCREWDialog();
- ecd.CREW = new CREW();
+ EditCREWDialog ecd = new EditCREWDialog
+ {
+ CREW = new CREW()
+ };
ecd.CREW.Identifier = CREW.GetNewIdentifier(_crewMessage.Elements);
ecd.CREW.MessageHeader = this._crewMessage;
@@ -351,9 +371,11 @@ namespace ENI2.DetailViewControls
if(!this._crewMessage.Elements.Contains(ecd.CREW))
this._crewMessage.Elements.Add(ecd.CREW);
this.dataGridCrewList.Items.Refresh();
- ecd.CREW = new CREW();
- ecd.CREW.MessageHeader = this._crewMessage;
- ecd.CREW.Identifier = CREW.GetNewIdentifier(_crewMessage.Elements);
+ ecd.CREW = new CREW
+ {
+ MessageHeader = this._crewMessage,
+ Identifier = CREW.GetNewIdentifier(_crewMessage.Elements)
+ };
this.SublistElementChanged(Message.NotificationClass.CREW);
};
@@ -368,12 +390,11 @@ namespace ENI2.DetailViewControls
private void DataGridCrewList_DeleteRequested(DatabaseEntity obj)
{
- CREW crew = obj as CREW;
- if (crew != null)
+ if (obj is CREW crew)
{
// are you sure dialog is in base class
_crewMessage.Elements.Remove(crew);
- DBManager.Instance.Delete(crew);
+ DBManager.Instance.Delete(crew);
}
}
@@ -386,8 +407,10 @@ namespace ENI2.DetailViewControls
private void DataGridCrewList_EditRequested(DatabaseEntity obj)
{
- EditCREWDialog ecd = new EditCREWDialog();
- ecd.CREW = obj as CREW;
+ EditCREWDialog ecd = new EditCREWDialog
+ {
+ CREW = obj as CREW
+ };
ecd.AddClicked += () =>
{
@@ -395,9 +418,11 @@ namespace ENI2.DetailViewControls
if(!_crewMessage.Elements.Contains(ecd.CREW))
_crewMessage.Elements.Add(ecd.CREW);
this.dataGridCrewList.Items.Refresh();
- ecd.CREW = new CREW();
- ecd.CREW.Identifier = CREW.GetNewIdentifier(_crewMessage.Elements);
- ecd.CREW.MessageHeader = _crewMessage;
+ ecd.CREW = new CREW
+ {
+ Identifier = CREW.GetNewIdentifier(_crewMessage.Elements),
+ MessageHeader = _crewMessage
+ };
this.SublistElementChanged(Message.NotificationClass.CREW);
};
@@ -433,8 +458,10 @@ namespace ENI2.DetailViewControls
private void buttonImportExcelCrew_Click(object sender, RoutedEventArgs e)
{
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "Excel Files|*.xls;*.xlsx";
+ OpenFileDialog ofd = new OpenFileDialog
+ {
+ Filter = "Excel Files|*.xls;*.xlsx"
+ };
if (ofd.ShowDialog() ?? false)
{
FileStream stream = null;
@@ -505,8 +532,10 @@ namespace ENI2.DetailViewControls
private void buttonImportExcelPassenger_Click(object sender, RoutedEventArgs e)
{
- OpenFileDialog ofd = new OpenFileDialog();
- ofd.Filter = "Excel Files|*.xls;*.xlsx";
+ OpenFileDialog ofd = new OpenFileDialog
+ {
+ Filter = "Excel Files|*.xls;*.xlsx"
+ };
if (ofd.ShowDialog() ?? false)
{
FileStream stream = null;
diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs
index 5d38bcbb..1bc0dbbd 100644
--- a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs
+++ b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs
@@ -28,7 +28,7 @@ namespace ENI2.DetailViewControls
private Message _noanodMessage;
private Timer _checkStatusTimer;
private DateTime _startStatusCheck;
- private object _collectionLock = new object();
+ private readonly object _collectionLock = new object();
public OverViewDetailControl()
{
@@ -81,11 +81,13 @@ namespace ENI2.DetailViewControls
this.comboBoxInitialHis.ItemsSource = Util.EnumHelper.GetAllValuesAndDescription(typeof(Message.NSWProvider));
this.comboBoxInitialHis.DataContext = this.Core;
- Binding vtBinding = new Binding();
- vtBinding.Source = this.Core;
- vtBinding.Path = this.Core.IsTransit ? new PropertyPath("TransitId") : new PropertyPath("VisitId");
- vtBinding.Mode = BindingMode.TwoWay;
- vtBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
+ Binding vtBinding = new Binding
+ {
+ Source = this.Core,
+ Path = this.Core.IsTransit ? new PropertyPath("TransitId") : new PropertyPath("VisitId"),
+ Mode = BindingMode.TwoWay,
+ UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
+ };
BindingOperations.SetBinding(textBoxDisplayId, TextBox.TextProperty, vtBinding);
if (this.Core.Cancelled ?? false) this.ShowCancelledLabel();
@@ -96,41 +98,53 @@ namespace ENI2.DetailViewControls
// Command Bindings verwenden. Hier ist das erklärt: https://docs.microsoft.com/en-us/dotnet/framework/wpf/advanced/commanding-overview#code-snippet-2
this.dataGridMessages.ContextMenu = new ContextMenu();
- MenuItem sendItem = new MenuItem();
- sendItem.Header = Properties.Resources.textSendToNSW;
- sendItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/mail_forward.png")) };
+ MenuItem sendItem = new MenuItem
+ {
+ Header = Properties.Resources.textSendToNSW,
+ Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/mail_forward.png")) }
+ };
//sendItem.Command =
- sendItem.Click += new RoutedEventHandler(this.contextSendMessage);
+ sendItem.Click += this.contextSendMessage;
this.dataGridMessages.ContextMenu.Items.Add(sendItem);
- MenuItem resetItem = new MenuItem();
- resetItem.Header = Properties.Resources.textReset;
- resetItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/mail_delete.png")) };
- resetItem.Click += new RoutedEventHandler(this.contextResetMessage);
+ MenuItem resetItem = new MenuItem
+ {
+ Header = Properties.Resources.textReset,
+ Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/mail_delete.png")) }
+ };
+ resetItem.Click += this.contextResetMessage;
this.dataGridMessages.ContextMenu.Items.Add(resetItem);
- MenuItem systemErrorItem = new MenuItem();
- systemErrorItem.Header = Properties.Resources.textSystemErrors;
- systemErrorItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/hand_red_card.png")) };
- systemErrorItem.Click += new RoutedEventHandler(this.buttonSystemErrors_Click);
+ MenuItem systemErrorItem = new MenuItem
+ {
+ Header = Properties.Resources.textSystemErrors,
+ Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/hand_red_card.png")) }
+ };
+ systemErrorItem.Click += this.buttonSystemErrors_Click;
this.dataGridMessages.ContextMenu.Items.Add(systemErrorItem);
- MenuItem errorItem = new MenuItem();
- errorItem.Header = Properties.Resources.textErrors;
- errorItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/error.png")) };
- errorItem.Click += new RoutedEventHandler(this.buttonErrors_Click);
+ MenuItem errorItem = new MenuItem
+ {
+ Header = Properties.Resources.textErrors,
+ Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/error.png")) }
+ };
+ errorItem.Click += this.buttonErrors_Click;
this.dataGridMessages.ContextMenu.Items.Add(errorItem);
- MenuItem vioItem = new MenuItem();
- vioItem.Header = Properties.Resources.textViolations;
- vioItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/sign_warning.png")) };
- vioItem.Click += new RoutedEventHandler(this.buttonWarnings_Click);
+ MenuItem vioItem = new MenuItem
+ {
+ Header = Properties.Resources.textViolations,
+ Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/sign_warning.png")) }
+ };
+ vioItem.Click += this.buttonWarnings_Click;
this.dataGridMessages.ContextMenu.Items.Add(vioItem);
- MenuItem pdfItem = new MenuItem();
- pdfItem.Header = Properties.Resources.textCreatePDF;
- pdfItem.Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/document_pdf.png")) };
- pdfItem.Click += new RoutedEventHandler(this.buttonCreatePDF_Click);
+ MenuItem pdfItem = new MenuItem
+ {
+ Header = Properties.Resources.textCreatePDF,
+ Icon = new Image { Source = new BitmapImage(new Uri("pack://application:,,,/Resources/document_pdf.png")) }
+ };
+ pdfItem.Click += this.buttonCreatePDF_Click;
this.dataGridMessages.ContextMenu.Items.Add(pdfItem);
#endregion
@@ -169,9 +183,11 @@ namespace ENI2.DetailViewControls
if (ata == null)
{
- ata = new ATA();
- ata.MessageCore = this.Core;
- ata.MessageHeader = this._ataMessage;
+ ata = new ATA
+ {
+ MessageCore = this.Core,
+ MessageHeader = this._ataMessage
+ };
_ataMessage.Elements.Add(ata);
}
@@ -197,9 +213,11 @@ namespace ENI2.DetailViewControls
if (atd == null)
{
- atd = new ATD();
- atd.MessageCore = this.Core;
- atd.MessageHeader = this._atdMessage;
+ atd = new ATD
+ {
+ MessageCore = this.Core,
+ MessageHeader = this._atdMessage
+ };
_atdMessage.Elements.Add(atd);
}
@@ -225,9 +243,11 @@ namespace ENI2.DetailViewControls
if (noa_nod == null)
{
- noa_nod = new NOA_NOD();
- noa_nod.MessageCore = this.Core;
- noa_nod.MessageHeader = this._noanodMessage;
+ noa_nod = new NOA_NOD
+ {
+ MessageCore = this.Core,
+ MessageHeader = this._noanodMessage
+ };
_noanodMessage.Elements.Add(noa_nod);
}
@@ -388,10 +408,12 @@ namespace ENI2.DetailViewControls
this.labelBSMDStatusInternal.DataContext = null;
this.labelBSMDStatusInternal.DataContext = this.Core;
- this.labelBSMDStatusInternal.GetBindingExpression(Label.ContentProperty)?.UpdateTarget();
+ this.labelBSMDStatusInternal.GetBindingExpression(Label.ContentProperty)?.UpdateTarget();
//MessageBox.Show(string.Format("Visit/Transit ID updated: {0}", this.Core.DisplayId));
- ShowIdDialog sid = new ShowIdDialog();
- sid.DisplayId = this.Core.DisplayId;
+ ShowIdDialog sid = new ShowIdDialog
+ {
+ DisplayId = this.Core.DisplayId
+ };
sid.Show();
this.Core.IsDirty = false; // ist ja schon gespeichert..
}
@@ -419,8 +441,7 @@ namespace ENI2.DetailViewControls
{
if (sender != null)
{
- DataGrid grid = sender as DataGrid;
- if ((grid != null) && (grid.SelectedItems != null) && (grid.SelectedItems.Count == 1))
+ if ((sender is DataGrid grid) && (grid.SelectedItems?.Count == 1))
{
DataGridRow dgr = grid.ItemContainerGenerator.ContainerFromItem(grid.SelectedItem) as DataGridRow;
Message selectedMessage = grid.SelectedItem as Message;
@@ -492,8 +513,19 @@ namespace ENI2.DetailViewControls
MessageBoxResult result = MessageBox.Show(Properties.Resources.textConfirmReset, Properties.Resources.textConfirm, MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
- foreach (Message selectedMessage in this.dataGridMessages.SelectedItems)
+ // Testen, ob der Reset an dasselbe HIS geht wie da wo die Meldung ursprünglich angelegt wurde
+ foreach(Message selectedMessage in this.dataGridMessages.SelectedItems)
{
+ if (selectedMessage.HIS != this.Core.InitialHIS)
+ {
+ string abortMsg = string.Format(Properties.Resources.textMessageHisNotMatching, selectedMessage.HIS, selectedMessage.MessageNotificationClassDisplay, this.Core.InitialHIS);
+ MessageBox.Show(abortMsg, Properties.Resources.textErrorMessage, MessageBoxButton.OK, MessageBoxImage.Exclamation);
+ return;
+ }
+ }
+
+ foreach (Message selectedMessage in this.dataGridMessages.SelectedItems)
+ {
selectedMessage.Reset = true;
selectedMessage.InternalStatus = Message.BSMDStatus.TOSEND;
selectedMessage.StatusInfo = string.Format(Properties.Resources.textMessageResetAt, DateTime.Now);
@@ -517,6 +549,14 @@ namespace ENI2.DetailViewControls
}
else
{
+ if(this.Core.InitialHIS != _message.HIS)
+ {
+ MessageBoxResult noMatchResult = MessageBox.Show(Properties.Resources.textHISNotMatching, Properties.Resources.textConfirm,
+ MessageBoxButton.OK, MessageBoxImage.Exclamation);
+ // todo: Hier den "Egal!" Fall berücksichtigen?
+ return;
+ }
+
MessageBoxResult result = MessageBox.Show(Properties.Resources.textConfirmCancel, Properties.Resources.textConfirm, MessageBoxButton.YesNo, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
@@ -575,10 +615,7 @@ namespace ENI2.DetailViewControls
if (elapsedSec < Properties.Settings.Default.RequestTimeout)
{
// not yet.. (calling ui thread async)
- this.Dispatcher.BeginInvoke(new Action(() =>
- {
- this.labelBusyTimeElapsed.Content = string.Format(Properties.Resources.textSecondsElapsed, elapsedSec.ToString("N0"));
- }));
+ this.Dispatcher.BeginInvoke(new Action(() => this.labelBusyTimeElapsed.Content = string.Format(Properties.Resources.textSecondsElapsed, elapsedSec.ToString("N0"))));
}
else
{
@@ -597,9 +634,11 @@ namespace ENI2.DetailViewControls
this.Dispatcher.BeginInvoke(new Action(() =>
{
MessageCore reloadedCore = DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).GetMessageCoreById(this.Core.Id.Value);
- CoreStatusInfoDialog csid = new CoreStatusInfoDialog();
- csid.IsModal = false;
- csid.Core = reloadedCore;
+ CoreStatusInfoDialog csid = new CoreStatusInfoDialog
+ {
+ IsModal = false,
+ Core = reloadedCore
+ };
csid.Show();
this.busyIndicator.IsBusy = false;
this.OnRequestReload();
@@ -617,17 +656,16 @@ namespace ENI2.DetailViewControls
{
// reload Core and all message classes
// container class needs to dismiss all created controls
- this.Dispatcher.BeginInvoke(new Action(() =>
- {
- this.OnRequestReload();
- }));
+ this.Dispatcher.BeginInvoke(new Action(() => this.OnRequestReload()));
}
private void buttonInfoCore_Click(object sender, RoutedEventArgs e)
{
- SimplePropertyViewDialog spvd = new SimplePropertyViewDialog();
- spvd.IsModal = false;
- spvd.DisplayObject = this.Core;
+ SimplePropertyViewDialog spvd = new SimplePropertyViewDialog
+ {
+ IsModal = false,
+ DisplayObject = this.Core
+ };
spvd.Show();
//CoreStatusInfoDialog csid = new CoreStatusInfoDialog();
@@ -642,8 +680,10 @@ namespace ENI2.DetailViewControls
if (this.dataGridMessages.SelectedItems.Count > 0)
{
Message selectedMessage = this.dataGridMessages.SelectedItems[0] as Message;
- ErrorListDialog eld = new ErrorListDialog();
- eld.Errors = selectedMessage.ErrorList;
+ ErrorListDialog eld = new ErrorListDialog
+ {
+ Errors = selectedMessage.ErrorList
+ };
eld.ShowDialog();
}
}
@@ -653,8 +693,10 @@ namespace ENI2.DetailViewControls
if (this.dataGridMessages.SelectedItems.Count > 0)
{
Message selectedMessage = this.dataGridMessages.SelectedItems[0] as Message;
- ViolationListDialog vld = new ViolationListDialog();
- vld.Violations = selectedMessage.ViolationList;
+ ViolationListDialog vld = new ViolationListDialog
+ {
+ Violations = selectedMessage.ViolationList
+ };
vld.ShowDialog();
}
}
@@ -707,8 +749,10 @@ namespace ENI2.DetailViewControls
if (this.dataGridMessages.SelectedItems.Count > 0)
{
Message selectedMessage = this.dataGridMessages.SelectedItems[0] as Message;
- SystemErrorDialog sed = new SystemErrorDialog();
- sed.SystemErrors = selectedMessage.SystemErrorList;
+ SystemErrorDialog sed = new SystemErrorDialog
+ {
+ SystemErrors = selectedMessage.SystemErrorList
+ };
sed.ShowDialog();
}
}
diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/SecurityDetailControl.xaml b/ENI-2/ENI2/ENI2/DetailViewControls/SecurityDetailControl.xaml
index 19919dba..7f25fba1 100644
--- a/ENI-2/ENI2/ENI2/DetailViewControls/SecurityDetailControl.xaml
+++ b/ENI-2/ENI2/ENI2/DetailViewControls/SecurityDetailControl.xaml
@@ -149,7 +149,7 @@
+ AutoGenerateColumns="False" Margin="0,5,0,0">
diff --git a/ENI-2/ENI2/ENI2/ENI2.csproj b/ENI-2/ENI2/ENI2/ENI2.csproj
index 86d5d534..e71de3c5 100644
--- a/ENI-2/ENI2/ENI2/ENI2.csproj
+++ b/ENI-2/ENI2/ENI2/ENI2.csproj
@@ -35,8 +35,8 @@
3.5.1.0
true
publish.html
- 1
- 5.0.11.%2a
+ 0
+ 5.0.12.%2a
false
true
true
@@ -52,6 +52,7 @@
prompt
4
false
+ ..\..\..\..\mtc\puls200.frame\frame.ruleset
AnyCPU
diff --git a/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs b/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs
index 5628a530..9bb85110 100644
--- a/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs
+++ b/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs
@@ -2195,6 +2195,15 @@ namespace ENI2.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to You must select the same HIS where this message / declaration was first created.
+ ///
+ public static string textHISNotMatching {
+ get {
+ return ResourceManager.GetString("textHISNotMatching", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to IBC item.
///
@@ -2870,6 +2879,15 @@ namespace ENI2.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to HIS {0} of message {1} and current target {2} do not match: Reset aborted.
+ ///
+ public static string textMessageHisNotMatching {
+ get {
+ return ResourceManager.GetString("textMessageHisNotMatching", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Message reset at {0}.
///
diff --git a/ENI-2/ENI2/ENI2/Properties/Resources.resx b/ENI-2/ENI2/ENI2/Properties/Resources.resx
index 82b0624e..a2557a61 100644
--- a/ENI-2/ENI2/ENI2/Properties/Resources.resx
+++ b/ENI-2/ENI2/ENI2/Properties/Resources.resx
@@ -1651,4 +1651,10 @@
{0} waste positions imported
+
+ You must select the same HIS where this message / declaration was first created
+
+
+ HIS {0} of message {1} and current target {2} do not match: Reset aborted
+
\ No newline at end of file
diff --git a/Stundensheet.xlsx b/Stundensheet.xlsx
index 554027a3..afa637b8 100644
Binary files a/Stundensheet.xlsx and b/Stundensheet.xlsx differ
diff --git a/nsw/Source/bsmd.ExcelReadService/ExcelReadService.cs b/nsw/Source/bsmd.ExcelReadService/ExcelReadService.cs
index 8a1a15a3..d1893e97 100644
--- a/nsw/Source/bsmd.ExcelReadService/ExcelReadService.cs
+++ b/nsw/Source/bsmd.ExcelReadService/ExcelReadService.cs
@@ -11,15 +11,14 @@ using System.IO;
using System.ServiceProcess;
using System.Timers;
-
namespace bsmd.ExcelReadService
{
public partial class ExcelReadService : ServiceBase
{
private Timer _timer;
- private object _timerlock = new object();
+ private readonly object _timerlock = new object();
private bool processRunning = false;
- private ILog _log = LogManager.GetLogger(typeof(ExcelReadService));
+ private readonly ILog _log = LogManager.GetLogger(typeof(ExcelReadService));
public ExcelReadService()
{
@@ -43,8 +42,10 @@ namespace bsmd.ExcelReadService
private void Init(string[] args)
{
- this._timer = new Timer();
- this._timer.Interval = Properties.Settings.Default.SleepSeconds * 1000;
+ this._timer = new Timer
+ {
+ Interval = Properties.Settings.Default.SleepSeconds * 1000
+ };
this._timer.Elapsed += _timer_Elapsed;
this._timer.Enabled = true;
}
@@ -65,7 +66,7 @@ namespace bsmd.ExcelReadService
string messageId = "";
string attachmentLocalPath = null;
string mailSender = "";
- string receiptSubject = "NSW Sheet Service Status INFO";
+ const string receiptSubject = "NSW Sheet Service Status INFO";
string mailSubject = "";
Dictionary reportingPartyDict = DBManager.Instance.GetReportingPartyDict();
@@ -130,8 +131,10 @@ namespace bsmd.ExcelReadService
{
try
{
- ImportHeader importHeader = new ImportHeader();
- importHeader.ImportDate = DateTime.Now;
+ ImportHeader importHeader = new ImportHeader
+ {
+ ImportDate = DateTime.Now
+ };
readResult = Util.ProcessSheet(reader, out readMessage, out messageCore);
if (readResult)
{
diff --git a/nsw/Source/bsmd.ExcelReadService/Util.cs b/nsw/Source/bsmd.ExcelReadService/Util.cs
index 20f0e24c..ab785c65 100644
--- a/nsw/Source/bsmd.ExcelReadService/Util.cs
+++ b/nsw/Source/bsmd.ExcelReadService/Util.cs
@@ -1112,13 +1112,16 @@ namespace bsmd.ExcelReadService
{
while (stat.ISMCompanyId.Length < 7)
stat.ISMCompanyId = "0" + stat.ISMCompanyId;
- }
+ }
string transportMode = reader.ReadText("STAT.TransportMode");
if(transportMode != null)
{
if (transportMode.Contains("maritime", StringComparison.OrdinalIgnoreCase)) stat.TransportMode = "1";
+ if (transportMode.Equals("1")) stat.TransportMode = transportMode;
+
if (transportMode.Contains("inland", StringComparison.OrdinalIgnoreCase)) stat.TransportMode = "8";
+ if (transportMode.Equals("8")) stat.TransportMode = transportMode;
}
reader.Conf.ConfirmText("STAT.TransportMode", transportMode, stat.TransportMode.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK);
diff --git a/nsw/Source/bsmd.LockingService/bsmd.LockingService.csproj b/nsw/Source/bsmd.LockingService/bsmd.LockingService.csproj
index 9f2f5339..3d606baf 100644
--- a/nsw/Source/bsmd.LockingService/bsmd.LockingService.csproj
+++ b/nsw/Source/bsmd.LockingService/bsmd.LockingService.csproj
@@ -22,6 +22,7 @@
+
true
@@ -33,6 +34,7 @@
4
true
false
+ ..\..\..\..\mtc\puls200.frame\frame.ruleset
pdbonly
diff --git a/nsw/Source/bsmd.LockingService/bsmd.LockingService.csproj.user b/nsw/Source/bsmd.LockingService/bsmd.LockingService.csproj.user
index 09edda29..afa33dd1 100644
--- a/nsw/Source/bsmd.LockingService/bsmd.LockingService.csproj.user
+++ b/nsw/Source/bsmd.LockingService/bsmd.LockingService.csproj.user
@@ -3,6 +3,12 @@
true
Debug|Any CPU
+
+
+
+
+
+
diff --git a/nsw/Source/bsmd.database/WAS.cs b/nsw/Source/bsmd.database/WAS.cs
index 17db380c..90dec340 100644
--- a/nsw/Source/bsmd.database/WAS.cs
+++ b/nsw/Source/bsmd.database/WAS.cs
@@ -22,11 +22,6 @@ namespace bsmd.database
private ObservableCollection waste = new ObservableCollection();
- private static readonly int[] dkWasteCodes = { 1100, 1200, 1300, 2100, 2200, 2300, 2311, 2308, 2600, 2300, 2309, 3000, 5100, 5200, 5300, 2300 };
- private static readonly int[] requiredCodes = { 1100, 1200, 1300, 2100, 2200, 2300, 2311, 2308, 2600, 2309, 3000, 5100, 5200, 5300 };
- private static readonly string[] dkWasteTypes = { "Waste oils - Sludge", "Waste oils - Bilge water", "Waste oils - Other", "Garbage - Food waste", "Garbage - Plastic", "Garbage - Other", "Garbage - Other - Cooking oil", "Garbage - Other - Incinerator ashes and clinkers", "Operational wastes", "Garbage - Other", "Garbage - Other - Animal carcasses", "Sewage", "Cargo residues - Marpol Annex I - Other", "Cargo residues - Marpol Annex II - Other", "Cargo residues - Marpol Annex V - Other", "Garbage - Other" };
- private static readonly string[] requiredTypes = { "Oily Residues (sludge)", "Oily Bilge Water", "Waste oil - others (specify)", "Food waste", "Plastics", "Domestic wastes", "Cooking oil", "Incinerator ashes", "Operational wastes", "Animal carcass(es)", "Sewage", "Cargo residues - Marpol Annex I", "Cargo residues - Marpol Annex II", "Cargo residues - Marpol Annex V" };
-
public WAS()
{
this.tablename = "[dbo].[WAS]";
@@ -35,13 +30,13 @@ namespace bsmd.database
#region Properties
- public static int[] DKWasteCodes { get { return dkWasteCodes; } }
+ public static int[] DKWasteCodes { get; } = { 1100, 1200, 1300, 2100, 2200, 2300, 2311, 2308, 2600, 2300, 2309, 3000, 5100, 5200, 5300, 2300 };
- public static string[] DKWasteTypes { get { return dkWasteTypes; } }
+ public static string[] DKWasteTypes { get; } = { "Waste oils - Sludge", "Waste oils - Bilge water", "Waste oils - Other", "Garbage - Food waste", "Garbage - Plastic", "Garbage - Other", "Garbage - Other - Cooking oil", "Garbage - Other - Incinerator ashes and clinkers", "Operational wastes", "Garbage - Other", "Garbage - Other - Animal carcasses", "Sewage", "Cargo residues - Marpol Annex I - Other", "Cargo residues - Marpol Annex II - Other", "Cargo residues - Marpol Annex V - Other", "Garbage - Other" };
- public static int[] RequiredCodes { get { return requiredCodes; } }
+ public static int[] RequiredCodes { get; } = { 1100, 1200, 1300, 2100, 2200, 2300, 2311, 2308, 2600, 2309, 3000, 5100, 5200, 5300 };
- public static string[] RequiredTypes { get { return requiredTypes; } }
+ public static string[] RequiredTypes { get; } = { "Oily Residues (sludge)", "Oily Bilge Water", "Waste oil - others (specify)", "Food waste", "Plastics", "Domestic wastes", "Cooking oil", "Incinerator ashes", "Operational wastes", "Animal carcass(es)", "Sewage", "Cargo residues - Marpol Annex I", "Cargo residues - Marpol Annex II", "Cargo residues - Marpol Annex V" };
[ShowReport]
[ENI2Validation]
@@ -131,9 +126,11 @@ namespace bsmd.database
}
else
{
- WasteDisposalServiceProvider newWDSP = new WasteDisposalServiceProvider();
- newWDSP.WAS = this;
- newWDSP.WasteDisposalServiceProviderName = serviceProviderName;
+ WasteDisposalServiceProvider newWDSP = new WasteDisposalServiceProvider
+ {
+ WAS = this,
+ WasteDisposalServiceProviderName = serviceProviderName
+ };
foundList.Add(newWDSP);
}
}
@@ -178,7 +175,7 @@ namespace bsmd.database
}
else
{
- scmd.Parameters.AddWithValue(@"ID", this.Id);
+ scmd.Parameters.AddWithValue("ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET WasteDisposalValidExemption = @P2, LastWasteDisposalPort = @P3, " +
"ConfirmationOfCorrectness = @P4, LastWasteDisposalDate = @P5, WasteDisposalDelivery = @P6, ConfirmationOfSufficiency = @P7 " +
"WHERE Id = @ID", this.Tablename);
@@ -212,9 +209,11 @@ namespace bsmd.database
while (reader.Read())
{
- WAS was = new WAS();
+ WAS was = new WAS
+ {
+ id = reader.GetGuid(0)
+ };
- was.id = reader.GetGuid(0);
if (!reader.IsDBNull(1)) was.WasteDisposalValidExemption = reader.GetBoolean(1);
if (!reader.IsDBNull(2)) was.LastWasteDisposalPort = reader.GetString(2);
if (!reader.IsDBNull(3)) was.ConfirmationOfCorrectness = reader.GetBoolean(3);
@@ -326,7 +325,7 @@ namespace bsmd.database
bool entryMissing = false;
int missingType = 0;
- foreach(int wasteCode in requiredCodes)
+ foreach(int wasteCode in RequiredCodes)
{
bool codeFound = false;
foreach(Waste w in this.Waste)
@@ -375,16 +374,18 @@ namespace bsmd.database
}
if (!wasteTypeFound)
{
- Waste newWaste = new Waste();
- newWaste.WasteType = wType;
- newWaste.WasteAmountGeneratedTillNextPort_MTQ = 0;
- newWaste.WasteAmountRetained_MTQ = 0;
- newWaste.WasteCapacity_MTQ = 0;
- newWaste.WasteDisposalAmount_MTQ = 0;
- newWaste.Identifier = "";
- newWaste.WasteDisposalPort = "ZZUKN";
- newWaste.WasteDescription = "-";
- newWaste.WAS = this;
+ Waste newWaste = new Waste
+ {
+ WasteType = wType,
+ WasteAmountGeneratedTillNextPort_MTQ = 0,
+ WasteAmountRetained_MTQ = 0,
+ WasteCapacity_MTQ = 0,
+ WasteDisposalAmount_MTQ = 0,
+ Identifier = "",
+ WasteDisposalPort = "ZZUKN",
+ WasteDescription = "-",
+ WAS = this
+ };
this.Waste.Add(newWaste);
result.Add(newWaste);
}
@@ -399,7 +400,7 @@ namespace bsmd.database
public void AddMissingWaste()
{
- foreach (int wasteCode in WAS.requiredCodes)
+ foreach (int wasteCode in WAS.RequiredCodes)
{
Waste foundWaste = null;
foreach (Waste waste in this.Waste)
@@ -412,17 +413,19 @@ namespace bsmd.database
}
if (foundWaste == null)
{
- Waste newWaste = new Waste();
- newWaste.Identifier = DatabaseEntity.GetNewIdentifier(this.Waste);
- newWaste.WAS = this;
- newWaste.WasteAmountGeneratedTillNextPort_MTQ = 0;
- newWaste.WasteAmountRetained_MTQ = 0;
- newWaste.WasteCapacity_MTQ = 0;
- newWaste.WasteDescription = (wasteCode == 1300) ? "-" : "";
- newWaste.WasteDisposalAmount_MTQ = 0;
- newWaste.WasteDisposalPort = "ZZUKN";
- newWaste.WasteDisposedAtLastPort_MTQ = 0;
- newWaste.WasteType = wasteCode;
+ Waste newWaste = new Waste
+ {
+ Identifier = DatabaseEntity.GetNewIdentifier(this.Waste),
+ WAS = this,
+ WasteAmountGeneratedTillNextPort_MTQ = 0,
+ WasteAmountRetained_MTQ = 0,
+ WasteCapacity_MTQ = 0,
+ WasteDescription = (wasteCode == 1300) ? "-" : "",
+ WasteDisposalAmount_MTQ = 0,
+ WasteDisposalPort = "ZZUKN",
+ WasteDisposedAtLastPort_MTQ = 0,
+ WasteType = wasteCode
+ };
this.Waste.Add(newWaste);
}
else
diff --git a/nsw/Source/bsmd.database/bsmd.database.csproj b/nsw/Source/bsmd.database/bsmd.database.csproj
index 887f2b8e..e32e1790 100644
--- a/nsw/Source/bsmd.database/bsmd.database.csproj
+++ b/nsw/Source/bsmd.database/bsmd.database.csproj
@@ -23,6 +23,7 @@
prompt
4
false
+ ..\..\..\..\mtc\puls200.frame\frame.ruleset
pdbonly