diff --git a/Stundensheet.xlsx b/Stundensheet.xlsx index fcbf57f2..e6b4cd14 100644 Binary files a/Stundensheet.xlsx and b/Stundensheet.xlsx differ diff --git a/nsw/Source/SQL/Update_3.1.3_To_3.5.sql b/nsw/Source/SQL/Update_3.1.3_To_3.5.sql index abd510c6..6b82d173 100644 --- a/nsw/Source/SQL/Update_3.1.3_To_3.5.sql +++ b/nsw/Source/SQL/Update_3.1.3_To_3.5.sql @@ -47,7 +47,7 @@ GO PRINT N'Creating [dbo].[STO]..'; GO CREATE TABLE [dbo].[STO] ( - [Id] UNIQUEIDENTIFIER CONSTRAINT [PK_PortArea_Id] DEFAULT (newid()) ROWGUIDCOL NOT NULL , + [Id] UNIQUEIDENTIFIER CONSTRAINT [PK_STO_Id] DEFAULT (newid()) ROWGUIDCOL NOT NULL , [MessageHeaderId] [uniqueidentifier] NULL, [Name] [NVARCHAR] (255) NULL, [Quantity] [INT] NULL, @@ -57,3 +57,5 @@ CREATE TABLE [dbo].[STO] ( ); GO +PRINT N'Update complete.'; +GO diff --git a/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs b/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs index 6c5c49b2..3e84d75c 100644 --- a/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs +++ b/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs @@ -16,6 +16,7 @@ using System.Drawing; using System.Globalization; using System.Linq; using System.Runtime.InteropServices; +using bsmd.database; namespace bsmd.ExcelReadService { @@ -128,6 +129,28 @@ namespace bsmd.ExcelReadService return new string(val.Where(c => !Char.IsWhiteSpace(c)).ToArray()); } + internal string ReadLoCode(string lookup) + { + string val = this.ReadText(lookup); + if(!val.IsNullOrEmpty()) + { + string portName = LocodeDB.PortNameFromLocode(val); + if(portName == null) + { + this.HighlightLookup(lookup, ReadState.WARN); + } + else + { + this.HighlightLookup(lookup, ReadState.OK); + } + } + else + { + this.HighlightLookup(lookup, ReadState.FAIL); + } + return val; + } + internal byte? ReadGender(string lookup) { byte? result = null; diff --git a/nsw/Source/bsmd.ExcelReadService/Util.cs b/nsw/Source/bsmd.ExcelReadService/Util.cs index 94910fb3..755987b1 100644 --- a/nsw/Source/bsmd.ExcelReadService/Util.cs +++ b/nsw/Source/bsmd.ExcelReadService/Util.cs @@ -99,6 +99,8 @@ namespace bsmd.ExcelReadService ScanLADG(messages, messageCore, reader); + ScanSTO(messages, messageCore, reader); + ScanINFO(messages, messageCore, reader); ScanSERV(messages, messageCore, reader); @@ -112,8 +114,8 @@ namespace bsmd.ExcelReadService ScanCREW(messages, messageCore, reader); ScanPAS(messages, messageCore, reader); - - // BPOL nicht im Sheet + + ScanBPOL(messages, messageCore, reader); ScanTOWA(messages, messageCore, reader); @@ -237,6 +239,55 @@ namespace bsmd.ExcelReadService #endregion + #region BPOL + + static void ScanBPOL(List messages, MessageCore messageCore, ExcelReader reader) + { + // Die Verarbeitung dieser Nachricht aktuell nur für + Message bpolMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.BPOL); + if (bpolMessage.Elements.Count == 0) + { + BPOL newBPOL = new BPOL(); + newBPOL.MessageHeader = bpolMessage; + bpolMessage.Elements.Add(newBPOL); + } + + BPOL bpol = bpolMessage.Elements[0] as BPOL; + Util.ScanMessage(bpol, reader); + + + // PortOfItinerary + for (int i = 1; i <= 10; i++) + { + string bpolName = string.Format("BPOL.PortOfItineraryName_{0}", i); + string bpolLocode = string.Format("BPOL.PortOfItineraryLoCode_{0}", i); + string bpolETA = string.Format("BPOL.PortOfItineraryETA_{0}", i); + + string bpolNameValue = reader.ReadText(bpolName)?.Trim(); + if (!bpolNameValue.IsNullOrEmpty()) + { + PortOfItinerary poi = bpol.GetSublistElementWithIdentifier(i.ToString()) as PortOfItinerary; + if (poi == null) + { + poi = new PortOfItinerary(); + poi.BPOL = bpol; + poi.Identifier = i.ToString(); + bpol.PortOfItineraries.Add(poi); + } + poi.PortOfItineraryName = bpolNameValue; + poi.PortOfItineraryLocode = reader.ReadLoCode(bpolLocode); + if (!poi.PortOfItineraryLocode.IsNullOrEmpty() && (poi.PortOfItineraryLocode.Length > 5)) + { + reader.HighlightLookup(bpolLocode, ExcelReader.ReadState.WARN); + } + poi.PortOfItineraryETA = reader.ReadDate(bpolETA); + + } + } + } + + #endregion + #region POBA static void ScanPOBA(List messages, MessageCore messageCore, ExcelReader reader) @@ -429,6 +480,8 @@ namespace bsmd.ExcelReadService noa_nod.ETDFromPortOfCall = reader.ReadDateTime("NOA_NOD.ETDDateFromPortOfCall", "NOA_NOD.ETDTimeFromPortOfCall"); 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"); } @@ -602,7 +655,7 @@ namespace bsmd.ExcelReadService } poc30d.PortOfCallLast30DaysDateOfDeparture = reader.ReadDate(depDate); - poc30d.PortOfCallLast30DaysLocode = reader.ReadTextNoWhitespace(locode); + poc30d.PortOfCallLast30DaysLocode = reader.ReadLoCode(locode); poc30d.PortOfCallLast30DaysCrewMembersJoined = reader.ReadBoolean(crewJoined); if (poc30d.PortOfCallLast30DaysCrewMembersJoined ?? false) @@ -714,7 +767,7 @@ namespace bsmd.ExcelReadService l10fc.PortFacilityPortName = reader.ReadText(portName); l10fc.PortFacilityPortCountry = reader.ReadText(portCountry); - l10fc.PortFacilityPortLoCode = reader.ReadTextNoWhitespace(portLocode); + l10fc.PortFacilityPortLoCode = reader.ReadLoCode(portLocode); l10fc.PortFacilityDateOfArrival = reader.ReadDate(portDateOfArrival); l10fc.PortFacilityDateOfDeparture = reader.ReadDate(portDateOfDeparture); l10fc.PortFacilityShipSecurityLevel = (byte?) reader.ReadNumber(portShipSecLevel); @@ -758,7 +811,7 @@ namespace bsmd.ExcelReadService continue; } - s2sActivity.ShipToShipActivityLocationLoCode = reader.ReadTextNoWhitespace(s2sLocode); + s2sActivity.ShipToShipActivityLocationLoCode = reader.ReadLoCode(s2sLocode); s2sActivity.ShipToShipActivityLocationCoordinatesLatitude = (int?)reader.ReadNumber(s2sLatitude); // keine "0" (d.h. fehlerhafte Koordinaten) ins ANSW übergeben falls im Sheet nichts ist aber der Reader das aus irgendeinem Grund liest if (s2sActivity.ShipToShipActivityLocationCoordinatesLatitude.HasValue && s2sActivity.ShipToShipActivityLocationCoordinatesLatitude.Value == 0) @@ -919,6 +972,41 @@ namespace bsmd.ExcelReadService #endregion + #region STO + + static void ScanSTO(List messages, MessageCore messageCore, ExcelReader reader) + { + Message stoMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.STO); + for(int i=0;i messages, MessageCore messageCore, ExcelReader reader) diff --git a/nsw/Source/bsmd.database/BPOL.cs b/nsw/Source/bsmd.database/BPOL.cs index 66559db7..1262ea93 100644 --- a/nsw/Source/bsmd.database/BPOL.cs +++ b/nsw/Source/bsmd.database/BPOL.cs @@ -30,6 +30,8 @@ namespace bsmd.database [Validation(ValidationCode.NOT_NULL)] public bool? StowawaysOnBoard { get; set; } + + [LookupName("BPOL.CruiseShip")] public bool? CruiseShip { get; set; } public List PortOfItineraries { get { return this.poi; } } diff --git a/nsw/Source/bsmd.database/DBManager.cs b/nsw/Source/bsmd.database/DBManager.cs index c5f0a8cf..fec3722d 100644 --- a/nsw/Source/bsmd.database/DBManager.cs +++ b/nsw/Source/bsmd.database/DBManager.cs @@ -531,6 +531,7 @@ namespace bsmd.database case Message.NotificationClass.HAZA: result = new HAZ(); break; case Message.NotificationClass.HAZD: result = new HAZ(); ((HAZ)result).IsDeparture = true; break; case Message.NotificationClass.AGNT: result = new AGNT(); break; + case Message.NotificationClass.STO: result = new STO(); break; default: break; // VISIT, TRANSIT diff --git a/nsw/Source/bsmd.database/Message.cs b/nsw/Source/bsmd.database/Message.cs index a5c47958..fb170caf 100644 --- a/nsw/Source/bsmd.database/Message.cs +++ b/nsw/Source/bsmd.database/Message.cs @@ -56,7 +56,8 @@ namespace bsmd.database NotificationClass.WAS, NotificationClass.ATA, NotificationClass.ATD, - NotificationClass.AGNT + NotificationClass.AGNT, + NotificationClass.STO }); #endregion @@ -95,7 +96,8 @@ namespace bsmd.database TOWD, HAZA, // 25 HAZD, - AGNT + AGNT, + STO // DK - only } public enum MessageStatus @@ -203,7 +205,7 @@ namespace bsmd.database /// /// Vorwärts-Referenzen auf die von diesem Header-Element abhängigen speziellen Nachrichten-Datensätzen /// Folgende Objekte können pro Nachricht n-fach vorkommen - /// BRKA, BRKD, LADG, CREW, PAS, SERV, TOWA, TOWD + /// BRKA, BRKD, LADG, CREW, PAS, SERV, TOWA, TOWD, STO /// sonst hat die Liste immer ein Element /// public List Elements { get { return this.elements; } } @@ -464,6 +466,7 @@ namespace bsmd.database case NotificationClass.PAS: return 30; case NotificationClass.TOWA: return 1; case NotificationClass.TOWD: return 1; + case NotificationClass.STO: return 10; default: return 0; diff --git a/nsw/Source/bsmd.database/STO.cs b/nsw/Source/bsmd.database/STO.cs new file mode 100644 index 00000000..ab8a3495 --- /dev/null +++ b/nsw/Source/bsmd.database/STO.cs @@ -0,0 +1,133 @@ +// +// Class: STO +// Current CLR: 4.0.30319.34209 +// System: Microsoft Visual Studio 10.0 +// Author: dani +// Created: 12/3/2016 6:48:58 PM +// +// Copyright (c) 2016 Informatikbüro Daniel Schick. All rights reserved. + +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Data; + +namespace bsmd.database +{ + + /// + /// Diese Meldeklasse ist bislang DK-Only und wird in den meisten Tools nicht berücksichtigt! + /// + public class STO : DatabaseEntity, ISublistElement + { + + public STO() + { + this.tablename = "[dbo].[STO]"; + } + + #region Properties + + + /// + /// ISublistElement implementation + /// + public string Identifier { get; set; } + + [LookupName("STO.Name")] + public string Name { get; set; } + + [LookupName("STO.Quantity")] + public int? Quantity { get; set; } + + [LookupName("STO.QuantityUnit")] + public string QuantityUnit { get; set; } + + [LookupName("STO.LocationOnBoard")] + public string LocationOnBoard { get; set; } + + [LookupName("STO.OfficialUse")] + public string OfficialUse { get; set; } + + #endregion + + #region DatabaseEntity implementation + + public override string Subtitle + { + get + { + return "Storage information"; + } + } + + public override List LoadList(IDataReader reader) + { + List result = new List(); + + while (reader.Read()) + { + STO sto = new STO(); + + sto.id = reader.GetGuid(0); + if (!reader.IsDBNull(1)) sto.Name = reader.GetString(1); + if (!reader.IsDBNull(2)) sto.Quantity = reader.GetInt32(2); + if (!reader.IsDBNull(3)) sto.QuantityUnit = reader.GetString(3); + if (!reader.IsDBNull(4)) sto.LocationOnBoard = reader.GetString(4); + if (!reader.IsDBNull(5)) sto.OfficialUse = reader.GetString(5); + if (!reader.IsDBNull(6)) sto.Identifier = reader.GetString(6); + result.Add(sto); + } + reader.Close(); + return result; + } + + public override void PrepareLoadCommand(IDbCommand cmd, Message.LoadFilter filter, params object[] criteria) + { + string query = string.Format("SELECT Id, Name, Quantity, QuantityUnit, LocationOnBoard, OfficialUse, Identifier FROM {0}", + this.Tablename); + + switch (filter) + { + case Message.LoadFilter.MESSAGEHEADER: + query += "WHERE MessageHeaderId = @MHID"; + ((SqlCommand)cmd).Parameters.AddWithValue("@MHID", criteria[0]); + break; + case Message.LoadFilter.ALL: + default: + + break; + } + + cmd.CommandText = query; + } + + public override void PrepareSave(IDbCommand cmd) + { + SqlCommand scmd = cmd as SqlCommand; + + scmd.Parameters.AddWithValue("@P1", this.MessageHeader.Id); + scmd.Parameters.AddWithNullableValue("@P2", this.Name); + scmd.Parameters.AddWithNullableValue("@P3", this.Quantity); + scmd.Parameters.AddWithNullableValue("@P4", this.QuantityUnit); + scmd.Parameters.AddWithNullableValue("@P5", this.LocationOnBoard); + scmd.Parameters.AddWithNullableValue("@P6", this.OfficialUse); + scmd.Parameters.AddWithNullableValue("@P7", this.Identifier); + + if (this.IsNew) + { + scmd.CommandText = string.Format("INSERT INTO {0} (MessageHeaderId, Name, Quantity, " + + "QuantityUnit, LocationOnBoard, OfficialUse, Identifier) VALUES ( @P1, @P2, @P3, @P4, @P5, @P6, @P7 )", this.Tablename); + } + else + { + scmd.Parameters.AddWithValue(@"ID", this.Id); + scmd.CommandText = string.Format("UPDATE {0} SET Name = @P2, Quantity = @P3, QuantityUnit = @P4, " + + "LocationOnBoard = @P5, OfficialUse = @P6 WHERE Id = @ID", this.Tablename); + } + } + + #endregion + + } +} diff --git a/nsw/Source/bsmd.database/XtraSendLogic.cs b/nsw/Source/bsmd.database/XtraSendLogic.cs index 34cbe5ad..3114e15e 100644 --- a/nsw/Source/bsmd.database/XtraSendLogic.cs +++ b/nsw/Source/bsmd.database/XtraSendLogic.cs @@ -41,7 +41,8 @@ namespace bsmd.database (message.MessageNotificationClass == Message.NotificationClass.LADG) || (message.MessageNotificationClass == Message.NotificationClass.SERV) || (message.MessageNotificationClass == Message.NotificationClass.WAS) || - (message.MessageNotificationClass == Message.NotificationClass.TOWD)) + (message.MessageNotificationClass == Message.NotificationClass.TOWD) || + (message.MessageNotificationClass == Message.NotificationClass.STO)) return false; } diff --git a/nsw/Source/bsmd.database/bsmd.database.csproj b/nsw/Source/bsmd.database/bsmd.database.csproj index 55a8d790..23298b61 100644 --- a/nsw/Source/bsmd.database/bsmd.database.csproj +++ b/nsw/Source/bsmd.database/bsmd.database.csproj @@ -108,6 +108,7 @@ +