diff --git a/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml.cs b/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml.cs index 23315ba9..a4a83408 100644 --- a/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/Controls/LocodeControl.xaml.cs @@ -58,7 +58,7 @@ namespace ENI2.Controls case RuleEngine.LocodeMode.STANDARD: portName = LocodeDB.PortNameFromLocode(value); break; case RuleEngine.LocodeMode.SSN: - portName = LocalizedLookup.SSNPortNameFromLocode(value); break; + portName = LocodeDB.SSNPortNameFromLocode(value); break; } LocodeState locodeState = portName.IsNullOrEmpty() ? LocodeState.INVALID : LocodeState.OK; this.SetLocodeStateImage(this.imageLocodeState, locodeState); @@ -143,7 +143,7 @@ namespace ENI2.Controls case RuleEngine.LocodeMode.STANDARD: portname = LocodeDB.PortNameFromLocode(directLocode); break; case RuleEngine.LocodeMode.SSN: - portname = LocalizedLookup.SSNPortNameFromLocode(directLocode); break; + portname = LocodeDB.SSNPortNameFromLocode(directLocode); break; } bool isLocode = !portname.IsNullOrEmpty(); diff --git a/ENI-2/ENI2/ENI2/LocalizedLookup.cs b/ENI-2/ENI2/ENI2/LocalizedLookup.cs index 37ddc170..a3253ab1 100644 --- a/ENI-2/ENI2/ENI2/LocalizedLookup.cs +++ b/ENI-2/ENI2/ENI2/LocalizedLookup.cs @@ -214,27 +214,7 @@ namespace ENI2 } reader.Close(); return result; - } - - public static string SSNPortNameFromLocode(string locode) - { - if (locode.IsNullOrEmpty()) return null; - if (locode.Length != 5) return null; - - string result = null; - string query = string.Format("SELECT LocationName FROM SSN_LOCODES WHERE LocationCode = '{0}'", locode); - - SQLiteCommand cmd = new SQLiteCommand(query, _con); - IDataReader reader = cmd.ExecuteReader(); - while (reader.Read()) - { - if (!reader.IsDBNull(0)) - result = reader.GetString(0); - break; - } - reader.Close(); - return result; - } + } public static List SSNAllLocodesForCityNameAsEntries(string city) { diff --git a/ENI-2/ENI2/ENI2/Util/GlobalStructures.cs b/ENI-2/ENI2/ENI2/Util/GlobalStructures.cs index 73e01eff..26984a1e 100644 --- a/ENI-2/ENI2/ENI2/Util/GlobalStructures.cs +++ b/ENI-2/ENI2/ENI2/Util/GlobalStructures.cs @@ -206,7 +206,7 @@ namespace ENI2.Util case RuleEngine.LocodeMode.NO_PORT_FLAG: return !LocodeDB.LocationNameFromLocode(locode).IsNullOrEmpty(); case RuleEngine.LocodeMode.SSN: - return !LocalizedLookup.SSNPortNameFromLocode(locode).IsNullOrEmpty(); + return !LocodeDB.SSNPortNameFromLocode(locode).IsNullOrEmpty(); default: return !LocodeDB.PortNameFromLocode(locode).IsNullOrEmpty(); } diff --git a/Stundensheet.xlsx b/Stundensheet.xlsx index d70f5d02..d9c2567f 100644 Binary files a/Stundensheet.xlsx and b/Stundensheet.xlsx differ diff --git a/nsw/Source/SendNSWMessageService/SendNSWMessageService.csproj b/nsw/Source/SendNSWMessageService/SendNSWMessageService.csproj index 72dac250..33d9864a 100644 --- a/nsw/Source/SendNSWMessageService/SendNSWMessageService.csproj +++ b/nsw/Source/SendNSWMessageService/SendNSWMessageService.csproj @@ -21,6 +21,7 @@ DEBUG;TRACE prompt 4 + ..\..\..\..\mtc\puls200.frame\frame.ruleset AnyCPU diff --git a/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs b/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs index dacb021f..333581ab 100644 --- a/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs +++ b/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs @@ -21,12 +21,10 @@ using bsmd.database; namespace bsmd.ExcelReadService { internal class ExcelReader : ExcelBase - { - private Dictionary stringVals = new Dictionary(); + { + internal enum ReadState { NONE, OK, WARN, FAIL }; - internal enum ReadState { NONE, OK, WARN, FAIL }; - - internal Dictionary ImportValues { get { return this.stringVals; } } + internal Dictionary ImportValues { get; } = new Dictionary(); public ExcelReader(string filePath) { @@ -129,7 +127,7 @@ namespace bsmd.ExcelReadService if (result != null) { result = result.Trim(); - this.stringVals[lookup] = result; + this.ImportValues[lookup] = result; } return result; @@ -147,6 +145,7 @@ namespace bsmd.ExcelReadService string val = this.ReadText(lookup); if(!val.IsNullOrEmpty()) { + val = val.ToUpper(); string portName = LocodeDB.PortNameFromLocode(val); if(portName == null) { @@ -292,9 +291,9 @@ namespace bsmd.ExcelReadService if(val != null) { - if (val.IndexOf("load", StringComparison.OrdinalIgnoreCase) >= 0) result = 0; - if (val.IndexOf("discharge", StringComparison.OrdinalIgnoreCase) >= 0) result = 1; - if (val.IndexOf("transit", StringComparison.OrdinalIgnoreCase) >= 0) result = 2; + if ((val.IndexOf("load", StringComparison.OrdinalIgnoreCase) >= 0) || val.Equals("1")) result = 0; + if ((val.IndexOf("discharge", StringComparison.OrdinalIgnoreCase) >= 0) || val.Equals("2")) result = 1; + if ((val.IndexOf("transit", StringComparison.OrdinalIgnoreCase) >= 0) || val.Equals("3")) result = 2; if (result == null) this.Conf.ConfirmText(lookup, val, ReadState.WARN); else @@ -422,9 +421,9 @@ namespace bsmd.ExcelReadService if (val != null) { - if (val.IndexOf("all", StringComparison.OrdinalIgnoreCase) >= 0) result = 0; - if (val.IndexOf("some", StringComparison.OrdinalIgnoreCase) >= 0) result = 1; - if (val.IndexOf("none", StringComparison.OrdinalIgnoreCase) >= 0) result = 2; + if ((val.IndexOf("all", StringComparison.OrdinalIgnoreCase) >= 0) || val.Equals("1")) result = 0; + if ((val.IndexOf("some", StringComparison.OrdinalIgnoreCase) >= 0) || val.Equals("2")) result = 1; + if ((val.IndexOf("none", StringComparison.OrdinalIgnoreCase) >= 0) || val.Equals("3")) result = 2; if (result == null) this.Conf.ConfirmText(lookup, val, ReadState.WARN); else @@ -473,7 +472,7 @@ namespace bsmd.ExcelReadService { CultureInfo provider = CultureInfo.InvariantCulture; string dateString = val.ToString(); - string format = "yyyyMMdd"; + const string format = "yyyyMMdd"; if (DateTime.TryParseExact(dateString, format, provider, DateTimeStyles.None, out DateTime tmpDate)) date = tmpDate; } @@ -562,7 +561,7 @@ namespace bsmd.ExcelReadService string dateString = val.ToString(); if (!dateString.Contains(":")) { - string format = "HHmm"; + const string format = "HHmm"; if (DateTime.TryParseExact(dateString, format, provider, DateTimeStyles.None, out DateTime tmpDate)) result = tmpDate; } diff --git a/nsw/Source/bsmd.ExcelReadService/LocodeDB.cs b/nsw/Source/bsmd.ExcelReadService/LocodeDB.cs index fcbf524f..a39fece0 100644 --- a/nsw/Source/bsmd.ExcelReadService/LocodeDB.cs +++ b/nsw/Source/bsmd.ExcelReadService/LocodeDB.cs @@ -162,6 +162,30 @@ namespace bsmd.ExcelReadService return result; } + /// + /// SSN Portname from Locode (for validation) + /// + public static string SSNPortNameFromLocode(string locode) + { + if (locode.IsNullOrEmpty()) return null; + if (locode.Length != 5) return null; + + string result = null; + string query = string.Format("SELECT LocationName FROM SSN_LOCODES WHERE LocationCode = '{0}'", locode); + + SQLiteCommand cmd = new SQLiteCommand(query, _con); + IDataReader reader = cmd.ExecuteReader(); + while (reader.Read()) + { + if (!reader.IsDBNull(0)) + result = reader.GetString(0); + break; + } + reader.Close(); + return result; + } + + /// /// Get Locationname from LOCODE /// diff --git a/nsw/Source/bsmd.ExcelReadService/Util.cs b/nsw/Source/bsmd.ExcelReadService/Util.cs index 7143fd90..51512b41 100644 --- a/nsw/Source/bsmd.ExcelReadService/Util.cs +++ b/nsw/Source/bsmd.ExcelReadService/Util.cs @@ -147,7 +147,7 @@ namespace bsmd.ExcelReadService #region ATA - static void ScanATA(List messages, MessageCore messageCore, ExcelReader reader) + private static void ScanATA(List messages, MessageCore messageCore, ExcelReader reader) { Message ataMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.ATA); if (ataMessage.Elements.Count == 0) @@ -172,7 +172,7 @@ namespace bsmd.ExcelReadService #region ATD - static void ScanATD(List messages, MessageCore messageCore, ExcelReader reader) + private static void ScanATD(List messages, MessageCore messageCore, ExcelReader reader) { Message atdMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.ATD); if (atdMessage.Elements.Count == 0) @@ -197,7 +197,7 @@ namespace bsmd.ExcelReadService #region TIEFA - static void ScanTIEFA(List messages, MessageCore messageCore, ExcelReader reader) + private static void ScanTIEFA(List messages, MessageCore messageCore, ExcelReader reader) { Message tiefaMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.TIEFA); if (tiefaMessage.Elements.Count == 0) @@ -297,8 +297,7 @@ namespace bsmd.ExcelReadService if (!bpolNameValue.IsNullOrEmpty() || !bpolLocodeValue.IsNullOrEmpty()) { - PortOfItinerary poi = bpol.GetSublistElementWithIdentifier(i.ToString()) as PortOfItinerary; - if (poi == null) + if (!(bpol.GetSublistElementWithIdentifier(i.ToString()) is PortOfItinerary poi)) { poi = new PortOfItinerary(); poi.BPOL = bpol; @@ -1098,7 +1097,7 @@ namespace bsmd.ExcelReadService reader.Conf.ConfirmText("STAT.MMSINumber", stat.MMSINumber, (stat.MMSINumber.IsNullOrEmpty() || (stat.MMSINumber.Length != 9)) ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK); stat.CallSign = reader.ReadTextNoWhitespace("STAT.CallSign"); - reader.Conf.ConfirmText("STAT.CallSign", stat.CallSign, (stat.CallSign.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK)); + reader.Conf.ConfirmText("STAT.CallSign", stat.CallSign, stat.CallSign.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK); stat.ISMCompanyId = reader.ReadTextNoWhitespace("STAT.ISMCompanyId"); @@ -1220,14 +1219,19 @@ namespace bsmd.ExcelReadService reader.Conf.ConfirmText("NOA_NOD.LastPort", lastPort, noa_nod.LastPort.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK); string nextPort = reader.ReadText("NOA_NOD.NextPort"); + bool? isValidSSNPort = false; if (!nextPort.IsNullOrEmpty()) { noa_nod.NextPort = nextPort.Trim(); if (noa_nod.NextPort.Length > 5) noa_nod.NextPort = noa_nod.NextPort.Substring(0, 5); //trunc - } + isValidSSNPort = !LocodeDB.SSNPortNameFromLocode(noa_nod.NextPort).IsNullOrEmpty(); + } - reader.Conf.ConfirmText("NOA_NOD.NextPort", nextPort, noa_nod.NextPort.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK); + if(!isValidSSNPort.HasValue) + reader.Conf.ConfirmText("NOA_NOD.NextPort", nextPort, ExcelReader.ReadState.WARN); + else + reader.Conf.ConfirmText("NOA_NOD.NextPort", nextPort, isValidSSNPort.Value ? ExcelReader.ReadState.OK : ExcelReader.ReadState.FAIL); if(messageCore.IsTransit) { @@ -1248,7 +1252,7 @@ namespace bsmd.ExcelReadService noa_nod.ETDFromLastPort = reader.ReadDateTime("NOA_NOD.ETDDateFromLastPort", "NOA_NOD.ETDTimeFromLastPort"); noa_nod.ETAToNextPort = reader.ReadDateTime("NOA_NOD.ETADateToNextPort", "NOA_NOD.ETATimeToNextPort"); // DK - noa_nod.IsAnchored = reader.ReadBoolean("NOA_NOD.IsAnchored", (reader.Mode == ExcelReader.CountryMode.DE)); + noa_nod.IsAnchored = reader.ReadBoolean("NOA_NOD.IsAnchored", reader.Mode == ExcelReader.CountryMode.DE); } @@ -1728,9 +1732,9 @@ namespace bsmd.ExcelReadService string isscType = reader.ReadText("SEC.ISSCType"); if(isscType != null) { - if (isscType.Equals("full", StringComparison.OrdinalIgnoreCase)) + if (isscType.Equals("full", StringComparison.OrdinalIgnoreCase) || isscType.Equals("1")) sec.ISSCType = 0; - if (isscType.Equals("interim", StringComparison.OrdinalIgnoreCase)) + if (isscType.Equals("interim", StringComparison.OrdinalIgnoreCase) || isscType.Equals("2")) sec.ISSCType = 1; } @@ -1752,9 +1756,9 @@ namespace bsmd.ExcelReadService string isscIssuerType = reader.ReadText("SEC.ISSCIssuerType"); if(isscIssuerType != null) { - if (isscIssuerType.Equals("rso", StringComparison.OrdinalIgnoreCase)) + if (isscIssuerType.Equals("rso", StringComparison.OrdinalIgnoreCase) || isscIssuerType.Equals("2")) sec.ISSCIssuerType = 1; - if (isscIssuerType.Contains("admin", StringComparison.OrdinalIgnoreCase)) + if (isscIssuerType.Contains("admin", StringComparison.OrdinalIgnoreCase) || isscIssuerType.Equals("1")) sec.ISSCIssuerType = 0; } diff --git a/nsw/Source/bsmd.dakosy/bsmd.dakosy.csproj b/nsw/Source/bsmd.dakosy/bsmd.dakosy.csproj index dae872b1..9f568b04 100644 --- a/nsw/Source/bsmd.dakosy/bsmd.dakosy.csproj +++ b/nsw/Source/bsmd.dakosy/bsmd.dakosy.csproj @@ -20,6 +20,7 @@ DEBUG;TRACE prompt 4 + ..\..\..\..\mtc\puls200.frame\frame.ruleset pdbonly diff --git a/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs b/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs index f4455e15..427dad81 100644 --- a/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs +++ b/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs @@ -2,6 +2,6 @@ [assembly: AssemblyCompany("schick Informatik")] [assembly: AssemblyProduct("BSMD NSW interface")] -[assembly: AssemblyInformationalVersion("5.1.2")] +[assembly: AssemblyInformationalVersion("5.1.3")] [assembly: AssemblyCopyright("Copyright © 2014-2018 schick Informatik")] [assembly: AssemblyTrademark("")] \ No newline at end of file diff --git a/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs b/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs index f7afc150..c3fff841 100644 --- a/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs +++ b/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs @@ -1,4 +1,4 @@ using System.Reflection; -[assembly: AssemblyVersion("5.1.2.*")] +[assembly: AssemblyVersion("5.1.3.*")] diff --git a/nsw/Source/bsmd.database/RuleEngine.cs b/nsw/Source/bsmd.database/RuleEngine.cs index adbbbed4..ed67fa6f 100644 --- a/nsw/Source/bsmd.database/RuleEngine.cs +++ b/nsw/Source/bsmd.database/RuleEngine.cs @@ -401,7 +401,7 @@ namespace bsmd.database // individuelle Fehler nach Nachrichtenklasse prüfen derivedEntity.MessageCore = aMessage.MessageCore; // some instance we need info from core (NOA / Transit) if ((derivedEntity is LADG) && aMessage.MessageCore.IsTransit) continue; // kein error reporting für LADG bei Transit (CH, 1.2.16) - if ((derivedEntity is SEC) && aMessage.MessageCore.IsSmallShip) continue; // keine STAT Validierung für kleine Schiffe (CH, 1.11.18) + if ((derivedEntity is SEC) && aMessage.MessageCore.IsSmallShip) continue; // keine SEC Validierung für kleine Schiffe (CH, 1.11.18) RuleEngine.ValidateProperties(derivedEntity, errors, violations); derivedEntity.Validate(errors, violations); } diff --git a/nsw/Source/bsmd.database/SEC.cs b/nsw/Source/bsmd.database/SEC.cs index 533e33c5..615a443c 100644 --- a/nsw/Source/bsmd.database/SEC.cs +++ b/nsw/Source/bsmd.database/SEC.cs @@ -383,6 +383,11 @@ namespace bsmd.database L10Called.Validate(errors, violations); } + if(this.LastTenPortFacilitesCalled.Count != 10) + { + violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Number of last port facilities != 10", null, this.Title, null, this.Tablename)); + } + foreach (ShipToShipActivitiesDuringLastTenPortFacilitiesCalled s2s in this.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled) { RuleEngine.ValidateProperties(s2s, errors, violations); diff --git a/nsw/Source/bsmd.dbh/bsmd.dbh.csproj b/nsw/Source/bsmd.dbh/bsmd.dbh.csproj index 31cbde11..43316a89 100644 --- a/nsw/Source/bsmd.dbh/bsmd.dbh.csproj +++ b/nsw/Source/bsmd.dbh/bsmd.dbh.csproj @@ -20,6 +20,7 @@ DEBUG;TRACE prompt 4 + ..\..\..\..\mtc\puls200.frame\frame.ruleset pdbonly diff --git a/nsw/Source/bsmd.hisnord/Request.cs b/nsw/Source/bsmd.hisnord/Request.cs index b36aa0c3..8f9a957c 100644 --- a/nsw/Source/bsmd.hisnord/Request.cs +++ b/nsw/Source/bsmd.hisnord/Request.cs @@ -19,21 +19,17 @@ namespace bsmd.hisnord { public class Request { - private static ILog _log = LogManager.GetLogger(typeof(Request)); + private static readonly ILog _log = LogManager.GetLogger(typeof(Request)); private static Dictionary _reportingPartyDict = null; - private static Dictionary> coreFilenameDict = new Dictionary>(); - private static Dictionary coreUseTestDict = new Dictionary(); + private static readonly Dictionary> coreFilenameDict = new Dictionary>(); + private static readonly Dictionary coreUseTestDict = new Dictionary(); //private static Dictionary noteMessageDict = new Dictionary(); internal static Dictionary ReportingPartyDict { get { - if (_reportingPartyDict == null) - { - _reportingPartyDict = DBManager.Instance.GetReportingPartyDict(); - } - return _reportingPartyDict; + return _reportingPartyDict ?? (_reportingPartyDict = DBManager.Instance.GetReportingPartyDict()); } } @@ -105,8 +101,8 @@ namespace bsmd.hisnord return false; } - _nsw.conveyance.owner_sender.name_short = @"BSMD"; - _nsw.conveyance.owner_sender.name_long = @"BSMD";// rp.Name; // core.Customer.Name; + _nsw.conveyance.owner_sender.name_short = "BSMD"; + _nsw.conveyance.owner_sender.name_long = "BSMD";// rp.Name; // core.Customer.Name; _nsw.conveyance.owner_sender.address = new addresstype(); @@ -116,7 +112,7 @@ namespace bsmd.hisnord // das hier ist der e-mail(!) Empfänger für Error/Violation Meldungen _nsw.conveyance.owner_sender.contact = new contacts(); - _nsw.conveyance.owner_sender.contact.name = @"BSMD"; // rp.LastName; + _nsw.conveyance.owner_sender.contact.name = "BSMD"; // rp.LastName; _nsw.conveyance.owner_sender.contact.email = rp.EMail; _nsw.conveyance.owner_sender.contact.firstname = string.Format("{0} {1}", rp.FirstName, rp.LastName); _nsw.conveyance.owner_sender.contact.phone = rp.Phone; @@ -207,7 +203,7 @@ namespace bsmd.hisnord hn_stat.InmarsatCallNumbers.InmarsatCallNumber = callNumbers.ToArray(); } - if (!stat.ISMCompanyName.IsNullOrEmpty() || ((stat.GrossTonnage ?? 0) > 500)) // Vio. 821 + if (!stat.ISMCompanyName.IsNullOrEmpty() && ((stat.GrossTonnage ?? 0) >= 500)) // Vio. 821 { hn_stat.ISMCompany = new ismcompany(); if (!stat.ISMCompanyCity.IsNullOrEmpty()) @@ -1024,7 +1020,7 @@ namespace bsmd.hisnord List mdh_items = new List(); List mdh_types = new List(); - if (mdh.MDHSimplification.HasValue && mdh.MDHSimplification.Value) + if (mdh.MDHSimplification == true) { mdh_items.Add(ytype.Y); mdh_types.Add(ItemsChoiceType5.MDHSimplification); diff --git a/nsw/Source/bsmd.hisnord/bsmd.hisnord.csproj b/nsw/Source/bsmd.hisnord/bsmd.hisnord.csproj index 3f164053..bf96dbe8 100644 --- a/nsw/Source/bsmd.hisnord/bsmd.hisnord.csproj +++ b/nsw/Source/bsmd.hisnord/bsmd.hisnord.csproj @@ -20,6 +20,7 @@ DEBUG;TRACE prompt 4 + ..\..\..\..\mtc\puls200.frame\frame.ruleset pdbonly diff --git a/nsw/Source/bsmd.status/bsmd.status.csproj b/nsw/Source/bsmd.status/bsmd.status.csproj index bfb15ccb..e5015984 100644 --- a/nsw/Source/bsmd.status/bsmd.status.csproj +++ b/nsw/Source/bsmd.status/bsmd.status.csproj @@ -21,6 +21,7 @@ DEBUG;TRACE prompt 4 + ..\..\..\..\mtc\puls200.frame\frame.ruleset pdbonly