NSW Code Work in Progress..

This commit is contained in:
Daniel Schick 2015-03-15 18:16:03 +00:00
parent bbed52967d
commit 62c97b6f4b
18 changed files with 6261 additions and 53 deletions

View File

@ -31,6 +31,7 @@ GO
ALTER TABLE MessageCore ADD [Created] [smalldatetime] NULL ALTER TABLE MessageCore ADD [Created] [smalldatetime] NULL
ALTER TABLE MessageCore ADD [Changed] [smalldatetime] NULL ALTER TABLE MessageCore ADD [Changed] [smalldatetime] NULL
ALTER TABLE [dbo].[MessageCore] ADD [InitialHIS] TINYINT NULL;
ALTER TABLE MessageHeader ADD [Created] [smalldatetime] NULL ALTER TABLE MessageHeader ADD [Created] [smalldatetime] NULL
ALTER TABLE MessageHeader ADD [Changed] [smalldatetime] NULL ALTER TABLE MessageHeader ADD [Changed] [smalldatetime] NULL

View File

@ -1,6 +1,36 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8" ?>
<configuration> <configuration>
<startup> <configSections>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
</startup> <section name="SendNSWMessageService.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,Log4net"/>
</configSections>
<log4net>
<root>
<level value="DEBUG" />
<appender-ref ref="LogFileAppender" />
</root>
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender" >
<param name="File" value="log-NSWMessageService.txt" />
<param name="AppendToFile" value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<param name="ConversionPattern" value="%date [%thread] %-5level [%logger] - %message%newline" />
</layout>
</appender>
</log4net>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<applicationSettings>
<SendNSWMessageService.Properties.Settings>
<setting name="ConnectionString" serializeAs="String">
<value>replace me!</value>
</setting>
</SendNSWMessageService.Properties.Settings>
</applicationSettings>
</configuration> </configuration>

View File

@ -28,8 +28,12 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
components = new System.ComponentModel.Container(); //
this.ServiceName = "Service1"; // NSWSendService
//
this.CanPauseAndContinue = true;
this.ServiceName = "NSWSendService";
} }
#endregion #endregion

View File

@ -4,25 +4,137 @@ using System.ComponentModel;
using System.Data; using System.Data;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.IO;
using System.ServiceProcess; using System.ServiceProcess;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Timers;
using log4net;
using bsmd.database;
using bsmd.dbh;
namespace SendNSWMessageService namespace SendNSWMessageService
{ {
public partial class NSWSendService : ServiceBase public partial class NSWSendService : ServiceBase
{ {
private Timer _timer;
private object _timerlock = new object();
private bool processRunning = false;
private ILog _log = LogManager.GetLogger(typeof(NSWSendService));
public NSWSendService() public NSWSendService()
{ {
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
InitializeComponent(); InitializeComponent();
} }
protected override void OnStart(string[] args) 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 Send Service started.", EventLogEntryType.Information);
}
public void Init(string[] args)
{
this._timer = new Timer();
this._timer.Interval = 5000; // 5 sec
this._timer.Elapsed += _timer_Elapsed;
this._timer.Enabled = true;
}
void _timer_Elapsed(object sender, ElapsedEventArgs e)
{
lock (this._timerlock)
{
if (this.processRunning) return;
else this.processRunning = true;
}
if (DBManager.Instance.Connect(Properties.Settings.Default.ConnectionString))
{
// Datenbank auf zu sendende Objekte überprüfen und laden
// "Core"-Messages sind Erst-Anmeldungen (für VISIT/TRANSIT Id) am NSW
List<MessageCore> toSendList = DBManager.Instance.GetToSendMessageCoreList();
foreach (MessageCore aMessageCore in toSendList)
{
string message = string.Format("Sending CORE message for {0} application to {1}",
aMessageCore.IsTransit ? "TRANSIT" : "VISIT", aMessageCore.InitialHIS.ToString());
_log.Info(message);
// switch über passendes HIS / Schnittstelle
switch (aMessageCore.InitialHIS)
{
case Message.NSWProvider.DBH:
//bsmd.dbh.Request.SendMessage()
break;
case Message.NSWProvider.DAKOSY:
break;
case Message.NSWProvider.DUDR:
break;
default:
break;
}
// senden
// ..
}
DBManager.Instance.Disconnect();
}
else
{
this.EventLog.WriteEntry("NSW Send Service stopped: DB connection failed", EventLogEntryType.Error);
this.Stop();
}
lock (this._timerlock)
{
this.processRunning = false;
}
}
protected override void OnPause()
{
this._timer.Stop();
}
protected override void OnContinue()
{
this._timer.Start();
} }
protected override void OnStop() protected override void OnStop()
{ {
this._timer.Enabled = false;
this.EventLog.WriteEntry("NSW Send Service stopped.", EventLogEntryType.Information);
} }
} }
} }

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

@ -1,9 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.ServiceProcess; using System.ServiceProcess;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using log4net;
namespace SendNSWMessageService namespace SendNSWMessageService
{ {
@ -13,13 +15,24 @@ namespace SendNSWMessageService
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
static void Main() static void Main()
{ {
ServiceBase[] ServicesToRun; ServiceBase[] ServicesToRun;
log4net.Config.XmlConfigurator.Configure();
ServicesToRun = new ServiceBase[] ServicesToRun = new ServiceBase[]
{ {
new NSWSendService() new NSWSendService()
}; };
ServiceBase.Run(ServicesToRun); if (Debugger.IsAttached)
{
((NSWSendService)ServicesToRun[0]).Init(null);
while (true) ;
}
else
{
ServiceBase.Run(ServicesToRun);
}
} }
} }
} }

View File

@ -0,0 +1,59 @@
namespace SendNSWMessageService
{
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.nswSendServiceProcessInstaller = new System.ServiceProcess.ServiceProcessInstaller();
this.nswSendServiceInstaller = new System.ServiceProcess.ServiceInstaller();
//
// nswSendServiceProcessInstaller
//
this.nswSendServiceProcessInstaller.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
this.nswSendServiceProcessInstaller.Password = null;
this.nswSendServiceProcessInstaller.Username = null;
//
// nswSendServiceInstaller
//
this.nswSendServiceInstaller.Description = "Sending NSW requests to HIS";
this.nswSendServiceInstaller.DisplayName = "NSW Send Service";
this.nswSendServiceInstaller.ServiceName = "NSWSendService";
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.nswSendServiceProcessInstaller,
this.nswSendServiceInstaller});
}
#endregion
private System.ServiceProcess.ServiceProcessInstaller nswSendServiceProcessInstaller;
private System.ServiceProcess.ServiceInstaller nswSendServiceInstaller;
}
}

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 SendNSWMessageService
{
[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="nswSendServiceProcessInstaller.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="nswSendServiceInstaller.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

@ -32,8 +32,13 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Management" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
@ -49,10 +54,44 @@
<DependentUpon>NSWSendService.cs</DependentUpon> <DependentUpon>NSWSendService.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">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" /> <None Include="App.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="NSWSendService.resx">
<DependentUpon>NSWSendService.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="ProjectInstaller.resx">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\bsmd.database\bsmd.database.csproj">
<Project>{19945af2-379b-46a5-b27a-303b5ec1d557}</Project>
<Name>bsmd.database</Name>
</ProjectReference>
<ProjectReference Include="..\bsmd.dbh\bsmd.dbh.csproj">
<Project>{df625ff0-2265-4686-9cb6-2a8511cb3b9d}</Project>
<Name>bsmd.dbh</Name>
</ProjectReference>
</ItemGroup> </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.

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
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")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("bsmd.dakosy")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[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("145fc80d-4894-4471-9d6c-502c72a1235a")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,59 @@
<?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>{6255F8C4-B0B5-4E77-860E-10EBCD7B368F}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>bsmd.dakosy</RootNamespace>
<AssemblyName>bsmd.dakosy</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</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.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="eDeclaration.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</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>

File diff suppressed because it is too large Load Diff

View File

@ -13,9 +13,13 @@ namespace bsmd.database
/// </summary> /// </summary>
public class Message : IDatabaseEntity public class Message : IDatabaseEntity
{ {
private Guid? id;
private Guid messageHeaderId; private Guid messageHeaderId;
private Guid? messageCoreId;
private MessageCore messageCore; private MessageCore messageCore;
private Guid? reportingPartyId;
private ReportingParty reportingParty; private ReportingParty reportingParty;
private DateTime? created;
#region Enumerations #region Enumerations
@ -39,7 +43,9 @@ namespace bsmd.database
ALL, ALL,
MESSAGETYPE, MESSAGETYPE,
REPORTINGPARTY, REPORTINGPARTY,
MESSAGEHEADER MESSAGEHEADER,
BSMDSTATUS,
WETRIS_SHIP_ID
} }
/// <summary> /// <summary>
@ -47,6 +53,7 @@ namespace bsmd.database
/// </summary> /// </summary>
public enum BSMDStatus public enum BSMDStatus
{ {
UNDEFINED,
PREPARE, PREPARE,
TOSEND, TOSEND,
SENT, SENT,
@ -61,6 +68,7 @@ namespace bsmd.database
/// </summary> /// </summary>
public enum NSWProvider public enum NSWProvider
{ {
UNDEFINED,
DBH, DBH,
DAKOSY, DAKOSY,
DUDR DUDR
@ -73,7 +81,7 @@ namespace bsmd.database
/// <summary> /// <summary>
/// Primärschlüssel /// Primärschlüssel
/// </summary> /// </summary>
public Guid MessageHeaderId { get { return this.messageHeaderId; } } public Guid? Id { get { return this.id; } }
/// <summary> /// <summary>
/// Dieser Wert wird vom NSW / HIS vergeben /// Dieser Wert wird vom NSW / HIS vergeben
@ -99,6 +107,8 @@ namespace bsmd.database
public MessageStatus? Status { get; set; } public MessageStatus? Status { get; set; }
public DateTime? Created { get { return this.created; } }
/// <summary> /// <summary>
/// Nachrichtentyp der abgeleiteten Meldeklassen /// Nachrichtentyp der abgeleiteten Meldeklassen
/// </summary> /// </summary>
@ -130,60 +140,71 @@ namespace bsmd.database
public bool IsNew public bool IsNew
{ {
get { throw new NotImplementedException(); } get { return !this.id.HasValue; }
} }
public void Save(System.Data.IDbConnection connection) public void PrepareSave(IDbCommand cmdParam)
{ {
SqlConnection sqlCon = connection as SqlConnection; SqlCommand cmd = cmdParam as SqlCommand;
if (sqlCon == null) return;
if (this.ClientRequestId != null)
cmd.Parameters.AddWithValue("@CLIENTREQUESTID", Guid.Parse(this.ClientRequestId));
else
cmd.Parameters.AddWithValue("@CLIENTREQUESTID", DBNull.Value);
cmd.Parameters.AddWithValue("@MESSAGECOREID", this.MessageCore.Id);
if (this.MessageId.HasValue)
cmd.Parameters.AddWithValue("@MESSAGEID", this.MessageId.Value);
else
cmd.Parameters.AddWithValue("@MESSAGEID", DBNull.Value);
if (this.SentAt.HasValue)
cmd.Parameters.AddWithValue("@SENTAT", this.SentAt.Value);
else
cmd.Parameters.AddWithValue("@SENTAT", DBNull.Value);
if (this.ReceivedAt.HasValue)
cmd.Parameters.AddWithValue("@RECEIVEDAT", this.ReceivedAt.Value);
else
cmd.Parameters.AddWithValue("@RECEIVEDAT", DBNull.Value);
if (this.RequestedAt.HasValue)
cmd.Parameters.AddWithValue("@REQUESTEDAT", this.RequestedAt.Value);
else
cmd.Parameters.AddWithValue("@REQUESTEDAT", DBNull.Value);
cmd.Parameters.AddWithValue("@NOTIFICATIONCLASS", (int)this.MessageNotificationClass);
cmd.Parameters.AddWithValue("@RESET", this.Reset);
cmd.Parameters.AddWithValue("@CANCEL", this.Cancel);
if (this.Status.HasValue)
cmd.Parameters.AddWithValue("@STATUS", (int)this.Status.Value);
else
cmd.Parameters.AddWithValue("@STATUS", DBNull.Value);
cmd.Parameters.AddWithValue("@REPORTINGPARTYID", this.ReportingParty.Id);
cmd.Parameters.AddWithValue("@BSMDSTATUS", this.InternalStatus);
cmd.Parameters.AddWithValue("@HIS", this.HIS);
if (this.IsNew) if (this.IsNew)
{ {
string query = "INSERT INTO MessageHeader (ClientRequestId, MessageCoreId, MessageId, SentAt, ReceivedAt, RequestedAt, NotificationClass, Reset, Cancel, Status, ReportingPartyId) " + string query = "INSERT INTO [MessageHeader] (ClientRequestId, MessageCoreId, MessageId, SentAt, ReceivedAt, RequestedAt, NotificationClass, Reset, Cancel, Status, ReportingPartyId, BSMDStatus, HIS) " +
"VALUES (@CLIENTREQUESTID, @MESSAGECOREID, @MESSAGEID, @SENTAT, @RECEIVEDAT, @REQUESTEDAT, @NOTIFICATIONCLASS, @RESET, @CANCEL, @STATUS, @REPORTINGPARTYID)"; "VALUES (@CLIENTREQUESTID, @MESSAGECOREID, @MESSAGEID, @SENTAT, @RECEIVEDAT, @REQUESTEDAT, @NOTIFICATIONCLASS, @RESET, @CANCEL, @STATUS, @REPORTINGPARTYID, @BSMDSTATUS, @HIS)";
SqlCommand cmd = new SqlCommand(query, sqlCon); cmd.CommandText = query;
if (this.ClientRequestId != null) }
cmd.Parameters.AddWithValue("@CLIENTREQUESTID", this.ClientRequestId); else
else {
cmd.Parameters.AddWithValue("@CLIENTREQUESTID", DBNull.Value); cmd.CommandText = "UPDATE [MessageHeader] SET ClientRequestId = @CLIENTREQUESTID, MessageId = @MESSAGEID, SentAt = @SENTAT, ReceivedAt = @RECEIVEDAT, RequestedAt = @REQUESTEDAT, " +
cmd.Parameters.AddWithValue("@MESSAGECOREID", this.MessageCore.Id); "NotificationClass = @NOTIFICATIONCLASS, Reset = @RESET, Cancel = @CANCEL, Status = @STATUS, ReportingPartyId = @REPORTINGPARTYID, BSMDStatus = @BSMDSTATUS, HIS = @HIS " +
if (this.MessageId.HasValue) "WHERE Id = @ID";
cmd.Parameters.AddWithValue("@MESSAGEID", this.MessageId.Value); cmd.Parameters.AddWithValue("@ID", this.messageHeaderId);
else
cmd.Parameters.AddWithValue("@MESSAGEID", DBNull.Value);
if (this.SentAt.HasValue)
cmd.Parameters.AddWithValue("@SENTAT", this.SentAt.Value);
else
cmd.Parameters.AddWithValue("@SENTAT", DBNull.Value);
if (this.ReceivedAt.HasValue)
cmd.Parameters.AddWithValue("@RECEIVEDAT", this.ReceivedAt.Value);
else
cmd.Parameters.AddWithValue("@RECEIVEDAT", DBNull.Value);
if (this.RequestedAt.HasValue)
cmd.Parameters.AddWithValue("@REQUESTEDAT", this.RequestedAt.Value);
else
cmd.Parameters.AddWithValue("@REQUESTEDAT", DBNull.Value);
cmd.Parameters.AddWithValue("@NOTIFICATIONCLASS", (int) this.MessageNotificationClass);
cmd.Parameters.AddWithValue("@RESET", this.Reset);
cmd.Parameters.AddWithValue("@CANCEL", this.Cancel);
if (this.Status.HasValue)
cmd.Parameters.AddWithValue("@STATUS", (int)this.Status.Value);
else
cmd.Parameters.AddWithValue("@STATUS", DBNull.Value);
cmd.Parameters.AddWithValue("@REPORTINGPARTYID", this.ReportingParty.Id);
} }
} }
public void Delete(System.Data.IDbConnection connection) public void PrepareDelete(IDbCommand cmdParam)
{ {
throw new NotImplementedException(); SqlCommand cmd = cmdParam as SqlCommand;
cmd.CommandText = "DELETE FROM [MessageHeader] WHERE Id = @ID";
cmd.Parameters.AddWithValue("@ID", this.messageHeaderId);
} }
public void PrepareLoadCommand(IDbCommand cmd, LoadFilter filter, params object[] criteria ) public void PrepareLoadCommand(IDbCommand cmd, LoadFilter filter, params object[] criteria )
{ {
string query = "SELECT Id, ClientRequestId, MessageCoreId, MessageId, SentAt, ReceivedAt, NotificationClass, " + string query = "SELECT Id, ClientRequestId, MessageCoreId, MessageId, SentAt, ReceivedAt, RequestedAt, NotificationClass, " +
"Reset, Cancel, Status, ReportingPartyId FROM MessageHeader "; "Reset, Cancel, Status, ReportingPartyId, BSMDStatus, HIS, Created FROM MessageHeader ";
switch (filter) switch (filter)
{ {
@ -201,6 +222,31 @@ namespace bsmd.database
cmd.CommandText = query; cmd.CommandText = query;
} }
public List<IDatabaseEntity> LoadList(IDataReader reader)
{
List<IDatabaseEntity> result = new List<IDatabaseEntity>();
while (reader.Read())
{
Message msg = new Message();
msg.id = reader.GetGuid(0);
if (!reader.IsDBNull(1)) msg.ClientRequestId = reader.GetGuid(1).ToString();
msg.messageCoreId = reader.GetGuid(2);
if(!reader.IsDBNull(3)) msg.MessageId = reader.GetGuid(3);
if (!reader.IsDBNull(4)) msg.SentAt = reader.GetDateTime(4);
if (!reader.IsDBNull(5)) msg.ReceivedAt = reader.GetDateTime(5);
if (!reader.IsDBNull(6)) msg.RequestedAt = reader.GetDateTime(6);
if (!reader.IsDBNull(7)) msg.MessageNotificationClass = (NotificationClass) Enum.ToObject(typeof(NotificationClass), reader.GetByte(7));
if (!reader.IsDBNull(8)) msg.Reset = reader.GetBoolean(8);
if (!reader.IsDBNull(9)) msg.Cancel = reader.GetBoolean(9);
if (!reader.IsDBNull(10)) msg.Status = (MessageStatus)Enum.ToObject(typeof(MessageStatus), reader.GetByte(10));
if (!reader.IsDBNull(11)) msg.reportingPartyId = reader.GetGuid(11);
if (!reader.IsDBNull(12)) msg.InternalStatus = (BSMDStatus)Enum.ToObject(typeof(BSMDStatus), reader.GetByte(12));
if (!reader.IsDBNull(13)) msg.HIS = (NSWProvider)Enum.ToObject(typeof(NSWProvider), reader.GetByte(13));
if (!reader.IsDBNull(14)) msg.created = reader.GetDateTime(14);
result.Add(msg);
}
return result;
}
#endregion #endregion

View File

@ -1,4 +1,6 @@
using System; using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -6,14 +8,18 @@ using System.Threading.Tasks;
namespace bsmd.database namespace bsmd.database
{ {
public class MessageCore public class MessageCore : IDatabaseEntity
{ {
private Guid id; private Guid id;
private Guid? previous;
private Guid? next;
private Guid? customerId;
private int? wetris_zz_56_datensatz_id;
#region Properties #region Properties
public Guid Id { get { return this.id; } } public Guid? Id { get { return this.id; } }
public string VisitId { get; set; } public string VisitId { get; set; }
@ -27,13 +33,90 @@ namespace bsmd.database
public string Portname { get; set; } public string Portname { get; set; }
public DateTime ETA { get; set; } public DateTime ETA { get; set; }
public bool IsTransit { get; set; } public bool IsTransit { get; set; }
public Message.BSMDStatus BSMDStatus { get; set; } public Message.BSMDStatus BSMDStatus { get; set; }
public Message.NSWProvider InitialHIS { get; set; }
#endregion #endregion
public bool IsNew
{
get { return !this.Id.HasValue; }
}
public void PrepareSave(IDbCommand cmd)
{
if (this.IsNew)
{
string query = "INSERT INTO [MessageCore] (VisitId, TransitId, IMO, ENI, PoC, Portname, ETA, CustomerId, " +
"Previous, Next, IsTransit, Wetris_zz_56_datensatz_id, BSMDStatus, InitialHIS) VALUES " +
"(@P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14)";
}
else
{
}
}
public void PrepareDelete(IDbCommand cmd)
{
throw new NotImplementedException();
}
public void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
{
string query = "SELECT Id, VisitId, TransitId, IMO, ENI, PoC, Portname, " +
"ETA, CustomerId, Previous, Next, IsTransit, Wetris_zz_56_datensatz_id, BSMDStatus, InitialHIS FROM [MessageCore] ";
switch (filter)
{
case Message.LoadFilter.WETRIS_SHIP_ID:
{
query += "WHERE Wetris_zz_56_datensatz_id = @WETRIS";
((SqlCommand)cmd).Parameters.AddWithValue("WETRIS", criteria[0]);
break;
}
case Message.LoadFilter.ALL:
default:
break;
}
cmd.CommandText = query;
}
public List<IDatabaseEntity> LoadList(IDataReader reader)
{
List<IDatabaseEntity> result = new List<IDatabaseEntity>();
while(reader.Read())
{
MessageCore core = new MessageCore();
core.id = reader.GetGuid(0);
if (!reader.IsDBNull(1)) core.VisitId = reader.GetString(1);
if (!reader.IsDBNull(2)) core.TransitId = reader.GetString(2);
if (!reader.IsDBNull(3)) core.IMO = reader.GetString(3);
if (!reader.IsDBNull(4)) core.ENI = reader.GetString(4);
if (!reader.IsDBNull(5)) core.PoC = reader.GetString(5);
if (!reader.IsDBNull(6)) core.Portname = reader.GetString(6);
if (!reader.IsDBNull(7)) core.ETA = reader.GetDateTime(7);
if (!reader.IsDBNull(8)) core.customerId = reader.GetGuid(8);
if (!reader.IsDBNull(9)) core.previous = reader.GetGuid(9);
if (!reader.IsDBNull(10)) core.next = reader.GetGuid(10);
core.IsTransit = reader.GetBoolean(11);
if (!reader.IsDBNull(12)) core.wetris_zz_56_datensatz_id = reader.GetInt32(12);
core.BSMDStatus = (Message.BSMDStatus) Enum.ToObject(typeof(Message.BSMDStatus), reader.GetByte(13));
core.InitialHIS = (Message.NSWProvider) Enum.ToObject(typeof(Message.NSWProvider), reader.GetByte(14));
result.Add(core);
}
reader.Close();
return result;
}
} }
} }

View File

@ -30,6 +30,9 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
@ -42,6 +45,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="DBManager.cs" />
<Compile Include="IDatabaseEntity.cs" /> <Compile Include="IDatabaseEntity.cs" />
<Compile Include="Message.cs" /> <Compile Include="Message.cs" />
<Compile Include="MessageCore.cs" /> <Compile Include="MessageCore.cs" />
@ -50,6 +54,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.Config" /> <None Include="App.Config" />
<None Include="packages.config" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" /> <Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />

View File

@ -30,6 +30,9 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
@ -51,6 +54,9 @@
<Name>bsmd.database</Name> <Name>bsmd.database</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</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.