Version 1.0.1: Ladelogik der Message-Objekte vollständig

This commit is contained in:
Daniel Schick 2015-04-03 11:19:37 +00:00
parent d15996b323
commit 5f56a6c4bf
15 changed files with 691 additions and 23 deletions

Binary file not shown.

View File

@ -31,6 +31,12 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
@ -80,6 +86,7 @@
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="..\bsmdKey.snk" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>

View File

@ -29,6 +29,12 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
@ -55,6 +61,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="..\bsmdKey.snk" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

View File

@ -0,0 +1,98 @@
//
// Class: BPOL
// Current CLR: 4.0.30319.34209
// System: Microsoft Visual Studio 10.0
// Author: dani
// Created: 4/2/2015 9:01:11 PM
//
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace bsmd.database
{
public class BPOL : DatabaseEntity, IMessageClass
{
private List<PortOfItinerary> poi = new List<PortOfItinerary>();
public BPOL()
{
this.tablename = "[dbo].[BPOL]";
}
#region Properties
public Message MessageHeader { get; set; }
public bool? StowawaysOnBoard { get; set; }
public List<PortOfItinerary> PortOfItineraries { get { return this.poi; } }
#endregion
#region DatabaseEntity implementation
public override void PrepareSave(System.Data.IDbCommand cmd)
{
SqlCommand scmd = cmd as SqlCommand;
scmd.Parameters.AddWithValue("@P1", this.MessageHeader.Id);
scmd.Parameters.AddWithNullableValue("@P2", this.StowawaysOnBoard);
if (this.IsNew)
{
scmd.CommandText = string.Format("INSERT INTO {0} (MessageHeaderId, StowawaysOnBoard) VALUES ( @P1, @P2 )",
this.Tablename);
}
else
{
scmd.Parameters.AddWithValue(@"ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET StowawaysOnBoard = @P2 WHERE Id = @ID", this.Tablename);
}
}
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
{
string query = string.Format("SELECT Id, StowawaysOnBoard 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 List<DatabaseEntity> LoadList(System.Data.IDataReader reader)
{
List<DatabaseEntity> result = new List<DatabaseEntity>();
while (reader.Read())
{
BPOL bpol = new BPOL();
bpol.id = reader.GetGuid(0);
if (!reader.IsDBNull(1)) bpol.StowawaysOnBoard = reader.GetBoolean(1);
result.Add(bpol);
}
reader.Close();
return result;
}
#endregion
}
}

View File

@ -19,7 +19,7 @@ namespace bsmd.database
{
private SqlConnection _con;
private static DBManager _instance;
private ILog _log = LogManager.GetLogger(typeof(DBManager));
private static ILog _log = LogManager.GetLogger(typeof(DBManager));
#region Properties
@ -170,6 +170,8 @@ namespace bsmd.database
}
}
#region CreateMessage()
/// <summary>
/// factory method for messages by type
/// </summary>
@ -178,14 +180,41 @@ namespace bsmd.database
DatabaseEntity result = null;
switch (notificationClass)
{
case Message.NotificationClass.STAT: result = new STAT(); break;
case Message.NotificationClass.NOA_NOD: result = new NOA_NOD(); break;
case Message.NotificationClass.ATA: result = new ATA(); break;
case Message.NotificationClass.ATD: result = new ATD(); break;
case Message.NotificationClass.SEC: result = new SEC(); break;
case Message.NotificationClass.POBA: result = new POBA(); break;
case Message.NotificationClass.POBD: result = new POBD(); break;
case Message.NotificationClass.NAME: result = new NAME(); break;
case Message.NotificationClass.TIEFA: result = new TIEFA(); break;
case Message.NotificationClass.TIEFD: result = new TIEFD(); break;
case Message.NotificationClass.BKRA: result = new BRKA(); break;
case Message.NotificationClass.BKRD: result = new BRKD(); break;
case Message.NotificationClass.STAT: result = new STAT(); break;
case Message.NotificationClass.LADG: result = new LADG(); break;
case Message.NotificationClass.INFO: result = new INFO(); break;
case Message.NotificationClass.SERV: result = new SERV(); break;
case Message.NotificationClass.PRE72H: result = new PRE72H(); break;
case Message.NotificationClass.MDH: result = new MDH(); break;
default: break;
case Message.NotificationClass.WAS: result = new WAS(); break;
case Message.NotificationClass.CREW: result = new CREW(); break;
case Message.NotificationClass.PAS: result = new PAS(); break;
case Message.NotificationClass.BPOL: result = new BPOL(); break;
case Message.NotificationClass.TOWA: result = new TOWA(); break;
case Message.NotificationClass.TOWD: result = new TOWD(); break;
case Message.NotificationClass.HAZA:
case Message.NotificationClass.HAZD:
default:
_log.WarnFormat("CreateMessage: message type {0} is not supported", notificationClass.ToString());
break;
}
return result;
}
#endregion
/// <summary>
/// Loads inner lists / collections
/// </summary>
@ -193,32 +222,109 @@ namespace bsmd.database
{
SqlCommand cmd = new SqlCommand();
if(databaseEntity.GetType().IsAssignableFrom(typeof(MDH)))
#region MDH
if (databaseEntity.GetType().IsAssignableFrom(typeof(MDH)))
{
MDH mdh = databaseEntity as MDH;
mdh.PrepareLoadCommand(cmd, Message.LoadFilter.MDH_ID);
PortOfCallLast30Days poc30 = new PortOfCallLast30Days();
poc30.PrepareLoadCommand(cmd, Message.LoadFilter.MDH_ID, mdh.Id);
SqlDataReader reader = this.PerformCommand(cmd);
List<DatabaseEntity> poc30s = mdh.LoadList(reader);
foreach (PortOfCallLast30Days poc30 in poc30s)
List<DatabaseEntity> poc30s = poc30.LoadList(reader);
foreach (PortOfCallLast30Days apoc30 in poc30s)
{
mdh.PortOfCallLast30Days.Add(poc30);
poc30.MDH = mdh;
this.LoadDependingLists(poc30);
mdh.PortOfCallLast30Days.Add(apoc30);
apoc30.MDH = mdh;
this.LoadDependingLists(apoc30);
}
}
if(databaseEntity.GetType().IsAssignableFrom(typeof(PortOfCallLast30Days)))
#endregion
#region PortOfCallLast30Days
if (databaseEntity.GetType().IsAssignableFrom(typeof(PortOfCallLast30Days)))
{
PortOfCallLast30Days poc30 = databaseEntity as PortOfCallLast30Days;
poc30.PrepareLoadCommand(cmd, Message.LoadFilter.POC30_ID);
PortOfCallLast30DaysCrewJoinedShip poc30s = new PortOfCallLast30DaysCrewJoinedShip();
poc30s.PrepareLoadCommand(cmd, Message.LoadFilter.POC30_ID, poc30.Id);
SqlDataReader reader = this.PerformCommand(cmd);
List<DatabaseEntity> poc30Names = poc30.LoadList(reader);
List<DatabaseEntity> poc30Names = poc30s.LoadList(reader);
foreach (PortOfCallLast30DaysCrewJoinedShip poc30Name in poc30Names)
{
poc30.CrewJoinedShip.Add(poc30Name);
poc30Name.PortOfCallLast30Days = poc30;
}
}
#endregion
#region SEC
if (databaseEntity.GetType().IsAssignableFrom(typeof(SEC)))
{
SEC sec = databaseEntity as SEC;
LastTenPortFacilitiesCalled ltp = new LastTenPortFacilitiesCalled();
ltp.PrepareLoadCommand(cmd, Message.LoadFilter.SEC_ID, sec.Id);
SqlDataReader reader = this.PerformCommand(cmd);
List<DatabaseEntity> ltps = ltp.LoadList(reader);
foreach (LastTenPortFacilitiesCalled altp in ltps)
{
sec.LastTenPortFacilitesCalled.Add(altp);
altp.SEC = sec;
}
cmd = new SqlCommand();
ShipToShipActivitiesDuringLastTenPortFacilitiesCalled sts = new ShipToShipActivitiesDuringLastTenPortFacilitiesCalled();
sts.PrepareLoadCommand(cmd, Message.LoadFilter.SEC_ID, sec.Id);
reader = this.PerformCommand(cmd);
List<DatabaseEntity> stss = sts.LoadList(reader);
foreach (ShipToShipActivitiesDuringLastTenPortFacilitiesCalled asts in stss)
{
sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Add(asts);
asts.SEC = sec;
}
}
#endregion
#region WAS
if(databaseEntity.GetType().IsAssignableFrom(typeof(WAS)))
{
WAS was = databaseEntity as WAS;
WasteDisposalServiceProvider wdsp = new WasteDisposalServiceProvider();
wdsp.PrepareLoadCommand(cmd, Message.LoadFilter.WAS_ID, was.Id);
SqlDataReader reader = this.PerformCommand(cmd);
List<DatabaseEntity> wdsps = wdsp.LoadList(reader);
foreach (WasteDisposalServiceProvider awdsp in wdsps)
{
was.WasteDisposalServiceProvider.Add(awdsp);
awdsp.WAS = was;
this.LoadDependingLists(awdsp);
}
}
#endregion
#region WasteDisposalServiceProvider
if(databaseEntity.GetType().IsAssignableFrom(typeof(WasteDisposalServiceProvider)))
{
WasteDisposalServiceProvider wdsp = databaseEntity as WasteDisposalServiceProvider;
Waste waste = new Waste();
waste.PrepareLoadCommand(cmd, Message.LoadFilter.WDSP_ID, wdsp.Id);
SqlDataReader reader = this.PerformCommand(cmd);
List<DatabaseEntity> wastes = wdsp.LoadList(reader);
foreach (Waste aWaste in wastes)
{
wdsp.Waste.Add(aWaste);
aWaste.WasteDisposalServiceProvider = wdsp;
}
}
#endregion
}
internal void LoadErrorList(Message message)
@ -243,6 +349,7 @@ namespace bsmd.database
message.ViolationList.Add(violation);
}
#region DB access methods
internal SqlDataReader PerformCommand(SqlCommand cmd)
{
@ -275,6 +382,7 @@ namespace bsmd.database
}
}
#endregion
#endregion

View File

@ -0,0 +1,129 @@
//
// Class: LastTenPortFacilitiesCalled
// Current CLR: 4.0.30319.34209
// System: Microsoft Visual Studio 10.0
// Author: dani
// Created: 4/3/2015 10:11:28 AM
//
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace bsmd.database
{
public class LastTenPortFacilitiesCalled : DatabaseEntity
{
public LastTenPortFacilitiesCalled()
{
this.tablename = "[dbo].[LastTenPortFacilitiesCalled]";
}
#region Properties
public SEC SEC { get; set; }
public string PortFacilityPortName { get; set; }
public string PortFacilityPortCode { get; set; }
public string PortFacilityPortLoCode { get; set; }
public DateTime? PortFacilityDateOfArrival { get; set; }
public DateTime? PortFacilityDateOfDeparture { get; set; }
public byte? PortFacilityShipSecurityLevel { get; set; }
public string PortFacilitySecurityMattersToReport { get; set; }
public string PortFacilityGISISCode { get; set; }
#endregion
#region DatabaseEntity implementation
public override void PrepareSave(System.Data.IDbCommand cmd)
{
SqlCommand scmd = cmd as SqlCommand;
scmd.Parameters.AddWithValue("@P1", this.SEC.Id);
scmd.Parameters.AddWithNullableValue("@P2", this.PortFacilityPortName);
scmd.Parameters.AddWithNullableValue("@P3", this.PortFacilityPortCode);
scmd.Parameters.AddWithNullableValue("@P4", this.PortFacilityPortLoCode);
scmd.Parameters.AddWithNullableValue("@P5", this.PortFacilityDateOfArrival);
scmd.Parameters.AddWithNullableValue("@P6", this.PortFacilityDateOfDeparture);
scmd.Parameters.AddWithNullableValue("@P7", this.PortFacilityShipSecurityLevel);
scmd.Parameters.AddWithNullableValue("@P8", this.PortFacilitySecurityMattersToReport);
scmd.Parameters.AddWithNullableValue("@P9", this.PortFacilityGISISCode);
if (this.IsNew)
{
scmd.CommandText = string.Format("INSERT INTO {0} (SEC_Id, PortFacilityPortName, PortFacilityPortCode, " +
"PortFacilityPortLoCode, PortFacilityDateOfArrival, PortFacilityDateOfDeparture, PortFacilityShipSecurityLevel, " +
"PortFacilitySecurityMattersToReport, PortFacilityGISISCode) VALUES ( @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9)",
this.Tablename);
}
else
{
scmd.Parameters.AddWithValue(@"ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET PortFacilityPortName = @P2, PortFacilityPortCode = @P3, " +
"PortFacilityPortLoCode = @P4, PortFacilityDateOfArrival = @P5, PortFacilityDateOfDeparture = @P6," +
"PortFacilityShipSecurityLevel = @P7, PortFacilitySecurityMattersToReport = @8, PortFacilityGISISCode = @P9 " +
" WHERE Id = @ID", this.Tablename);
}
}
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
{
string query = string.Format("SELECT Id, PortFacilityPortName, PortFacilityPortCode, PortFacilityPortLoCode, " +
"PortFacilityDateOfArrival, PortFacilityDateOfDeparture, PortFacilityShipSecurityLevel, PortFacilitySecurityMattersToReport, " +
"PortFacilityGISISCode FROM {0}", this.Tablename);
switch (filter)
{
case Message.LoadFilter.SEC_ID:
query += "WHERE SEC_Id = @SECID";
((SqlCommand)cmd).Parameters.AddWithValue("@SECID", criteria[0]);
break;
case Message.LoadFilter.ALL:
default:
break;
}
cmd.CommandText = query;
}
public override List<DatabaseEntity> LoadList(System.Data.IDataReader reader)
{
List<DatabaseEntity> result = new List<DatabaseEntity>();
while (reader.Read())
{
LastTenPortFacilitiesCalled ltpfc = new LastTenPortFacilitiesCalled();
ltpfc.id = reader.GetGuid(0);
if (!reader.IsDBNull(1)) ltpfc.PortFacilityPortName = reader.GetString(1);
if (!reader.IsDBNull(2)) ltpfc.PortFacilityPortCode = reader.GetString(2);
if (!reader.IsDBNull(3)) ltpfc.PortFacilityPortLoCode = reader.GetString(3);
if (!reader.IsDBNull(4)) ltpfc.PortFacilityDateOfArrival = reader.GetDateTime(4);
if (!reader.IsDBNull(5)) ltpfc.PortFacilityDateOfDeparture = reader.GetDateTime(5);
if (!reader.IsDBNull(6)) ltpfc.PortFacilityShipSecurityLevel = reader.GetByte(6);
if (!reader.IsDBNull(7)) ltpfc.PortFacilitySecurityMattersToReport = reader.GetString(7);
if (!reader.IsDBNull(8)) ltpfc.PortFacilityGISISCode = reader.GetString(8);
result.Add(ltpfc);
}
reader.Close();
return result;
}
#endregion
}
}

View File

@ -51,7 +51,8 @@ namespace bsmd.database
POC30_ID,
WAS_ID,
WDSP_ID,
BPOL_ID
BPOL_ID,
SEC_ID
}
/// <summary>

View File

@ -2,6 +2,6 @@
[assembly: AssemblyCompany("Informatikbüro Daniel Schick")]
[assembly: AssemblyProduct("bsmd.database")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyCopyright("Copyright © 2014-2015 Informatikbüro Daniel Schick. All rights reserved.")]
[assembly: AssemblyTrademark("")]

View File

@ -4,5 +4,6 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.*")]
[assembly: AssemblyFileVersion("1.0.0.*")]
[assembly: AssemblyVersion("1.0.1.*")]
// wenn das nicht auskommentiert wird erhalten wir eine Warnung
// [assembly: AssemblyFileVersion("1.0.0.*")]

View File

@ -26,6 +26,6 @@ using System.Runtime.CompilerServices;
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]
// [assembly: AssemblyDelaySign(false)]
// [assembly: AssemblyKeyFile("..\bsmdKey.snk")]
// [assembly: AssemblyKeyName("")]

View File

@ -0,0 +1,172 @@
//
// Class: SEC
// Current CLR: 4.0.30319.34209
// System: Microsoft Visual Studio 10.0
// Author: dani
// Created: 4/3/2015 10:11:02 AM
//
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace bsmd.database
{
public class SEC : DatabaseEntity, IMessageClass
{
private List<LastTenPortFacilitiesCalled> ltpfc = new List<LastTenPortFacilitiesCalled>();
private List<ShipToShipActivitiesDuringLastTenPortFacilitiesCalled> lsts = new List<ShipToShipActivitiesDuringLastTenPortFacilitiesCalled>();
public SEC()
{
this.tablename = "[dbo].[SEC]";
}
#region Properties
public Message MessageHeader { get; set; }
public string SECSimplification { get; set; }
public string PortOfCallWhereCompleteSECNotified { get; set; }
public string CSOLastName { get; set; }
public string CSOFirstName { get; set; }
public string CSOPhone { get; set; }
public string CSOEMail { get; set; }
public bool? ValidISSCOnBoard { get; set; }
public string ReasonsForNoValidISSC { get; set; }
public byte? ISSCType { get; set; }
public byte? ISSCIssuerType { get; set; }
public string ISSCIssuerName { get; set; }
public DateTime? ISSCDateOfExpiration { get; set; }
public bool? ApprovedSecurityPlanOnBoard { get; set; }
public byte? CurrentShipSecurityLevel { get; set; }
public string PortFacilityOfArrival { get; set; }
public byte? GeneralDescriptionOfCargo { get; set; }
public List<LastTenPortFacilitiesCalled> LastTenPortFacilitesCalled { get { return this.ltpfc; } }
public List<ShipToShipActivitiesDuringLastTenPortFacilitiesCalled> ShipToShipActivitiesDuringLastTenPortFacilitiesCalled { get { return this.lsts; } }
#endregion
#region DatabaseEntity implementation
public override void PrepareSave(System.Data.IDbCommand cmd)
{
SqlCommand scmd = cmd as SqlCommand;
scmd.Parameters.AddWithValue("@P1", this.MessageHeader.Id);
scmd.Parameters.AddWithNullableValue("@P2", this.SECSimplification);
scmd.Parameters.AddWithNullableValue("@P3", this.PortOfCallWhereCompleteSECNotified);
scmd.Parameters.AddWithNullableValue("@P4", this.CSOLastName);
scmd.Parameters.AddWithNullableValue("@P5", this.CSOFirstName);
scmd.Parameters.AddWithNullableValue("@P6", this.CSOPhone);
scmd.Parameters.AddWithNullableValue("@P7", this.CSOEMail);
scmd.Parameters.AddWithNullableValue("@P8", this.ValidISSCOnBoard);
scmd.Parameters.AddWithNullableValue("@P9", this.ReasonsForNoValidISSC);
scmd.Parameters.AddWithNullableValue("@P10", this.ISSCType);
scmd.Parameters.AddWithNullableValue("@P11", this.ISSCIssuerType);
scmd.Parameters.AddWithNullableValue("@P12", this.ISSCIssuerName);
scmd.Parameters.AddWithNullableValue("@P13", this.ISSCDateOfExpiration);
scmd.Parameters.AddWithNullableValue("@P14", this.ApprovedSecurityPlanOnBoard);
scmd.Parameters.AddWithNullableValue("@P15", this.CurrentShipSecurityLevel);
scmd.Parameters.AddWithNullableValue("@P16", this.PortFacilityOfArrival);
scmd.Parameters.AddWithNullableValue("@P17", this.GeneralDescriptionOfCargo);
if (this.IsNew)
{
scmd.CommandText = string.Format("INSERT INTO {0} (MessageHeaderId, SECSimplification, PortOfCallWhereCompleteSECNotified, " +
"CSOLastName, CSOFirstName, CSOPhone, CSOEMail, ValidISSCOnBoard, ReasonsForNoValidISSC, " +
"ISSCType, ISSCIssuerType, ISSCIssuerName,ISSCDateOfExpiration, ApprovedSecurityPlanOnBoard, " +
"CurrentShipSecurityLevel, PortFacilityOfArrival, GeneralDescriptionOfCargo) " +
"VALUES ( @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, @P15, @P16, @P17 )", this.Tablename);
}
else
{
scmd.Parameters.AddWithValue(@"ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET SECSimplification = @P2, PortOfCallWhereCompleteSECNotified = @P3, " +
"CSOLastName = @P4, CSOFirstName = @P5, CSOPhone = @P6," +
"CSOEMail = @P7, ValidISSCOnBoard = @8, ReasonsForNoValidISSC = @P9, " +
"ISSCType = @P10, ISSCIssuerType = @P11, ISSCIssuerName = @P12, ISSCDateOfExpiration = @P13, " +
"ApprovedSecurityPlanOnBoard = @P14, CurrentShipSecurityLevel = @P15, PortFacilityOfArrival = @P16, " +
"GeneralDescriptionOfCargo = @P17 WHERE Id = @ID", this.Tablename);
}
}
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
{
string query = string.Format("SELECT Id, SECSimplification, PortOfCallWhereCompleteSECNotified, CSOLastName, " +
"CSOFirstName, CSOPhone, CSOEMail, ValidISSCOnBoard, ReasonsForNoValidISSC, " +
"ISSCType, ISSCIssuerType, ISSCIssuerName, ISSCDateOfExpiration, ApprovedSecurityPlanOnBoard, " +
"CurrentShipSecurityLevel, PortFacilityOfArrival, GeneralDescriptionOfCargo 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 List<DatabaseEntity> LoadList(System.Data.IDataReader reader)
{
List<DatabaseEntity> result = new List<DatabaseEntity>();
while (reader.Read())
{
SEC sec = new SEC();
sec.id = reader.GetGuid(0);
if (!reader.IsDBNull(1)) sec.SECSimplification = reader.GetString(1);
if (!reader.IsDBNull(2)) sec.PortOfCallWhereCompleteSECNotified = reader.GetString(2);
if (!reader.IsDBNull(3)) sec.CSOLastName = reader.GetString(3);
if (!reader.IsDBNull(4)) sec.CSOFirstName = reader.GetString(4);
if (!reader.IsDBNull(5)) sec.CSOPhone = reader.GetString(5);
if (!reader.IsDBNull(6)) sec.CSOEMail = reader.GetString(6);
if (!reader.IsDBNull(7)) sec.ValidISSCOnBoard = reader.GetBoolean(7);
if (!reader.IsDBNull(8)) sec.ReasonsForNoValidISSC = reader.GetString(8);
if (!reader.IsDBNull(9)) sec.ISSCType = reader.GetByte(9);
if (!reader.IsDBNull(9)) sec.ISSCIssuerType = reader.GetByte(9);
if (!reader.IsDBNull(9)) sec.ISSCIssuerName = reader.GetString(9);
if (!reader.IsDBNull(9)) sec.ISSCDateOfExpiration = reader.GetDateTime(9);
if (!reader.IsDBNull(9)) sec.ApprovedSecurityPlanOnBoard = reader.GetBoolean(9);
if (!reader.IsDBNull(9)) sec.CurrentShipSecurityLevel = reader.GetByte(9);
if (!reader.IsDBNull(9)) sec.PortFacilityOfArrival = reader.GetString(9);
if (!reader.IsDBNull(9)) sec.GeneralDescriptionOfCargo = reader.GetByte(9);
result.Add(sec);
}
reader.Close();
return result;
}
#endregion
}
}

View File

@ -0,0 +1,128 @@
//
// Class: ShipToShipActivitiesDuringLastTenPortFacilitiesCalled
// Current CLR: 4.0.30319.34209
// System: Microsoft Visual Studio 10.0
// Author: dani
// Created: 4/3/2015 12:01:28 PM
//
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
namespace bsmd.database
{
public class ShipToShipActivitiesDuringLastTenPortFacilitiesCalled : DatabaseEntity
{
public ShipToShipActivitiesDuringLastTenPortFacilitiesCalled()
{
this.tablename = "[dbo].[ShipToShipActivitiesDuringLastTenPortFacilitiesCalled]";
}
#region Properties
public SEC SEC { get; set; }
public string ShipToShipActivityLocationName { get; set; }
public string ShipToShipActivityLocationLoCode { get; set; }
public int? ShipToShipActivityLocationCoordinatesLatitude { get; set; }
public int? ShipToShipActivityLocationCoordinatesLongitude { get; set; }
public DateTime? ShipToShipActivityDateFrom { get; set; }
public DateTime? ShipToShipActivityDateTo { get; set; }
public string ShipToShipActivityType { get; set; }
public string ShipToShipActivitySecurityMattersToReport { get; set; }
#endregion
#region DatabaseEntity implementation
public override void PrepareSave(System.Data.IDbCommand cmd)
{
SqlCommand scmd = cmd as SqlCommand;
scmd.Parameters.AddWithValue("@P1", this.SEC.Id);
scmd.Parameters.AddWithNullableValue("@P2", this.ShipToShipActivityLocationName);
scmd.Parameters.AddWithNullableValue("@P3", this.ShipToShipActivityLocationLoCode);
scmd.Parameters.AddWithNullableValue("@P4", this.ShipToShipActivityLocationCoordinatesLatitude);
scmd.Parameters.AddWithNullableValue("@P5", this.ShipToShipActivityLocationCoordinatesLongitude);
scmd.Parameters.AddWithNullableValue("@P6", this.ShipToShipActivityDateFrom);
scmd.Parameters.AddWithNullableValue("@P7", this.ShipToShipActivityDateTo);
scmd.Parameters.AddWithNullableValue("@P8", this.ShipToShipActivityType);
scmd.Parameters.AddWithNullableValue("@P9", this.ShipToShipActivitySecurityMattersToReport);
if (this.IsNew)
{
scmd.CommandText = string.Format("INSERT INTO {0} (SEC_Id, ShipToShipActivityLocationName, ShipToShipActivityLocationLoCode, " +
"ShipToShipActivityLocationCoordinatesLatitude, ShipToShipActivityLocationCoordinatesLongitude, ShipToShipActivityDateFrom, ShipToShipActivityDateTo, " +
"ShipToShipActivityType, ShipToShipActivitySecurityMattersToReport) VALUES ( @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9)",
this.Tablename);
}
else
{
scmd.Parameters.AddWithValue(@"ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET ShipToShipActivityLocationName = @P2, ShipToShipActivityLocationLoCode = @P3, " +
"ShipToShipActivityLocationCoordinatesLatitude = @P4, ShipToShipActivityLocationCoordinatesLongitude = @P5, ShipToShipActivityDateFrom = @P6," +
"ShipToShipActivityDateTo = @P7, ShipToShipActivityType = @8, ShipToShipActivitySecurityMattersToReport = @P9 " +
" WHERE Id = @ID", this.Tablename);
}
}
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
{
string query = string.Format("SELECT Id, ShipToShipActivityLocationName, ShipToShipActivityLocationLoCode, ShipToShipActivityLocationCoordinatesLatitude, " +
"ShipToShipActivityLocationCoordinatesLongitude, ShipToShipActivityDateFrom, ShipToShipActivityDateTo, ShipToShipActivityType, " +
"ShipToShipActivitySecurityMattersToReport FROM {0}", this.Tablename);
switch (filter)
{
case Message.LoadFilter.SEC_ID:
query += "WHERE SEC_Id = @SECID";
((SqlCommand)cmd).Parameters.AddWithValue("@SECID", criteria[0]);
break;
case Message.LoadFilter.ALL:
default:
break;
}
cmd.CommandText = query;
}
public override List<DatabaseEntity> LoadList(System.Data.IDataReader reader)
{
List<DatabaseEntity> result = new List<DatabaseEntity>();
while (reader.Read())
{
ShipToShipActivitiesDuringLastTenPortFacilitiesCalled sts = new ShipToShipActivitiesDuringLastTenPortFacilitiesCalled();
sts.id = reader.GetGuid(0);
if (!reader.IsDBNull(1)) sts.ShipToShipActivityLocationName = reader.GetString(1);
if (!reader.IsDBNull(2)) sts.ShipToShipActivityLocationLoCode = reader.GetString(2);
if (!reader.IsDBNull(3)) sts.ShipToShipActivityLocationCoordinatesLatitude = reader.GetInt32(3);
if (!reader.IsDBNull(4)) sts.ShipToShipActivityLocationCoordinatesLongitude = reader.GetInt32(4);
if (!reader.IsDBNull(5)) sts.ShipToShipActivityDateFrom = reader.GetDateTime(5);
if (!reader.IsDBNull(6)) sts.ShipToShipActivityDateTo = reader.GetDateTime(6);
if (!reader.IsDBNull(7)) sts.ShipToShipActivityType = reader.GetString(7);
if (!reader.IsDBNull(8)) sts.ShipToShipActivitySecurityMattersToReport = reader.GetString(8);
result.Add(sts);
}
reader.Close();
return result;
}
#endregion
}
}

View File

@ -29,6 +29,12 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
@ -45,6 +51,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="LastTenPortFacilitiesCalled.cs" />
<Compile Include="Properties\AssemblyProductInfo.cs" />
<Compile Include="Properties\AssemblyProjectInfo.cs" />
<Compile Include="Properties\AssemblyProjectKeyInfo.cs" />
@ -75,7 +82,9 @@
<Compile Include="PRE72H.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ReportingParty.cs" />
<Compile Include="SEC.cs" />
<Compile Include="SERV.cs" />
<Compile Include="ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.cs" />
<Compile Include="STAT.cs" />
<Compile Include="TIEFA.cs" />
<Compile Include="TIEFD.cs" />
@ -88,6 +97,7 @@
</ItemGroup>
<ItemGroup>
<None Include="App.Config" />
<None Include="..\bsmdKey.snk" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>

View File

@ -29,6 +29,12 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
@ -64,6 +70,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="..\bsmdKey.snk" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

BIN
nsw/Source/bsmdKey.snk Normal file

Binary file not shown.