Implementierung ExcelReader: Erweiterung neues Erfassungssheet (inkl. DK!)
This commit is contained in:
parent
f969bb7850
commit
a5ed1b7763
Binary file not shown.
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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<Message> 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<Message> 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<Message> messages, MessageCore messageCore, ExcelReader reader)
|
||||
{
|
||||
Message stoMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.STO);
|
||||
for(int i=0;i<stoMessage.NumberOfExcelRows;i++) // 10
|
||||
{
|
||||
string stoName = string.Format("STO.Name_{0}", i + 1);
|
||||
string stoQuantity = string.Format("STO_Quantity_{0}", i + 1);
|
||||
string stoQuantityUnit = string.Format("STO_QuantityUnit_{0}", i + 1);
|
||||
string stoLocationOnBoard = string.Format("STO_LocationOnBoard_{0}", i + 1);
|
||||
string stoOfficialUse = string.Format("STO_OfficialUse_{0}", i + 1);
|
||||
STO sto = stoMessage.GetSublistElementWithIdentifier((i + 1).ToString()) as STO;
|
||||
if(sto == null)
|
||||
{
|
||||
sto = new STO();
|
||||
sto.Identifier = (i + 1).ToString();
|
||||
sto.MessageHeader = stoMessage;
|
||||
stoMessage.Elements.Add(sto);
|
||||
}
|
||||
|
||||
sto.Name = reader.ReadTextNoWhitespace(stoName);
|
||||
sto.Quantity = (int?)reader.ReadNumber(stoQuantity);
|
||||
sto.QuantityUnit = reader.ReadTextNoWhitespace(stoQuantityUnit);
|
||||
sto.LocationOnBoard = reader.ReadTextNoWhitespace(stoLocationOnBoard);
|
||||
sto.OfficialUse = reader.ReadTextNoWhitespace(stoOfficialUse);
|
||||
|
||||
// dont save empty element
|
||||
if (sto.IsNew && sto.Name.IsNullOrEmpty())
|
||||
stoMessage.Elements.Remove(sto);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region LADG
|
||||
|
||||
static void ScanLADG(List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
||||
|
||||
@ -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<PortOfItinerary> PortOfItineraries { get { return this.poi; } }
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// </summary>
|
||||
public List<DatabaseEntity> 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;
|
||||
|
||||
133
nsw/Source/bsmd.database/STO.cs
Normal file
133
nsw/Source/bsmd.database/STO.cs
Normal file
@ -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
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Diese Meldeklasse ist bislang DK-Only und wird in den meisten Tools nicht berücksichtigt!
|
||||
/// </summary>
|
||||
public class STO : DatabaseEntity, ISublistElement
|
||||
{
|
||||
|
||||
public STO()
|
||||
{
|
||||
this.tablename = "[dbo].[STO]";
|
||||
}
|
||||
|
||||
#region Properties
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// ISublistElement implementation
|
||||
/// </summary>
|
||||
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<DatabaseEntity> LoadList(IDataReader reader)
|
||||
{
|
||||
List<DatabaseEntity> result = new List<DatabaseEntity>();
|
||||
|
||||
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
|
||||
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -108,6 +108,7 @@
|
||||
<Compile Include="ShowReportAttribute.cs" />
|
||||
<Compile Include="SOAPLoggerExtension.cs" />
|
||||
<Compile Include="STAT.cs" />
|
||||
<Compile Include="STO.cs" />
|
||||
<Compile Include="StowawaysJoiningLocation.cs" />
|
||||
<Compile Include="SubsidiaryRisks.cs" />
|
||||
<Compile Include="TIEFA.cs" />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user