1.5 alles fertig vor Besuch in Bremen am 11.5.15

This commit is contained in:
Daniel Schick 2015-05-09 17:50:02 +00:00
parent 457751893c
commit e97cc741ae
76 changed files with 2847 additions and 175 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,2 +1,15 @@
GO GO
ALTER TABLE [dbo].[MDH] ALTER COLUMN [MDHSimplification] BIT NULL; ALTER TABLE [dbo].[MDH] ALTER COLUMN [MDHSimplification] BIT NULL;
GO
ALTER TABLE [dbo].[SEC] ALTER COLUMN [SECSimplification] BIT NULL;
GO
ALTER TABLE [dbo].[SEC] ADD [CSOFax] NVARCHAR (100) NULL;
GO
EXECUTE sp_rename @objname = N'[dbo].[LastTenPortFacilitiesCalled].[PortFacilityPortCode]', @newname = N'PortFacilityPortCountry', @objtype = N'COLUMN';
GO
ALTER TABLE [dbo].[WAS] ADD [LastWasteDisposalDate] DATETIME NULL;
GO
EXECUTE sp_rename @objname = N'[dbo].[Waste].[WasteDisposalServiceProviderId]', @newname = N'WASId', @objtype = N'COLUMN';
GO
ALTER TABLE [dbo].[WAS] ADD [WasteDisposalDelivery] TINYINT NULL;
GO

View File

@ -0,0 +1,6 @@
GO
ALTER TABLE [dbo].[MessageCore]
ADD [HerbergReportType] NVARCHAR (50) NULL,
[HerbergEmailContactReportingVessel] NVARCHAR (255) NULL,
[HerbergEmail24HrsContact] NVARCHAR (255) NULL;
GO

View File

@ -0,0 +1,17 @@
GO
CREATE TABLE [dbo].[Customer] (
[Id] UNIQUEIDENTIFIER ROWGUIDCOL NOT NULL,
[Name] NVARCHAR (100) NULL,
[Phone] NVARCHAR (50) NULL,
[Email] NVARCHAR (100) NULL,
[ContactFirstName] NVARCHAR (50) NULL,
[ContactLastName] NVARCHAR (50) NULL,
[StreetAndNumber] NVARCHAR (50) NULL,
[PostalCode] NVARCHAR (50) NULL,
[City] NVARCHAR (50) NULL,
[Country] NVARCHAR (50) NULL,
[CustomerNumber] NVARCHAR (50) NULL
);
GO

View File

@ -67,44 +67,45 @@ namespace SendNSWMessageService
// Datenbank auf zu sendende Objekte überprüfen und laden // Datenbank auf zu sendende Objekte überprüfen und laden
List<DatabaseEntity> messagesToSendList = DBManager.Instance.GetToSendMessageList(); List<Message> messagesToSendList = DBManager.Instance.GetToSendMessageList();
foreach (DatabaseEntity entity in messagesToSendList) foreach (Message message in messagesToSendList)
{ {
try try
{ {
_log.InfoFormat("Sending CORE message for {0} application to {1}", _log.InfoFormat("Sending {0} message to {1}",
entity.MessageCore.IsTransit ? "TRANSIT" : "VISIT", entity.MessageCore.InitialHIS.ToString()); message.MessageNotificationClass.ToString(), message.HIS.ToString());
bool sendSucceeded = false; bool sendSucceeded = false;
// switch über passendes HIS / Schnittstelle // switch über passendes HIS / Schnittstelle
switch (entity.MessageCore.InitialHIS) switch (message.HIS)
{ {
case Message.NSWProvider.DBH: case Message.NSWProvider.DBH:
sendSucceeded = bsmd.dbh.Request.SendMessage(entity); sendSucceeded = bsmd.dbh.Request.SendMessage(message);
break; break;
case Message.NSWProvider.DAKOSY: case Message.NSWProvider.DAKOSY:
_log.Warn("Cannot send via DAKOSY yet"); sendSucceeded = bsmd.dakosy.Request.Send(message);
break; break;
case Message.NSWProvider.DUDR: case Message.NSWProvider.DUDR:
_log.Warn("Cannot send via Daten und Dienste HRO yet"); _log.Warn("Cannot send via Daten und Dienste HRO yet");
break; break;
default: default:
_log.WarnFormat("Initial HIS not specified for message {0}", entity.Id); _log.WarnFormat("Initial HIS not specified for message {0}", message.Id);
break; break;
} }
if (sendSucceeded) if (sendSucceeded)
{ {
entity.InternalStatus = Message.BSMDStatus.SENT; message.InternalStatus = Message.BSMDStatus.SENT;
DBManager.Instance.Save(entity); message.SentAt = DateTime.Now;
DBManager.Instance.Save(message);
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
_log.ErrorFormat("SENDING message {0}: {1}", entity.Id.ToString(), ex.Message); _log.ErrorFormat("SENDING message {0}: {1}", message.Id.ToString(), ex.Message);
} }
} }

View File

@ -102,6 +102,10 @@
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\bsmd.dakosy\bsmd.dakosy.csproj">
<Project>{6255f8c4-b0b5-4e77-860e-10ebcd7b368f}</Project>
<Name>bsmd.dakosy</Name>
</ProjectReference>
<ProjectReference Include="..\bsmd.database\bsmd.database.csproj"> <ProjectReference Include="..\bsmd.database\bsmd.database.csproj">
<Project>{19945af2-379b-46a5-b27a-303b5ec1d557}</Project> <Project>{19945af2-379b-46a5-b27a-303b5ec1d557}</Project>
<Name>bsmd.database</Name> <Name>bsmd.database</Name>

View File

@ -47,11 +47,12 @@ namespace bsmd.EMailReceiveService
this.Init(args); this.Init(args);
this.EventLog.WriteEntry("NSW Send Service started.", EventLogEntryType.Information); this.EventLog.WriteEntry("NSW EMail Receive Service started.", EventLogEntryType.Information);
} }
protected override void OnStop() protected override void OnStop()
{ {
_log.Info("EmailReceiveService stopped");
} }
public void Init(string[] args) public void Init(string[] args)

View File

@ -1,5 +1,4 @@
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following // General Information about an assembly is controlled through the following

View File

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

View File

@ -0,0 +1,34 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.21005.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsmd.dakosy.ResponseService", "bsmd.dakosy.ResponseService\bsmd.dakosy.ResponseService.csproj", "{FAA407A9-E95B-4481-B215-3BBDCD5142BD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsmd.database", "bsmd.database\bsmd.database.csproj", "{19945AF2-379B-46A5-B27A-303B5EC1D557}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bsmd.dakosy", "bsmd.dakosy\bsmd.dakosy.csproj", "{6255F8C4-B0B5-4E77-860E-10EBCD7B368F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FAA407A9-E95B-4481-B215-3BBDCD5142BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FAA407A9-E95B-4481-B215-3BBDCD5142BD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FAA407A9-E95B-4481-B215-3BBDCD5142BD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FAA407A9-E95B-4481-B215-3BBDCD5142BD}.Release|Any CPU.Build.0 = Release|Any CPU
{19945AF2-379B-46A5-B27A-303B5EC1D557}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19945AF2-379B-46A5-B27A-303B5EC1D557}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19945AF2-379B-46A5-B27A-303B5EC1D557}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19945AF2-379B-46A5-B27A-303B5EC1D557}.Release|Any CPU.Build.0 = Release|Any CPU
{6255F8C4-B0B5-4E77-860E-10EBCD7B368F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6255F8C4-B0B5-4E77-860E-10EBCD7B368F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6255F8C4-B0B5-4E77-860E-10EBCD7B368F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6255F8C4-B0B5-4E77-860E-10EBCD7B368F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="bsmd.dakosy.ResponseService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<userSettings>
<bsmd.dakosy.ResponseService.Properties.Settings>
<setting name="ConnectionString" serializeAs="String">
<value>replace me!</value>
</setting>
</bsmd.dakosy.ResponseService.Properties.Settings>
</userSettings>
</configuration>

View File

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading.Tasks;
namespace bsmd.dakosy.ResponseService
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new SFTPService()
};
if (Debugger.IsAttached)
{
((SFTPService)ServicesToRun[0]).Init(null);
while (true) ;
}
else
{
ServiceBase.Run(ServicesToRun);
}
}
}
}

View File

@ -0,0 +1,17 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("bsmd.dakosy.ResponseService")]
[assembly: AssemblyDescription("Windows Service checks SFTP directory for NSW reponse messages")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2c75088a-ee3a-4d17-a2e1-42c6dcd6f66f")]

View File

@ -0,0 +1,38 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34209
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace bsmd.dakosy.ResponseService.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("replace me!")]
public string ConnectionString {
get {
return ((string)(this["ConnectionString"]));
}
set {
this["ConnectionString"] = value;
}
}
}
}

View File

@ -0,0 +1,9 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="bsmd.dakosy.ResponseService.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="ConnectionString" Type="System.String" Scope="User">
<Value Profile="(Default)">replace me!</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@ -0,0 +1,37 @@
namespace bsmd.dakosy.ResponseService
{
partial class SFTPService
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.ServiceName = "Service1";
}
#endregion
}
}

View File

@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Timers;
using System.Threading.Tasks;
using log4net;
using bsmd.database;
using bsmd.dakosy;
namespace bsmd.dakosy.ResponseService
{
/// <summary>
/// Windows service zum Abruf von NSW Response Dateien via SFTP und Import der Dateien in die DB
/// </summary>
public partial class SFTPService : ServiceBase
{
private Timer _timer;
private object _timerlock = new object();
private bool processRunning = false;
private ILog _log = LogManager.GetLogger(typeof(SFTPService));
public SFTPService()
{
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
InitializeComponent();
}
protected override void OnStart(string[] args)
{
this.EventLog.Source = this.ServiceName;
this.EventLog.Log = "Application";
this.EventLog.BeginInit();
if (!EventLog.SourceExists(this.EventLog.Source, this.EventLog.Log))
EventLog.CreateEventSource(this.EventLog.Source, this.EventLog.Log);
this.EventLog.EndInit();
this.Init(args);
this.EventLog.WriteEntry("NSW SFTP Response Service started.", EventLogEntryType.Information);
}
protected override void OnStop()
{
_log.Info("SFTPService stopped");
}
public void Init(string[] args)
{
this._timer = new Timer();
this._timer.Interval = 600000; // 10 Min, TODO: Settings
this._timer.Elapsed += _timer_Elapsed;
this._timer.Enabled = true;
if (Debugger.IsAttached)
this._timer_Elapsed(null, null);
}
void _timer_Elapsed(object sender, ElapsedEventArgs e)
{
lock (this._timerlock)
{
if (this.processRunning) return;
else this.processRunning = true;
}
string localDir = ""; // TBD
if (DBManager.Instance.Connect(Properties.Settings.Default.ConnectionString))
{
try
{
// SFTP verbindung öffnen und alle Dateien herunterladen
sftp.GetAll(localDir);
// lokale Dateien verarbeiten
foreach(string inputFile in Directory.GetFiles(localDir))
{
if (!Response.Read(inputFile))
_log.ErrorFormat("Error reading input file {0}", inputFile);
else
File.Delete(inputFile); // alternativ: move to archive folder
}
}
catch (Exception ex)
{
_log.ErrorFormat("Exception occurred: {0}", ex.ToString());
}
}
else
{
this.EventLog.WriteEntry("FormService stopped: DB connection failed", EventLogEntryType.Error);
this.Stop();
}
lock (this._timerlock)
{
this.processRunning = false;
}
}
}
}

View File

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FAA407A9-E95B-4481-B215-3BBDCD5142BD}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>bsmd.dakosy.ResponseService</RootNamespace>
<AssemblyName>bsmd.dakosy.ResponseService</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<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>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\bsmd.database\Properties\AssemblyProductInfo.cs">
<Link>Properties\AssemblyProductInfo.cs</Link>
</Compile>
<Compile Include="..\bsmd.database\Properties\AssemblyProjectInfo.cs">
<Link>Properties\AssemblyProjectInfo.cs</Link>
</Compile>
<Compile Include="..\bsmd.database\Properties\AssemblyProjectKeyInfo.cs">
<Link>Properties\AssemblyProjectKeyInfo.cs</Link>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="SFTPService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="SFTPService.Designer.cs">
<DependentUpon>SFTPService.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="..\bsmdKey.snk" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\bsmd.dakosy\bsmd.dakosy.csproj">
<Project>{6255f8c4-b0b5-4e77-860e-10ebcd7b368f}</Project>
<Name>bsmd.dakosy</Name>
</ProjectReference>
<ProjectReference Include="..\bsmd.database\bsmd.database.csproj">
<Project>{19945af2-379b-46a5-b27a-303b5ec1d557}</Project>
<Name>bsmd.database</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.3" targetFramework="net45" />
</packages>

View File

@ -0,0 +1,777 @@
//
// Class: Request
// Current CLR: 4.0.30319.34209
// System: Microsoft Visual Studio 10.0
// Author: dani
// Created: 4/29/2015 7:20:50 AM
//
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using log4net;
using bsmd.database;
namespace bsmd.dakosy
{
public class Request
{
private static ILog _log = LogManager.GetLogger(typeof(Request));
public static bool Send(DatabaseEntity dbEntity)
{
bool retval = true;
try
{
Message aMessage = null;
if (dbEntity.GetType().IsAssignableFrom(typeof(Message)))
aMessage = (Message)dbEntity;
else
aMessage = dbEntity.MessageHeader;
// fill eDeclaration class
eDeclarationMessage edm = new eDeclarationMessage();
edm.Version = "08.15";
edm.InterchangeHeader = new InterchangeHeaderType();
edm.InterchangeHeader.CreationTime = DateTime.UtcNow;
edm.InterchangeHeader.ExchangeNumber = "tbd";
edm.InterchangeHeader.TestIndicator = Properties.Settings.Default.TestMode;
edm.InterchangeHeader.Sender = new Participant();
edm.InterchangeHeader.Sender.ParticipantCode = new ParticipantCode();
edm.InterchangeHeader.Sender.ParticipantCode.AgencyID = "DAK";
edm.InterchangeHeader.Sender.ParticipantCode.Value = "BSM";
edm.InterchangeHeader.Recipient = new Participant();
edm.InterchangeHeader.Recipient.ParticipantCode = new ParticipantCode();
edm.InterchangeHeader.Recipient.ParticipantCode.AgencyID = "DAK";
edm.InterchangeHeader.Recipient.ParticipantCode.Value = "DAK";
eDeclarationMessageInterchangeBody b = new eDeclarationMessageInterchangeBody();
edm.InterchangeBody = b;
switch (aMessage.MessageNotificationClass)
{
#region VISIT / TRANSIT
case Message.NotificationClass.VISIT:
case Message.NotificationClass.TRANSIT:
{
eDeclarationMessageInterchangeBodyRequestIdList reqList = new eDeclarationMessageInterchangeBodyRequestIdList();
b.Item = reqList;
reqList.RequestId = new RequestId[1];
reqList.RequestId[0] = new RequestId();
reqList.RequestId[0].MessageHeader = new MessageHeaderType();
reqList.RequestId[0].MessageHeader.MessageReferenceNumber = aMessage.Id.ToString();
reqList.RequestId[0].MessageHeader = new MessageHeaderType();
reqList.RequestId[0].MessageHeader.CreationTime = DateTime.UtcNow;
reqList.RequestId[0].MessageHeader.CreationTimeSpecified = true;
reqList.RequestId[0].LocalReferenceNumber = aMessage.MessageCore.Id.Value.ToString("N");
reqList.RequestId[0].OriginatorsVoyageNumber = "tbd";
reqList.RequestId[0].MessageHeader.MessageRecipient = new Participant();
reqList.RequestId[0].MessageHeader.MessageRecipient.ParticipantCode = new ParticipantCode();
reqList.RequestId[0].MessageHeader.MessageRecipient.ParticipantCode.AgencyID = "DAK";
reqList.RequestId[0].MessageHeader.MessageRecipient.ParticipantCode.Value = "NSW";
reqList.RequestId[0].MessageHeader.MessageSender = new Participant();
reqList.RequestId[0].MessageHeader.MessageSender.ParticipantCode = new ParticipantCode();
reqList.RequestId[0].MessageHeader.MessageSender.ParticipantCode.AgencyID = "DAK";
reqList.RequestId[0].MessageHeader.MessageSender.ParticipantCode.Value = "TBD"; // TODO -> Absprache!
reqList.RequestId[0].ReportingParty = new ReportingParty();
reqList.RequestId[0].ReportingParty.City = aMessage.ReportingParty.City;
reqList.RequestId[0].ReportingParty.Country = aMessage.ReportingParty.Country;
reqList.RequestId[0].ReportingParty.EMail = aMessage.ReportingParty.EMail;
reqList.RequestId[0].ReportingParty.Fax = aMessage.ReportingParty.Fax;
reqList.RequestId[0].ReportingParty.FirstName = aMessage.ReportingParty.FirstName;
reqList.RequestId[0].ReportingParty.LastName = aMessage.ReportingParty.LastName;
reqList.RequestId[0].ReportingParty.Name = aMessage.ReportingParty.Name;
reqList.RequestId[0].ReportingParty.Phone = aMessage.ReportingParty.Phone;
reqList.RequestId[0].ReportingParty.PostalCode = aMessage.ReportingParty.PostalCode;
int lastBlank = aMessage.ReportingParty.StreetAndNumber.LastIndexOf(' ');
if (lastBlank > 0)
{
reqList.RequestId[0].ReportingParty.StreetName = aMessage.ReportingParty.StreetAndNumber.Substring(0, lastBlank);
reqList.RequestId[0].ReportingParty.StreetNumber = aMessage.ReportingParty.StreetAndNumber.Substring(lastBlank);
}
reqList.RequestId[0].ReportingParty.Type = ReportingPartyType.OTHERS; // TBD
reqList.RequestId[0].ReportingParty.TypeSpecified = false; // TBD
if (aMessage.MessageNotificationClass == Message.NotificationClass.TRANSIT)
{
reqList.RequestId[0].REG_TRANSIT = new REG_TRANSIT();
reqList.RequestId[0].REG_TRANSIT.EniNumber = aMessage.MessageCore.ENI;
reqList.RequestId[0].REG_TRANSIT.EtaKielCanal = aMessage.MessageCore.ETA.Value;
reqList.RequestId[0].REG_TRANSIT.ImoNumber = aMessage.MessageCore.IMO;
}
else
{
reqList.RequestId[0].REG_VISIT = new REG_VISIT();
reqList.RequestId[0].REG_VISIT.EniNumber = aMessage.MessageCore.ENI;
reqList.RequestId[0].REG_VISIT.EtaPortOfCall = aMessage.MessageCore.ETA.Value;
reqList.RequestId[0].REG_VISIT.ImoNumber = aMessage.MessageCore.IMO;
reqList.RequestId[0].REG_VISIT.PortOfCall = aMessage.MessageCore.PoC;
}
}
#endregion
break;
default:
eDeclarationMessageInterchangeBodyVisitList vList = new eDeclarationMessageInterchangeBodyVisitList();
b.Item = vList;
vList.Visit = new Visit[1];
vList.Visit[0] = new Visit();
vList.Visit[0].MessageHeader = new MessageHeaderType();
vList.Visit[0].MessageHeader.CreationTime = DateTime.UtcNow;
vList.Visit[0].MessageHeader.CreationTimeSpecified = true;
vList.Visit[0].MessageHeader.MessageRecipient = new Participant();
vList.Visit[0].MessageHeader.MessageRecipient.ParticipantCode = new ParticipantCode();
vList.Visit[0].MessageHeader.MessageRecipient.ParticipantCode.AgencyID = "DAK";
vList.Visit[0].MessageHeader.MessageRecipient.ParticipantCode.Value = "NSW";
vList.Visit[0].MessageHeader.MessageSender = new Participant();
vList.Visit[0].MessageHeader.MessageSender.ParticipantCode = new ParticipantCode();
vList.Visit[0].MessageHeader.MessageSender.ParticipantCode.AgencyID = "DAK";
vList.Visit[0].MessageHeader.MessageSender.ParticipantCode.Value = "TBD"; // TODO -> Absprache!
vList.Visit[0].MessageHeader.MessageReferenceNumber = aMessage.Id.Value.ToString("N");
vList.Visit[0].MessageType = MessageType.FULL; // bei DRAFT geht es nicht an das NSW
if (aMessage.MessageCore.IsTransit)
vList.Visit[0].TransitID = aMessage.MessageCore.TransitId;
else
vList.Visit[0].VisitID = aMessage.MessageCore.VisitId;
vList.Visit[0].RegisterAndAddTransitIdSpecified = false; // das machen wir erstmal nicht weil das so ein Spezialverfahren
vList.Visit[0].RegisterAndAddVisitIdSpecified = false; // von Dakosy zu sein scheint
vList.Visit[0].ImoNumber = aMessage.MessageCore.IMO;
vList.Visit[0].EniNumber = aMessage.MessageCore.ENI;
vList.Visit[0].LocalReferenceNumber = aMessage.MessageCore.Id.Value.ToString("N");
if (aMessage.Cancel)
{
vList.Visit[0].Cancelled = aMessage.Cancel;
vList.Visit[0].CancelledSpecified = true;
}
vList.Visit[0].RegularFerryRoute = false; // TBD, ist gar nicht bei uns bekannt?
vList.Visit[0].RegularFerryRouteSpecified = false;
vList.Visit[0].VesselOperator = new Participant();
vList.Visit[0].VesselOperator.ParticipantCode = new ParticipantCode();
vList.Visit[0].VesselOperator.ParticipantCode.AgencyID = "DAK";
vList.Visit[0].VesselOperator.ParticipantCode.Value = "TBD"; // TBD, das weiß ich auch nicht!
vList.Visit[0].ReportingParty = new ReportingParty();
vList.Visit[0].ReportingParty.City = aMessage.ReportingParty.City;
vList.Visit[0].ReportingParty.Country = aMessage.ReportingParty.Country;
vList.Visit[0].ReportingParty.EMail = aMessage.ReportingParty.EMail;
vList.Visit[0].ReportingParty.Fax = aMessage.ReportingParty.Fax;
vList.Visit[0].ReportingParty.FirstName = aMessage.ReportingParty.FirstName;
vList.Visit[0].ReportingParty.LastName = aMessage.ReportingParty.LastName;
vList.Visit[0].ReportingParty.Name = aMessage.ReportingParty.Name;
vList.Visit[0].ReportingParty.Phone = aMessage.ReportingParty.Phone;
vList.Visit[0].ReportingParty.PostalCode = aMessage.ReportingParty.PostalCode;
int aLastBlank = aMessage.ReportingParty.StreetAndNumber.LastIndexOf(' ');
if (aLastBlank > 0)
{
vList.Visit[0].ReportingParty.StreetName = aMessage.ReportingParty.StreetAndNumber.Substring(0, aLastBlank);
vList.Visit[0].ReportingParty.StreetNumber = aMessage.ReportingParty.StreetAndNumber.Substring(aLastBlank);
}
vList.Visit[0].ReportingParty.Type = ReportingPartyType.OTHERS; // TBD
vList.Visit[0].ReportingParty.TypeSpecified = false; // TBD
switch (aMessage.MessageNotificationClass)
{
case Message.NotificationClass.NOA_NOD:
bsmd.database.NOA_NOD noa_nod = dbEntity as bsmd.database.NOA_NOD;
if (noa_nod == null) throw new ApplicationException("dbEntity is no NOA_NOD message!");
vList.Visit[0].NOA_NOD = new NOA_NOD();
//vList.Visit[0].NOA_NOD.CallPurpose
vList.Visit[0].NOA_NOD.EtaToKielCanalSpecified = noa_nod.ETAToKielCanal.HasValue;
if (noa_nod.ETAToKielCanal.HasValue) vList.Visit[0].NOA_NOD.EtaToKielCanal = noa_nod.ETAToKielCanal.Value;
vList.Visit[0].NOA_NOD.EtaToNextPortSpecified = noa_nod.ETAToNextPort.HasValue;
if (noa_nod.ETAToNextPort.HasValue) vList.Visit[0].NOA_NOD.EtaToNextPort = noa_nod.ETAToNextPort.Value;
vList.Visit[0].NOA_NOD.EtaToPortOfCallSpecified = noa_nod.ETAToPortOfCall.HasValue;
if (noa_nod.ETAToPortOfCall.HasValue) vList.Visit[0].NOA_NOD.EtaToPortOfCall = noa_nod.ETAToPortOfCall.Value;
vList.Visit[0].NOA_NOD.EtdFromKielCanalSpecified = noa_nod.ETDFromKielCanal.HasValue;
if (noa_nod.ETDFromKielCanal.HasValue) vList.Visit[0].NOA_NOD.EtdFromKielCanal = noa_nod.ETDFromKielCanal.Value;
vList.Visit[0].NOA_NOD.EtdFromLastPortSpecified = noa_nod.ETDFromLastPort.HasValue;
if (noa_nod.ETDFromLastPort.HasValue) vList.Visit[0].NOA_NOD.EtdFromLastPort = noa_nod.ETDFromLastPort.Value;
vList.Visit[0].NOA_NOD.EtdFromPortOfCallSpecified = noa_nod.ETDFromPortOfCall.HasValue;
if (noa_nod.ETDFromPortOfCall.HasValue) vList.Visit[0].NOA_NOD.EtdFromPortOfCall = noa_nod.ETDFromPortOfCall.Value;
vList.Visit[0].NOA_NOD.LastPort = noa_nod.LastPort;
vList.Visit[0].NOA_NOD.NextPort = noa_nod.NextPort;
vList.Visit[0].NOA_NOD.CallPurpose = new CallPurpose[1];
if (noa_nod.CallPurposeCode.HasValue) // TBD: wir haben nur einen CallPurposeCode, hier gibt es mehrere?
{
vList.Visit[0].NOA_NOD.CallPurpose[0].CallPurposeCode = noa_nod.CallPurposeCode.Value;
vList.Visit[0].NOA_NOD.CallPurpose[0].CallPurposeDescription = noa_nod.CallPurposeDescription;
}
break;
case Message.NotificationClass.ATA:
bsmd.database.ATA ata = dbEntity as bsmd.database.ATA;
vList.Visit[0].ATA = new ATA();
if(ata.ATAPortOfCall.HasValue)
vList.Visit[0].ATA.AtaPortOfCall = ata.ATAPortOfCall.Value;
break;
case Message.NotificationClass.ATD:
bsmd.database.ATD atd = dbEntity as bsmd.database.ATD;
vList.Visit[0].ATD = new ATD();
if (atd.ATDPortOfCall.HasValue)
vList.Visit[0].ATD.AtdPortOfCall = atd.ATDPortOfCall.Value;
break;
case Message.NotificationClass.BPOL:
bsmd.database.BPOL bpol = dbEntity as bsmd.database.BPOL;
vList.Visit[0].BPOL = new BPOL();
if (bpol.PortOfItineraries.Count > 0)
{
vList.Visit[0].BPOL.PortOfItinerary = new PortOfItinerary[bpol.PortOfItineraries.Count];
for (int i = 0; i < bpol.PortOfItineraries.Count; i++)
{
if (bpol.PortOfItineraries[i].PortOfItineraryETA.HasValue)
vList.Visit[0].BPOL.PortOfItinerary[i].PortOfItineraryETA = bpol.PortOfItineraries[i].PortOfItineraryETA.Value;
vList.Visit[0].BPOL.PortOfItinerary[i].PortOfItineraryName = bpol.PortOfItineraries[i].PortOfItineraryName;
}
}
vList.Visit[0].BPOL.StowawayOnBoard = bpol.StowawaysOnBoard ?? false;
break;
case Message.NotificationClass.BKRA:
{
if (aMessage.Elements.Count > 0)
{
vList.Visit[0].BKRA = new BunkerFuel[aMessage.Elements.Count];
for (int i = 0; i < aMessage.Elements.Count; i++)
{
bsmd.database.BRKA bkra = aMessage.Elements[i] as bsmd.database.BRKA;
vList.Visit[0].BKRA[i] = new BunkerFuel();
vList.Visit[0].BKRA[i].BunkerFuelQuantityTNESpecified = bkra.BunkerFuelQuantity_TNE.HasValue;
vList.Visit[0].BKRA[i].BunkerFuelQuantityTNE = (double) (bkra.BunkerFuelQuantity_TNE ?? 0);
vList.Visit[0].BKRA[i].BunkerFuelType = bkra.BunkerFuelType;
}
}
}
break;
case Message.NotificationClass.BKRD:
{
if (aMessage.Elements.Count > 0)
{
vList.Visit[0].BKRD = new BunkerFuel[aMessage.Elements.Count];
for (int i = 0; i < aMessage.Elements.Count; i++)
{
bsmd.database.BRKD bkrd = aMessage.Elements[i] as bsmd.database.BRKD;
vList.Visit[0].BKRD[i] = new BunkerFuel();
vList.Visit[0].BKRD[i].BunkerFuelQuantityTNESpecified = bkrd.BunkerFuelQuantity_TNE.HasValue;
vList.Visit[0].BKRD[i].BunkerFuelQuantityTNE = (double)(bkrd.BunkerFuelQuantity_TNE ?? 0);
vList.Visit[0].BKRD[i].BunkerFuelType = bkrd.BunkerFuelType;
}
}
}
break;
case Message.NotificationClass.LADG: // TBD: dito
{
if (aMessage.Elements.Count > 0)
{
vList.Visit[0].LADG = new Cargo[aMessage.Elements.Count];
for (int i = 0; i < aMessage.Elements.Count; i++)
{
bsmd.database.LADG ladg = aMessage.Elements[i] as bsmd.database.LADG;
vList.Visit[0].LADG[i] = new Cargo();
vList.Visit[0].LADG[i].CargoCode = new CargoCode();
vList.Visit[0].LADG[i].CargoCode.CodeType = "NST_2007";
vList.Visit[0].LADG[i].CargoCode.Value = ladg.CargoCodeNST;
vList.Visit[0].LADG[i].CargoHandlingTypeSpecified = ladg.CargoHandlingType.HasValue;
byte ht = ladg.CargoHandlingType ?? 0;
vList.Visit[0].LADG[i].CargoHandlingType = (CargoHandlingType)ht;
vList.Visit[0].LADG[i].CargoGrossQuantityTNESpecified = ladg.CargoGrossQuantity_TNE.HasValue;
vList.Visit[0].LADG[i].CargoGrossQuantityTNE = (double) (ladg.CargoGrossQuantity_TNE ?? 0);
vList.Visit[0].LADG[i].CargoNumberOfItemsSpecified = ladg.CargoNumberOfItems.HasValue;
vList.Visit[0].LADG[i].CargoNumberOfItems = ladg.CargoNumberOfItems ?? 0;
}
}
}
break;
case Message.NotificationClass.CREW: // TBD: dito
{
if (aMessage.Elements.Count > 0)
{
vList.Visit[0].CREW = new CrewMember[aMessage.Elements.Count];
for (int i = 0; i < aMessage.Elements.Count; i++)
{
bsmd.database.CREW crew = aMessage.Elements[i] as bsmd.database.CREW;
vList.Visit[0].CREW[i] = new CrewMember();
vList.Visit[0].CREW[i].DateOfBirthSpecified = crew.CrewMemberDateOfBirth.HasValue;
if (vList.Visit[0].CREW[i].DateOfBirthSpecified)
vList.Visit[0].CREW[i].DateOfBirth = crew.CrewMemberDateOfBirth.Value;
vList.Visit[0].CREW[i].Duty = crew.CrewMemberDuty;
vList.Visit[0].CREW[i].FirstName = crew.CrewMemberFirstName;
vList.Visit[0].CREW[i].GenderSpecified = crew.CrewMemberGender.HasValue;
byte gender = crew.CrewMemberGender ?? 0;
vList.Visit[0].CREW[i].Gender = (GenderType)gender;
vList.Visit[0].CREW[i].IdentityDocumentId = crew.CrewMemberIdentityDocumentId;
vList.Visit[0].CREW[i].IdentityDocumentTypeSpecified = crew.CrewMemberIdentityDocumentType.HasValue;
byte dType = crew.CrewMemberIdentityDocumentType ?? 0;
vList.Visit[0].CREW[i].IdentityDocumentType = (IdentityDocumentType)dType;
vList.Visit[0].CREW[i].LastName = crew.CrewMemberLastName;
vList.Visit[0].CREW[i].Nationality = crew.CrewMemberNationality;
vList.Visit[0].CREW[i].PlaceOfBirth = crew.CrewMemberPlaceOfBirth;
vList.Visit[0].CREW[i].VisaNumber = crew.CrewMemberVisaNumber;
}
}
}
break;
case Message.NotificationClass.TIEFA:
bsmd.database.TIEFA tiefa = dbEntity as bsmd.database.TIEFA;
vList.Visit[0].TIEFA = new TIEFA();
if (tiefa.DraughtUponArrival_DMT.HasValue)
vList.Visit[0].TIEFA.DraughtUponArrivalDMT = tiefa.DraughtUponArrival_DMT.Value;
break;
case Message.NotificationClass.TIEFD:
bsmd.database.TIEFD tiefd = dbEntity as bsmd.database.TIEFD;
vList.Visit[0].TIEFD = new TIEFD();
if (tiefd.DraughtUponDeparture_DMT.HasValue)
vList.Visit[0].TIEFD.draughtUponDepartureDMT = tiefd.DraughtUponDeparture_DMT.Value;
break;
case Message.NotificationClass.INFO:
bsmd.database.INFO info = dbEntity as bsmd.database.INFO;
vList.Visit[0].INFO = new INFO();
if(info.ShippingArea.HasValue)
vList.Visit[0].INFO.ShippingArea = (ShippingAreaType)info.ShippingArea.Value;
vList.Visit[0].INFO.RequestedPositionInPortOfCall = info.RequestedPositionInPortOfCall;
vList.Visit[0].INFO.SpecialRequirementsOfShipAtBerth = info.SpecialRequirementsOfShipAtBerth;
vList.Visit[0].INFO.ConstructionCharacteristicsOfShip = info.ConstructionCharacteristicsOfShip;
vList.Visit[0].INFO.FumigatedBulkCargoSpecified = info.FumigatedBulkCargo.HasValue;
if(info.FumigatedBulkCargo.HasValue)
vList.Visit[0].INFO.FumigatedBulkCargo = info.FumigatedBulkCargo.Value != 0;
vList.Visit[0].INFO.DeadWeightSummerTNESpecified = info.DeplacementSummerDraught_TNE.HasValue;
if (info.DeplacementSummerDraught_TNE.HasValue)
vList.Visit[0].INFO.DeadWeightSummerTNE = info.DeplacementSummerDraught_TNE.Value;
break;
case Message.NotificationClass.MDH:
bsmd.database.MDH mdh = dbEntity as bsmd.database.MDH;
vList.Visit[0].MDH = new MDH();
vList.Visit[0].MDH.MdhSimplificationSpecified = mdh.MDHSimplification.HasValue;
vList.Visit[0].MDH.MdhSimplification = mdh.MDHSimplification ?? false;
vList.Visit[0].MDH.PortOfCallWhereCompleteMDHNotified = mdh.PortOfCallWhereCompleteMDHNotified;
vList.Visit[0].MDH.NonAccidentialDeathsDuringVoyageSpecified = mdh.NonAccidentalDeathsDuringVoyage.HasValue;
vList.Visit[0].MDH.NonAccidentialDeathsDuringVoyage = mdh.NonAccidentalDeathsDuringVoyage ?? false;
vList.Visit[0].MDH.NonAccidentialDeathsDuringVoyageCountSpecified = mdh.NonAccidentalDeathsDuringVoyageCount.HasValue;
vList.Visit[0].MDH.NonAccidentialDeathsDuringVoyageCount = mdh.NonAccidentalDeathsDuringVoyageCount ?? 0;
vList.Visit[0].MDH.SuspisionInfectiousNatureSpecified = mdh.SuspisionInfectiousNature.HasValue;
vList.Visit[0].MDH.SuspisionInfectiousNature = mdh.SuspisionInfectiousNature ?? false;
vList.Visit[0].MDH.NumberOfIllPersonsHigherThanExpectedSpecified = mdh.NumberOfIllPersonsHigherThanExpected.HasValue;
vList.Visit[0].MDH.NumberOfIllPersonsHigherThanExpected = mdh.NumberOfIllPersonsHigherThanExpected ?? false;
vList.Visit[0].MDH.NumberOfIllPersonsSpecified = mdh.NumberOfIllPersons.HasValue;
vList.Visit[0].MDH.NumberOfIllPersons = mdh.NumberOfIllPersons ?? 0;
vList.Visit[0].MDH.SickPersonsOnBoardSpecified = mdh.SickPersonsOnBoard.HasValue;
vList.Visit[0].MDH.SickPersonsOnBoard = mdh.SickPersonsOnBoard ?? false;
vList.Visit[0].MDH.MedicalConsultedSpecified = mdh.MedicalConsulted.HasValue;
vList.Visit[0].MDH.MedicalConsulted = mdh.MedicalConsulted ?? false;
vList.Visit[0].MDH.AwareOfConditionsForFurtherInfectionsSpecified = mdh.AwareOfFurtherInfections.HasValue;
vList.Visit[0].MDH.AwareOfConditionsForFurtherInfections = mdh.AwareOfFurtherInfections ?? false;
vList.Visit[0].MDH.SanitaryMeasuresAppliedSpecified = mdh.SanitaryMeasuresApplied.HasValue;
vList.Visit[0].MDH.SanitaryMeasuresApplied = mdh.SanitaryMeasuresApplied ?? false;
vList.Visit[0].MDH.SanitaryMeasuresDetails = new SanitaryMeasuresDetails();
vList.Visit[0].MDH.SanitaryMeasuresDetails.SanitaryMeasuresType = mdh.SanitaryMeasuresType;
vList.Visit[0].MDH.SanitaryMeasuresDetails.SanitaryMeasuresLocation = mdh.SanitaryMeasuresLocation;
if (mdh.SanitaryMeasuresDate.HasValue)
vList.Visit[0].MDH.SanitaryMeasuresDetails.SanitaryMeasuresDate = mdh.SanitaryMeasuresDate.Value;
vList.Visit[0].MDH.StowawaysDetectedSpecified = mdh.StowawaysDetected.HasValue;
vList.Visit[0].MDH.StowawaysDetected = mdh.StowawaysDetected ?? false;
vList.Visit[0].MDH.StowawaysJoiningLocation = mdh.StowawaysJoiningLocation;
vList.Visit[0].MDH.SickAnimalOrPetOnBoardSpecified = mdh.SickAnimalOrPetOnBoard.HasValue;
vList.Visit[0].MDH.SickAnimalOrPetOnBoard = mdh.SickAnimalOrPetOnBoard ?? false;
vList.Visit[0].MDH.ValidSanitaryControlExemptionOrCertificateOnBoardSpecified = mdh.ValidSanitaryControlExemptionOrCertificateOnBoard.HasValue;
vList.Visit[0].MDH.ValidSanitaryControlExemptionOrCertificateOnBoard = mdh.ValidSanitaryControlExemptionOrCertificateOnBoard ?? false;
vList.Visit[0].MDH.ValidSanitaryControlExemptionOrCertificate = new ValidSanitaryControlExemptionOrCertificate();
vList.Visit[0].MDH.ValidSanitaryControlExemptionOrCertificate.PlaceOfIssue = mdh.PlaceOfIssue;
if (mdh.DateOfIssue.HasValue)
vList.Visit[0].MDH.ValidSanitaryControlExemptionOrCertificate.DateOfIssue = mdh.DateOfIssue.Value;
vList.Visit[0].MDH.SanitaryControlReinspectionRequiredSpecified = mdh.SanitaryControlReinspectionRequired.HasValue;
vList.Visit[0].MDH.SanitaryControlReinspectionRequired = mdh.SanitaryControlReinspectionRequired ?? false;
vList.Visit[0].MDH.InfectedAreaVisitedSpecified = mdh.InfectedAreaVisited.HasValue;
vList.Visit[0].MDH.InfectedAreaVisited = mdh.InfectedAreaVisited ?? false;
vList.Visit[0].MDH.InfectedArea = new InfectedArea();
if (mdh.InfectedAreaDate.HasValue)
vList.Visit[0].MDH.InfectedArea.InfectedAreaDate = mdh.InfectedAreaDate.Value;
vList.Visit[0].MDH.InfectedArea.InfectedAreaPort = mdh.InfectedAreaPort;
if (mdh.PortOfCallLast30Days.Count > 0)
{
vList.Visit[0].MDH.PortsOfCallLast30Days = new PortOfCallLast30Days[mdh.PortOfCallLast30Days.Count];
for (int i = 0; i < mdh.PortOfCallLast30Days.Count; i++)
{
vList.Visit[0].MDH.PortsOfCallLast30Days[i] = new PortOfCallLast30Days();
vList.Visit[0].MDH.PortsOfCallLast30Days[i].Locode = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysLocode;
if (mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysDateOfDeparture.HasValue)
vList.Visit[0].MDH.PortsOfCallLast30Days[i].DateOfDeparture = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysDateOfDeparture.Value;
if (mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewMembersJoined.HasValue)
{
vList.Visit[0].MDH.PortsOfCallLast30Days[i].CrewMembersJoined = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewMembersJoined.Value;
if(mdh.PortOfCallLast30Days[i].CrewJoinedShip.Count > 0) {
vList.Visit[0].MDH.PortsOfCallLast30Days[i].CrewJoinedShipName = new CrewJoinedShipName[mdh.PortOfCallLast30Days[i].CrewJoinedShip.Count];
for (int j = 0; j < vList.Visit[0].MDH.PortsOfCallLast30Days[i].CrewJoinedShipName.Length; j++)
{
vList.Visit[0].MDH.PortsOfCallLast30Days[i].CrewJoinedShipName[j] = new CrewJoinedShipName();
vList.Visit[0].MDH.PortsOfCallLast30Days[i].CrewJoinedShipName[j].Name = mdh.PortOfCallLast30Days[i].CrewJoinedShip[j].PortOfCallLast30DaysCrewJoinedShipName;
}
}
}
}
}
break;
case Message.NotificationClass.NAME:
bsmd.database.NAME name = dbEntity as bsmd.database.NAME;
vList.Visit[0].NAME = new NAME();
vList.Visit[0].NAME.NameOfMaster = name.NameOfMaster;
break;
case Message.NotificationClass.PAS:
{
if (aMessage.Elements.Count > 0)
{
vList.Visit[0].PAS = new Passenger[aMessage.Elements.Count];
for (int i = 0; i < aMessage.Elements.Count; i++)
{
bsmd.database.PAS pas = aMessage.Elements[i] as bsmd.database.PAS;
vList.Visit[0].PAS[i] = new Passenger();
vList.Visit[0].PAS[i].DateOfBirthSpecified = pas.PassengerDateOfBirth.HasValue;
if (pas.PassengerDateOfBirth.HasValue)
vList.Visit[0].PAS[i].DateOfBirth = pas.PassengerDateOfBirth.Value;
vList.Visit[0].PAS[i].FirstName = pas.PassengerFirstName;
vList.Visit[0].PAS[i].GenderSpecified = pas.PassengerGender.HasValue;
if (pas.PassengerGender.HasValue)
vList.Visit[0].PAS[i].Gender = (GenderType)pas.PassengerGender.Value;
vList.Visit[0].PAS[i].IdentityDocumentId = pas.PassengerIdentityDocumentId;
vList.Visit[0].PAS[i].IdentityDocumentTypeSpecified = pas.PassengerIdentityDocumentType.HasValue;
if (pas.PassengerIdentityDocumentType.HasValue)
vList.Visit[0].PAS[i].IdentityDocumentType = (IdentityDocumentType)pas.PassengerIdentityDocumentType.Value;
vList.Visit[0].PAS[i].InTransitSpecified = pas.PassengerInTransit.HasValue;
if (pas.PassengerInTransit.HasValue)
vList.Visit[0].PAS[i].InTransit = pas.PassengerInTransit.Value;
vList.Visit[0].PAS[i].LastName = pas.PassengerLastName;
vList.Visit[0].PAS[i].Nationality = pas.PassengerNationality;
vList.Visit[0].PAS[i].PlaceOfBirth = pas.PassengerPlaceOfBirth;
vList.Visit[0].PAS[i].PortOfDisembarkation = pas.PassengerPortOfDisembarkation;
vList.Visit[0].PAS[i].PortOfEmbarkation = pas.PassengerPortOfEmbarkation;
vList.Visit[0].PAS[i].VisaNumber = pas.PassengerVisaNumber;
}
}
}
break;
case Message.NotificationClass.POBA:
{
bsmd.database.POBA poba = dbEntity as bsmd.database.POBA;
vList.Visit[0].PoBA = new PoBA();
if (poba.TotalCrewMembersOnBoardUponArrival.HasValue)
vList.Visit[0].PoBA.TotalCrewMembersOnBoardUponArrival = poba.TotalCrewMembersOnBoardUponArrival.Value;
if (poba.TotalPassengersOnBoardUponArrival.HasValue)
vList.Visit[0].PoBA.TotalPassengersOnBoardUponArrival = poba.TotalPassengersOnBoardUponArrival.Value;
if (poba.TotalStowawaysOnBoardUponArrival.HasValue)
vList.Visit[0].PoBA.TotalStowawaysOnBoardUponArrival = poba.TotalStowawaysOnBoardUponArrival.Value;
vList.Visit[0].PoBA.TotalPersonsOnBoardUponArrivalSpecified = poba.TotalPersonsOnBoardUponArrival.HasValue;
vList.Visit[0].PoBA.TotalPersonsOnBoardUponArrival = poba.TotalPersonsOnBoardUponArrival ?? 0;
}
break;
case Message.NotificationClass.POBD:
{
bsmd.database.POBD pobd = dbEntity as bsmd.database.POBD;
vList.Visit[0].PoBD = new PoBD();
if (pobd.TotalCrewMembersOnBoardUponDeparture.HasValue)
vList.Visit[0].PoBD.TotalCrewMembersOnBoardUponDeparture = pobd.TotalCrewMembersOnBoardUponDeparture.Value;
if (pobd.TotalPassengersOnBoardUponDeparture.HasValue)
vList.Visit[0].PoBD.TotalPassengersOnBoardUponDeparture = pobd.TotalPassengersOnBoardUponDeparture.Value;
if (pobd.TotalStowawaysOnBoardUponDeparture.HasValue)
vList.Visit[0].PoBD.TotalStowawaysOnBoardUponDeparture = pobd.TotalStowawaysOnBoardUponDeparture.Value;
vList.Visit[0].PoBD.TotalPersonsOnBoardUponDepartureSpecified = pobd.TotalPersonsOnBoardUponDeparture.HasValue;
vList.Visit[0].PoBD.TotalPersonsOnBoardUponDeparture = pobd.TotalPersonsOnBoardUponDeparture ?? 0;
}
break;
case Message.NotificationClass.PRE72H:
{
bsmd.database.PRE72H pre72h = dbEntity as bsmd.database.PRE72H;
vList.Visit[0].PRE72H = new PRE72H();
vList.Visit[0].PRE72H.Tanker = pre72h.Tanker ?? false;
if (vList.Visit[0].PRE72H.Tanker)
{
vList.Visit[0].PRE72H.TankerDetails = new TankerDetails();
byte thc = pre72h.TankerHullConfiguration ?? 0;
vList.Visit[0].PRE72H.TankerDetails.TankerHullConfiguration = (TankerHullConfigurationType)thc;
byte ccbt = pre72h.ConditionCargoBallastTanks ?? 0;
vList.Visit[0].PRE72H.TankerDetails.ConditionCargoBallastTanks = (ConditionCargoBallastTanksType)ccbt;
vList.Visit[0].PRE72H.TankerDetails.NatureOfCargo = pre72h.NatureOfCargo;
vList.Visit[0].PRE72H.TankerDetails.VolumeOfCargoTNESpecified = pre72h.VolumeOfCargo.HasValue;
vList.Visit[0].PRE72H.TankerDetails.VolumeOfCargoTNE = pre72h.VolumeOfCargo ?? 0.0f;
}
vList.Visit[0].PRE72H.PlannedOperations = pre72h.PlannedOperations;
vList.Visit[0].PRE72H.PlannedWorks = pre72h.PlannedWorks;
if(pre72h.DateOfLastExpandedInspection.HasValue)
vList.Visit[0].PRE72H.DateOfLastExpandedInspection = pre72h.DateOfLastExpandedInspection.Value;
if (pre72h.PlannedPeriodOfStay_HUR.HasValue)
vList.Visit[0].PRE72H.PlannedPeriodOfStayHUR = (double)pre72h.PlannedPeriodOfStay_HUR.Value;
}
break;
case Message.NotificationClass.SEC:
{
bsmd.database.SEC sec = dbEntity as bsmd.database.SEC;
vList.Visit[0].SEC = new SEC();
vList.Visit[0].SEC.SecSimplificationSpecified = sec.SECSimplification.HasValue;
vList.Visit[0].SEC.SecSimplification = sec.SECSimplification ?? false;
vList.Visit[0].SEC.PortOfCallWhereCompleteSECNotified = sec.PortOfCallWhereCompleteSECNotified;
vList.Visit[0].SEC.CsoLastName = sec.CSOLastName;
vList.Visit[0].SEC.CsoFirstName = sec.CSOFirstName;
vList.Visit[0].SEC.CsoPhone = sec.CSOPhone;
vList.Visit[0].SEC.CsoFax = sec.CSOFax;
vList.Visit[0].SEC.CsoeMail = sec.CSOEMail;
vList.Visit[0].SEC.ValidISSCOnBoardSpecified = sec.ValidISSCOnBoard.HasValue;
vList.Visit[0].SEC.ValidISSCOnBoard = sec.ValidISSCOnBoard ?? false;
vList.Visit[0].SEC.ReasonsForNoValidISSC = sec.ReasonsForNoValidISSC;
vList.Visit[0].SEC.IsscTypeSpecified = sec.ISSCType.HasValue;
byte isscType = sec.ISSCType ?? 0;
vList.Visit[0].SEC.IsscType = (IsscType)isscType;
vList.Visit[0].SEC.IsscIssuerTypeSpecified = sec.ISSCIssuerType.HasValue;
byte isscIssuerType = sec.ISSCIssuerType ?? 0;
vList.Visit[0].SEC.IsscIssuerType = (IsscIssuerType)isscIssuerType;
vList.Visit[0].SEC.IsscIssuerName = sec.ISSCIssuerName;
vList.Visit[0].SEC.IsscDateOfExpirationSpecified = sec.ISSCDateOfExpiration.HasValue;
if (sec.ISSCDateOfExpiration.HasValue)
vList.Visit[0].SEC.IsscDateOfExpiration = sec.ISSCDateOfExpiration.Value;
vList.Visit[0].SEC.ApprovedSecurityPlanOnBoardSpecified = sec.ApprovedSecurityPlanOnBoard.HasValue;
vList.Visit[0].SEC.ApprovedSecurityPlanOnBoard = sec.ApprovedSecurityPlanOnBoard ?? false;
vList.Visit[0].SEC.CurrentShipSecurityLevelSpecified = sec.CurrentShipSecurityLevel.HasValue;
vList.Visit[0].SEC.CurrentShipSecurityLevel = sec.CurrentShipSecurityLevel ?? 0;
vList.Visit[0].SEC.PortFacilityOfArrival = sec.PortFacilityOfArrival;
vList.Visit[0].SEC.GeneralDescriptionOfCargoSpecified = sec.GeneralDescriptionOfCargo.HasValue;
byte gdc = sec.GeneralDescriptionOfCargo ?? 0;
vList.Visit[0].SEC.GeneralDescriptionOfCargo = (GeneralCargoType)gdc;
if (sec.LastTenPortFacilitesCalled.Count > 0)
{
vList.Visit[0].SEC.LastTenPortFacilitiesCalled = new LastTenPortFacilitiesCalled[sec.LastTenPortFacilitesCalled.Count];
for (int i = 0; i < sec.LastTenPortFacilitesCalled.Count; i++)
{
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i] = new LastTenPortFacilitiesCalled();
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].PortName = sec.LastTenPortFacilitesCalled[i].PortFacilityPortName;
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].PortCountry = sec.LastTenPortFacilitesCalled[i].PortFacilityPortCountry;
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].PortLoCode = sec.LastTenPortFacilitesCalled[i].PortFacilityPortLoCode;
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].DateOfArrivalSpecified = sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfArrival.HasValue;
if (sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfArrival.HasValue)
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].DateOfArrival = sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfArrival.Value;
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].DateOfDepartureSpecified = sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfDeparture.HasValue;
if (sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfDeparture.HasValue)
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].DateOfDeparture = sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfDeparture.Value;
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].ShipSecurityLevelSpecified = sec.LastTenPortFacilitesCalled[i].PortFacilityShipSecurityLevel.HasValue;
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].ShipSecurityLevel = sec.LastTenPortFacilitesCalled[i].PortFacilityShipSecurityLevel ?? 0;
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].SecurityMattersToReport = sec.LastTenPortFacilitesCalled[i].PortFacilitySecurityMattersToReport;
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].GISISCode = sec.LastTenPortFacilitesCalled[i].PortFacilityGISISCode;
}
}
if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count > 0)
{
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled = new ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count];
for(int i=0;i<sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count;i++)
{
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationName = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationName;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationCode = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationLoCode;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationCoordinatesLatitudeSpecified = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLatitude.HasValue;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationCoordinatesLatitude = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLatitude ?? 0;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationCoordinatesLongitudeSpecified = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLongitude.HasValue;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationCoordinatesLongitude = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLongitude ?? 0;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].DateFromSpecified = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateFrom.HasValue;
if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateFrom.HasValue)
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].DateFrom = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateFrom.Value;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].DateToSpecified = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateTo.HasValue;
if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateTo.HasValue)
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].DateTo = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateTo.Value;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ActivityType = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityType;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].SecurityMattersToReport = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivitySecurityMattersToReport;
}
}
}
break;
case Message.NotificationClass.SERV:
{
if (aMessage.Elements.Count > 0)
{
vList.Visit[0].SERV = new Service[aMessage.Elements.Count];
for (int i = 0; i < aMessage.Elements.Count; i++)
{
bsmd.database.SERV serv = aMessage.Elements[i] as bsmd.database.SERV;
vList.Visit[0].SERV[i] = new Service();
vList.Visit[0].SERV[i].Beneficiary = serv.ServiceBeneficiary;
vList.Visit[0].SERV[i].InvoiceRecipient = serv.ServiceInvoiceRecipient;
vList.Visit[0].SERV[i].Name = serv.ServiceName;
}
}
}
break;
case Message.NotificationClass.TOWA:
{
if (aMessage.Elements.Count > 0)
{
vList.Visit[0].TOWA = new TowageArrival[aMessage.Elements.Count];
for (int i = 0; i < aMessage.Elements.Count; i++)
{
bsmd.database.TOWA towa = aMessage.Elements[i] as bsmd.database.TOWA;
vList.Visit[0].TOWA[i] = new TowageArrival();
vList.Visit[0].TOWA[i].BeamMTRSpecified = towa.TowageOnArrivalBeam_MTR.HasValue;
if (towa.TowageOnArrivalBeam_MTR.HasValue)
vList.Visit[0].TOWA[i].BeamMTR = towa.TowageOnArrivalBeam_MTR.Value;
vList.Visit[0].TOWA[i].DraughtDMTSpecified = towa.TowageOnArrivalDraught_DMT.HasValue;
if (towa.TowageOnArrivalDraught_DMT.HasValue)
vList.Visit[0].TOWA[i].DraughtDMT = towa.TowageOnArrivalDraught_DMT.Value;
vList.Visit[0].TOWA[i].Flag = towa.TowageOnArrivalFlag;
vList.Visit[0].TOWA[i].GrossTonnage = towa.TowageOnArrivalGrossTonnage ?? 0;
vList.Visit[0].TOWA[i].LengthOverallMTRSpecified = towa.TowageOnArrivalLengthOverall_MTR.HasValue;
if (towa.TowageOnArrivalLengthOverall_MTR.HasValue)
vList.Visit[0].TOWA[i].LengthOverallMTR = towa.TowageOnArrivalLengthOverall_MTR.Value;
vList.Visit[0].TOWA[i].Name = towa.TowageOnArrivalName;
vList.Visit[0].TOWA[i].PurposeOfCall = towa.TowageOnArrivalPurposeOfCall;
vList.Visit[0].TOWA[i].Remarks = towa.TowageOnArrivalRemarks;
vList.Visit[0].TOWA[i].TOWAOperator = new TOWAOperator();
vList.Visit[0].TOWA[i].TOWAOperator.OperatorCity = towa.TowageOnArrivalOperatorCity;
vList.Visit[0].TOWA[i].TOWAOperator.OperatorCompanyName = towa.TowageOnArrivalOperatorCompanyName;
vList.Visit[0].TOWA[i].TOWAOperator.OperatorCountry = towa.TowageOnArrivalOperatorCountry;
vList.Visit[0].TOWA[i].TOWAOperator.OperatorEMail = towa.TowageOnArrivalOperatorEmail;
vList.Visit[0].TOWA[i].TOWAOperator.OperatorFax = towa.TowageOnArrivalOperatorFax;
vList.Visit[0].TOWA[i].TOWAOperator.OperatorPhone = towa.TowageOnArrivalOperatorPhone;
vList.Visit[0].TOWA[i].TOWAOperator.OperatorPostalCode = towa.TowageOnArrivalOperatorPostalCode;
vList.Visit[0].TOWA[i].TOWAOperator.OperatorStreetAndNumber = towa.TowageOnArrivalOperatorStreetNameAndNumber;
}
}
}
break;
case Message.NotificationClass.TOWD:
{
if (aMessage.Elements.Count > 0)
{
vList.Visit[0].TOWD = new TowageDeparture[aMessage.Elements.Count];
for (int i = 0; i < aMessage.Elements.Count; i++)
{
bsmd.database.TOWD towd = aMessage.Elements[i] as bsmd.database.TOWD;
vList.Visit[0].TOWD[i] = new TowageDeparture();
vList.Visit[0].TOWD[i].BeamMTRSpecified = towd.TowageOnDepartureBeam_MTR.HasValue;
if (towd.TowageOnDepartureBeam_MTR.HasValue)
vList.Visit[0].TOWD[i].BeamMTR = towd.TowageOnDepartureBeam_MTR.Value;
vList.Visit[0].TOWD[i].DraughtDMTSpecified = towd.TowageOnDepartureDraught_DMT.HasValue;
if (towd.TowageOnDepartureDraught_DMT.HasValue)
vList.Visit[0].TOWD[i].DraughtDMT = towd.TowageOnDepartureDraught_DMT.Value;
vList.Visit[0].TOWD[i].Flag = towd.TowageOnDepartureFlag;
//vList.Visit[0].TOWD[i].GrossTonnage = towd.TowageOnDepartureGrossTonnage ?? 0;
//vList.Visit[0].TOWD[i].LengthOverallMTRSpecified = towd.TowageOnDepartureLengthOverall_MTR.HasValue;
//if (towd.TowageOnDepartureLengthOverall_MTR.HasValue)
//vList.Visit[0].TOWD[i].LengthOverallMTR = towd.TowageOnDepartureLengthOverall_MTR.Value;
vList.Visit[0].TOWD[i].Name = towd.TowageOnDepartureName;
// vList.Visit[0].TOWD[i].PurposeOfCall = towd.TowageOnDeparturePurposeOfCall;
vList.Visit[0].TOWD[i].Remarks = towd.TowageOnDepartureRemarks;
vList.Visit[0].TOWD[i].TOWDOperator = new TOWDOperator();
vList.Visit[0].TOWD[i].TOWDOperator.OperatorCity = towd.TowageOnDepartureOperatorCity;
vList.Visit[0].TOWD[i].TOWDOperator.OperatorCountry = towd.TowageOnDepartureOperatorCountry;
vList.Visit[0].TOWD[i].TOWDOperator.OperatorEMail = towd.TowageOnDepartureOperatorEmail;
vList.Visit[0].TOWD[i].TOWDOperator.OperatorFax = towd.TowageOnDepartureOperatorFax;
vList.Visit[0].TOWD[i].TOWDOperator.OperatorPhone = towd.TowageOnDepartureOperatorPhone;
vList.Visit[0].TOWD[i].TOWDOperator.OperatorPostalCode = towd.TowageOnDepartureOperatorPostalCode;
vList.Visit[0].TOWD[i].TOWDOperator.OperatorStreetAndNumber = towd.TowageOnDepartureOperatorStreetNameAndNumber;
}
}
}
break;
case Message.NotificationClass.STAT:
{
bsmd.database.STAT stat = dbEntity as bsmd.database.STAT;
vList.Visit[0].STAT = new STAT();
vList.Visit[0].STAT.ShipName = stat.ShipName;
vList.Visit[0].STAT.CallSign = stat.CallSign;
vList.Visit[0].STAT.MmsiNumber = stat.MMSINumber;
vList.Visit[0].STAT.Flag = stat.Flag;
vList.Visit[0].STAT.LengthOverallMTRSpecified = stat.LengthOverall_MTR.HasValue;
vList.Visit[0].STAT.LengthOverallMTR = stat.LengthOverall_MTR ?? 0;
vList.Visit[0].STAT.BeamMTRSpecified = stat.Beam_MTR.HasValue;
vList.Visit[0].STAT.BeamMTR = stat.Beam_MTR ?? 0;
vList.Visit[0].STAT.GrossTonnageSpecified = stat.GrossTonnage.HasValue;
vList.Visit[0].STAT.GrossTonnage = stat.GrossTonnage ?? 0;
vList.Visit[0].STAT.PortOfRegistry = stat.PortOfRegistry;
vList.Visit[0].STAT.InmarsatCallNumber = stat.InmarsatCallNumber;
vList.Visit[0].STAT.ShipType = stat.ShipType;
vList.Visit[0].STAT.ISMCompany = new ISMCompany();
vList.Visit[0].STAT.ISMCompany.IsmCompanyName = stat.ISMCompanyName;
vList.Visit[0].STAT.ISMCompany.IsmCompanyId = stat.ISMCompanyId;
vList.Visit[0].STAT.ISMCompany.IsmCompanyPostalCode = stat.ISMCompanyPostalCode;
int lastBlank = stat.ISMCompanyStreetAndNumber.LastIndexOf(' ');
if (lastBlank > 0)
{
vList.Visit[0].STAT.ISMCompany.IsmCompanyStreetName = stat.ISMCompanyStreetAndNumber.Substring(0, lastBlank);
vList.Visit[0].STAT.ISMCompany.IsmCompanyStreetNumber = stat.ISMCompanyStreetAndNumber.Substring(lastBlank);
}
vList.Visit[0].STAT.ISMCompany.IsmCompanyCity = stat.ISMCompanyCity;
vList.Visit[0].STAT.ISMCompany.IsmCompanyCountry = stat.ISMCompanyCountry;
}
break;
case Message.NotificationClass.WAS:
{
bsmd.database.WAS was = dbEntity as bsmd.database.WAS;
vList.Visit[0].WAS = new WAS();
vList.Visit[0].WAS.WasteDisposalValidExemptionSpecified = was.WasteDisposalValidExemption.HasValue;
vList.Visit[0].WAS.WasteDisposalValidExemption = was.WasteDisposalValidExemption ?? false;
vList.Visit[0].WAS.LastWasteDisposalPort = was.LastWasteDisposalPort;
vList.Visit[0].WAS.ConfirmationOfCorrectnessSpecified = was.ConfirmationOfCorrectness.HasValue;
vList.Visit[0].WAS.ConfirmationOfCorrectness = was.ConfirmationOfCorrectness ?? false;
vList.Visit[0].WAS.LastWasteDisposalDateSpecified = was.LastWasteDisposalDate.HasValue;
if (vList.Visit[0].WAS.LastWasteDisposalDateSpecified)
vList.Visit[0].WAS.LastWasteDisposalDate = was.LastWasteDisposalDate.Value;
if (was.WasteDisposalServiceProvider.Count > 0)
{
vList.Visit[0].WAS.WasteDisposalServiceProviderName = new WasteDisposalServiceProviderName[was.WasteDisposalServiceProvider.Count];
for (int i = 0; i < was.WasteDisposalServiceProvider.Count; i++)
{
vList.Visit[0].WAS.WasteDisposalServiceProviderName[i].ServiceProviderName = was.WasteDisposalServiceProvider[i].WasteDisposalServiceProviderName;
}
}
vList.Visit[0].WAS.WasteDisposalDeliverySpecified = was.WasteDisposalDelivery.HasValue;
byte wdd = was.WasteDisposalDelivery ?? 0;
vList.Visit[0].WAS.WasteDisposalDelivery = (WasteDisposalDeliveryType) wdd;
if (was.Waste.Count > 0)
{
vList.Visit[0].WAS.Waste = new Waste[was.Waste.Count];
for (int i = 0; i < was.Waste.Count; i++)
{
byte wt = was.Waste[i].WasteType ?? 0;
vList.Visit[0].WAS.Waste[i].WasteType = (WasteType)wt;
vList.Visit[0].WAS.Waste[i].Description = was.Waste[i].WasteDescription;
vList.Visit[0].WAS.Waste[i].DisposalAmountMTQSpecified = was.Waste[i].WasteDisposalAmount_MTQ.HasValue;
vList.Visit[0].WAS.Waste[i].DisposalAmountMTQ = was.Waste[i].WasteDisposalAmount_MTQ ?? 0;
vList.Visit[0].WAS.Waste[i].CapacityMTQSpecified = was.Waste[i].WasteCapacity_MTQ.HasValue;
vList.Visit[0].WAS.Waste[i].CapacityMTQ = was.Waste[i].WasteCapacity_MTQ ?? 0;
vList.Visit[0].WAS.Waste[i].AmountRetainedMTQSpecified = was.Waste[i].WasteAmountRetained_MTQ.HasValue;
vList.Visit[0].WAS.Waste[i].AmountRetainedMTQ = was.Waste[i].WasteAmountRetained_MTQ ?? 0;
vList.Visit[0].WAS.Waste[i].DisposalPort = was.Waste[i].WasteDisposalPort;
vList.Visit[0].WAS.Waste[i].AmountGeneratedTillNextPortMTQSpecified = was.Waste[i].WasteAmountGeneratedTillNextPort_MTQ.HasValue;
vList.Visit[0].WAS.Waste[i].AmountGeneratedTillNextPortMTQ = was.Waste[i].WasteAmountGeneratedTillNextPort_MTQ ?? 0;
}
}
}
break;
}
break;
}
// save to temp file
string fileName = string.Format(@"{0}\{1}.xml", Properties.Settings.Default.SFTPOutDir, Guid.NewGuid().ToString());
XmlSerializer serializer = new XmlSerializer(typeof(eDeclarationMessage));
using(TextWriter tw = new StreamWriter(fileName)) {
serializer.Serialize(tw, edm);
}
// call sftp client to send
sftp.Put(fileName);
// remove sent file if not test mode
if (!Properties.Settings.Default.TestMode)
File.Delete(fileName);
}
catch(Exception ex)
{
_log.ErrorFormat("sending failed:{0}", ex.Message);
retval = false;
}
return retval;
}
}
}

View File

@ -0,0 +1,100 @@
//
// Class: Response
// Current CLR: 4.0.30319.34209
// System: Microsoft Visual Studio 10.0
// Author: dani
// Created: 5/5/2015 8:13:01 AM
//
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
using log4net;
using bsmd.database;
namespace bsmd.dakosy
{
public class Response
{
private static ILog _log = LogManager.GetLogger(typeof(Request));
public static bool Read(string fullPath)
{
bool retval = true;
try
{
XmlSerializer serializer = new XmlSerializer(typeof(EdiResponse));
FileStream fs = new FileStream(fullPath, FileMode.Open);
using (TextReader reader = new StreamReader(fs))
{
EdiResponse ediResponse = (EdiResponse)serializer.Deserialize(reader);
Guid localReferenceId, messageReferenceId;
if (!Guid.TryParseExact(ediResponse.LocalReferenceNumber, "N", out localReferenceId))
{
_log.ErrorFormat("unable to parse local reference number {0}", ediResponse.LocalReferenceNumber);
}
if(!Guid.TryParseExact(ediResponse.MessageHeader.MessageReferenceNumber, "N", out messageReferenceId))
{
_log.ErrorFormat("unable to parse message reference id {0}", ediResponse.MessageHeader.MessageReferenceNumber);
}
// passendes Objekt in der DB finden:
MessageCore core = DBManager.Instance.GetMessageCoreById(localReferenceId);
DatabaseEntity dbEntity = DBManager.Instance.GetMessageById(messageReferenceId);
// Objekte aktualisieren und speichern
Message aMessage = null;
if (dbEntity.GetType().IsAssignableFrom(typeof(Message)))
aMessage = (Message)dbEntity;
else
aMessage = dbEntity.MessageHeader;
//ediResponse.ResponseSubType == EdiResponseSubType.FUNCTIONAL // TECHNICAL
switch (ediResponse.ResponseType)
{
case EdiResponseType.ACCEPTED:
_log.Info("response message accepted");
break;
case EdiResponseType.ERROR:
_log.Info("response message error status");
break;
case EdiResponseType.PART_ACCEPTED:
_log.Info("response message part accepted");
break;
case EdiResponseType.RECEIVED:
_log.Info("response message received");
break;
}
//aMessage.Status = Message.MessageStatus.
aMessage.InternalStatus = Message.BSMDStatus.RESPONDED;
DBManager.Instance.Save(aMessage);
}
fs.Close();
}
catch (Exception ex)
{
_log.ErrorFormat("error parsing response:{0}", ex.ToString());
retval = false;
}
return retval;
}
}
}

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="bsmd.dakosy.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
</configSections>
<applicationSettings>
<bsmd.dakosy.Properties.Settings>
<setting name="SFTPSessionName" serializeAs="String">
<value>dakosy</value>
</setting>
<setting name="SFTPLog" serializeAs="String">
<value>c:\temp\sftp_log.xml</value>
</setting>
<setting name="SFTPOutDir" serializeAs="String">
<value>e:\temp\dakosy\out</value>
</setting>
<setting name="SFTPInDir" serializeAs="String">
<value>e:\temp\dakosy\in</value>
</setting>
<setting name="TestMode" serializeAs="String">
<value>True</value>
</setting>
<setting name="WINSCPFullPath" serializeAs="String">
<value>E:\Tools\WinScp\WinSCP.exe</value>
</setting>
</bsmd.dakosy.Properties.Settings>
</applicationSettings>
</configuration>

View File

@ -65,6 +65,7 @@
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
</Compile> </Compile>
<Compile Include="Request.cs" /> <Compile Include="Request.cs" />
<Compile Include="Response.cs" />
<Compile Include="sftp.cs" /> <Compile Include="sftp.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -716,6 +716,9 @@ public enum EdiResponseType {
/// <remarks/> /// <remarks/>
ERROR, ERROR,
/// <remarks/>
PART_ACCEPTED,
/// <remarks/> /// <remarks/>
RECEIVED, RECEIVED,
} }

View File

@ -0,0 +1,90 @@
//
// Class: sftp
// Current CLR: 4.0.30319.34209
// System: Microsoft Visual Studio 10.0
// Author: dani
// Created: 4/28/2015 8:53:41 AM
//
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
using System;
using System.Diagnostics;
using System.Xml;
using System.Xml.XPath;
using System.Collections.Generic;
namespace bsmd.dakosy
{
/// <summary>
/// Hilfsklasse zur Kommunikation via SFTP. Wir machen es uns hier leicht und verwenden das beliebte WINSCP im
/// Process-Modus. (http://winscp.net/eng/docs/guide_dotnet)
/// </summary>
public static class sftp
{
public static void Put(string fullPath)
{
Process winscp = new Process();
winscp.StartInfo.FileName = Properties.Settings.Default.WINSCPFullPath;
winscp.StartInfo.Arguments = "/xmllog=\"" + Properties.Settings.Default.SFTPLog + "\"";
winscp.StartInfo.UseShellExecute = false;
winscp.StartInfo.RedirectStandardInput = true;
winscp.StartInfo.RedirectStandardOutput = true;
winscp.StartInfo.CreateNoWindow = true;
winscp.Start();
// Feed in the scripting commands
winscp.StandardInput.WriteLine("option batch abort");
winscp.StandardInput.WriteLine("option confirm off");
winscp.StandardInput.WriteLine("open " + Properties.Settings.Default.SFTPSessionName);
winscp.StandardInput.WriteLine("ls");
winscp.StandardInput.WriteLine("put " + fullPath);
winscp.StandardInput.Close();
// Collect all output (not used in this example)
string output = winscp.StandardOutput.ReadToEnd();
// Wait until WinSCP finishes
winscp.WaitForExit();
/*
// Parse and interpret the XML log
// (Note that in case of fatal failure the log file may not exist at all)
XPathDocument log = new XPathDocument(Properties.Settings.Default.SFTPLog);
XmlNamespaceManager ns = new XmlNamespaceManager(new NameTable());
ns.AddNamespace("w", @"http://winscp.net/schema/session/1.0");
XPathNavigator nav = log.CreateNavigator();
// Success (0) or error?
if (winscp.ExitCode != 0)
{
Console.WriteLine("Error occured");
// See if there are any messages associated with the error
foreach (XPathNavigator message in nav.Select("//w:message", ns))
{
Console.WriteLine(message.Value);
}
}
else
{
// It can be worth looking for directory listing even in case of
// error as possibly only upload may fail
XPathNodeIterator files = nav.Select("//w:file", ns);
Console.WriteLine(string.Format("There are {0} files and subdirectories:", files.Count));
foreach (XPathNavigator file in files)
{
Console.WriteLine(file.SelectSingleNode("w:filename/@value", ns).Value);
}
}
*/
}
public static void GetAll(string fullPath)
{
}
}
}

View File

@ -19,7 +19,7 @@ namespace bsmd.database
public BRKA() public BRKA()
{ {
this.tablename = "[dbo].[BRKA]"; this.tablename = "[dbo].[BKRA]";
} }
#region Properties #region Properties
@ -82,7 +82,7 @@ namespace bsmd.database
bkra.id = reader.GetGuid(0); bkra.id = reader.GetGuid(0);
if (!reader.IsDBNull(1)) bkra.BunkerFuelType = reader.GetString(1); if (!reader.IsDBNull(1)) bkra.BunkerFuelType = reader.GetString(1);
if (!reader.IsDBNull(2)) bkra.BunkerFuelQuantity_TNE = reader.GetFloat(2); if (!reader.IsDBNull(2)) bkra.BunkerFuelQuantity_TNE = (float) reader.GetDouble(2);
result.Add(bkra); result.Add(bkra);
} }
reader.Close(); reader.Close();

View File

@ -19,7 +19,7 @@ namespace bsmd.database
public BRKD() public BRKD()
{ {
this.tablename = "[dbo].[BRKD]"; this.tablename = "[dbo].[BKRD]";
} }
#region Properties #region Properties
@ -82,7 +82,7 @@ namespace bsmd.database
bkrd.id = reader.GetGuid(0); bkrd.id = reader.GetGuid(0);
if (!reader.IsDBNull(1)) bkrd.BunkerFuelType = reader.GetString(1); if (!reader.IsDBNull(1)) bkrd.BunkerFuelType = reader.GetString(1);
if (!reader.IsDBNull(2)) bkrd.BunkerFuelQuantity_TNE = reader.GetFloat(2); if (!reader.IsDBNull(2)) bkrd.BunkerFuelQuantity_TNE = (float) reader.GetDouble(2);
result.Add(bkrd); result.Add(bkrd);
} }
reader.Close(); reader.Close();

View File

@ -36,7 +36,7 @@ namespace bsmd.database
public string CrewMemberNationality { get; set; } public string CrewMemberNationality { get; set; }
public byte? CrewMemberDocumentType { get; set; } public byte? CrewMemberIdentityDocumentType { get; set; }
public string CrewMemberIdentityDocumentId { get; set; } public string CrewMemberIdentityDocumentId { get; set; }
@ -60,7 +60,7 @@ namespace bsmd.database
scmd.Parameters.AddWithNullableValue("@P5", this.CrewMemberDateOfBirth); scmd.Parameters.AddWithNullableValue("@P5", this.CrewMemberDateOfBirth);
scmd.Parameters.AddWithNullableValue("@P6", this.CrewMemberGender); scmd.Parameters.AddWithNullableValue("@P6", this.CrewMemberGender);
scmd.Parameters.AddWithNullableValue("@P7", this.CrewMemberNationality); scmd.Parameters.AddWithNullableValue("@P7", this.CrewMemberNationality);
scmd.Parameters.AddWithNullableValue("@P8", this.CrewMemberDocumentType); scmd.Parameters.AddWithNullableValue("@P8", this.CrewMemberIdentityDocumentType);
scmd.Parameters.AddWithNullableValue("@P9", this.CrewMemberIdentityDocumentId); scmd.Parameters.AddWithNullableValue("@P9", this.CrewMemberIdentityDocumentId);
scmd.Parameters.AddWithNullableValue("@P10", this.CrewMemberVisaNumber); scmd.Parameters.AddWithNullableValue("@P10", this.CrewMemberVisaNumber);
scmd.Parameters.AddWithNullableValue("@P11", this.CrewMemberDuty); scmd.Parameters.AddWithNullableValue("@P11", this.CrewMemberDuty);
@ -68,7 +68,7 @@ namespace bsmd.database
if (this.IsNew) if (this.IsNew)
{ {
scmd.CommandText = string.Format("INSERT INTO {0} (MessageHeaderId, CrewMemberLastName, CrewMemberFirstName, " + scmd.CommandText = string.Format("INSERT INTO {0} (MessageHeaderId, CrewMemberLastName, CrewMemberFirstName, " +
"CrewMemberPlaceOfBirth, CrewMemberDateOfBirth, CrewMemberGender, CrewMemberNationality,CrewMemberDocumentType, " + "CrewMemberPlaceOfBirth, CrewMemberDateOfBirth, CrewMemberGender, CrewMemberNationality,CrewMemberIdentityDocumentType, " +
"CrewMemberIdentityDocumentId, CrewMemberVisaNumber, CrewMemberDuty) " + "CrewMemberIdentityDocumentId, CrewMemberVisaNumber, CrewMemberDuty) " +
"VALUES ( @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11 )", this.Tablename); "VALUES ( @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11 )", this.Tablename);
} }
@ -77,7 +77,7 @@ namespace bsmd.database
scmd.Parameters.AddWithValue(@"ID", this.Id); scmd.Parameters.AddWithValue(@"ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET CrewMemberLastName = @P2, CrewMemberFirstName = @P3, " + scmd.CommandText = string.Format("UPDATE {0} SET CrewMemberLastName = @P2, CrewMemberFirstName = @P3, " +
"CrewMemberPlaceOfBirth = @P4, CrewMemberDateOfBirth = @P5, CrewMemberGender = @P6, CrewMemberNationality = @P7, "+ "CrewMemberPlaceOfBirth = @P4, CrewMemberDateOfBirth = @P5, CrewMemberGender = @P6, CrewMemberNationality = @P7, "+
"CrewMemberDocumentType = @P8, CrewMemberIdentityDocumentId = @P9, CrewMemberVisaNumber = @P10, " + "CrewMemberIdentityDocumentType = @P8, CrewMemberIdentityDocumentId = @P9, CrewMemberVisaNumber = @P10, " +
"CrewMemberDuty = @P11 WHERE Id = @ID", this.Tablename); "CrewMemberDuty = @P11 WHERE Id = @ID", this.Tablename);
} }
} }
@ -85,7 +85,7 @@ namespace bsmd.database
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria) public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
{ {
string query = string.Format("SELECT Id, CrewMemberLastName, CrewMemberFirstName, CrewMemberPlaceOfBirth, " + string query = string.Format("SELECT Id, CrewMemberLastName, CrewMemberFirstName, CrewMemberPlaceOfBirth, " +
"CrewMemberDateOfBirth, CrewMemberGender, CrewMemberNationality, CrewMemberDocumentType, CrewMemberIdentityDocumentId, " + "CrewMemberDateOfBirth, CrewMemberGender, CrewMemberNationality, CrewMemberIdentityDocumentType, CrewMemberIdentityDocumentId, " +
"CrewMemberVisaNumber, CrewMemberDuty FROM {0}", this.Tablename); "CrewMemberVisaNumber, CrewMemberDuty FROM {0}", this.Tablename);
switch (filter) switch (filter)
@ -118,7 +118,7 @@ namespace bsmd.database
if (!reader.IsDBNull(4)) crew.CrewMemberDateOfBirth = reader.GetDateTime(4); if (!reader.IsDBNull(4)) crew.CrewMemberDateOfBirth = reader.GetDateTime(4);
if (!reader.IsDBNull(5)) crew.CrewMemberGender = reader.GetByte(5); if (!reader.IsDBNull(5)) crew.CrewMemberGender = reader.GetByte(5);
if (!reader.IsDBNull(6)) crew.CrewMemberNationality = reader.GetString(6); if (!reader.IsDBNull(6)) crew.CrewMemberNationality = reader.GetString(6);
if (!reader.IsDBNull(7)) crew.CrewMemberDocumentType = reader.GetByte(7); if (!reader.IsDBNull(7)) crew.CrewMemberIdentityDocumentType = reader.GetByte(7);
if (!reader.IsDBNull(8)) crew.CrewMemberIdentityDocumentId = reader.GetString(8); if (!reader.IsDBNull(8)) crew.CrewMemberIdentityDocumentId = reader.GetString(8);
if (!reader.IsDBNull(9)) crew.CrewMemberVisaNumber = reader.GetString(9); if (!reader.IsDBNull(9)) crew.CrewMemberVisaNumber = reader.GetString(9);
if (!reader.IsDBNull(10)) crew.CrewMemberDuty = reader.GetString(10); if (!reader.IsDBNull(10)) crew.CrewMemberDuty = reader.GetString(10);

View File

@ -0,0 +1,138 @@
//
// Class: Customer
// Current CLR: 4.0.30319.34209
// System: Microsoft Visual Studio 10.0
// Author: dani
// Created: 5/9/2015 4:56:38 PM
//
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
namespace bsmd.database
{
/// <summary>
/// EU-NOAD: "Agency" Einträge werden in dieser Klasse/Tabelle gespeichert
/// TODO: Späterer Abgleich mit Wetris
/// </summary>
public class Customer : DatabaseEntity
{
public Customer()
{
this.tablename = "[dbo].[Customer]";
}
#region Properties
public string Name { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
public string ContactFirstName { get; set; }
public string ContactLastName { get; set; }
public string StreetAndNumber { get; set; }
public string PostalCode { get; set; }
public string City { get; set; }
public string Country { get; set; }
public string CustomerNumber { get; set; }
#endregion
public override string ToString()
{
return this.Name;
}
#region DatabaseEntity implementation
public override void PrepareSave(System.Data.IDbCommand cmd)
{
SqlCommand scmd = cmd as SqlCommand;
scmd.Parameters.AddWithNullableValue("@NAME", this.Name);
scmd.Parameters.AddWithNullableValue("@PHONE", this.Phone);
scmd.Parameters.AddWithNullableValue("@EMAIL", this.Email);
scmd.Parameters.AddWithNullableValue("@CFNAME", this.ContactFirstName);
scmd.Parameters.AddWithNullableValue("@CLNAME", this.ContactLastName);
scmd.Parameters.AddWithNullableValue("@STREET", this.StreetAndNumber);
scmd.Parameters.AddWithNullableValue("@POSTALCODE", this.PostalCode);
scmd.Parameters.AddWithNullableValue("@CITY", this.City);
scmd.Parameters.AddWithNullableValue("@COUNTRY", this.Country);
scmd.Parameters.AddWithNullableValue("@NUMBER", this.CustomerNumber);
if (this.IsNew)
{
this.CreateId();
scmd.Parameters.AddWithValue("@ID", this.Id);
scmd.CommandText = string.Format("INSERT INTO {0} (Id, Name, Phone, Email, ContactFirstName, ContactLastName, " +
"StreetAndNumber, PostalCode, City, Country, CustomerNumber) VALUES (@ID, @NAME, @PHONE, @EMAIL, @CFNAME, " +
"@CLNAME, @STREET, @POSTALCODE, @CITY, @COUNTRY, @NUMBER)", this.Tablename);
}
else
{
scmd.Parameters.AddWithValue("@ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET Name = @NAME, Phone = @Phone, Email = @EMAIL, " +
"ContactFirstName = @CFNAME, ContactLastName = @CLNAME, StreetAndNumber = @STREET, PostalCode = @POSTALCODE, " +
"City = @CITY, Country = @COUNTRY, CustomerNumber = @NUMBER 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, Name, Phone, Email, ContactFirstName, ContactLastName, StreetAndNumber, " +
"PostalCode, City, Country, CustomerNumber FROM {0} ", this.Tablename);
switch (filter)
{
case Message.LoadFilter.BY_ID:
query += " WHERE Id = @ID";
((SqlCommand)cmd).Parameters.AddWithValue("@ID", criteria[0]);
break;
default:
break;
}
cmd.CommandText = query;
}
public override List<DatabaseEntity> LoadList(System.Data.IDataReader reader)
{
List<DatabaseEntity> result = new List<DatabaseEntity>();
while (reader.Read())
{
Customer c = new Customer();
c.id = reader.GetGuid(0);
if (!reader.IsDBNull(1)) c.Name = reader.GetString(1);
if (!reader.IsDBNull(2)) c.Phone = reader.GetString(2);
if (!reader.IsDBNull(3)) c.Email = reader.GetString(3);
if (!reader.IsDBNull(4)) c.ContactFirstName = reader.GetString(4);
if (!reader.IsDBNull(5)) c.ContactLastName = reader.GetString(5);
if (!reader.IsDBNull(6)) c.StreetAndNumber = reader.GetString(6);
if (!reader.IsDBNull(7)) c.PostalCode = reader.GetString(7);
if (!reader.IsDBNull(8)) c.City = reader.GetString(8);
if (!reader.IsDBNull(9)) c.Country = reader.GetString(9);
if (!reader.IsDBNull(10)) c.CustomerNumber = reader.GetString(10);
result.Add(c);
}
reader.Close();
return result;
}
#endregion
}
}

View File

@ -79,6 +79,11 @@ namespace bsmd.database
return result; return result;
} }
/// <summary>
/// Lädt MessageCore (=Schiffsanlauf) einer EU-NOAD Nachricht vom Fleettracker / Herberg
/// </summary>
/// <param name="herbergFormGuid"></param>
/// <returns></returns>
public MessageCore GetHerbergFormMessage(Guid herbergFormGuid) public MessageCore GetHerbergFormMessage(Guid herbergFormGuid)
{ {
MessageCore aMessageCore = new MessageCore(); MessageCore aMessageCore = new MessageCore();
@ -94,7 +99,22 @@ namespace bsmd.database
return null; return null;
} }
public List<DatabaseEntity> GetToSendMessageList() public List<Message> GetMessagesForCore(MessageCore core)
{
Message aMessage = new Message();
SqlCommand cmd = new SqlCommand();
aMessage.PrepareLoadCommand(cmd, Message.LoadFilter.BY_CORE, core.Id);
IDataReader reader = this.PerformCommand(cmd);
List<DatabaseEntity> messages = aMessage.LoadList(reader);
List<Message> messageList = new List<Message>();
foreach (Message message in messages)
messageList.Add(message);
this.LoadMessageDependencies(messageList);
return messageList;
}
public List<Message> GetToSendMessageList()
{ {
Message aMessage = new Message(); Message aMessage = new Message();
SqlCommand cmd = new SqlCommand(); SqlCommand cmd = new SqlCommand();
@ -108,9 +128,9 @@ namespace bsmd.database
foreach (Message message in messages) foreach (Message message in messages)
messageList.Add(message); messageList.Add(message);
List<DatabaseEntity> result = this.LoadMessageDependencies(messageList); this.LoadMessageDependencies(messageList);
return result; return messageList;
} }
public Dictionary<Guid, ReportingParty> GetReportingPartyDict() public Dictionary<Guid, ReportingParty> GetReportingPartyDict()
@ -142,11 +162,13 @@ namespace bsmd.database
foreach (Message message in messages) foreach (Message message in messages)
messageList.Add(message); messageList.Add(message);
List<DatabaseEntity> result = this.LoadMessageDependencies(messageList); if (messageList.Count == 0) return null;
if(((Message)result[0]).MessageCoreId.HasValue)
result[0].MessageCore = this.GetMessageCoreById(((Message)result[0]).MessageCoreId.Value);
return result[0]; this.LoadMessageDependencies(messageList);
if(messageList[0].MessageCoreId.HasValue)
messageList[0].MessageCore = this.GetMessageCoreById(messageList[0].MessageCoreId.Value);
return messageList[0];
} }
public MessageCore GetMessageCoreById(Guid id) public MessageCore GetMessageCoreById(Guid id)
@ -159,8 +181,22 @@ namespace bsmd.database
SqlDataReader reader = this.PerformCommand(cmd); SqlDataReader reader = this.PerformCommand(cmd);
List<DatabaseEntity> cores = aCore.LoadList(reader); List<DatabaseEntity> cores = aCore.LoadList(reader);
if (cores.Count > 0) return cores[0] as MessageCore; MessageCore result = null;
return null; if (cores.Count > 0)
{
result = cores[0] as MessageCore;
if (result.CustomerId.HasValue)
{
Customer c = new Customer();
SqlCommand cCmd = new SqlCommand();
c.PrepareLoadCommand(cCmd, Message.LoadFilter.BY_ID, result.CustomerId.Value);
reader = this.PerformCommand(cCmd);
List<DatabaseEntity> customers = c.LoadList(reader);
if (customers.Count > 0)
result.Customer = customers[0] as Customer;
}
}
return result;
} }
@ -184,6 +220,14 @@ namespace bsmd.database
public void Save(MessageCore core) public void Save(MessageCore core)
{ {
if (core.Customer != null)
{
SqlCommand cCmd = new SqlCommand();
core.Customer.PrepareSave(cCmd);
_log.InfoFormat("Saved Customer to Core: {0}", this.PerformNonQuery(cCmd));
core.CustomerId = core.Customer.Id;
}
SqlCommand cmd = new SqlCommand(); SqlCommand cmd = new SqlCommand();
core.PrepareSave(cmd); core.PrepareSave(cmd);
int queryResult = this.PerformNonQuery(cmd); int queryResult = this.PerformNonQuery(cmd);
@ -197,11 +241,10 @@ namespace bsmd.database
#region internal/private funcs #region internal/private funcs
internal List<DatabaseEntity> LoadMessageDependencies(List<Message> messageList) internal void LoadMessageDependencies(List<Message> messageList)
{ {
Dictionary<Guid, MessageCore> messageCoreDict = this.GetToSendMessageCoreList(); Dictionary<Guid, MessageCore> messageCoreDict = this.GetToSendMessageCoreList();
Dictionary<Guid, ReportingParty> reportingPartyDict = this.GetReportingPartyDict(); Dictionary<Guid, ReportingParty> reportingPartyDict = this.GetReportingPartyDict();
List<DatabaseEntity> result = new List<DatabaseEntity>();
// Zuordnung MessageCore,Zuordnung Reporting party // Zuordnung MessageCore,Zuordnung Reporting party
Message.AssignReportingParties(messageList, reportingPartyDict); Message.AssignReportingParties(messageList, reportingPartyDict);
@ -221,19 +264,18 @@ namespace bsmd.database
msgClass.PrepareLoadCommand(cmd, Message.LoadFilter.MESSAGEHEADER, message.Id); msgClass.PrepareLoadCommand(cmd, Message.LoadFilter.MESSAGEHEADER, message.Id);
SqlDataReader reader = this.PerformCommand(cmd); SqlDataReader reader = this.PerformCommand(cmd);
List<DatabaseEntity> statList = msgClass.LoadList(reader); List<DatabaseEntity> statList = msgClass.LoadList(reader);
if (statList.Count > 0) message.DerivedMessage = statList[0]; foreach (DatabaseEntity derivedMessage in statList)
msgClass.MessageHeader = message; {
this.LoadDependingLists(msgClass); message.Elements.Add(derivedMessage);
result.Add(msgClass); derivedMessage.MessageHeader = message;
this.LoadDependingLists(derivedMessage);
}
} }
else else
{ {
_log.ErrorFormat("cannot create a message class for notification type {0}", message.MessageNotificationClass); _log.ErrorFormat("cannot create a message class for notification type {0}", message.MessageNotificationClass);
result.Add(message);
} }
} }
return result;
} }
#region CreateMessage() #region CreateMessage()
@ -360,6 +402,7 @@ namespace bsmd.database
if(databaseEntity.GetType().IsAssignableFrom(typeof(WAS))) if(databaseEntity.GetType().IsAssignableFrom(typeof(WAS)))
{ {
WAS was = databaseEntity as WAS; WAS was = databaseEntity as WAS;
WasteDisposalServiceProvider wdsp = new WasteDisposalServiceProvider(); WasteDisposalServiceProvider wdsp = new WasteDisposalServiceProvider();
wdsp.PrepareLoadCommand(cmd, Message.LoadFilter.WAS_ID, was.Id); wdsp.PrepareLoadCommand(cmd, Message.LoadFilter.WAS_ID, was.Id);
SqlDataReader reader = this.PerformCommand(cmd); SqlDataReader reader = this.PerformCommand(cmd);
@ -370,6 +413,17 @@ namespace bsmd.database
awdsp.WAS = was; awdsp.WAS = was;
this.LoadDependingLists(awdsp); this.LoadDependingLists(awdsp);
} }
Waste waste = new Waste();
waste.PrepareLoadCommand(cmd, Message.LoadFilter.WDSP_ID, was.Id);
SqlDataReader reader2 = this.PerformCommand(cmd);
List<DatabaseEntity> wastes = wdsp.LoadList(reader2);
foreach (Waste aWaste in wastes)
{
was.Waste.Add(aWaste);
aWaste.WAS = was;
}
} }
#endregion #endregion
@ -379,15 +433,7 @@ namespace bsmd.database
if(databaseEntity.GetType().IsAssignableFrom(typeof(WasteDisposalServiceProvider))) if(databaseEntity.GetType().IsAssignableFrom(typeof(WasteDisposalServiceProvider)))
{ {
WasteDisposalServiceProvider wdsp = databaseEntity as 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 #endregion

View File

@ -55,6 +55,11 @@ namespace bsmd.database
/// </summary> /// </summary>
public bool IsNew { get { return !this.id.HasValue; } } public bool IsNew { get { return !this.id.HasValue; } }
/// <summary>
/// when it's time (during save), create id
/// </summary>
public void CreateId() { this.id = Guid.NewGuid(); }
public abstract void PrepareSave(IDbCommand cmd); public abstract void PrepareSave(IDbCommand cmd);
public virtual void PrepareDelete(IDbCommand cmd) public virtual void PrepareDelete(IDbCommand cmd)

View File

@ -103,7 +103,7 @@ namespace bsmd.database
if (!reader.IsDBNull(3)) info.SpecialRequirementsOfShipAtBerth = reader.GetString(3); if (!reader.IsDBNull(3)) info.SpecialRequirementsOfShipAtBerth = reader.GetString(3);
if (!reader.IsDBNull(4)) info.ConstructionCharacteristicsOfShip = reader.GetString(4); if (!reader.IsDBNull(4)) info.ConstructionCharacteristicsOfShip = reader.GetString(4);
if (!reader.IsDBNull(5)) info.FumigatedBulkCargo = reader.GetByte(5); if (!reader.IsDBNull(5)) info.FumigatedBulkCargo = reader.GetByte(5);
if (!reader.IsDBNull(6)) info.DeplacementSummerDraught_TNE = reader.GetFloat(6); if (!reader.IsDBNull(6)) info.DeplacementSummerDraught_TNE = (float) reader.GetDouble(6);
result.Add(info); result.Add(info);
} }
reader.Close(); reader.Close();

View File

@ -92,7 +92,7 @@ namespace bsmd.database
if (!reader.IsDBNull(1)) ladg.CargoHandlingType = reader.GetByte(1); if (!reader.IsDBNull(1)) ladg.CargoHandlingType = reader.GetByte(1);
if (!reader.IsDBNull(2)) ladg.CargoCodeNST = reader.GetString(2); if (!reader.IsDBNull(2)) ladg.CargoCodeNST = reader.GetString(2);
if (!reader.IsDBNull(3)) ladg.CargoNumberOfItems = reader.GetInt32(3); if (!reader.IsDBNull(3)) ladg.CargoNumberOfItems = reader.GetInt32(3);
if (!reader.IsDBNull(4)) ladg.CargoGrossQuantity_TNE = reader.GetFloat(4); if (!reader.IsDBNull(4)) ladg.CargoGrossQuantity_TNE = (float) reader.GetDouble(4);
result.Add(ladg); result.Add(ladg);
} }
reader.Close(); reader.Close();

View File

@ -28,7 +28,7 @@ namespace bsmd.database
public string PortFacilityPortName { get; set; } public string PortFacilityPortName { get; set; }
public string PortFacilityPortCode { get; set; } public string PortFacilityPortCountry { get; set; }
public string PortFacilityPortLoCode { get; set; } public string PortFacilityPortLoCode { get; set; }
@ -53,7 +53,7 @@ namespace bsmd.database
scmd.Parameters.AddWithValue("@P1", this.SEC.Id); scmd.Parameters.AddWithValue("@P1", this.SEC.Id);
scmd.Parameters.AddWithNullableValue("@P2", this.PortFacilityPortName); scmd.Parameters.AddWithNullableValue("@P2", this.PortFacilityPortName);
scmd.Parameters.AddWithNullableValue("@P3", this.PortFacilityPortCode); scmd.Parameters.AddWithNullableValue("@P3", this.PortFacilityPortCountry);
scmd.Parameters.AddWithNullableValue("@P4", this.PortFacilityPortLoCode); scmd.Parameters.AddWithNullableValue("@P4", this.PortFacilityPortLoCode);
scmd.Parameters.AddWithNullableValue("@P5", this.PortFacilityDateOfArrival); scmd.Parameters.AddWithNullableValue("@P5", this.PortFacilityDateOfArrival);
scmd.Parameters.AddWithNullableValue("@P6", this.PortFacilityDateOfDeparture); scmd.Parameters.AddWithNullableValue("@P6", this.PortFacilityDateOfDeparture);
@ -63,7 +63,7 @@ namespace bsmd.database
if (this.IsNew) if (this.IsNew)
{ {
scmd.CommandText = string.Format("INSERT INTO {0} (SEC_Id, PortFacilityPortName, PortFacilityPortCode, " + scmd.CommandText = string.Format("INSERT INTO {0} (SEC_Id, PortFacilityPortName, PortFacilityPortCountry, " +
"PortFacilityPortLoCode, PortFacilityDateOfArrival, PortFacilityDateOfDeparture, PortFacilityShipSecurityLevel, " + "PortFacilityPortLoCode, PortFacilityDateOfArrival, PortFacilityDateOfDeparture, PortFacilityShipSecurityLevel, " +
"PortFacilitySecurityMattersToReport, PortFacilityGISISCode) VALUES ( @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9)", "PortFacilitySecurityMattersToReport, PortFacilityGISISCode) VALUES ( @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9)",
this.Tablename); this.Tablename);
@ -71,7 +71,7 @@ namespace bsmd.database
else else
{ {
scmd.Parameters.AddWithValue(@"ID", this.Id); scmd.Parameters.AddWithValue(@"ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET PortFacilityPortName = @P2, PortFacilityPortCode = @P3, " + scmd.CommandText = string.Format("UPDATE {0} SET PortFacilityPortName = @P2, PortFacilityPortCountry = @P3, " +
"PortFacilityPortLoCode = @P4, PortFacilityDateOfArrival = @P5, PortFacilityDateOfDeparture = @P6," + "PortFacilityPortLoCode = @P4, PortFacilityDateOfArrival = @P5, PortFacilityDateOfDeparture = @P6," +
"PortFacilityShipSecurityLevel = @P7, PortFacilitySecurityMattersToReport = @8, PortFacilityGISISCode = @P9 " + "PortFacilityShipSecurityLevel = @P7, PortFacilitySecurityMattersToReport = @8, PortFacilityGISISCode = @P9 " +
" WHERE Id = @ID", this.Tablename); " WHERE Id = @ID", this.Tablename);
@ -80,7 +80,7 @@ namespace bsmd.database
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria) public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
{ {
string query = string.Format("SELECT Id, PortFacilityPortName, PortFacilityPortCode, PortFacilityPortLoCode, " + string query = string.Format("SELECT Id, PortFacilityPortName, PortFacilityPortCountry, PortFacilityPortLoCode, " +
"PortFacilityDateOfArrival, PortFacilityDateOfDeparture, PortFacilityShipSecurityLevel, PortFacilitySecurityMattersToReport, " + "PortFacilityDateOfArrival, PortFacilityDateOfDeparture, PortFacilityShipSecurityLevel, PortFacilitySecurityMattersToReport, " +
"PortFacilityGISISCode FROM {0}", this.Tablename); "PortFacilityGISISCode FROM {0}", this.Tablename);
@ -109,7 +109,7 @@ namespace bsmd.database
ltpfc.id = reader.GetGuid(0); ltpfc.id = reader.GetGuid(0);
if (!reader.IsDBNull(1)) ltpfc.PortFacilityPortName = reader.GetString(1); if (!reader.IsDBNull(1)) ltpfc.PortFacilityPortName = reader.GetString(1);
if (!reader.IsDBNull(2)) ltpfc.PortFacilityPortCode = reader.GetString(2); if (!reader.IsDBNull(2)) ltpfc.PortFacilityPortCountry = reader.GetString(2);
if (!reader.IsDBNull(3)) ltpfc.PortFacilityPortLoCode = reader.GetString(3); if (!reader.IsDBNull(3)) ltpfc.PortFacilityPortLoCode = reader.GetString(3);
if (!reader.IsDBNull(4)) ltpfc.PortFacilityDateOfArrival = reader.GetDateTime(4); if (!reader.IsDBNull(4)) ltpfc.PortFacilityDateOfArrival = reader.GetDateTime(4);
if (!reader.IsDBNull(5)) ltpfc.PortFacilityDateOfDeparture = reader.GetDateTime(5); if (!reader.IsDBNull(5)) ltpfc.PortFacilityDateOfDeparture = reader.GetDateTime(5);

View File

@ -113,7 +113,7 @@ namespace bsmd.database
if (this.IsNew) if (this.IsNew)
{ {
scmd.CommandText = string.Format("INSERT INTO {0} MessageHeaderId, MDHSimplification, PortOfCallWhereCompleteMDHNotified, " + scmd.CommandText = string.Format("INSERT INTO {0} (MessageHeaderId, MDHSimplification, PortOfCallWhereCompleteMDHNotified, " +
"NonAccidentalDeathsDuringVoyage, NonAccidentalDeathsDuringVoyageCount, SuspisionInfectiousNature, NumberOfIllPersonsHigherThanExpected, " + "NonAccidentalDeathsDuringVoyage, NonAccidentalDeathsDuringVoyageCount, SuspisionInfectiousNature, NumberOfIllPersonsHigherThanExpected, " +
"NumberOfIllPersons, SickPersonsOnBoard, MedicalConsulted, AwareOfFurtherInfections, SanitaryMeasuresApplied, SanitaryMeasuresType, " + "NumberOfIllPersons, SickPersonsOnBoard, MedicalConsulted, AwareOfFurtherInfections, SanitaryMeasuresApplied, SanitaryMeasuresType, " +
"SanitaryMeasuresLocation, SanitaryMeasuresDate, StowawaysDetected, StowawaysJoiningLocation, SickAnimalOrPetOnBoard, " + "SanitaryMeasuresLocation, SanitaryMeasuresDate, StowawaysDetected, StowawaysJoiningLocation, SickAnimalOrPetOnBoard, " +
@ -166,7 +166,7 @@ namespace bsmd.database
{ {
MDH mdh = new MDH(); MDH mdh = new MDH();
this.id = reader.GetGuid(0); mdh.id = reader.GetGuid(0);
if (!reader.IsDBNull(1)) mdh.MDHSimplification = reader.GetBoolean(1); if (!reader.IsDBNull(1)) mdh.MDHSimplification = reader.GetBoolean(1);
if (!reader.IsDBNull(2)) mdh.PortOfCallWhereCompleteMDHNotified = reader.GetString(2); if (!reader.IsDBNull(2)) mdh.PortOfCallWhereCompleteMDHNotified = reader.GetString(2);
if (!reader.IsDBNull(3)) mdh.NonAccidentalDeathsDuringVoyage = reader.GetBoolean(3); if (!reader.IsDBNull(3)) mdh.NonAccidentalDeathsDuringVoyage = reader.GetBoolean(3);

View File

@ -13,13 +13,13 @@ namespace bsmd.database
/// </summary> /// </summary>
public class Message : DatabaseEntity public class Message : DatabaseEntity
{ {
private Guid messageHeaderId;
private Guid? messageCoreId; private Guid? messageCoreId;
private Guid? reportingPartyId; private Guid? reportingPartyId;
private ReportingParty reportingParty; private ReportingParty reportingParty;
private DateTime? created; private DateTime? created;
private List<MessageError> errorList = new List<MessageError>(); private List<MessageError> errorList = new List<MessageError>();
private List<MessageViolation> violationList = new List<MessageViolation>(); private List<MessageViolation> violationList = new List<MessageViolation>();
private List<DatabaseEntity> elements = new List<DatabaseEntity>();
#region Enumerations #region Enumerations
@ -53,7 +53,8 @@ namespace bsmd.database
BPOL_ID, BPOL_ID,
SEC_ID, SEC_ID,
HERBERG_FORMGUID, HERBERG_FORMGUID,
BY_ID BY_ID,
BY_CORE
} }
/// <summary> /// <summary>
@ -99,7 +100,7 @@ namespace bsmd.database
public Guid? MessageId { get; set; } public Guid? MessageId { get; set; }
public Guid? MessageCoreId { get { return this.messageCoreId; } } public Guid? MessageCoreId { get { return this.messageCoreId; } set { this.messageCoreId = value; } }
public DateTime? SentAt { get; set; } public DateTime? SentAt { get; set; }
@ -115,10 +116,33 @@ namespace bsmd.database
public DateTime? Created { get { return this.created; } } public DateTime? Created { get { return this.created; } }
/// <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
/// sonst hat die Liste immer ein Element
/// </summary>
public List<DatabaseEntity> Elements { get { return this.elements; } }
/// <summary> /// <summary>
/// Der Meldende /// Der Meldende
/// </summary> /// </summary>
public ReportingParty ReportingParty { get { return this.reportingParty; } } public ReportingParty ReportingParty
{
get { return this.reportingParty; }
set
{
if (value == null)
{
this.reportingPartyId = null;
}
else
{
this.reportingPartyId = value.Id;
}
this.reportingParty = value;
}
}
/// <summary> /// <summary>
/// die zur Kommunikation zu verwendende HIS Schnittstelle /// die zur Kommunikation zu verwendende HIS Schnittstelle
@ -135,11 +159,6 @@ namespace bsmd.database
/// </summary> /// </summary>
public List<MessageViolation> ViolationList { get { return this.violationList; } } public List<MessageViolation> ViolationList { get { return this.violationList; } }
/// <summary>
/// Vorwärtsreferenz auf spezielle Message (damit wir über Message loopen können)
/// </summary>
public DatabaseEntity DerivedMessage { get; set; }
#endregion #endregion
#region IDatabaseEntity implementation #region IDatabaseEntity implementation
@ -176,23 +195,26 @@ namespace bsmd.database
cmd.Parameters.AddWithValue("@STATUS", (int)this.Status.Value); cmd.Parameters.AddWithValue("@STATUS", (int)this.Status.Value);
else else
cmd.Parameters.AddWithValue("@STATUS", DBNull.Value); cmd.Parameters.AddWithValue("@STATUS", DBNull.Value);
cmd.Parameters.AddWithValue("@REPORTINGPARTYID", this.ReportingParty.Id);
cmd.Parameters.AddWithNullableValue("@REPORTINGPARTYID", this.reportingPartyId);
cmd.Parameters.AddWithValue("@BSMDSTATUS", this.InternalStatus); cmd.Parameters.AddWithValue("@BSMDSTATUS", this.InternalStatus);
cmd.Parameters.AddWithValue("@HIS", this.HIS); cmd.Parameters.AddWithValue("@HIS", this.HIS);
if (this.IsNew) if (this.IsNew)
{ {
string query = string.Format("INSERT INTO {0} (ClientRequestId, MessageCoreId, MessageId, SentAt, ReceivedAt, RequestedAt, NotificationClass, Reset, Cancel, Status, ReportingPartyId, BSMDStatus, HIS) " + this.CreateId();
"VALUES (@CLIENTREQUESTID, @MESSAGECOREID, @MESSAGEID, @SENTAT, @RECEIVEDAT, @REQUESTEDAT, @NOTIFICATIONCLASS, @RESET, @CANCEL, @STATUS, @REPORTINGPARTYID, @BSMDSTATUS, @HIS)", cmd.Parameters.AddWithValue("@ID", this.Id);
string query = string.Format("INSERT INTO {0} (Id, ClientRequestId, MessageCoreId, MessageId, SentAt, ReceivedAt, RequestedAt, NotificationClass, Reset, Cancel, Status, ReportingPartyId, BSMDStatus, HIS) " +
"VALUES (@ID, @CLIENTREQUESTID, @MESSAGECOREID, @MESSAGEID, @SENTAT, @RECEIVEDAT, @REQUESTEDAT, @NOTIFICATIONCLASS, @RESET, @CANCEL, @STATUS, @REPORTINGPARTYID, @BSMDSTATUS, @HIS)",
this.Tablename); this.Tablename);
cmd.CommandText = query; cmd.CommandText = query;
} }
else else
{ {
cmd.Parameters.AddWithValue("@ID", this.Id);
cmd.CommandText = string.Format("UPDATE {0} SET ClientRequestId = @CLIENTREQUESTID, MessageId = @MESSAGEID, SentAt = @SENTAT, ReceivedAt = @RECEIVEDAT, RequestedAt = @REQUESTEDAT, " + cmd.CommandText = string.Format("UPDATE {0} SET ClientRequestId = @CLIENTREQUESTID, MessageId = @MESSAGEID, SentAt = @SENTAT, ReceivedAt = @RECEIVEDAT, RequestedAt = @REQUESTEDAT, " +
"NotificationClass = @NOTIFICATIONCLASS, Reset = @RESET, Cancel = @CANCEL, Status = @STATUS, ReportingPartyId = @REPORTINGPARTYID, BSMDStatus = @BSMDSTATUS, HIS = @HIS " + "NotificationClass = @NOTIFICATIONCLASS, Reset = @RESET, Cancel = @CANCEL, Status = @STATUS, ReportingPartyId = @REPORTINGPARTYID, BSMDStatus = @BSMDSTATUS, HIS = @HIS " +
"WHERE Id = @ID", this.Tablename); "WHERE Id = @ID", this.Tablename);
cmd.Parameters.AddWithValue("@ID", this.messageHeaderId);
} }
} }
@ -222,6 +244,12 @@ namespace bsmd.database
((SqlCommand)cmd).Parameters.AddWithValue("@ID", criteria[0]); ((SqlCommand)cmd).Parameters.AddWithValue("@ID", criteria[0]);
break; break;
} }
case LoadFilter.BY_CORE:
{
query += "WHERE MessageCoreId = @COREID";
((SqlCommand)cmd).Parameters.AddWithValue("@COREID", criteria[0]);
break;
}
case LoadFilter.ALL: case LoadFilter.ALL:
default: default:
break; break;

View File

@ -47,6 +47,16 @@ namespace bsmd.database
public Guid? HerbergFormTemplateGuid { get; set; } public Guid? HerbergFormTemplateGuid { get; set; }
public string HerbergReportType { get; set; }
public string HerbergEmailContactReportingVessel { get; set; }
public string HerbergEmail24HrsContact { get; set; }
public Customer Customer { get; set; }
public Guid? CustomerId { get { return this.customerId; } set { this.customerId = value; } }
#endregion #endregion
public override void PrepareSave(IDbCommand cmd) public override void PrepareSave(IDbCommand cmd)
@ -80,13 +90,19 @@ namespace bsmd.database
scmd.Parameters.AddWithValue("@P14", this.InitialHIS); scmd.Parameters.AddWithValue("@P14", this.InitialHIS);
scmd.Parameters.AddWithNullableValue("@P15", this.HerbergFormGuid); scmd.Parameters.AddWithNullableValue("@P15", this.HerbergFormGuid);
scmd.Parameters.AddWithNullableValue("@P16", this.HerbergFormTemplateGuid); scmd.Parameters.AddWithNullableValue("@P16", this.HerbergFormTemplateGuid);
scmd.Parameters.AddWithNullableValue("@P17", this.HerbergReportType);
scmd.Parameters.AddWithNullableValue("@P18", this.HerbergEmailContactReportingVessel);
scmd.Parameters.AddWithNullableValue("@P19", this.HerbergEmail24HrsContact);
if (this.IsNew) if (this.IsNew)
{ {
string query = string.Format("INSERT INTO {0} (VisitId, TransitId, IMO, ENI, PoC, Portname, ETA, CustomerId, " + this.CreateId();
scmd.Parameters.AddWithValue("@ID", this.Id);
string query = string.Format("INSERT INTO {0} (Id, VisitId, TransitId, IMO, ENI, PoC, Portname, ETA, CustomerId, " +
"Previous, Next, IsTransit, Wetris_zz_56_datensatz_id, BSMDStatus, InitialHIS, HerbergFormGuid, " + "Previous, Next, IsTransit, Wetris_zz_56_datensatz_id, BSMDStatus, InitialHIS, HerbergFormGuid, " +
"HerbergFormTemplateGuid) VALUES " + "HerbergFormTemplateGuid, HerbergReportType, HerbergEmailcontactReportingVessel, HerbergEmail24HrsContact) VALUES " +
"(@P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, @P15, @P16)", "(@ID, @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, @P15, @P16, @P17, @P18, @P19)",
this.Tablename); this.Tablename);
scmd.CommandText = query; scmd.CommandText = query;
} }
@ -96,8 +112,9 @@ namespace bsmd.database
string query = string.Format("UPDATE {0} SET VisitId = @P1, TransitId = @P2, IMO = @P3, ENI = @P4, Poc = @P5, " + string query = string.Format("UPDATE {0} SET VisitId = @P1, TransitId = @P2, IMO = @P3, ENI = @P4, Poc = @P5, " +
"Portname = @P6, ETA = @P7, CustomerId = @P8, Previous = @P9, Next = @P10, IsTransit = @P11, " + "Portname = @P6, ETA = @P7, CustomerId = @P8, Previous = @P9, Next = @P10, IsTransit = @P11, " +
"Wetris_zz_56_datensatz_id = @P12, BSMDStatus = @P13, InitialHIS = @P14, HerbergFormGuid = @P15, " + "Wetris_zz_56_datensatz_id = @P12, BSMDStatus = @P13, InitialHIS = @P14, HerbergFormGuid = @P15, " +
"HerbergFormTemplateGuid = @P16 WHERE Id = @ID", this.Tablename); "HerbergFormTemplateGuid = @P16, HerbergReportType = @P17, HerbergEmailContactReportingVessel = @P18, " +
"HerbergEmail24HrsContact = @P19 WHERE Id = @ID", this.Tablename);
scmd.CommandText = query;
} }
} }
@ -105,7 +122,7 @@ namespace bsmd.database
{ {
string query = string.Format("SELECT Id, VisitId, TransitId, IMO, ENI, PoC, Portname, " + string query = string.Format("SELECT Id, VisitId, TransitId, IMO, ENI, PoC, Portname, " +
"ETA, CustomerId, Previous, Next, IsTransit, Wetris_zz_56_datensatz_id, BSMDStatus, InitialHIS, " + "ETA, CustomerId, Previous, Next, IsTransit, Wetris_zz_56_datensatz_id, BSMDStatus, InitialHIS, " +
"HerbergFormGuid, HerbergFormTemplateGuid FROM {0} ", "HerbergFormGuid, HerbergFormTemplateGuid, HerbergReportType, HerbergEmailContactReportingVessel, HerbergEmail24HrsContact FROM {0} ",
this.Tablename); this.Tablename);
switch (filter) switch (filter)
@ -153,6 +170,9 @@ namespace bsmd.database
core.InitialHIS = (Message.NSWProvider) Enum.ToObject(typeof(Message.NSWProvider), reader.GetByte(14)); core.InitialHIS = (Message.NSWProvider) Enum.ToObject(typeof(Message.NSWProvider), reader.GetByte(14));
if (!reader.IsDBNull(15)) core.HerbergFormGuid = reader.GetGuid(15); if (!reader.IsDBNull(15)) core.HerbergFormGuid = reader.GetGuid(15);
if (!reader.IsDBNull(16)) core.HerbergFormTemplateGuid = reader.GetGuid(16); if (!reader.IsDBNull(16)) core.HerbergFormTemplateGuid = reader.GetGuid(16);
if (!reader.IsDBNull(17)) core.HerbergReportType = reader.GetString(17);
if (!reader.IsDBNull(18)) core.HerbergEmailContactReportingVessel = reader.GetString(18);
if (!reader.IsDBNull(19)) core.HerbergEmail24HrsContact = reader.GetString(19);
result.Add(core); result.Add(core);
} }

View File

@ -36,7 +36,7 @@ namespace bsmd.database
public string PassengerNationality { get; set; } public string PassengerNationality { get; set; }
public byte PassengerIdentityDocumentType { get; set; } public byte? PassengerIdentityDocumentType { get; set; }
public string PassengerIdentityDocumentId { get; set; } public string PassengerIdentityDocumentId { get; set; }

View File

@ -55,7 +55,7 @@ namespace bsmd.database
{ {
scmd.Parameters.AddWithValue(@"ID", this.Id); scmd.Parameters.AddWithValue(@"ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET TotalPersonsOnBoardUponArrival = @P2, " + scmd.CommandText = string.Format("UPDATE {0} SET TotalPersonsOnBoardUponArrival = @P2, " +
"TotalCrewMembersOnBoardUponArrival = @P3, TotalPassengersOnBoardUponArrival = @P4" + "TotalCrewMembersOnBoardUponArrival = @P3, TotalPassengersOnBoardUponArrival = @P4, " +
"TotalStowawaysOnBoardUponArrival = @P5 WHERE Id = @ID", this.Tablename); "TotalStowawaysOnBoardUponArrival = @P5 WHERE Id = @ID", this.Tablename);
} }

View File

@ -55,7 +55,7 @@ namespace bsmd.database
{ {
scmd.Parameters.AddWithValue(@"ID", this.Id); scmd.Parameters.AddWithValue(@"ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET TotalPersonsOnBoardUponDeparture = @P2, " + scmd.CommandText = string.Format("UPDATE {0} SET TotalPersonsOnBoardUponDeparture = @P2, " +
"TotalCrewMembersOnBoardUponDeparture = @P3, TotalPassengersOnBoardUponDeparture = @P4" + "TotalCrewMembersOnBoardUponDeparture = @P3, TotalPassengersOnBoardUponDeparture = @P4, " +
"TotalStowawaysOnBoardUponDeparture = @P5 WHERE Id = @ID", this.Tablename); "TotalStowawaysOnBoardUponDeparture = @P5 WHERE Id = @ID", this.Tablename);
} }
} }

View File

@ -113,11 +113,11 @@ namespace bsmd.database
if (!reader.IsDBNull(2)) pre72h.TankerHullConfiguration = reader.GetByte(2); if (!reader.IsDBNull(2)) pre72h.TankerHullConfiguration = reader.GetByte(2);
if (!reader.IsDBNull(3)) pre72h.ConditionCargoBallastTanks = reader.GetByte(3); if (!reader.IsDBNull(3)) pre72h.ConditionCargoBallastTanks = reader.GetByte(3);
if (!reader.IsDBNull(4)) pre72h.NatureOfCargo = reader.GetString(4); if (!reader.IsDBNull(4)) pre72h.NatureOfCargo = reader.GetString(4);
if (!reader.IsDBNull(5)) pre72h.VolumeOfCargo = reader.GetFloat(5); if (!reader.IsDBNull(5)) pre72h.VolumeOfCargo = (float) reader.GetDouble(5);
if (!reader.IsDBNull(6)) pre72h.PlannedOperations = reader.GetString(6); if (!reader.IsDBNull(6)) pre72h.PlannedOperations = reader.GetString(6);
if (!reader.IsDBNull(7)) pre72h.PlannedWorks = reader.GetString(7); if (!reader.IsDBNull(7)) pre72h.PlannedWorks = reader.GetString(7);
if (!reader.IsDBNull(8)) pre72h.DateOfLastExpandedInspection = reader.GetDateTime(8); if (!reader.IsDBNull(8)) pre72h.DateOfLastExpandedInspection = reader.GetDateTime(8);
if (!reader.IsDBNull(9)) pre72h.PlannedPeriodOfStay_HUR = reader.GetFloat(9); if (!reader.IsDBNull(9)) pre72h.PlannedPeriodOfStay_HUR = (float) reader.GetDouble(9);
result.Add(pre72h); result.Add(pre72h);
} }
reader.Close(); reader.Close();

View File

@ -72,7 +72,7 @@ namespace bsmd.database
{ {
case Message.LoadFilter.MDH_ID: case Message.LoadFilter.MDH_ID:
query += "WHERE MDH_Id = @MDHID"; query += "WHERE MDH_Id = @MDHID";
((SqlCommand)cmd).Parameters.AddWithValue("@MHID", criteria[0]); ((SqlCommand)cmd).Parameters.AddWithValue("@MDHID", criteria[0]);
break; break;
case Message.LoadFilter.ALL: case Message.LoadFilter.ALL:
default: default:

View File

@ -73,7 +73,6 @@ namespace bsmd.database
switch (filter) switch (filter)
{ {
/// tbd
case Message.LoadFilter.ALL: case Message.LoadFilter.ALL:
default: default:

View File

@ -28,7 +28,7 @@ namespace bsmd.database
#region Properties #region Properties
public string SECSimplification { get; set; } public bool? SECSimplification { get; set; }
public string PortOfCallWhereCompleteSECNotified { get; set; } public string PortOfCallWhereCompleteSECNotified { get; set; }
@ -38,6 +38,8 @@ namespace bsmd.database
public string CSOPhone { get; set; } public string CSOPhone { get; set; }
public string CSOFax { get; set; }
public string CSOEMail { get; set; } public string CSOEMail { get; set; }
public bool? ValidISSCOnBoard { get; set; } public bool? ValidISSCOnBoard { get; set; }
@ -90,14 +92,15 @@ namespace bsmd.database
scmd.Parameters.AddWithNullableValue("@P15", this.CurrentShipSecurityLevel); scmd.Parameters.AddWithNullableValue("@P15", this.CurrentShipSecurityLevel);
scmd.Parameters.AddWithNullableValue("@P16", this.PortFacilityOfArrival); scmd.Parameters.AddWithNullableValue("@P16", this.PortFacilityOfArrival);
scmd.Parameters.AddWithNullableValue("@P17", this.GeneralDescriptionOfCargo); scmd.Parameters.AddWithNullableValue("@P17", this.GeneralDescriptionOfCargo);
scmd.Parameters.AddWithNullableValue("@P18", this.CSOFax);
if (this.IsNew) if (this.IsNew)
{ {
scmd.CommandText = string.Format("INSERT INTO {0} (MessageHeaderId, SECSimplification, PortOfCallWhereCompleteSECNotified, " + scmd.CommandText = string.Format("INSERT INTO {0} (MessageHeaderId, SECSimplification, PortOfCallWhereCompleteSECNotified, " +
"CSOLastName, CSOFirstName, CSOPhone, CSOEMail, ValidISSCOnBoard, ReasonsForNoValidISSC, " + "CSOLastName, CSOFirstName, CSOPhone, CSOEMail, ValidISSCOnBoard, ReasonsForNoValidISSC, " +
"ISSCType, ISSCIssuerType, ISSCIssuerName,ISSCDateOfExpiration, ApprovedSecurityPlanOnBoard, " + "ISSCType, ISSCIssuerType, ISSCIssuerName,ISSCDateOfExpiration, ApprovedSecurityPlanOnBoard, " +
"CurrentShipSecurityLevel, PortFacilityOfArrival, GeneralDescriptionOfCargo) " + "CurrentShipSecurityLevel, PortFacilityOfArrival, GeneralDescriptionOfCargo, CSOFax) " +
"VALUES ( @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, @P15, @P16, @P17 )", this.Tablename); "VALUES ( @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, @P15, @P16, @P17, @P18 )", this.Tablename);
} }
else else
{ {
@ -107,7 +110,7 @@ namespace bsmd.database
"CSOEMail = @P7, ValidISSCOnBoard = @8, ReasonsForNoValidISSC = @P9, " + "CSOEMail = @P7, ValidISSCOnBoard = @8, ReasonsForNoValidISSC = @P9, " +
"ISSCType = @P10, ISSCIssuerType = @P11, ISSCIssuerName = @P12, ISSCDateOfExpiration = @P13, " + "ISSCType = @P10, ISSCIssuerType = @P11, ISSCIssuerName = @P12, ISSCDateOfExpiration = @P13, " +
"ApprovedSecurityPlanOnBoard = @P14, CurrentShipSecurityLevel = @P15, PortFacilityOfArrival = @P16, " + "ApprovedSecurityPlanOnBoard = @P14, CurrentShipSecurityLevel = @P15, PortFacilityOfArrival = @P16, " +
"GeneralDescriptionOfCargo = @P17 WHERE Id = @ID", this.Tablename); "GeneralDescriptionOfCargo = @P17, CSOFax = @P18 WHERE Id = @ID", this.Tablename);
} }
} }
@ -116,7 +119,7 @@ namespace bsmd.database
string query = string.Format("SELECT Id, SECSimplification, PortOfCallWhereCompleteSECNotified, CSOLastName, " + string query = string.Format("SELECT Id, SECSimplification, PortOfCallWhereCompleteSECNotified, CSOLastName, " +
"CSOFirstName, CSOPhone, CSOEMail, ValidISSCOnBoard, ReasonsForNoValidISSC, " + "CSOFirstName, CSOPhone, CSOEMail, ValidISSCOnBoard, ReasonsForNoValidISSC, " +
"ISSCType, ISSCIssuerType, ISSCIssuerName, ISSCDateOfExpiration, ApprovedSecurityPlanOnBoard, " + "ISSCType, ISSCIssuerType, ISSCIssuerName, ISSCDateOfExpiration, ApprovedSecurityPlanOnBoard, " +
"CurrentShipSecurityLevel, PortFacilityOfArrival, GeneralDescriptionOfCargo FROM {0}", this.Tablename); "CurrentShipSecurityLevel, PortFacilityOfArrival, GeneralDescriptionOfCargo, CSOFax FROM {0}", this.Tablename);
switch (filter) switch (filter)
{ {
@ -142,7 +145,7 @@ namespace bsmd.database
SEC sec = new SEC(); SEC sec = new SEC();
sec.id = reader.GetGuid(0); sec.id = reader.GetGuid(0);
if (!reader.IsDBNull(1)) sec.SECSimplification = reader.GetString(1); if (!reader.IsDBNull(1)) sec.SECSimplification = reader.GetBoolean(1);
if (!reader.IsDBNull(2)) sec.PortOfCallWhereCompleteSECNotified = reader.GetString(2); if (!reader.IsDBNull(2)) sec.PortOfCallWhereCompleteSECNotified = reader.GetString(2);
if (!reader.IsDBNull(3)) sec.CSOLastName = reader.GetString(3); if (!reader.IsDBNull(3)) sec.CSOLastName = reader.GetString(3);
if (!reader.IsDBNull(4)) sec.CSOFirstName = reader.GetString(4); if (!reader.IsDBNull(4)) sec.CSOFirstName = reader.GetString(4);
@ -151,13 +154,14 @@ namespace bsmd.database
if (!reader.IsDBNull(7)) sec.ValidISSCOnBoard = reader.GetBoolean(7); if (!reader.IsDBNull(7)) sec.ValidISSCOnBoard = reader.GetBoolean(7);
if (!reader.IsDBNull(8)) sec.ReasonsForNoValidISSC = reader.GetString(8); if (!reader.IsDBNull(8)) sec.ReasonsForNoValidISSC = reader.GetString(8);
if (!reader.IsDBNull(9)) sec.ISSCType = reader.GetByte(9); if (!reader.IsDBNull(9)) sec.ISSCType = reader.GetByte(9);
if (!reader.IsDBNull(9)) sec.ISSCIssuerType = reader.GetByte(9); if (!reader.IsDBNull(10)) sec.ISSCIssuerType = reader.GetByte(10);
if (!reader.IsDBNull(9)) sec.ISSCIssuerName = reader.GetString(9); if (!reader.IsDBNull(11)) sec.ISSCIssuerName = reader.GetString(11);
if (!reader.IsDBNull(9)) sec.ISSCDateOfExpiration = reader.GetDateTime(9); if (!reader.IsDBNull(12)) sec.ISSCDateOfExpiration = reader.GetDateTime(12);
if (!reader.IsDBNull(9)) sec.ApprovedSecurityPlanOnBoard = reader.GetBoolean(9); if (!reader.IsDBNull(13)) sec.ApprovedSecurityPlanOnBoard = reader.GetBoolean(13);
if (!reader.IsDBNull(9)) sec.CurrentShipSecurityLevel = reader.GetByte(9); if (!reader.IsDBNull(14)) sec.CurrentShipSecurityLevel = reader.GetByte(14);
if (!reader.IsDBNull(9)) sec.PortFacilityOfArrival = reader.GetString(9); if (!reader.IsDBNull(15)) sec.PortFacilityOfArrival = reader.GetString(15);
if (!reader.IsDBNull(9)) sec.GeneralDescriptionOfCargo = reader.GetByte(9); if (!reader.IsDBNull(16)) sec.GeneralDescriptionOfCargo = reader.GetByte(16);
if (!reader.IsDBNull(17)) sec.CSOFax = reader.GetString(17);
result.Add(sec); result.Add(sec);
} }
reader.Close(); reader.Close();

View File

@ -64,7 +64,7 @@ namespace bsmd.database
{ {
string query = string.Format("SELECT Id, ShipName, Callsign, MMSINumber, Flag, LengthOverall_MTR, Beam_MTR, " + string query = string.Format("SELECT Id, ShipName, Callsign, MMSINumber, Flag, LengthOverall_MTR, Beam_MTR, " +
"GrossTonnage, PortOfRegistry, InmarsatCallNumber, ShipType, ISMCompanyName, ISMCompanyId, ISMCompanyStreetAndNumber, " + "GrossTonnage, PortOfRegistry, InmarsatCallNumber, ShipType, ISMCompanyName, ISMCompanyId, ISMCompanyStreetAndNumber, " +
"ISMCompanyPostalAddress, ISMCompanyCity, ISMCompanyCountry FROM {0}", this.Tablename); "ISMCompanyPostalCode, ISMCompanyCity, ISMCompanyCountry FROM {0} ", this.Tablename);
switch (filter) switch (filter)
{ {
@ -94,8 +94,8 @@ namespace bsmd.database
if (!reader.IsDBNull(2)) stat.CallSign = reader.GetString(2); if (!reader.IsDBNull(2)) stat.CallSign = reader.GetString(2);
if (!reader.IsDBNull(3)) stat.MMSINumber = reader.GetString(3); if (!reader.IsDBNull(3)) stat.MMSINumber = reader.GetString(3);
if (!reader.IsDBNull(4)) stat.Flag = reader.GetString(4); if (!reader.IsDBNull(4)) stat.Flag = reader.GetString(4);
if (!reader.IsDBNull(5)) stat.LengthOverall_MTR = reader.GetFloat(5); if (!reader.IsDBNull(5)) stat.LengthOverall_MTR = (float) reader.GetDouble(5);
if (!reader.IsDBNull(6)) stat.Beam_MTR = reader.GetFloat(6); if (!reader.IsDBNull(6)) stat.Beam_MTR = (float) reader.GetDouble(6);
if (!reader.IsDBNull(7)) stat.GrossTonnage = reader.GetInt32(7); if (!reader.IsDBNull(7)) stat.GrossTonnage = reader.GetInt32(7);
if (!reader.IsDBNull(8)) stat.PortOfRegistry = reader.GetString(8); if (!reader.IsDBNull(8)) stat.PortOfRegistry = reader.GetString(8);
if (!reader.IsDBNull(9)) stat.InmarsatCallNumber = reader.GetString(9); if (!reader.IsDBNull(9)) stat.InmarsatCallNumber = reader.GetString(9);
@ -154,8 +154,8 @@ namespace bsmd.database
if (this.IsNew) if (this.IsNew)
{ {
cmd.CommandText = string.Format("INSERT INTO {0} (MessageHeaderId, ShipName, CallSign, MMSINumber, " + cmd.CommandText = string.Format("INSERT INTO {0} (MessageHeaderId, ShipName, CallSign, MMSINumber, " +
"Flag, LengthOverall_MTR, Beam_MTR, GrossTonnage, PortOfRegistry, InmarsatCallNumber, ShiptType, " + "Flag, LengthOverall_MTR, Beam_MTR, GrossTonnage, PortOfRegistry, InmarsatCallNumber, ShipType, " +
"ISMCompanyName, ISMCompanyId, ISMCompanyStreetAndNumber, ISMCompanyPostalAddress, ISMCompanyCity, " + "ISMCompanyName, ISMCompanyId, ISMCompanyStreetAndNumber, ISMCompanyPostalCode, ISMCompanyCity, " +
"ISMCompanyCountry) VALUES (@P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, " + "ISMCompanyCountry) VALUES (@P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, " +
"@P15, @P16, @P17)", this.Tablename); "@P15, @P16, @P17)", this.Tablename);
} }
@ -164,7 +164,7 @@ namespace bsmd.database
cmd.CommandText = string.Format("UPDATE {0} SET ShipName = @P2, CallSign = @P3, MMSINumber = @P4, Flag = @P5, " + cmd.CommandText = string.Format("UPDATE {0} SET ShipName = @P2, CallSign = @P3, MMSINumber = @P4, Flag = @P5, " +
"LengthOverall_MTR = @P6, Beam_MTR = @P7, GrossTonnage = @P8, PortOfRegistry = @P9, InmarsatCallNumber = @P10, " + "LengthOverall_MTR = @P6, Beam_MTR = @P7, GrossTonnage = @P8, PortOfRegistry = @P9, InmarsatCallNumber = @P10, " +
"ShipType = @P11, ISMCompanyName = @P12, ISMCompanyId = @P13, ISMCompanyStreetAndNumber = @P14, " + "ShipType = @P11, ISMCompanyName = @P12, ISMCompanyId = @P13, ISMCompanyStreetAndNumber = @P14, " +
"ISMCompanyPostalAddress = @P15, ISMCompanyCity = @P16, ISMCompanyCountry = @P17 WHERE Id = @ID", this.Tablename); "ISMCompanyPostalCode = @P15, ISMCompanyCity = @P16, ISMCompanyCountry = @P17 WHERE Id = @ID", this.Tablename);
scmd.Parameters.AddWithValue("@ID", this.Id); scmd.Parameters.AddWithValue("@ID", this.Id);
} }

View File

@ -78,7 +78,7 @@ namespace bsmd.database
TIEFA tiefa = new TIEFA(); TIEFA tiefa = new TIEFA();
tiefa.id = reader.GetGuid(0); tiefa.id = reader.GetGuid(0);
if (!reader.IsDBNull(1)) tiefa.DraughtUponArrival_DMT = reader.GetFloat(1); if (!reader.IsDBNull(1)) tiefa.DraughtUponArrival_DMT = (float) reader.GetDouble(1);
result.Add(tiefa); result.Add(tiefa);
} }
reader.Close(); reader.Close();

View File

@ -78,7 +78,7 @@ namespace bsmd.database
TIEFD tiefd = new TIEFD(); TIEFD tiefd = new TIEFD();
tiefd.id = reader.GetGuid(0); tiefd.id = reader.GetGuid(0);
if (!reader.IsDBNull(1)) tiefd.DraughtUponDeparture_DMT = reader.GetFloat(1); if (!reader.IsDBNull(1)) tiefd.DraughtUponDeparture_DMT = (float) reader.GetDouble(1);
result.Add(tiefd); result.Add(tiefd);
} }
reader.Close(); reader.Close();

View File

@ -99,7 +99,7 @@ namespace bsmd.database
scmd.Parameters.AddWithValue(@"ID", this.Id); scmd.Parameters.AddWithValue(@"ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET TowageOnArrivalName = @P2, TowageOnArrivalFlag = @P3, " + scmd.CommandText = string.Format("UPDATE {0} SET TowageOnArrivalName = @P2, TowageOnArrivalFlag = @P3, " +
"TowageOnArrivalOperatorCompanyName = @P4, TowageOnArrivalOperatorStreetNameAndNumber = @P5, " + "TowageOnArrivalOperatorCompanyName = @P4, TowageOnArrivalOperatorStreetNameAndNumber = @P5, " +
"TowageOnArrivalOperatorPostalCode = @P6, TowageOnArrivalOperatorCity = @P7, TowageOnArrivalOperatorCountry = @8, " + "TowageOnArrivalOperatorPostalCode = @P6, TowageOnArrivalOperatorCity = @P7, TowageOnArrivalOperatorCountry = @P8, " +
"TowageOnArrivalOperatorPhone = @P9, TowageOnArrivalOperatorFax = @P10, TowageOnArrivalOperatorEmail = @P11, " + "TowageOnArrivalOperatorPhone = @P9, TowageOnArrivalOperatorFax = @P10, TowageOnArrivalOperatorEmail = @P11, " +
"TowageOnArrivalGrossTonnage = @P12, TowageOnArrivalLengthOverall_MTR = @P13, " + "TowageOnArrivalGrossTonnage = @P12, TowageOnArrivalLengthOverall_MTR = @P13, " +
"TowageOnArrivalBeam_MTR = @P14, TowageOnArrivalPurposeOfCall = @P15, TowageOnArrivalDraught_DMT = @P16, " + "TowageOnArrivalBeam_MTR = @P14, TowageOnArrivalPurposeOfCall = @P15, TowageOnArrivalDraught_DMT = @P16, " +
@ -151,10 +151,10 @@ namespace bsmd.database
if (!reader.IsDBNull(9)) towa.TowageOnArrivalOperatorFax = reader.GetString(9); if (!reader.IsDBNull(9)) towa.TowageOnArrivalOperatorFax = reader.GetString(9);
if (!reader.IsDBNull(10)) towa.TowageOnArrivalOperatorEmail = reader.GetString(10); if (!reader.IsDBNull(10)) towa.TowageOnArrivalOperatorEmail = reader.GetString(10);
if (!reader.IsDBNull(11)) towa.TowageOnArrivalGrossTonnage = reader.GetInt32(11); if (!reader.IsDBNull(11)) towa.TowageOnArrivalGrossTonnage = reader.GetInt32(11);
if (!reader.IsDBNull(12)) towa.TowageOnArrivalLengthOverall_MTR = reader.GetFloat(12); if (!reader.IsDBNull(12)) towa.TowageOnArrivalLengthOverall_MTR = (float) reader.GetDouble(12);
if (!reader.IsDBNull(13)) towa.TowageOnArrivalBeam_MTR = reader.GetFloat(13); if (!reader.IsDBNull(13)) towa.TowageOnArrivalBeam_MTR = (float)reader.GetDouble(13);
if (!reader.IsDBNull(14)) towa.TowageOnArrivalPurposeOfCall = reader.GetString(14); if (!reader.IsDBNull(14)) towa.TowageOnArrivalPurposeOfCall = reader.GetString(14);
if (!reader.IsDBNull(15)) towa.TowageOnArrivalDraught_DMT = reader.GetFloat(15); if (!reader.IsDBNull(15)) towa.TowageOnArrivalDraught_DMT = (float)reader.GetDouble(15);
if (!reader.IsDBNull(16)) towa.TowageOnArrivalRemarks = reader.GetString(16); if (!reader.IsDBNull(16)) towa.TowageOnArrivalRemarks = reader.GetString(16);
result.Add(towa); result.Add(towa);

View File

@ -99,7 +99,7 @@ namespace bsmd.database
scmd.Parameters.AddWithValue(@"ID", this.Id); scmd.Parameters.AddWithValue(@"ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET TowageOnDepartureName = @P2, TowageOnDepartureFlag = @P3, " + scmd.CommandText = string.Format("UPDATE {0} SET TowageOnDepartureName = @P2, TowageOnDepartureFlag = @P3, " +
"TowageOnDepartureOperatorCompanyName = @P4, TowageOnDepartureOperatorStreetNameAndNumber = @P5, " + "TowageOnDepartureOperatorCompanyName = @P4, TowageOnDepartureOperatorStreetNameAndNumber = @P5, " +
"TowageOnDepartureOperatorPostalCode = @P6, TowageOnDepartureOperatorCity = @P7, TowageOnDepartureOperatorCountry = @8, " + "TowageOnDepartureOperatorPostalCode = @P6, TowageOnDepartureOperatorCity = @P7, TowageOnDepartureOperatorCountry = @P8, " +
"TowageOnDepartureOperatorPhone = @P9, TowageOnDepartureOperatorFax = @P10, TowageOnDepartureOperatorEmail = @P11, " + "TowageOnDepartureOperatorPhone = @P9, TowageOnDepartureOperatorFax = @P10, TowageOnDepartureOperatorEmail = @P11, " +
"TowageOnDepartureGrossTonnage = @P12, TowageOnDepartureLengthOverall_MTR = @P13, " + "TowageOnDepartureGrossTonnage = @P12, TowageOnDepartureLengthOverall_MTR = @P13, " +
"TowageOnDepartureBeam_MTR = @P14, TowageOnDeparturePurposeOfCall = @P15, TowageOnDepartureDraught_DMT = @P16, " + "TowageOnDepartureBeam_MTR = @P14, TowageOnDeparturePurposeOfCall = @P15, TowageOnDepartureDraught_DMT = @P16, " +
@ -151,10 +151,10 @@ namespace bsmd.database
if (!reader.IsDBNull(9)) towd.TowageOnDepartureOperatorFax = reader.GetString(9); if (!reader.IsDBNull(9)) towd.TowageOnDepartureOperatorFax = reader.GetString(9);
if (!reader.IsDBNull(10)) towd.TowageOnDepartureOperatorEmail = reader.GetString(10); if (!reader.IsDBNull(10)) towd.TowageOnDepartureOperatorEmail = reader.GetString(10);
if (!reader.IsDBNull(11)) towd.TowageOnDepartureGrossTonnage = reader.GetInt32(11); if (!reader.IsDBNull(11)) towd.TowageOnDepartureGrossTonnage = reader.GetInt32(11);
if (!reader.IsDBNull(12)) towd.TowageOnDepartureLengthOverall_MTR = reader.GetFloat(12); if (!reader.IsDBNull(12)) towd.TowageOnDepartureLengthOverall_MTR = (float) reader.GetDouble(12);
if (!reader.IsDBNull(13)) towd.TowageOnDepartureBeam_MTR = reader.GetFloat(13); if (!reader.IsDBNull(13)) towd.TowageOnDepartureBeam_MTR = (float) reader.GetDouble(13);
if (!reader.IsDBNull(14)) towd.TowageOnDeparturePurposeOfCall = reader.GetString(14); if (!reader.IsDBNull(14)) towd.TowageOnDeparturePurposeOfCall = reader.GetString(14);
if (!reader.IsDBNull(15)) towd.TowageOnDepartureDraught_DMT = reader.GetFloat(15); if (!reader.IsDBNull(15)) towd.TowageOnDepartureDraught_DMT = (float) reader.GetDouble(15);
if (!reader.IsDBNull(16)) towd.TowageOnDepartureRemarks = reader.GetString(16); if (!reader.IsDBNull(16)) towd.TowageOnDepartureRemarks = reader.GetString(16);
result.Add(towd); result.Add(towd);

View File

@ -19,6 +19,8 @@ namespace bsmd.database
private List<WasteDisposalServiceProvider> wdsp = new List<WasteDisposalServiceProvider>(); private List<WasteDisposalServiceProvider> wdsp = new List<WasteDisposalServiceProvider>();
private List<Waste> waste = new List<Waste>();
public WAS() public WAS()
{ {
this.tablename = "[dbo].[WAS]"; this.tablename = "[dbo].[WAS]";
@ -32,6 +34,12 @@ namespace bsmd.database
public bool? ConfirmationOfCorrectness { get; set; } public bool? ConfirmationOfCorrectness { get; set; }
public DateTime? LastWasteDisposalDate { get; set; }
public byte? WasteDisposalDelivery { get; set; }
public List<Waste> Waste { get { return this.waste; } }
public List<WasteDisposalServiceProvider> WasteDisposalServiceProvider { get { return this.wdsp; } } public List<WasteDisposalServiceProvider> WasteDisposalServiceProvider { get { return this.wdsp; } }
#endregion #endregion
@ -47,23 +55,27 @@ namespace bsmd.database
scmd.Parameters.AddWithNullableValue("@P2", this.WasteDisposalValidExemption); scmd.Parameters.AddWithNullableValue("@P2", this.WasteDisposalValidExemption);
scmd.Parameters.AddWithNullableValue("@P3", this.LastWasteDisposalPort); scmd.Parameters.AddWithNullableValue("@P3", this.LastWasteDisposalPort);
scmd.Parameters.AddWithNullableValue("@P4", this.ConfirmationOfCorrectness); scmd.Parameters.AddWithNullableValue("@P4", this.ConfirmationOfCorrectness);
scmd.Parameters.AddWithNullableValue("@P5", this.LastWasteDisposalDate);
scmd.Parameters.AddWithNullableValue("@P6", this.WasteDisposalDelivery);
if (this.IsNew) if (this.IsNew)
{ {
scmd.CommandText = string.Format("INSERT INTO {0} (MessageHeaderId, WasteDisposalValidExemption, " + scmd.CommandText = string.Format("INSERT INTO {0} (MessageHeaderId, WasteDisposalValidExemption, " +
"LastWasteDisposalPort, ConfirmationOfCorrectness) VALUES ( @P1, @P2, @P3, @P4 )", this.Tablename); "LastWasteDisposalPort, ConfirmationOfCorrectness, LastWasteDisposalDate, WasteDisposalDelivery) " +
"VALUES ( @P1, @P2, @P3, @P4, @P5, @P6 )", this.Tablename);
} }
else else
{ {
scmd.Parameters.AddWithValue(@"ID", this.Id); scmd.Parameters.AddWithValue(@"ID", this.Id);
scmd.CommandText = string.Format("UPDATE {0} SET WasteDisposalValidExemption = @P2, LastWasteDisposalPort = @P3, " + scmd.CommandText = string.Format("UPDATE {0} SET WasteDisposalValidExemption = @P2, LastWasteDisposalPort = @P3, " +
"ConfirmationOfCorrectness = @P4 WHERE Id = @ID", this.Tablename); "ConfirmationOfCorrectness = @P4, LastWasteDisposalDate = @P5, WasteDisposalDelivery = @P6 " +
"WHERE Id = @ID", this.Tablename);
} }
} }
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria) public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
{ {
string query = string.Format("SELECT Id, WasteDisposalValidExemption, LastWasteDisposalPort, ConfirmationOfCorrectness " + string query = string.Format("SELECT Id, WasteDisposalValidExemption, LastWasteDisposalPort, ConfirmationOfCorrectness, LastWasteDisposalDate, WasteDisposalDelivery " +
"FROM {0}", this.Tablename); "FROM {0}", this.Tablename);
switch (filter) switch (filter)
@ -93,6 +105,8 @@ namespace bsmd.database
if (!reader.IsDBNull(1)) was.WasteDisposalValidExemption = reader.GetBoolean(1); if (!reader.IsDBNull(1)) was.WasteDisposalValidExemption = reader.GetBoolean(1);
if (!reader.IsDBNull(2)) was.LastWasteDisposalPort = reader.GetString(2); if (!reader.IsDBNull(2)) was.LastWasteDisposalPort = reader.GetString(2);
if (!reader.IsDBNull(3)) was.ConfirmationOfCorrectness = reader.GetBoolean(3); if (!reader.IsDBNull(3)) was.ConfirmationOfCorrectness = reader.GetBoolean(3);
if (!reader.IsDBNull(4)) was.LastWasteDisposalDate = reader.GetDateTime(4);
if (!reader.IsDBNull(5)) was.WasteDisposalDelivery = reader.GetByte(5);
result.Add(was); result.Add(was);
} }
reader.Close(); reader.Close();

View File

@ -24,7 +24,7 @@ namespace bsmd.database
#region Properties #region Properties
public WasteDisposalServiceProvider WasteDisposalServiceProvider { get; set; } public WAS WAS { get; set; }
public byte? WasteType { get; set; } public byte? WasteType { get; set; }
@ -49,7 +49,7 @@ namespace bsmd.database
SqlCommand scmd = cmd as SqlCommand; SqlCommand scmd = cmd as SqlCommand;
scmd.Parameters.AddWithValue("@P1", this.WasteDisposalServiceProvider.Id); scmd.Parameters.AddWithValue("@P1", this.WAS.Id);
scmd.Parameters.AddWithNullableValue("@P2", this.WasteType); scmd.Parameters.AddWithNullableValue("@P2", this.WasteType);
scmd.Parameters.AddWithNullableValue("@P3", this.WasteDescription); scmd.Parameters.AddWithNullableValue("@P3", this.WasteDescription);
scmd.Parameters.AddWithNullableValue("@P4", this.WasteDisposalAmount_MTQ); scmd.Parameters.AddWithNullableValue("@P4", this.WasteDisposalAmount_MTQ);
@ -60,7 +60,7 @@ namespace bsmd.database
if (this.IsNew) if (this.IsNew)
{ {
scmd.CommandText = string.Format("INSERT INTO {0} (WasteDisposalServiceProviderId, WasteType, WasteDescription, " + scmd.CommandText = string.Format("INSERT INTO {0} (WASId, WasteType, WasteDescription, " +
"WasteDisposalAmount_MTQ, WasteCapacity_MTQ, WasteAmountRetained_MTQ, WasteDisposalPort, WasteAmountGeneratedTillNextPort_MTQ) " + "WasteDisposalAmount_MTQ, WasteCapacity_MTQ, WasteAmountRetained_MTQ, WasteDisposalPort, WasteAmountGeneratedTillNextPort_MTQ) " +
" VALUES ( @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8 )", this.Tablename); " VALUES ( @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8 )", this.Tablename);
} }
@ -83,7 +83,7 @@ namespace bsmd.database
switch (filter) switch (filter)
{ {
case Message.LoadFilter.WDSP_ID: case Message.LoadFilter.WDSP_ID:
query += "WHERE WasteDisposalServiceProviderId = @WDID"; query += "WHERE WASId = @WDID";
((SqlCommand)cmd).Parameters.AddWithValue("@WDID", criteria[0]); ((SqlCommand)cmd).Parameters.AddWithValue("@WDID", criteria[0]);
break; break;
case Message.LoadFilter.ALL: case Message.LoadFilter.ALL:
@ -106,11 +106,11 @@ namespace bsmd.database
waste.id = reader.GetGuid(0); waste.id = reader.GetGuid(0);
if (!reader.IsDBNull(1)) waste.WasteType = reader.GetByte(1); if (!reader.IsDBNull(1)) waste.WasteType = reader.GetByte(1);
if (!reader.IsDBNull(2)) waste.WasteDescription = reader.GetString(2); if (!reader.IsDBNull(2)) waste.WasteDescription = reader.GetString(2);
if (!reader.IsDBNull(3)) waste.WasteDisposalAmount_MTQ = reader.GetFloat(3); if (!reader.IsDBNull(3)) waste.WasteDisposalAmount_MTQ = (float) reader.GetDouble(3);
if (!reader.IsDBNull(4)) waste.WasteCapacity_MTQ = reader.GetFloat(4); if (!reader.IsDBNull(4)) waste.WasteCapacity_MTQ = (float) reader.GetDouble(4);
if (!reader.IsDBNull(5)) waste.WasteAmountRetained_MTQ = reader.GetFloat(5); if (!reader.IsDBNull(5)) waste.WasteAmountRetained_MTQ = (float) reader.GetDouble(5);
if (!reader.IsDBNull(6)) waste.WasteDisposalPort = reader.GetString(6); if (!reader.IsDBNull(6)) waste.WasteDisposalPort = reader.GetString(6);
if (!reader.IsDBNull(7)) waste.WasteAmountGeneratedTillNextPort_MTQ = reader.GetFloat(4); if (!reader.IsDBNull(7)) waste.WasteAmountGeneratedTillNextPort_MTQ = (float) reader.GetDouble(4);
result.Add(waste); result.Add(waste);
} }
reader.Close(); reader.Close();

View File

@ -17,8 +17,6 @@ namespace bsmd.database
public class WasteDisposalServiceProvider : DatabaseEntity public class WasteDisposalServiceProvider : DatabaseEntity
{ {
private List<Waste> waste = new List<Waste>();
public WasteDisposalServiceProvider() public WasteDisposalServiceProvider()
{ {
this.tablename = "[dbo].[WasteDisposalServiceProvider]"; this.tablename = "[dbo].[WasteDisposalServiceProvider]";
@ -26,8 +24,6 @@ namespace bsmd.database
#region Properties #region Properties
public List<Waste> Waste { get { return this.waste; } }
public WAS WAS { get; set; } public WAS WAS { get; set; }
public string WasteDisposalServiceProviderName { get; set; } public string WasteDisposalServiceProviderName { get; set; }

View File

@ -51,6 +51,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Customer.cs" />
<Compile Include="LastTenPortFacilitiesCalled.cs" /> <Compile Include="LastTenPortFacilitiesCalled.cs" />
<Compile Include="Properties\AssemblyProductInfo.cs" /> <Compile Include="Properties\AssemblyProductInfo.cs" />
<Compile Include="Properties\AssemblyProjectInfo.cs" /> <Compile Include="Properties\AssemblyProjectInfo.cs" />

View File

@ -65,7 +65,7 @@ namespace bsmd.dbh
DateTime timestamp = DateTime.Now; DateTime timestamp = DateTime.Now;
string version = "2.0"; string version = "2.0";
object item = null; object item = null;
string senderReference = dbEntity.Id.ToString(); string senderReference = dbEntity.Id.Value.ToString("N");
ItemChoiceType2 itemChoiceType2 = ItemChoiceType2.Visit; // ? ItemChoiceType2 itemChoiceType2 = ItemChoiceType2.Visit; // ?
@ -185,6 +185,7 @@ namespace bsmd.dbh
{ {
RootATA rootATA = new RootATA(); RootATA rootATA = new RootATA();
rootType = RootType.DATA; rootType = RootType.DATA;
if(ata.ATAPortOfCall.HasValue)
rootATA.ATAPortOfCall = ata.ATAPortOfCall.Value; rootATA.ATAPortOfCall = ata.ATAPortOfCall.Value;
item = rootATA; item = rootATA;
} }
@ -238,6 +239,39 @@ namespace bsmd.dbh
} }
#endregion #endregion
#region CREW
case Message.NotificationClass.CREW:
{
if (aMessage.Elements.Count > 0)
{
RootCREW rootCREW = new RootCREW();
rootType = RootType.DATA;
rootCREW.CrewMember = new RootCREWCrewMember[aMessage.Elements.Count];
for (int i = 0; i < aMessage.Elements.Count; i++)
{
CREW crew = aMessage.Elements[i] as CREW;
rootCREW.CrewMember[i] = new RootCREWCrewMember();
if (crew.CrewMemberDateOfBirth.HasValue)
rootCREW.CrewMember[i].CrewMemberDateOfBirth = crew.CrewMemberDateOfBirth.Value;
rootCREW.CrewMember[i].CrewMemberDuty = crew.CrewMemberDuty;
rootCREW.CrewMember[i].CrewMemberFirstName = crew.CrewMemberFirstName;
rootCREW.CrewMember[i].CrewMemberGenderSpecified = crew.CrewMemberGender.HasValue;
if (crew.CrewMemberGender.HasValue)
rootCREW.CrewMember[i].CrewMemberGender = (RootCREWCrewMemberCrewMemberGender) crew.CrewMemberGender.Value;
rootCREW.CrewMember[i].CrewMemberIdentityDocumentId = crew.CrewMemberIdentityDocumentId;
if(crew.CrewMemberIdentityDocumentType.HasValue)
rootCREW.CrewMember[i].CrewMemberIdentityDocumentType = (RootCREWCrewMemberCrewMemberIdentityDocumentType)crew.CrewMemberIdentityDocumentType.Value;
rootCREW.CrewMember[i].CrewMemberLastName = crew.CrewMemberLastName;
rootCREW.CrewMember[i].CrewMemberNationality = crew.CrewMemberNationality;
rootCREW.CrewMember[i].CrewMemberPlaceOfBirth = crew.CrewMemberPlaceOfBirth;
rootCREW.CrewMember[i].CrewMemberVisaNumber = crew.CrewMemberVisaNumber;
}
item = rootCREW;
}
}
break;
#endregion
default: default:
{ {
_log.ErrorFormat("DBH send message: message type {0} not implemented", aMessage.MessageNotificationClass); _log.ErrorFormat("DBH send message: message type {0} not implemented", aMessage.MessageNotificationClass);
@ -250,8 +284,38 @@ namespace bsmd.dbh
bool returnval = true; bool returnval = true;
try try
{ {
string result = client.Root(version, timestamp, Properties.Settings.Default.Sender, senderReference, rootType, object[] items = null;
item, itemChoiceType2, null, rp, null, null); if ((rootType == RootType.CANCEL) || (rootType == RootType.DATA) || (rootType == RootType.RESET))
{
items = new object[1];
items[0] = item;
if (aMessage.MessageCore.IsTransit)
{
item = aMessage.MessageCore.TransitId;
itemChoiceType2 = ItemChoiceType2.TransitId;
}
else
{
item = aMessage.MessageCore.VisitId;
itemChoiceType2 = ItemChoiceType2.VisitId;
}
}
string result = client.Root(
version,
timestamp,
Properties.Settings.Default.Sender, // BSMD sender Kennung (festverdrahtet)
senderReference,
rootType,
item,
itemChoiceType2,
null, // sisnumbers (weglassen)
rp,
items,
null // violations (weglassen)
);
} }
catch (Exception ex) catch (Exception ex)
{ {

View File

@ -67,7 +67,7 @@ namespace bsmd.dbh
} }
Guid messageId; Guid messageId;
if (!Guid.TryParse(aResponse.SenderReference, out messageId)) if (!Guid.TryParseExact(aResponse.SenderReference, "N", out messageId))
{ {
_log.WarnFormat("SenderReference {0} is not a guid, skipping message processing!", aResponse.SenderReference); _log.WarnFormat("SenderReference {0} is not a guid, skipping message processing!", aResponse.SenderReference);
return; return;
@ -86,11 +86,11 @@ namespace bsmd.dbh
case dbh.response.RootType.VISIT: case dbh.response.RootType.VISIT:
// neue VISIT - ID // neue VISIT - ID
aMessage.MessageCore.VisitId = aResponse.VisitId; aMessage.MessageCore.VisitId = aResponse.VisitId;
DBManager.Instance.Save(aMessage.MessageCore);
break; break;
case dbh.response.RootType.TRANSIT: case dbh.response.RootType.TRANSIT:
aMessage.MessageCore.TransitId = aResponse.TransitId; aMessage.MessageCore.TransitId = aResponse.TransitId;
DBManager.Instance.Save(aMessage.MessageCore);
break; break;
case dbh.response.RootType.CANCEL: case dbh.response.RootType.CANCEL:
@ -104,6 +104,7 @@ namespace bsmd.dbh
} }
//aMessage.Status = Message.MessageStatus. //aMessage.Status = Message.MessageStatus.
aMessage.ReceivedAt = DateTime.Now;
aMessage.InternalStatus = Message.BSMDStatus.RESPONDED; aMessage.InternalStatus = Message.BSMDStatus.RESPONDED;
DBManager.Instance.Save(aMessage); DBManager.Instance.Save(aMessage);
} }

View File

@ -43,6 +43,18 @@
<setting name="ClientGuid" serializeAs="String"> <setting name="ClientGuid" serializeAs="String">
<value>76994eae-48de-44d4-a86d-6508e2e03dcf</value> <value>76994eae-48de-44d4-a86d-6508e2e03dcf</value>
</setting> </setting>
<setting name="IntervalLastDay" serializeAs="String">
<value>0</value>
</setting>
<setting name="IntervalLastHour" serializeAs="String">
<value>2</value>
</setting>
<setting name="IntervalLastMinute" serializeAs="String">
<value>0</value>
</setting>
<setting name="SleepSeconds" serializeAs="String">
<value>300</value>
</setting>
</bsmd.herberg.FormService.Properties.Settings> </bsmd.herberg.FormService.Properties.Settings>
</userSettings> </userSettings>
<system.serviceModel> <system.serviceModel>

View File

@ -28,8 +28,11 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
components = new System.ComponentModel.Container(); //
this.ServiceName = "Service1"; // FormService
//
this.ServiceName = "EU-NOAD Reader";
} }
#endregion #endregion

View File

@ -34,8 +34,15 @@ namespace bsmd.herberg.FormService
this.EventLog.Source = this.ServiceName; this.EventLog.Source = this.ServiceName;
this.EventLog.Log = "Application"; this.EventLog.Log = "Application";
this.EventLog.BeginInit(); this.EventLog.BeginInit();
try
{
if (!EventLog.SourceExists(this.EventLog.Source, this.EventLog.Log)) if (!EventLog.SourceExists(this.EventLog.Source, this.EventLog.Log))
EventLog.CreateEventSource(this.EventLog.Source, this.EventLog.Log); EventLog.CreateEventSource(this.EventLog.Source, this.EventLog.Log);
}
catch (Exception ex)
{
_log.ErrorFormat("Source exists exception: {0}", ex.ToString());
}
this.EventLog.EndInit(); this.EventLog.EndInit();
this.Init(args); this.Init(args);
@ -50,7 +57,7 @@ namespace bsmd.herberg.FormService
public void Init(string[] args) public void Init(string[] args)
{ {
this._timer = new Timer(); this._timer = new Timer();
this._timer.Interval = 5000; // 5 sec this._timer.Interval = Properties.Settings.Default.SleepSeconds * 1000;
this._timer.Elapsed += _timer_Elapsed; this._timer.Elapsed += _timer_Elapsed;
this._timer.Enabled = true; this._timer.Enabled = true;
@ -84,9 +91,13 @@ namespace bsmd.herberg.FormService
body.ffFolderTemplateTypeTag = "NSWAD"; body.ffFolderTemplateTypeTag = "NSWAD";
body.timeFrameRequestFilter = new TimeFrameRequestFilter(); body.timeFrameRequestFilter = new TimeFrameRequestFilter();
body.timeFrameRequestFilter.startDate = DateTime.Now - new TimeSpan(30, 0, 0, 0); // last 30 days body.timeFrameRequestFilter.startDate = DateTime.Now -
new TimeSpan(Properties.Settings.Default.IntervalLastDay,
Properties.Settings.Default.IntervalLastHour,
Properties.Settings.Default.IntervalLastMinute,
0);
body.timeFrameRequestFilter.startDateSpecified = true; body.timeFrameRequestFilter.startDateSpecified = true;
body.timeFrameRequestFilter.endDate = DateTime.Now + new TimeSpan(30, 0, 0, 0); body.timeFrameRequestFilter.endDate = DateTime.Now + new TimeSpan(1, 0, 0, 0);
body.timeFrameRequestFilter.endDateSpecified = true; body.timeFrameRequestFilter.endDateSpecified = true;
// Liste der verfügbaren Formulare abholen // Liste der verfügbaren Formulare abholen
@ -100,7 +111,15 @@ namespace bsmd.herberg.FormService
{ {
FormDataInfoDataset dataSet = listReponse.formDataInfoDatasets[i]; FormDataInfoDataset dataSet = listReponse.formDataInfoDatasets[i];
// prüfen, ob ich das Formular schon habe? -> RS Jan /* prüfen, ob ich das Formular schon habe? -> RS Jan
> Ein Formular, identifiziert durch formGuid würde dann immer einem
> Schiffsanlauf entsprechen? d.h. der nächste Hafenanlauf hätte dann
> dieselbe formTemplateGuid, aber unterschiedliche formGuids?
Das ist korrekt. Allerdings kann sich die FormTemplate-GUID mit der Zeit
ändern, wenn wir z.B. das Template updaten. Theoretisch kann das auch
zwischen Initial und Update passieren.
*/
// Formular abholen // Formular abholen
GetFormDataRequestData formBody = new GetFormDataRequestData(); GetFormDataRequestData formBody = new GetFormDataRequestData();
@ -122,6 +141,7 @@ namespace bsmd.herberg.FormService
aMessageCore.HerbergFormGuid = new Guid(formBody.formGuid); aMessageCore.HerbergFormGuid = new Guid(formBody.formGuid);
// aMessageCore.HerbergFormTemplateGuid = formResponse. // aMessageCore.HerbergFormTemplateGuid = formResponse.
aMessageCore.IMO = formResponse.imoNumber.ToString(); aMessageCore.IMO = formResponse.imoNumber.ToString();
if (aMessageCore.IMO.Length > 7) if (aMessageCore.IMO.Length > 7)
{ {
_log.WarnFormat("IMO {0} is longer than 7 chars, truncating!", aMessageCore.IMO); _log.WarnFormat("IMO {0} is longer than 7 chars, truncating!", aMessageCore.IMO);
@ -131,7 +151,7 @@ namespace bsmd.herberg.FormService
} }
// Änderungen im Formular übertragen und speichern // Änderungen im Formular übertragen und speichern
Util.UpdateFormCore(aMessageCore); Util.UpdateFormCore(aMessageCore, formResponse);
} }
else else

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

View File

@ -0,0 +1,59 @@
namespace bsmd.herberg.FormService
{
partial class ProjectInstaller
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
//
// serviceInstaller1
//
this.serviceInstaller1.Description = "Reads EU-NOAD forms from Fleettracker server";
this.serviceInstaller1.DisplayName = "EU-NOAD Reader";
this.serviceInstaller1.ServiceName = "EU-NOAD Reader";
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.serviceInstaller1});
}
#endregion
private System.ServiceProcess.ServiceProcessInstaller serviceProcessInstaller1;
private System.ServiceProcess.ServiceInstaller serviceInstaller1;
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.Threading.Tasks;
namespace bsmd.herberg.FormService
{
[RunInstaller(true)]
public partial class ProjectInstaller : System.Configuration.Install.Installer
{
public ProjectInstaller()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="serviceProcessInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="serviceInstaller1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>196, 17</value>
</metadata>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

View File

@ -80,5 +80,53 @@ namespace bsmd.herberg.FormService.Properties {
this["ClientGuid"] = value; this["ClientGuid"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
public int IntervalLastDay {
get {
return ((int)(this["IntervalLastDay"]));
}
set {
this["IntervalLastDay"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("2")]
public int IntervalLastHour {
get {
return ((int)(this["IntervalLastHour"]));
}
set {
this["IntervalLastHour"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
public int IntervalLastMinute {
get {
return ((int)(this["IntervalLastMinute"]));
}
set {
this["IntervalLastMinute"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("300")]
public int SleepSeconds {
get {
return ((int)(this["SleepSeconds"]));
}
set {
this["SleepSeconds"] = value;
}
}
} }
} }

View File

@ -17,5 +17,17 @@
<Setting Name="ClientGuid" Type="System.Guid" Scope="User"> <Setting Name="ClientGuid" Type="System.Guid" Scope="User">
<Value Profile="(Default)">76994eae-48de-44d4-a86d-6508e2e03dcf</Value> <Value Profile="(Default)">76994eae-48de-44d4-a86d-6508e2e03dcf</Value>
</Setting> </Setting>
<Setting Name="IntervalLastDay" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="IntervalLastHour" Type="System.Int32" Scope="User">
<Value Profile="(Default)">2</Value>
</Setting>
<Setting Name="IntervalLastMinute" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
</Setting>
<Setting Name="SleepSeconds" Type="System.Int32" Scope="User">
<Value Profile="(Default)">300</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -9,6 +9,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using log4net; using log4net;
using bsmd.database; using bsmd.database;
@ -19,11 +20,410 @@ namespace bsmd.herberg.FormService
{ {
private static ILog _log = LogManager.GetLogger(typeof(Util)); private static ILog _log = LogManager.GetLogger(typeof(Util));
public static void UpdateFormCore(MessageCore core) internal static void UpdateFormCore(MessageCore aMessageCore, WebReference.GetFormDataResponseData formResponse)
{
ReportingParty bsmdParty = null;
Dictionary<Guid, ReportingParty> repDict = DBManager.Instance.GetReportingPartyDict();
foreach (Guid key in repDict.Keys)
{
if (repDict[key].Name.Equals("BSMD"))
{
bsmdParty = repDict[key];
break;
}
}
for (int i = 0; i < formResponse.formDatasets.Length; i++)
{
Dictionary<string, Dictionary<string, string>> groupedVals = new Dictionary<string, Dictionary<string, string>>();
WebReference.FormDataset fds = formResponse.formDatasets[i];
if (fds.startPeriodSpecified)
Trace.WriteLine(fds.startPeriod);
Trace.WriteLine(string.Format("Dataset {0}", i));
foreach(WebReference.FormData formData in fds.formData)
{
string[] nElems = formData.name.Split('.');
if (nElems.Length != 2)
{
_log.WarnFormat("Field name {0} has wrong format!", formData.name);
continue;
}
Trace.WriteLine(string.Format("Set:{0} Type:{1} Name:{2} Value:{3}", i, nElems[0], nElems[1], formData.value));
if (!groupedVals.ContainsKey(nElems[0]))
groupedVals[nElems[0]] = new Dictionary<string, string>();
groupedVals[nElems[0]][nElems[1]] = formData.value;
}
// jetzt können wir die Felder nach Nachrichtentyp abarbeiten
Dictionary<string, Message> messages = Util.PrepareMessageDict(aMessageCore);
foreach (string messageType in groupedVals.Keys)
{
Dictionary<string, string> vDict = groupedVals[messageType];
DatabaseEntity derivedMessage = null;
Message theMessage = null;
if (!messages.ContainsKey(messageType))
{
theMessage = new Message();
if (messageType.Equals("HAZ")) continue; // HE spezial, sollte HAZA o. HAZD sein
if (messageType.Equals("Agency"))
{
if (aMessageCore.Customer == null) aMessageCore.Customer = new Customer();
if (vDict.ContainsKey("Name")) aMessageCore.Customer.Name = vDict["Name"];
if (vDict.ContainsKey("Phone")) aMessageCore.Customer.Phone = vDict["Phone"];
if (vDict.ContainsKey("Email")) aMessageCore.Customer.Email = vDict["Email"];
if (vDict.ContainsKey("ContactFirstName")) aMessageCore.Customer.ContactFirstName = vDict["ContactFirstName"];
if (vDict.ContainsKey("ContactLastName")) aMessageCore.Customer.ContactLastName = vDict["ContactLastName"];
continue; // das Zeug verhält sich wie eine Not. Class
}
theMessage.MessageNotificationClass = (Message.NotificationClass) Enum.Parse(typeof(Message.NotificationClass), messageType, true);
theMessage.MessageCoreId = aMessageCore.Id;
theMessage.MessageCore = aMessageCore;
if (bsmdParty != null)
theMessage.ReportingParty = bsmdParty;
}
else
{
theMessage = messages[messageType];
}
switch (messageType)
{
case "ATA":
{
if (theMessage.Elements.Count == 0)
{
ATA newATA = new ATA();
newATA.MessageHeader = theMessage;
theMessage.MessageNotificationClass = Message.NotificationClass.ATA;
theMessage.Elements.Add(newATA);
}
ATA ata = theMessage.Elements[0] as ATA;
derivedMessage = ata;
if (ata != null)
{
try
{ {
}
catch (Exception ex)
{
_log.ErrorFormat("Error reading ATA fields: {0}", ex.Message);
}
}
}
break;
case "NOA_NOD":
{
if (theMessage.Elements.Count == 0)
{
NOA_NOD newNOA_NOD = new NOA_NOD();
newNOA_NOD.MessageHeader = theMessage;
theMessage.MessageNotificationClass = Message.NotificationClass.NOA_NOD;
theMessage.Elements.Add(newNOA_NOD);
}
NOA_NOD noa_nod = theMessage.Elements[0] as NOA_NOD;
derivedMessage = noa_nod;
if (noa_nod != null)
{
try
{
if (vDict.ContainsKey("CallPurposeCode")) noa_nod.CallPurposeCode = Int32.Parse(vDict["CallPurposeCode"]);
if (vDict.ContainsKey("ETAToNextPort")) noa_nod.ETAToNextPort = DateTime.Parse(vDict["ETAToNextPort"]);
if (vDict.ContainsKey("ETDFromLastPort")) noa_nod.ETDFromLastPort = DateTime.Parse(vDict["ETDFromLastPort"]);
if (vDict.ContainsKey("ETAToPortOfCall")) noa_nod.ETAToPortOfCall = DateTime.Parse(vDict["ETAToPortOfCall"]);
if (vDict.ContainsKey("ETDFromPortOfCall")) noa_nod.ETDFromPortOfCall = DateTime.Parse(vDict["ETDFromPortOfCall"]);
if (vDict.ContainsKey("CallPurposeDescription")) noa_nod.CallPurposeDescription = vDict["CallPurposeDescription"];
// if(vDict.ContainsKey("CountryOfNextPort")) noa_nod. nicht relevant
if (vDict.ContainsKey("ETAToKielCanal")) noa_nod.ETAToKielCanal = DateTime.Parse(vDict["ETAToKielCanal"]);
if (vDict.ContainsKey("ETDFromKielCanal")) noa_nod.ETDFromKielCanal = DateTime.Parse(vDict["ETDFromKielCanal"]);
if (vDict.ContainsKey("CountryCodeOfLastPort") && vDict.ContainsKey("LastPortCode"))
noa_nod.LastPort = vDict["CountryCodeOfLastPort"] + vDict["LastPortCode"];
if (vDict.ContainsKey("CountryCodeOfNextPort") && vDict.ContainsKey("NextPortCode"))
noa_nod.NextPort = vDict["CountryCodeOfNextPort"] + vDict["NextPortCode"];
}
catch (Exception ex)
{
_log.ErrorFormat("Error reading NOA_NOD fields: {0}", ex.Message);
}
}
}
break;
case "STAT":
if(theMessage.Elements.Count == 0) {
STAT newStat = new STAT();
newStat.MessageHeader = theMessage;
theMessage.MessageNotificationClass = Message.NotificationClass.STAT;
theMessage.Elements.Add(newStat);
}
STAT stat = theMessage.Elements[0] as STAT;
derivedMessage = stat;
if(stat != null) {
try
{
if (vDict.ContainsKey("ShipName")) stat.ShipName = vDict["ShipName"];
if (vDict.ContainsKey("CallSign")) stat.CallSign = vDict["CallSign"];
if (vDict.ContainsKey("MMSINumber")) stat.MMSINumber = vDict["MMSINumber"];
if (vDict.ContainsKey("Flag")) stat.Flag = vDict["Flag"];
if (vDict.ContainsKey("ShipType")) stat.ShipType = vDict["ShipType"];
if (vDict.ContainsKey("LengthOverall_MTR")) stat.LengthOverall_MTR = (float)Double.Parse(vDict["LengthOverall_MTR"]);
if (vDict.ContainsKey("Beam_MTR")) stat.Beam_MTR = (float)Double.Parse(vDict["Beam_MTR"]);
if (vDict.ContainsKey("GrossTonnage")) stat.GrossTonnage = Int32.Parse(vDict["GrossTonnage"]);
// if (vDict.ContainsKey("PortNameOfRegistry")) stat.PortOfRegistry = vDict["PortNameOfRegistry"]; // existiert nicht
if (vDict.ContainsKey("InmarsatCallNumber")) stat.InmarsatCallNumber = vDict["InmarsatCallNumber"];
// if(vDict.ContainsKey("CountryOfRegistry")) stat.r // existiert nicht in spec
if (vDict.ContainsKey("PortCodeOfRegistry") && vDict.ContainsKey("CountryCodeOfRegistry"))
stat.PortOfRegistry = vDict["CountryCodeOfRegistry"] + vDict["PortCodeOfRegistry"];
if (vDict.ContainsKey("ShipTypeCode")) stat.ShipType = vDict["ShipTypeCode"];
if (vDict.ContainsKey("ISMCompanyName")) stat.ISMCompanyName = vDict["ISMCompanyName"];
if (vDict.ContainsKey("ISMCompanyId")) stat.ISMCompanyId = vDict["ISMCompanyId"];
if (vDict.ContainsKey("ISMCompanyStreetAndNumber")) stat.ISMCompanyStreetAndNumber = vDict["ISMCompanyStreetAndNumber"];
if (vDict.ContainsKey("ISMCompanyPostalCode")) stat.ISMCompanyPostalCode = vDict["ISMCompanyPostalCode"];
if (vDict.ContainsKey("ISMCompanyCity")) stat.ISMCompanyCity = vDict["ISMCompanyCity"];
if (vDict.ContainsKey("ISMCompanyCountry")) stat.ISMCompanyCountry = vDict["ISMCompanyCountry"];
}
catch (Exception ex)
{
_log.ErrorFormat("Error reading STAT fields: {0}", ex.Message);
}
}
break;
case "MDH":
{
if (theMessage.Elements.Count == 0)
{
MDH newMDH = new MDH();
newMDH.MessageHeader = theMessage;
theMessage.MessageNotificationClass = Message.NotificationClass.MDH;
theMessage.Elements.Add(newMDH);
}
MDH mdh = theMessage.Elements[0] as MDH;
derivedMessage = mdh;
if (mdh != null)
{
try
{
if (vDict.ContainsKey("SickAnimalOrPetOnBoard")) mdh.SickAnimalOrPetOnBoard = vDict["SickAnimalOrPetOnBoard"].Equals("Y");
if (vDict.ContainsKey("Simplification")) mdh.MDHSimplification = vDict["Simplification"].Equals("Y");
if (vDict.ContainsKey("SanitaryMeasuresApplied")) mdh.SanitaryMeasuresApplied = vDict["SanitaryMeasuresApplied"].Equals("Y");
if (vDict.ContainsKey("NonAccidentialDeathsDuringVoyage")) mdh.NonAccidentalDeathsDuringVoyage = vDict["NonAccidentialDeathsDuringVoyage"].Equals("Y");
if (vDict.ContainsKey("SuspisionInfectiousNature")) mdh.SuspisionInfectiousNature = vDict["SuspisionInfectiousNature"].Equals("Y");
if (vDict.ContainsKey("NumberOfIllPersonsHigherThanExpected")) mdh.NumberOfIllPersonsHigherThanExpected = vDict["NumberOfIllPersonsHigherThanExpected"].Equals("Y");
if (vDict.ContainsKey("SickPersonsOnBoard")) mdh.SickPersonsOnBoard = vDict["SickPersonsOnBoard"].Equals("Y");
if (vDict.ContainsKey("MedicalConsulted")) mdh.MedicalConsulted = vDict["MedicalConsulted"].Equals("Y");
if (vDict.ContainsKey("AwareOfConditionsForFurtherInfections")) mdh.AwareOfFurtherInfections = vDict["AwareOfConditionsForFurtherInfections"].Equals("Y");
if (vDict.ContainsKey("ValidSanitaryControlExemptionOrCertificateOnBoard")) mdh.ValidSanitaryControlExemptionOrCertificateOnBoard = vDict["ValidSanitaryControlExemptionOrCertificateOnBoard"].Equals("Y");
if (vDict.ContainsKey("SanitaryControlReinspectionRequired")) mdh.SanitaryControlReinspectionRequired = vDict["SanitaryControlReinspectionRequired"].Equals("Y");
if (vDict.ContainsKey("InfectedAreaVisited")) mdh.InfectedAreaVisited = vDict["InfectedAreaVisited"].Equals("Y");
}
catch (Exception ex)
{
_log.ErrorFormat("Error reading MDH fields: {0}", ex.Message);
}
}
}
break;
case "POBA":
{
if (theMessage.Elements.Count == 0)
{
POBA newPOBA = new POBA();
newPOBA.MessageHeader = theMessage;
theMessage.MessageNotificationClass = Message.NotificationClass.POBA;
theMessage.Elements.Add(newPOBA);
}
POBA poba = theMessage.Elements[0] as POBA;
derivedMessage = poba;
if (poba != null)
{
try
{
if (vDict.ContainsKey("TotalPersonsOnBoardUponArrival")) poba.TotalPersonsOnBoardUponArrival = Int32.Parse(vDict["TotalPersonsOnBoardUponArrival"]);
if (vDict.ContainsKey("TotalCrewMembersOnBoardUponArrival")) poba.TotalCrewMembersOnBoardUponArrival = Int32.Parse(vDict["TotalCrewMembersOnBoardUponArrival"]);
if (vDict.ContainsKey("TotalPassengersOnBoardUponArrival")) poba.TotalPassengersOnBoardUponArrival = Int32.Parse(vDict["TotalPassengersOnBoardUponArrival"]);
if (vDict.ContainsKey("TotalStowawaysOnBoardUponArrival")) poba.TotalStowawaysOnBoardUponArrival = Int32.Parse(vDict["TotalStowawaysOnBoardUponArrival"]);
}
catch (Exception ex)
{
_log.ErrorFormat("Error reading POBA fields: {0}", ex.Message);
}
}
}
break;
case "POBD":
{
if (theMessage.Elements.Count == 0)
{
POBD newPOBD = new POBD();
newPOBD.MessageHeader = theMessage;
theMessage.MessageNotificationClass = Message.NotificationClass.POBD;
theMessage.Elements.Add(newPOBD);
}
POBD pobd = theMessage.Elements[0] as POBD;
derivedMessage = pobd;
if (pobd != null)
{
try
{
if (vDict.ContainsKey("TotalPersonsOnBoardUponDeparture")) pobd.TotalPersonsOnBoardUponDeparture = Int32.Parse(vDict["TotalPersonsOnBoardUponDeparture"]);
if (vDict.ContainsKey("TotalCrewMembersOnBoardUponDeparture")) pobd.TotalCrewMembersOnBoardUponDeparture = Int32.Parse(vDict["TotalCrewMembersOnBoardUponDeparture"]);
if (vDict.ContainsKey("TotalPassengersOnBoardUponDeparture")) pobd.TotalPassengersOnBoardUponDeparture = Int32.Parse(vDict["TotalPassengersOnBoardUponDeparture"]);
if (vDict.ContainsKey("TotalStowawaysOnBoardUponDeparture")) pobd.TotalStowawaysOnBoardUponDeparture = Int32.Parse(vDict["TotalStowawaysOnBoardUponDeparture"]);
}
catch (Exception ex)
{
_log.ErrorFormat("Error reading POBA fields: {0}", ex.Message);
}
}
}
break;
case "BKRA":
{
if (theMessage.Elements.Count == 0)
{
BRKA newBRKA = new BRKA();
newBRKA.MessageHeader = theMessage;
theMessage.MessageNotificationClass = Message.NotificationClass.BKRA;
theMessage.Elements.Add(newBRKA);
}
BRKA bkra = theMessage.Elements[0] as BRKA;
derivedMessage = bkra;
if (bkra != null)
{
try
{
if (vDict.ContainsKey("BunkerFuelType")) bkra.BunkerFuelType = vDict["BunkerFuelType"];
if (vDict.ContainsKey("BunkerFuelQuantity_TNE")) bkra.BunkerFuelQuantity_TNE = (float)Double.Parse(vDict["BunkerFuelQuantity_TNE"]);
}
catch (Exception ex)
{
_log.ErrorFormat("Error reading BKRA fields: {0}", ex.Message);
}
}
}
break;
case "WAS":
break;
case "Visit":
{
theMessage.MessageNotificationClass = Message.NotificationClass.VISIT;
if (vDict.ContainsKey("PortNameOfCall")) aMessageCore.Portname = vDict["PortNameOfCall"];
if (vDict.ContainsKey("PortOfCall")) aMessageCore.PoC = "DE" + vDict["PortOfCall"];
if (vDict.ContainsKey("TransitKielCanal")) aMessageCore.IsTransit = vDict["TransitKielCanal"].Equals("Y");
if (vDict.ContainsKey("ETAPortOfCall")) aMessageCore.ETA = DateTime.Parse(vDict["ETAPortOfCall"]);
} }
break;
case "Agency":
break;
case "Transit":
break;
case "TOWA":
if(theMessage.Elements.Count == 0) {
TOWA newTOWA = new TOWA();
newTOWA.MessageHeader = theMessage;
theMessage.MessageNotificationClass = Message.NotificationClass.TOWA;
theMessage.Elements.Add(newTOWA);
}
TOWA towa = theMessage.Elements[0] as TOWA;
derivedMessage = towa;
if (towa != null)
{
try
{
if (vDict.ContainsKey("TowageOnArrivalBeam_MTR")) towa.TowageOnArrivalBeam_MTR = (float)Double.Parse(vDict["TowageOnArrivalBeam_MTR"]);
if (vDict.ContainsKey("TowageOnArrivalDraught_DMT")) towa.TowageOnArrivalDraught_DMT = (float)Double.Parse(vDict["TowageOnArrivalDraught_DMT"]);
if (vDict.ContainsKey("TowageOnArrivalLengthOverall_MTR")) towa.TowageOnArrivalLengthOverall_MTR = (float)Double.Parse(vDict["TowageOnArrivalLengthOverall_MTR"]);
if (vDict.ContainsKey("TowageOnArrivalGrossTonnage")) towa.TowageOnArrivalGrossTonnage = Int32.Parse(vDict["TowageOnArrivalGrossTonnage"]);
if (vDict.ContainsKey("TowageOnArrivalOperatorCountry")) towa.TowageOnArrivalOperatorCountry = vDict["TowageOnArrivalOperatorCountry"];
if (vDict.ContainsKey("TowageOnArrivalPurposeOfCall")) towa.TowageOnArrivalPurposeOfCall = vDict["TowageOnArrivalPurposeOfCall"];
if (vDict.ContainsKey("TowageOnArrivalName")) towa.TowageOnArrivalName = vDict["TowageOnArrivalName"];
if (vDict.ContainsKey("TowageOnArrivalFlag")) towa.TowageOnArrivalFlag = vDict["TowageOnArrivalFlag"];
if (vDict.ContainsKey("TowageOnArrivalOperatorCompanyName")) towa.TowageOnArrivalOperatorCompanyName = vDict["TowageOnArrivalOperatorCompanyName"];
if (vDict.ContainsKey("TowageOnArrivalOperatorStreetAndNumber")) towa.TowageOnArrivalOperatorStreetNameAndNumber = vDict["TowageOnArrivalOperatorStreetAndNumber"];
if (vDict.ContainsKey("TowageOnArrivalOperatorPostalCode")) towa.TowageOnArrivalOperatorPostalCode = vDict["TowageOnArrivalOperatorPostalCode"];
if (vDict.ContainsKey("TowageOnArrivalOperatorCity")) towa.TowageOnArrivalOperatorCity = vDict["TowageOnArrivalOperatorCity"];
if (vDict.ContainsKey("TowageOnArrivalOperatorPhone")) towa.TowageOnArrivalOperatorPhone = vDict["TowageOnArrivalOperatorPhone"];
if (vDict.ContainsKey("TowageOnArrivalOperatorFax")) towa.TowageOnArrivalOperatorFax = vDict["TowageOnArrivalOperatorFax"];
if (vDict.ContainsKey("TowageOnArrivalOperatorEmail")) towa.TowageOnArrivalOperatorEmail = vDict["TowageOnArrivalOperatorEmail"];
if (vDict.ContainsKey("TowageOnArrivalRemarks")) towa.TowageOnArrivalRemarks = vDict["TowageOnArrivalRemarks"];
}
catch (Exception ex)
{
_log.ErrorFormat("Error reading TOWA fields: {0}", ex.Message);
}
}
break;
case "TIEFA":
{
if (theMessage.Elements.Count == 0)
{
TIEFA newTIEFA = new TIEFA();
newTIEFA.MessageHeader = theMessage;
theMessage.MessageNotificationClass = Message.NotificationClass.TIEFA;
theMessage.Elements.Add(newTIEFA);
}
TIEFA tiefa = theMessage.Elements[0] as TIEFA;
derivedMessage = tiefa;
if (tiefa != null)
{
try
{
if (vDict.ContainsKey("DraughtUponArrival_DMT")) tiefa.DraughtUponArrival_DMT = (float)Double.Parse(vDict["DraughtUponArrival_DMT"]);
}
catch (Exception ex)
{
_log.ErrorFormat("Error reading TIEFA fields: {0}", ex.Message);
}
}
break;
}
}
DBManager.Instance.Save(theMessage);
if (derivedMessage != null)
DBManager.Instance.Save(derivedMessage);
}
DBManager.Instance.Save(aMessageCore); // warum?
}
}
/// <summary>
/// Aufbereitung eines Dictionaries: Nachrichtentyp (aus Feld-Präfixen) zu eigentlichen Nachrichten
/// </summary>
private static Dictionary<string, Message> PrepareMessageDict(MessageCore aMessageCore)
{
List<Message> messages = DBManager.Instance.GetMessagesForCore(aMessageCore);
Dictionary<string, Message> result = new Dictionary<string, Message>();
foreach (Message message in messages)
{
if (!result.ContainsKey(message.MessageNotificationClass.ToString()))
{
result.Add(message.MessageNotificationClass.ToString(), message);
}
else
{
// es gibt schon einen Nachricht mit diesem Typ.
// Das kann nur der Fall sein wenn es schon eine Cancel/Reset Nachricht gegeben hat. In diesem Fall wird eine
// Nachricht überschrieben, wenn beide Flags nicht gesetzt sind
if (!message.Reset && !message.Cancel)
{
result[message.MessageNotificationClass.ToString()] = message;
}
}
}
return result;
}
} }
} }

View File

@ -31,13 +31,18 @@
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<StartupObject>bsmd.herberg.FormService.Program</StartupObject>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net"> <Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.EnterpriseServices" /> <Reference Include="System.EnterpriseServices" />
<Reference Include="System.Management" />
<Reference Include="System.Runtime.Serialization" /> <Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" /> <Reference Include="System.ServiceModel" />
<Reference Include="System.Web.Services" /> <Reference Include="System.Web.Services" />
@ -56,6 +61,12 @@
<DependentUpon>FormService.cs</DependentUpon> <DependentUpon>FormService.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="ProjectInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ProjectInstaller.Designer.cs">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs"> <Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
@ -140,6 +151,14 @@
<CachedSettingsPropName>bsmd_herberg_FormService_WebReference_WSAPIFormData</CachedSettingsPropName> <CachedSettingsPropName>bsmd_herberg_FormService_WebReference_WSAPIFormData</CachedSettingsPropName>
</WebReferenceUrl> </WebReferenceUrl>
</ItemGroup> </ItemGroup>
<ItemGroup>
<EmbeddedResource Include="FormService.resx">
<DependentUpon>FormService.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ProjectInstaller.resx">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -0,0 +1,46 @@
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>OpenPop.NET</id>
<version>2.0.6.1102</version>
<title>OpenPop.NET</title>
<authors>OpenPop</authors>
<owners>OpenPop</owners>
<licenseUrl>http://unlicense.org/</licenseUrl>
<projectUrl>http://hpop.sourceforge.net/</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>OpenPop.NET is an open source implementation of a POP3 client and a robust MIME parser written in C#.
It allows developers easy access to email on a POP3 server in a matter of minutes.
The project is backed by several hundred test cases and is therefore believed to be very robust.
If you find a bug, please report this by sending an email to hpop-users@lists.sourceforge.net.
POP3 Client Features
- Easy to use POP3 client
- Support for plain TCP or TLS/SSL connections
- Authentication methods supported
- - Plain
- - APOP
- - CRAM-MD5 (RFC 2195)
- CAPA capabilities command supported (RFC 2449)
MIME Parsing Features
- Preserves the MIME email hierarchy
- Easy access to different MediaType parts of the email
- Headers are parsed into strong types and are easy to examine
- Includes robust decoders for
- - QuotedPrintable
- - Base64
- - EncodedWord
- - Continuation and encoding of header fields (RFC 2231)
- Emails are fully persistable</description>
<summary>.NET library written in C# with a full implementation of a POP3 client. Easy to use but yet powerful. Includes a robust MIME parser backed by several hundred test cases.</summary>
<releaseNotes>See the main project page (http://hpop.sourceforge.net/) for release notes.</releaseNotes>
<copyright>OpenPop.NET is Public Domain</copyright>
<language>en-US</language>
<tags>POP3 Client TCP SSL MIME Parsing email</tags>
<references>
<reference file="OpenPop.dll" />
</references>
</metadata>
</package>

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<repositories> <repositories>
<repository path="..\bsmd.dakosy.ResponseService\packages.config" />
<repository path="..\bsmd.dakosy\packages.config" /> <repository path="..\bsmd.dakosy\packages.config" />
<repository path="..\bsmd.database\packages.config" /> <repository path="..\bsmd.database\packages.config" />
<repository path="..\bsmd.dbh.ResponseService\packages.config" /> <repository path="..\bsmd.dbh.ResponseService\packages.config" />

View File

@ -716,6 +716,9 @@ public enum EdiResponseType {
/// <remarks/> /// <remarks/>
ERROR, ERROR,
/// <remarks/>
PART_ACCEPTED,
/// <remarks/> /// <remarks/>
RECEIVED, RECEIVED,
} }

View File

@ -522,6 +522,12 @@ Validierungsregel wenn im Element "MessageType" der Wert "FULL" steht: Die Namen
<xs:documentation xml:lang="DE">Die vorangehende Nachricht wurde aufgrund eines Fehlers vom System des Nachrichtensenders abgelehnt.</xs:documentation> <xs:documentation xml:lang="DE">Die vorangehende Nachricht wurde aufgrund eines Fehlers vom System des Nachrichtensenders abgelehnt.</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:enumeration> </xs:enumeration>
<xs:enumeration value="PART_ACCEPTED">
<xs:annotation>
<xs:documentation xml:lang="DE"> teilweise akzeptiert (partially accepted). Wird verwendet, wenn Meldeklassen teilweise an das NSW gesendet und akzeptiert wurden und teilweise mit Fehlermeldungen abgelehnt wurden. Details zu den abgelehnten Meldeklassen finden Sie im Element "Errors".</xs:documentation>
<xs:documentation xml:lang="EN">partially accepted: Used when notifications were partially sent to the NSW and accepted and partially rejected with error messages. Details about the rejected notifications can be found in item "Errors".</xs:documentation>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="RECEIVED"> <xs:enumeration value="RECEIVED">
<xs:annotation> <xs:annotation>
<xs:documentation xml:lang="EN">A notification about the receipt of the interchange.</xs:documentation> <xs:documentation xml:lang="EN">A notification about the receipt of the interchange.</xs:documentation>