diff --git a/REDIRECT.txt b/REDIRECT.txt
new file mode 100644
index 00000000..b8d56360
--- /dev/null
+++ b/REDIRECT.txt
@@ -0,0 +1,33 @@
+Der einzige von außen erreichbare Server ist der Wetris Server (Domain u.a. www.schiffsmelder.de).
+Um die Konfig möglichst nicht zu ändern, habe ich eine Umleitung eingerichtet.
+Zunächst mit HTTP redirect, was aber den Nachteil hat, dass die neu vergebene URL nach aussen sichtbar wird.
+
+Daher habe ich am 6.4.15 das Application Routing Redirect (ARR) auf dem Server installiert.
+Damit kann man ein sog. URL rewrite machen, so dass der Zugriff auf das Unterverzeichnis
+http://www.schiffsmelder.de/nswservice/ direkt auf die URL http://smnsw01.bsmd.local/
+gemappt wird, und zwar ohne dass der Anwender von aussen das sieht.
+
+Dazu wählt man das Unterverzeichnis in den IIS Einstellungen und klickt "URL Rewrite".
+Rechtsklick und dann im unteren Bereich "Eingehende und ausgehende Regeln" Reverseproxy wählen.
+Das klappt nur wenn man das ARR vorher installiert hat!
+
+Dann muss man lediglich oben den Server angeben und alles wird gut.
+
+
+
+URL Rewrite KnowHow:
+
+Im Proxy und backend web.config müssen folgende Einträge stehen, sonst tut es nicht:
+
+
+
+
+
+
+Global rewrite rules are used to define server-wide URL rewriting logic. These rules are defined within applicationHost.config file and they cannot be overridden or disabled on any lower configuration levels, such as site or virtual directory. Global rules always operate on the absolute URL path (that is, requested URI without the server name). For example if a request was made to http://localhost/directory1/directory2/index.html, then the URL rewrite module will pass “directory1/directory2/index.html” as an input to a global rule.
+
+Distributed rewrite rules are used to define URL rewriting logic specific to a particular configuration scope. Distributed rules can be defined on any configuration level (except file) by using web.config files. Local rules always operate on URLs relative to the location of Web.config file where they are defined. For example if a request was made to http://localhost/directory1/directory2/index.html and a rewrite rule was defined in Web.config file located in directory1, then the URL rewrite module will pass “directory2/index.html” as an input to that rule.
+
+Global rule set is always evaluated first, and after that distributed rule set will be evaluated by using a URL string produced by global rule set.
+
+http://www.iis.net/learn/extensions/url-rewrite-module/using-global-and-distributed-rewrite-rules
\ No newline at end of file
diff --git a/Stundensheet.xlsx b/Stundensheet.xlsx
index b6e40248..ea4af98a 100644
Binary files a/Stundensheet.xlsx and b/Stundensheet.xlsx differ
diff --git a/nsw/Source/SQL/Update_1.1_To_1.2.sql b/nsw/Source/SQL/Update_1.1_To_1.2.sql
new file mode 100644
index 00000000..e69330f0
--- /dev/null
+++ b/nsw/Source/SQL/Update_1.1_To_1.2.sql
@@ -0,0 +1,7 @@
+GO
+ALTER TABLE [dbo].[MessageCore]
+ ADD [HerbergFormGuid] UNIQUEIDENTIFIER NULL,
+ [HerbergFormTemplateGuid] UNIQUEIDENTIFIER NULL;
+
+
+GO
\ No newline at end of file
diff --git a/nsw/Source/SendNSWMessageService/App.config b/nsw/Source/SendNSWMessageService/App.config
index 9efbbd47..25181ad4 100644
--- a/nsw/Source/SendNSWMessageService/App.config
+++ b/nsw/Source/SendNSWMessageService/App.config
@@ -29,7 +29,7 @@
- replace me!
+ Data Source=(localdb)\Projects;Initial Catalog=nsw;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False
diff --git a/nsw/Source/SendNSWMessageService/NSWSendService.cs b/nsw/Source/SendNSWMessageService/NSWSendService.cs
index 35cbe981..e1d93a11 100644
--- a/nsw/Source/SendNSWMessageService/NSWSendService.cs
+++ b/nsw/Source/SendNSWMessageService/NSWSendService.cs
@@ -48,10 +48,10 @@ namespace SendNSWMessageService
public void Init(string[] args)
{
this._timer = new Timer();
- this._timer.Interval = 5000; // 5 sec
+ this._timer.Interval = 60000; // 1 min
this._timer.Elapsed += _timer_Elapsed;
this._timer.Enabled = true;
-
+ _timer_Elapsed(null, null);
}
void _timer_Elapsed(object sender, ElapsedEventArgs e)
@@ -67,21 +67,21 @@ namespace SendNSWMessageService
// Datenbank auf zu sendende Objekte überprüfen und laden
- List messagesToSendList = DBManager.Instance.GetToSendMessageList();
+ List messagesToSendList = DBManager.Instance.GetToSendMessageList();
- foreach (Message message in messagesToSendList)
+ foreach (DatabaseEntity entity in messagesToSendList)
{
try
{
_log.InfoFormat("Sending CORE message for {0} application to {1}",
- message.MessageCore.IsTransit ? "TRANSIT" : "VISIT", message.MessageCore.InitialHIS.ToString());
-
+ entity.MessageCore.IsTransit ? "TRANSIT" : "VISIT", entity.MessageCore.InitialHIS.ToString());
+
bool sendSucceeded = false;
// switch über passendes HIS / Schnittstelle
- switch (message.MessageCore.InitialHIS)
+ switch (entity.MessageCore.InitialHIS)
{
case Message.NSWProvider.DBH:
- sendSucceeded = bsmd.dbh.Request.SendMessage(message);
+ sendSucceeded = bsmd.dbh.Request.SendMessage(entity);
break;
case Message.NSWProvider.DAKOSY:
_log.Warn("Cannot send via DAKOSY yet");
@@ -91,20 +91,20 @@ namespace SendNSWMessageService
_log.Warn("Cannot send via Daten und Dienste HRO yet");
break;
default:
- _log.WarnFormat("Initial HIS not specified for message {0}", message.Id);
+ _log.WarnFormat("Initial HIS not specified for message {0}", entity.Id);
break;
}
if (sendSucceeded)
{
- message.InternalStatus = Message.BSMDStatus.SENT;
- DBManager.Instance.Save(message);
+ entity.InternalStatus = Message.BSMDStatus.SENT;
+ DBManager.Instance.Save(entity);
}
}
catch (Exception ex)
{
- _log.ErrorFormat("SENDING message {0}: {1}", message.ToString(), ex.Message);
+ _log.ErrorFormat("SENDING message {0}: {1}", entity.Id.ToString(), ex.Message);
}
}
diff --git a/nsw/Source/SendNSWMessageService/Properties/Settings.Designer.cs b/nsw/Source/SendNSWMessageService/Properties/Settings.Designer.cs
new file mode 100644
index 00000000..2a491cb0
--- /dev/null
+++ b/nsw/Source/SendNSWMessageService/Properties/Settings.Designer.cs
@@ -0,0 +1,35 @@
+//------------------------------------------------------------------------------
+//
+// 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.
+//
+//------------------------------------------------------------------------------
+
+namespace SendNSWMessageService.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.ApplicationScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("replace me!")]
+ public string ConnectionString {
+ get {
+ return ((string)(this["ConnectionString"]));
+ }
+ }
+ }
+}
diff --git a/nsw/Source/SendNSWMessageService/Properties/Settings.settings b/nsw/Source/SendNSWMessageService/Properties/Settings.settings
new file mode 100644
index 00000000..e742b0a3
--- /dev/null
+++ b/nsw/Source/SendNSWMessageService/Properties/Settings.settings
@@ -0,0 +1,9 @@
+
+
+
+
+
+ replace me!
+
+
+
\ No newline at end of file
diff --git a/nsw/Source/bsmd.EMailReceiveService.sln b/nsw/Source/bsmd.EMailReceiveService.sln
new file mode 100644
index 00000000..0baa26f5
--- /dev/null
+++ b/nsw/Source/bsmd.EMailReceiveService.sln
@@ -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.EMailReceiveService", "bsmd.EMailReceiveService\bsmd.EMailReceiveService.csproj", "{6D46F847-24F2-4883-8B0E-21386FFD0C96}"
+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.dbh", "bsmd.dbh\bsmd.dbh.csproj", "{DF625FF0-2265-4686-9CB6-2A8511CB3B9D}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {6D46F847-24F2-4883-8B0E-21386FFD0C96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6D46F847-24F2-4883-8B0E-21386FFD0C96}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6D46F847-24F2-4883-8B0E-21386FFD0C96}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6D46F847-24F2-4883-8B0E-21386FFD0C96}.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
+ {DF625FF0-2265-4686-9CB6-2A8511CB3B9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DF625FF0-2265-4686-9CB6-2A8511CB3B9D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DF625FF0-2265-4686-9CB6-2A8511CB3B9D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DF625FF0-2265-4686-9CB6-2A8511CB3B9D}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/nsw/Source/bsmd.EMailReceiveService/App.config b/nsw/Source/bsmd.EMailReceiveService/App.config
new file mode 100644
index 00000000..edfcd46f
--- /dev/null
+++ b/nsw/Source/bsmd.EMailReceiveService/App.config
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ replace me!
+
+
+ replace me!
+
+
+ replace me!
+
+
+ replace me!
+
+
+ 995
+
+
+
+
\ No newline at end of file
diff --git a/nsw/Source/bsmd.EMailReceiveService/EmailReceiveService.Designer.cs b/nsw/Source/bsmd.EMailReceiveService/EmailReceiveService.Designer.cs
new file mode 100644
index 00000000..1f6bc51d
--- /dev/null
+++ b/nsw/Source/bsmd.EMailReceiveService/EmailReceiveService.Designer.cs
@@ -0,0 +1,37 @@
+namespace bsmd.EMailReceiveService
+{
+ partial class EmailReceiveService
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ components = new System.ComponentModel.Container();
+ this.ServiceName = "Service1";
+ }
+
+ #endregion
+ }
+}
diff --git a/nsw/Source/bsmd.EMailReceiveService/EmailReceiveService.cs b/nsw/Source/bsmd.EMailReceiveService/EmailReceiveService.cs
new file mode 100644
index 00000000..afe55036
--- /dev/null
+++ b/nsw/Source/bsmd.EMailReceiveService/EmailReceiveService.cs
@@ -0,0 +1,151 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Diagnostics;
+using System.Linq;
+using System.IO;
+using System.ServiceProcess;
+using System.Text;
+using System.Timers;
+using System.Threading.Tasks;
+
+using OpenPop;
+using log4net;
+using bsmd.database;
+
+namespace bsmd.EMailReceiveService
+{
+
+ ///
+ /// Simpler Windows-Service zum Abruf von NSW Antworten via E-mail. Ich verwende OpenPop.NET Library (via NuGet)
+ /// http://hpop.sourceforge.net/
+ ///
+ ///
+ public partial class EmailReceiveService : ServiceBase
+ {
+
+ private Timer _timer;
+ private object _timerlock = new object();
+ private bool processRunning = false;
+ private ILog _log = LogManager.GetLogger(typeof(EmailReceiveService));
+
+ public EmailReceiveService()
+ {
+ 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 Send Service started.", EventLogEntryType.Information);
+ }
+
+ protected override void OnStop()
+ {
+ }
+
+ 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;
+ }
+
+ if (DBManager.Instance.Connect(Properties.Settings.Default.ConnectionString))
+ {
+ try
+ {
+
+ // dbh E-Mail aus Postfach abrufen
+ using (OpenPop.Pop3.Pop3Client client = new OpenPop.Pop3.Pop3Client())
+ {
+ client.Connect(Properties.Settings.Default.Host, Properties.Settings.Default.Port, true);
+ client.Authenticate(Properties.Settings.Default.User, Properties.Settings.Default.Password);
+
+ int messageNum = client.GetMessageCount();
+ _log.DebugFormat("Mail Server has {0} messages", messageNum);
+
+ if (messageNum > 0)
+ {
+ // We want to download all messages
+ List allMessages = new List(messageNum);
+
+ // Messages are numbered in the interval: [1, messageCount]
+ // Ergo: message numbers are 1-based.
+ // Most servers give the latest message the highest number
+ for (int i = 1; i <= messageNum; i++)
+ {
+ allMessages.Add(client.GetMessage(i));
+ }
+
+ for (int i = 0; i < allMessages.Count; i++)
+ {
+ // XML Anhang extrahieren und in einen string schreiben
+ OpenPop.Mime.Message message = allMessages[i];
+
+ List messageParts = message.FindAllAttachments();
+ for (int partIndex = 0; partIndex < messageParts.Count; partIndex++)
+ {
+ OpenPop.Mime.MessagePart part = messageParts[partIndex];
+ _log.DebugFormat("{0} Encoding: {1}", partIndex, part.ContentTransferEncoding);
+
+ switch (part.ContentTransferEncoding)
+ {
+ case OpenPop.Mime.Header.ContentTransferEncoding.Base64:
+ // decode base64 body
+
+ break;
+ default:
+ break;
+ }
+
+ }
+
+
+ // E-Mail entfernen
+
+ // client.DeleteMessage(i+1);
+ }
+ }
+ }
+ }
+ 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;
+ }
+ }
+ }
+}
diff --git a/nsw/Source/bsmd.EMailReceiveService/Program.cs b/nsw/Source/bsmd.EMailReceiveService/Program.cs
new file mode 100644
index 00000000..5f2ed440
--- /dev/null
+++ b/nsw/Source/bsmd.EMailReceiveService/Program.cs
@@ -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.EMailReceiveService
+{
+ static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ static void Main()
+ {
+ ServiceBase[] ServicesToRun;
+ ServicesToRun = new ServiceBase[]
+ {
+ new EmailReceiveService()
+ };
+
+ if (Debugger.IsAttached)
+ {
+ ((EmailReceiveService)ServicesToRun[0]).Init(null);
+ while (true) ;
+ }
+ else
+ {
+ ServiceBase.Run(ServicesToRun);
+ }
+ }
+ }
+}
diff --git a/nsw/Source/bsmd.EMailReceiveService/Properties/AssemblyInfo.cs b/nsw/Source/bsmd.EMailReceiveService/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..e4ed6cad
--- /dev/null
+++ b/nsw/Source/bsmd.EMailReceiveService/Properties/AssemblyInfo.cs
@@ -0,0 +1,18 @@
+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.EMailReceiveService")]
+[assembly: AssemblyDescription("E-Mail checker for NSW response messages sent by mail")]
+[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("03d0b447-a06c-46ad-b888-94501a6ea618")]
\ No newline at end of file
diff --git a/nsw/Source/bsmd.EMailReceiveService/Properties/Settings.Designer.cs b/nsw/Source/bsmd.EMailReceiveService/Properties/Settings.Designer.cs
new file mode 100644
index 00000000..abd44164
--- /dev/null
+++ b/nsw/Source/bsmd.EMailReceiveService/Properties/Settings.Designer.cs
@@ -0,0 +1,86 @@
+//------------------------------------------------------------------------------
+//
+// 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.
+//
+//------------------------------------------------------------------------------
+
+namespace bsmd.EMailReceiveService.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;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("replace me!")]
+ public string User {
+ get {
+ return ((string)(this["User"]));
+ }
+ set {
+ this["User"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("replace me!")]
+ public string Host {
+ get {
+ return ((string)(this["Host"]));
+ }
+ set {
+ this["Host"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("replace me!")]
+ public string Password {
+ get {
+ return ((string)(this["Password"]));
+ }
+ set {
+ this["Password"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("995")]
+ public int Port {
+ get {
+ return ((int)(this["Port"]));
+ }
+ set {
+ this["Port"] = value;
+ }
+ }
+ }
+}
diff --git a/nsw/Source/bsmd.EMailReceiveService/Properties/Settings.settings b/nsw/Source/bsmd.EMailReceiveService/Properties/Settings.settings
new file mode 100644
index 00000000..aa60a589
--- /dev/null
+++ b/nsw/Source/bsmd.EMailReceiveService/Properties/Settings.settings
@@ -0,0 +1,21 @@
+
+
+
+
+
+ replace me!
+
+
+ replace me!
+
+
+ replace me!
+
+
+ replace me!
+
+
+ 995
+
+
+
\ No newline at end of file
diff --git a/nsw/Source/bsmd.EMailReceiveService/bsmd.EMailReceiveService.csproj b/nsw/Source/bsmd.EMailReceiveService/bsmd.EMailReceiveService.csproj
new file mode 100644
index 00000000..4ac9fbb3
--- /dev/null
+++ b/nsw/Source/bsmd.EMailReceiveService/bsmd.EMailReceiveService.csproj
@@ -0,0 +1,103 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {6D46F847-24F2-4883-8B0E-21386FFD0C96}
+ WinExe
+ Properties
+ bsmd.EMailReceiveService
+ bsmd.EMailReceiveService
+ v4.5
+ 512
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ packages\log4net.2.0.3\lib\net40-full\log4net.dll
+
+
+ packages\OpenPop.NET.2.0.6.1102\lib\net40\OpenPop.dll
+
+
+
+
+
+
+
+
+
+
+
+
+ Properties\AssemblyProductInfo.cs
+
+
+ Properties\AssemblyProjectInfo.cs
+
+
+ Properties\AssemblyProjectKeyInfo.cs
+
+
+ Component
+
+
+ EmailReceiveService.cs
+
+
+
+
+ True
+ True
+ Settings.settings
+
+
+
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+ {19945af2-379b-46a5-b27a-303b5ec1d557}
+ bsmd.database
+
+
+ {df625ff0-2265-4686-9cb6-2a8511cb3b9d}
+ bsmd.dbh
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/nsw/Source/bsmd.EMailReceiveService/packages.config b/nsw/Source/bsmd.EMailReceiveService/packages.config
new file mode 100644
index 00000000..d9f96dd1
--- /dev/null
+++ b/nsw/Source/bsmd.EMailReceiveService/packages.config
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/nsw/Source/bsmd.EMailReceiveService/readme.txt b/nsw/Source/bsmd.EMailReceiveService/readme.txt
new file mode 100644
index 00000000..f3555084
--- /dev/null
+++ b/nsw/Source/bsmd.EMailReceiveService/readme.txt
@@ -0,0 +1,11 @@
+DB Connection string lokal:
+Data Source=(localdb)\Projects;Initial Catalog=nsw;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False
+
+Testaccount:
+
+nsw@textbausteine.net
+
+Passwort: 3kjksJSD343
+Server: pop3.strato.de
+
+Port: 995
diff --git a/nsw/Source/bsmd.database/DBManager.cs b/nsw/Source/bsmd.database/DBManager.cs
index 92fc2fb2..a0db0bf5 100644
--- a/nsw/Source/bsmd.database/DBManager.cs
+++ b/nsw/Source/bsmd.database/DBManager.cs
@@ -79,7 +79,22 @@ namespace bsmd.database
return result;
}
- public List GetToSendMessageList()
+ public MessageCore GetHerbergFormMessage(Guid herbergFormGuid)
+ {
+ MessageCore aMessageCore = new MessageCore();
+ SqlCommand cmd = new SqlCommand();
+ aMessageCore.PrepareLoadCommand(cmd, Message.LoadFilter.HERBERG_FORMGUID, herbergFormGuid);
+
+ SqlDataReader reader = this.PerformCommand(cmd);
+ List cores = aMessageCore.LoadList(reader);
+ if (cores.Count > 1) _log.WarnFormat("Herberg form message: {0} cores found for guid {1}",
+ cores.Count, herbergFormGuid);
+ if(cores.Count > 0)
+ return (MessageCore) cores[0];
+ return null;
+ }
+
+ public List GetToSendMessageList()
{
Message aMessage = new Message();
SqlCommand cmd = new SqlCommand();
@@ -88,11 +103,12 @@ namespace bsmd.database
SqlDataReader reader = this.PerformCommand(cmd);
List messages = aMessage.LoadList(reader);
- List result = new List();
- foreach (Message message in messages)
- result.Add(message);
- this.LoadMessageDependencies(result);
+ List messageList = new List();
+ foreach (Message message in messages)
+ messageList.Add(message);
+
+ List result = this.LoadMessageDependencies(messageList);
return result;
}
@@ -112,32 +128,44 @@ namespace bsmd.database
return result;
}
- public void Save(Message message)
+ public void Save(DatabaseEntity entity)
{
SqlCommand cmd = new SqlCommand();
- message.PrepareSave(cmd);
+ entity.PrepareSave(cmd);
int queryResult = this.PerformNonQuery(cmd);
switch(queryResult)
{
case 1:
- _log.InfoFormat("Message {0} saved", message.Id); break;
+ _log.InfoFormat("Message {0} saved", entity.Id); break;
case 0:
- _log.WarnFormat("Message {0} save affected no rows", message.Id); break;
+ _log.WarnFormat("Message {0} save affected no rows", entity.Id); break;
case -1:
- _log.WarnFormat("Message {0} save: error occurred", message.Id); break;
+ _log.WarnFormat("Message {0} save: error occurred", entity.Id); break;
default:
- _log.WarnFormat("Message {0} save affected {1} rows", message.Id, queryResult); break;
+ _log.WarnFormat("Message {0} save affected {1} rows", entity.Id, queryResult); break;
}
}
+ public void Save(MessageCore core)
+ {
+ SqlCommand cmd = new SqlCommand();
+ core.PrepareSave(cmd);
+ int queryResult = this.PerformNonQuery(cmd);
+ if (queryResult == 1)
+ _log.InfoFormat("MessageCore {0} saved", core.Id);
+ else
+ _log.WarnFormat("MessageCore {0} save affected {1} rows", core.Id, queryResult);
+ }
+
#endregion
#region internal/private funcs
- internal void LoadMessageDependencies(List messageList)
+ internal List LoadMessageDependencies(List messageList)
{
Dictionary messageCoreDict = this.GetToSendMessageCoreList();
Dictionary reportingPartyDict = this.GetReportingPartyDict();
+ List result = new List();
// Zuordnung MessageCore,Zuordnung Reporting party
Message.AssignReportingParties(messageList, reportingPartyDict);
@@ -159,15 +187,17 @@ namespace bsmd.database
List statList = msgClass.LoadList(reader);
if (statList.Count > 0) message.DerivedMessage = statList[0];
((IMessageClass)msgClass).MessageHeader = message;
+ this.LoadDependingLists(msgClass);
+ result.Add(msgClass);
}
else
{
_log.ErrorFormat("cannot create a message class for notification type {0}", message.MessageNotificationClass);
- }
-
- this.LoadDependingLists(message);
-
+ result.Add(message);
+ }
}
+
+ return result;
}
#region CreateMessage()
@@ -206,9 +236,10 @@ namespace bsmd.database
case Message.NotificationClass.HAZA:
case Message.NotificationClass.HAZD:
- default:
_log.WarnFormat("CreateMessage: message type {0} is not supported", notificationClass.ToString());
break;
+ default:
+ break; // VISIT, TRANSIT
}
return result;
}
diff --git a/nsw/Source/bsmd.database/DatabaseEntity.cs b/nsw/Source/bsmd.database/DatabaseEntity.cs
index ced5ec69..6c01c088 100644
--- a/nsw/Source/bsmd.database/DatabaseEntity.cs
+++ b/nsw/Source/bsmd.database/DatabaseEntity.cs
@@ -17,10 +17,24 @@ namespace bsmd.database
public abstract class DatabaseEntity
{
- protected Guid? id;
-
+ protected Guid? id;
protected string tablename;
+ ///
+ /// Nachrichtentyp der abgeleiteten Meldeklassen
+ ///
+ public Message.NotificationClass MessageNotificationClass { get; set; }
+
+ ///
+ /// Referenz zur eigentlichen Schiffankunft
+ ///
+ public MessageCore MessageCore { get; set; }
+
+ ///
+ /// Status für Services
+ ///
+ public Message.BSMDStatus InternalStatus { get; set; }
+
///
/// SQL Table name to construct queries
///
diff --git a/nsw/Source/bsmd.database/IMessageClass.cs b/nsw/Source/bsmd.database/IMessageClass.cs
index ab1b13cb..0843ba7e 100644
--- a/nsw/Source/bsmd.database/IMessageClass.cs
+++ b/nsw/Source/bsmd.database/IMessageClass.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace bsmd.database
{
- interface IMessageClass
+ public interface IMessageClass
{
Message MessageHeader { get; set; }
}
diff --git a/nsw/Source/bsmd.database/Message.cs b/nsw/Source/bsmd.database/Message.cs
index cce40054..b3ec4366 100644
--- a/nsw/Source/bsmd.database/Message.cs
+++ b/nsw/Source/bsmd.database/Message.cs
@@ -14,8 +14,7 @@ namespace bsmd.database
public class Message : DatabaseEntity
{
private Guid messageHeaderId;
- private Guid? messageCoreId;
- private MessageCore messageCore;
+ private Guid? messageCoreId;
private Guid? reportingPartyId;
private ReportingParty reportingParty;
private DateTime? created;
@@ -52,7 +51,8 @@ namespace bsmd.database
WAS_ID,
WDSP_ID,
BPOL_ID,
- SEC_ID
+ SEC_ID,
+ HERBERG_FORMGUID
}
///
@@ -93,12 +93,7 @@ namespace bsmd.database
///
/// Dieser Wert wird vom NSW / HIS vergeben
///
- public string ClientRequestId { set; get; }
-
- ///
- /// Referenz zur eigentlichen Schiffankunft
- ///
- public MessageCore MessageCore { get { return this.messageCore; } }
+ public string ClientRequestId { set; get; }
public Guid? MessageId { get; set; }
@@ -114,22 +109,12 @@ namespace bsmd.database
public MessageStatus? Status { get; set; }
- public DateTime? Created { get { return this.created; } }
-
- ///
- /// Nachrichtentyp der abgeleiteten Meldeklassen
- ///
- public NotificationClass MessageNotificationClass { get; set; }
+ public DateTime? Created { get { return this.created; } }
///
/// Der Meldende
///
- public ReportingParty ReportingParty { get { return this.reportingParty; } }
-
- ///
- /// Status für Services
- ///
- public BSMDStatus InternalStatus { get; set; }
+ public ReportingParty ReportingParty { get { return this.reportingParty; } }
///
/// die zur Kommunikation zu verwendende HIS Schnittstelle
@@ -153,7 +138,7 @@ namespace bsmd.database
#endregion
- #region IDatabaseEntity implementation
+ #region IDatabaseEntity implementation
public override void PrepareSave(IDbCommand cmdParam)
{
@@ -280,7 +265,7 @@ namespace bsmd.database
foreach (Message message in messages)
{
if (message.messageCoreId.HasValue && messageCores.ContainsKey(message.messageCoreId.Value))
- message.messageCore = messageCores[message.messageCoreId.Value];
+ message.MessageCore = messageCores[message.messageCoreId.Value];
}
}
diff --git a/nsw/Source/bsmd.database/MessageCore.cs b/nsw/Source/bsmd.database/MessageCore.cs
index 1d250d31..04b27080 100644
--- a/nsw/Source/bsmd.database/MessageCore.cs
+++ b/nsw/Source/bsmd.database/MessageCore.cs
@@ -21,7 +21,7 @@ namespace bsmd.database
this.tablename = "[dbo].[MessageCore]";
}
- #region Properties
+ #region Properties
public string VisitId { get; set; }
@@ -43,6 +43,10 @@ namespace bsmd.database
public Message.NSWProvider InitialHIS { get; set; }
+ public Guid? HerbergFormGuid { get; set; }
+
+ public Guid? HerbergFormTemplateGuid { get; set; }
+
#endregion
public override void PrepareSave(IDbCommand cmd)
@@ -74,12 +78,16 @@ namespace bsmd.database
else scmd.Parameters.AddWithValue("@P12", DBNull.Value);
scmd.Parameters.AddWithValue("@P13", this.BSMDStatus);
scmd.Parameters.AddWithValue("@P14", this.InitialHIS);
+ scmd.Parameters.AddWithNullableValue("@P15", this.HerbergFormGuid);
+ scmd.Parameters.AddWithNullableValue("@P16", this.HerbergFormTemplateGuid);
if (this.IsNew)
{
string query = string.Format("INSERT INTO {0} (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)", this.Tablename);
+ "Previous, Next, IsTransit, Wetris_zz_56_datensatz_id, BSMDStatus, InitialHIS, HerbergFormGuid, " +
+ "HerbergFormTemplateGuid) VALUES " +
+ "(@P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, @P15, @P16)",
+ this.Tablename);
scmd.CommandText = query;
}
else
@@ -87,7 +95,8 @@ namespace bsmd.database
scmd.Parameters.AddWithValue("@ID", this.Id);
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, " +
- "Wetris_zz_56_datensatz_id = @P12, BSMDStatus = @P13, InitialHIS = @P14 WHERE Id = @ID", this.Tablename);
+ "Wetris_zz_56_datensatz_id = @P12, BSMDStatus = @P13, InitialHIS = @P14, HerbergFormGuid = @P15, " +
+ "HerbergFormTemplateGuid = @P16 WHERE Id = @ID", this.Tablename);
}
}
@@ -95,7 +104,8 @@ namespace bsmd.database
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
{
string query = string.Format("SELECT Id, VisitId, TransitId, IMO, ENI, PoC, Portname, " +
- "ETA, CustomerId, Previous, Next, IsTransit, Wetris_zz_56_datensatz_id, BSMDStatus, InitialHIS FROM {0} ",
+ "ETA, CustomerId, Previous, Next, IsTransit, Wetris_zz_56_datensatz_id, BSMDStatus, InitialHIS, " +
+ "HerbergFormGuid, HerbergFormTemplateGuid FROM {0} ",
this.Tablename);
switch (filter)
@@ -103,7 +113,13 @@ namespace bsmd.database
case Message.LoadFilter.WETRIS_SHIP_ID:
{
query += "WHERE Wetris_zz_56_datensatz_id = @WETRIS";
- ((SqlCommand)cmd).Parameters.AddWithValue("WETRIS", criteria[0]);
+ ((SqlCommand)cmd).Parameters.AddWithValue("@WETRIS", criteria[0]);
+ break;
+ }
+ case Message.LoadFilter.HERBERG_FORMGUID:
+ {
+ query += "WHERE HerbergFormGuid = @HFG";
+ ((SqlCommand)cmd).Parameters.AddWithValue("@HFG", criteria[0]);
break;
}
case Message.LoadFilter.ALL:
@@ -135,6 +151,8 @@ namespace bsmd.database
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));
+ if (!reader.IsDBNull(15)) core.HerbergFormGuid = reader.GetGuid(15);
+ if (!reader.IsDBNull(16)) core.HerbergFormTemplateGuid = reader.GetGuid(16);
result.Add(core);
}
diff --git a/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs b/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs
index b9c7b103..f4676181 100644
--- a/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs
+++ b/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs
@@ -1,7 +1,7 @@
using System.Reflection;
[assembly: AssemblyCompany("Informatikbüro Daniel Schick")]
-[assembly: AssemblyProduct("bsmd.database")]
-[assembly: AssemblyInformationalVersion("1.0.1")]
+[assembly: AssemblyProduct("BSMD NSW interface")]
+[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyCopyright("Copyright © 2014-2015 Informatikbüro Daniel Schick. All rights reserved.")]
[assembly: AssemblyTrademark("")]
\ No newline at end of file
diff --git a/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs b/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs
index c0768bed..63664c9c 100644
--- a/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs
+++ b/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs
@@ -4,6 +4,6 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.1.*")]
+[assembly: AssemblyVersion("1.0.2.*")]
// wenn das nicht auskommentiert wird erhalten wir eine Warnung
// [assembly: AssemblyFileVersion("1.0.0.*")]
diff --git a/nsw/Source/bsmd.database/bsmd.database.csproj b/nsw/Source/bsmd.database/bsmd.database.csproj
index 9cdabfe6..da42866e 100644
--- a/nsw/Source/bsmd.database/bsmd.database.csproj
+++ b/nsw/Source/bsmd.database/bsmd.database.csproj
@@ -96,7 +96,6 @@
-
diff --git a/nsw/Source/bsmd.dbh.ResponseService.v12.suo b/nsw/Source/bsmd.dbh.ResponseService.v12.suo
index 44ba1f92..bdb60852 100644
Binary files a/nsw/Source/bsmd.dbh.ResponseService.v12.suo and b/nsw/Source/bsmd.dbh.ResponseService.v12.suo differ
diff --git a/nsw/Source/bsmd.dbh.ResponseService/IResponseService.cs b/nsw/Source/bsmd.dbh.ResponseService/IResponseService.cs
index 7a9f7f77..9c5bafb2 100644
--- a/nsw/Source/bsmd.dbh.ResponseService/IResponseService.cs
+++ b/nsw/Source/bsmd.dbh.ResponseService/IResponseService.cs
@@ -12,38 +12,19 @@ namespace bsmd.dbh.ResponseService
[ServiceContract]
public interface IResponseService
{
-
+ /*
[OperationContract]
string GetData(int value);
+ */
+
///
/// Da die Schnittstelle nur mit einem .xsd definiert war ist die Signatur der Methode fraglich
/// Sicher ist Void, weniger sicher der Namen und der Name des Parameters. Dessen Type allerdings schon.
///
[OperationContract]
+ [XmlSerializerFormatAttribute()]
void NSWResponse(bsmd.dbh.response.Root root);
}
-
- // Use a data contract as illustrated in the sample below to add composite types to service operations.
- [DataContract]
- public class CompositeType
- {
- bool boolValue = true;
- string stringValue = "Hello ";
-
- [DataMember]
- public bool BoolValue
- {
- get { return boolValue; }
- set { boolValue = value; }
- }
-
- [DataMember]
- public string StringValue
- {
- get { return stringValue; }
- set { stringValue = value; }
- }
- }
}
diff --git a/nsw/Source/bsmd.dbh.ResponseService/Properties/AssemblyInfo.cs b/nsw/Source/bsmd.dbh.ResponseService/Properties/AssemblyInfo.cs
index 918ac936..4ab01a4a 100644
--- a/nsw/Source/bsmd.dbh.ResponseService/Properties/AssemblyInfo.cs
+++ b/nsw/Source/bsmd.dbh.ResponseService/Properties/AssemblyInfo.cs
@@ -6,14 +6,9 @@ using System.Runtime.InteropServices;
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("bsmd.dbh.ResponseService")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("bsmd.dbh.ResponseService")]
-[assembly: AssemblyCopyright("Copyright © 2015")]
-[assembly: AssemblyTrademark("")]
+[assembly: AssemblyDescription("Webservice zum Empfang der NSW Response Nachrichten von dbh")]
[assembly: AssemblyCulture("")]
-
+[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", Watch = true)]
// 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.
@@ -22,15 +17,3 @@ using System.Runtime.InteropServices;
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f9d61dd1-3f43-4c8b-83b1-b778d28a5367")]
-// 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 Revision and Build Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/nsw/Source/bsmd.dbh.ResponseService/ResponseService.svc b/nsw/Source/bsmd.dbh.ResponseService/ResponseService.svc
index 1d8674d0..6cd9a438 100644
--- a/nsw/Source/bsmd.dbh.ResponseService/ResponseService.svc
+++ b/nsw/Source/bsmd.dbh.ResponseService/ResponseService.svc
@@ -1 +1 @@
-<%@ ServiceHost Language="C#" Debug="true" Service="bsmd.dbh.ResponseService.ResponseService" CodeBehind="Service1.svc.cs" %>
\ No newline at end of file
+<%@ ServiceHost Language="C#" Debug="true" Service="bsmd.dbh.ResponseService.ResponseService" CodeBehind="ResponseService.svc.cs" %>
\ No newline at end of file
diff --git a/nsw/Source/bsmd.dbh.ResponseService/ResponseService.svc.cs b/nsw/Source/bsmd.dbh.ResponseService/ResponseService.svc.cs
index b5ca7f4a..e4f2d602 100644
--- a/nsw/Source/bsmd.dbh.ResponseService/ResponseService.svc.cs
+++ b/nsw/Source/bsmd.dbh.ResponseService/ResponseService.svc.cs
@@ -1,11 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Runtime.Serialization;
-using System.ServiceModel;
-using System.ServiceModel.Web;
-using System.Text;
-using log4net;
+using log4net;
namespace bsmd.dbh.ResponseService
{
@@ -13,18 +6,12 @@ namespace bsmd.dbh.ResponseService
// NOTE: In order to launch WCF Test Client for testing this service, please select Service1.svc or Service1.svc.cs at the Solution Explorer and start debugging.
public class ResponseService : IResponseService
{
- private ILog _log = LogManager.GetLogger("dbh ResponseService");
-
- public string GetData(int value)
- {
- return string.Format("You entered: {0}", value);
- }
+ private ILog _log = LogManager.GetLogger("dbh ResponseService");
public void NSWResponse(bsmd.dbh.response.Root root)
{
_log.Info("response received!");
- Response.ProcessResponse(root);
+ Response.ProcessResponse(root, Properties.Settings.Default.DBConnectionString);
}
-
}
}
diff --git a/nsw/Source/bsmd.dbh.ResponseService/Web.config b/nsw/Source/bsmd.dbh.ResponseService/Web.config
index e571e6dc..8cc2ea40 100644
--- a/nsw/Source/bsmd.dbh.ResponseService/Web.config
+++ b/nsw/Source/bsmd.dbh.ResponseService/Web.config
@@ -1,6 +1,11 @@

-
+
+
+
+
+
+
@@ -32,5 +37,11 @@
-->
-
+
+
+
+ replace me!
+
+
+
diff --git a/nsw/Source/bsmd.dbh.ResponseService/bsmd.dbh.ResponseService.csproj b/nsw/Source/bsmd.dbh.ResponseService/bsmd.dbh.ResponseService.csproj
index 62150741..a7d99f8e 100644
--- a/nsw/Source/bsmd.dbh.ResponseService/bsmd.dbh.ResponseService.csproj
+++ b/nsw/Source/bsmd.dbh.ResponseService/bsmd.dbh.ResponseService.csproj
@@ -63,9 +63,25 @@
-
+
+ Designer
+
+
+ Properties\AssemblyProductInfo.cs
+
+
+ Properties\AssemblyProjectInfo.cs
+
+
+ Properties\AssemblyProjectKeyInfo.cs
+
+
+ True
+ True
+ Settings.settings
+
ResponseService.svc
@@ -77,6 +93,17 @@
+
+ bsmdKey.snk
+
+
+ PreserveNewest
+ Designer
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
Web.config
@@ -98,6 +125,12 @@
10.0
$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+
+ true
+
+
+ ..\bsmdKey.snk
+
diff --git a/nsw/Source/bsmd.dbh.ResponseService/log4net.config b/nsw/Source/bsmd.dbh.ResponseService/log4net.config
new file mode 100644
index 00000000..49245923
--- /dev/null
+++ b/nsw/Source/bsmd.dbh.ResponseService/log4net.config
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nsw/Source/bsmd.dbh/NSWResponse.cs b/nsw/Source/bsmd.dbh/NSWResponse.cs
index 551855b1..473575b6 100644
--- a/nsw/Source/bsmd.dbh/NSWResponse.cs
+++ b/nsw/Source/bsmd.dbh/NSWResponse.cs
@@ -13,7 +13,6 @@ using System.Xml.Serialization;
//
// This source code was auto-generated by xsd, Version=4.0.30319.1.
//
-
namespace bsmd.dbh.response
{
@@ -743,4 +742,4 @@ namespace bsmd.dbh.response
ERROR,
}
-}
+}
\ No newline at end of file
diff --git a/nsw/Source/bsmd.dbh/NSWResponse.xsd b/nsw/Source/bsmd.dbh/NSWResponse.xsd
new file mode 100644
index 00000000..f26fd398
--- /dev/null
+++ b/nsw/Source/bsmd.dbh/NSWResponse.xsd
@@ -0,0 +1,296 @@
+
+
+
+
+
+
+
+
+ Version number of schema
+
+
+
+
+
+
+
+
+
+
+
+ Required when TransitId is missing and field "Type" is not "VISIT or "TRANSIT"
+
+
+
+
+
+
+
+
+
+
+ Required when VisitId is missing and field "Type" is not "VISIT or "TRANSIT"
+
+
+
+
+
+
+
+
+
+
+ Timestamp, when the message is sent
+
+
+
+
+ The message type (should be the same as in the request message):
+- VISIT: Creates a new declaration with the application for a VisitId. It's allowed to send further data in one or more reporting classes
+- TRANSIT: same with TransitId
+- DATA: Only data for one or more reporting classes are included
+- RESET: The data of one or more reporting classes are deleted
+- CANCEL: The whole declaration is cancelled
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Reporting classes that are received with all necessary data.
+
+
+
+
+
+ The code of a reporting class.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Reporting classes that are received with some data missing (see Messages for errors/violations).
+
+
+
+
+
+ The code of a reporting class.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Reporting classes that are received with some data missing (see Messages for errors/violations).
+
+
+
+
+
+ The code of a reporting class.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Reporting classes that are resetted (due to a message with Type RESET).
+
+
+
+
+
+ The code of a reporting class.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Errors, Violations, etc.
+
+
+
+
+
+
+
+
+ ID (given from NSW)
+
+
+
+
+
+
+
+
+
+
+
+ Type of Message (functional error, process error in report, process error in message basket, process error during status request, or violation)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/nsw/Source/bsmd.dbh/Request.cs b/nsw/Source/bsmd.dbh/Request.cs
index 1cb48750..13dbf459 100644
--- a/nsw/Source/bsmd.dbh/Request.cs
+++ b/nsw/Source/bsmd.dbh/Request.cs
@@ -9,94 +9,238 @@
using System;
using System.Collections.Generic;
+using log4net;
using bsmd.database;
-using bsmd.dbh.request;
+//using bsmd.dbh.request;
+using bsmd.dbh.DBHWebReference;
namespace bsmd.dbh
{
public class Request
{
+ private static ILog _log = LogManager.GetLogger(typeof(Request));
- public static bool SendMessage(Message aMessage)
+ public static bool SendMessage(DatabaseEntity dbEntity)
{
-
- if (aMessage == null) return false;
+ if (dbEntity == null) return false;
+
+ Message aMessage = null;
+
+
+ if (dbEntity.GetType().IsAssignableFrom(typeof(Message)))
+ {
+ aMessage = (Message)dbEntity;
+ }
+ else
+ {
+ IMessageClass msgClass = (IMessageClass)dbEntity;
+ aMessage = msgClass.MessageHeader;
+ }
// map message to dbh NSWRequest object
- Root root = new Root();
- root.Version = "1.8";
- root.ReportingParty = new RootReportingParty();
- root.ReportingParty.RPCity = aMessage.ReportingParty.City;
- root.ReportingParty.RPCountry = aMessage.ReportingParty.Country;
- root.ReportingParty.RPEMail = aMessage.ReportingParty.EMail;
- root.ReportingParty.RPFax = aMessage.ReportingParty.Fax;
- root.ReportingParty.RPFirstName = aMessage.ReportingParty.FirstName;
- root.ReportingParty.RPLastName = aMessage.ReportingParty.LastName;
- root.ReportingParty.RPName = aMessage.ReportingParty.Name;
- root.ReportingParty.RPPhone = aMessage.ReportingParty.Phone;
- root.ReportingParty.RPPostalCode = aMessage.ReportingParty.PostalCode;
- root.ReportingParty.RPStreetAndNumber = aMessage.ReportingParty.StreetAndNumber;
- root.ReportingParty.RPTypeSpecified = aMessage.ReportingParty.ReportingPartyType.HasValue;
- if (root.ReportingParty.RPTypeSpecified)
- root.ReportingParty.RPType = (RootReportingPartyRPType) aMessage.ReportingParty.ReportingPartyType.Value;
+ Dbh_Osis_Answ_Ws client = new Dbh_Osis_Answ_Ws();
- root.Timestamp = DateTime.Now;
+ RootReportingParty rp = new RootReportingParty();
+ rp.RPCity = aMessage.ReportingParty.City;
+ rp.RPCountry = aMessage.ReportingParty.Country;
+ rp.RPEMail = aMessage.ReportingParty.EMail;
+ rp.RPFax = aMessage.ReportingParty.Fax;
+ rp.RPFirstName = aMessage.ReportingParty.FirstName;
+ rp.RPLastName = aMessage.ReportingParty.LastName;
+ rp.RPName = aMessage.ReportingParty.Name;
+ rp.RPPhone = aMessage.ReportingParty.Phone;
+ rp.RPPostalCode = aMessage.ReportingParty.PostalCode;
+ rp.RPStreetAndNumber = aMessage.ReportingParty.StreetAndNumber;
+ rp.RPTypeSpecified = aMessage.ReportingParty.ReportingPartyType.HasValue;
+ if (rp.RPTypeSpecified)
+ rp.RPType = (RootReportingPartyRPType)aMessage.ReportingParty.ReportingPartyType.Value;
- switch(aMessage.MessageNotificationClass)
+ DateTime timestamp = DateTime.Now;
+ string version = "1.9";
+ object item = null;
+ string senderReference = Guid.NewGuid().ToString(); // TODO
+ RootType rootType = RootType.DATA;
+ ItemChoiceType2 itemChoiceType2 = ItemChoiceType2.Visit; // ?
+
+ switch (aMessage.MessageNotificationClass)
{
+
+ #region VISIT
case Message.NotificationClass.VISIT:
{
- root.Type = RootType.VISIT;
- root.Item = new RootVisit();
+ RootVisit rootVisit = new RootVisit();
+ rootType = RootType.VISIT;
+
if (aMessage.MessageCore.IMO != null)
{
- ((RootVisit)root.Item).ItemElementName = ItemChoiceType.IMONumber;
- ((RootVisit)root.Item).Item = aMessage.MessageCore.IMO;
+ rootVisit.ItemElementName = ItemChoiceType.IMONumber;
+ rootVisit.Item = aMessage.MessageCore.IMO;
}
else
{
- ((RootVisit)root.Item).ItemElementName = ItemChoiceType.ENINumber;
- ((RootVisit)root.Item).Item = aMessage.MessageCore.ENI;
+ rootVisit.ItemElementName = ItemChoiceType.ENINumber;
+ rootVisit.Item = aMessage.MessageCore.ENI;
}
- ((RootVisit)root.Item).PortOfCall = aMessage.MessageCore.PoC;
- ((RootVisit)root.Item).ETAPortOfCall = aMessage.MessageCore.ETA.Value;
-
+ rootVisit.PortOfCall = aMessage.MessageCore.PoC;
+ rootVisit.ETAPortOfCall = aMessage.MessageCore.ETA.Value;
+ item = rootVisit;
break;
}
+ #endregion
+
+ #region TRANSIT
case Message.NotificationClass.TRANSIT:
- root.Type = RootType.TRANSIT;
- root.Item = new RootTransit();
- if (aMessage.MessageCore.IMO != null)
{
- ((RootTransit)root.Item).ItemElementName = ItemChoiceType1.IMONumber;
- ((RootTransit)root.Item).Item = aMessage.MessageCore.IMO;
+ RootTransit rootTransit = new RootTransit();
+ rootType = RootType.TRANSIT;
+
+ if (aMessage.MessageCore.IMO != null)
+ {
+ rootTransit.ItemElementName = ItemChoiceType1.IMONumber;
+ rootTransit.Item = aMessage.MessageCore.IMO;
+ }
+ else
+ {
+ rootTransit.ItemElementName = ItemChoiceType1.ENINumber;
+ rootTransit.Item = aMessage.MessageCore.ENI;
+ }
+
+ rootTransit.ETAKielCanal = aMessage.MessageCore.ETA.Value;
+ item = rootTransit;
+
+ break;
}
- else
+ #endregion
+
+ #region NOA_NOD
+ case Message.NotificationClass.NOA_NOD:
{
- ((RootTransit)root.Item).ItemElementName = ItemChoiceType1.ENINumber;
- ((RootTransit)root.Item).Item = aMessage.MessageCore.ENI;
+ NOA_NOD noa_nod = dbEntity as NOA_NOD;
+ if (noa_nod != null)
+ {
+ RootNOA_NOD rootNoaNod = new RootNOA_NOD();
+ rootType = RootType.DATA;
+ if (noa_nod.ETAToNextPort.HasValue)
+ rootNoaNod.ETAToNextPort = noa_nod.ETAToNextPort.Value;
+ rootNoaNod.ETAToNextPortSpecified = noa_nod.ETAToNextPort.HasValue;
+
+ if (noa_nod.ETDFromLastPort.HasValue)
+ rootNoaNod.ETDFromLastPort = noa_nod.ETDFromLastPort.Value;
+ rootNoaNod.ETDFromLastPortSpecified = noa_nod.ETDFromLastPort.HasValue;
+
+ rootNoaNod.LastPort = noa_nod.LastPort;
+ rootNoaNod.NextPort = noa_nod.NextPort;
+
+ ItemsChoiceType[] choiceArray = new ItemsChoiceType[3];
+ object[] choices = new object[3];
+
+ choiceArray[0] = ItemsChoiceType.CallPurpose;
+ RootNOA_NODCallPurpose rnncp = new RootNOA_NODCallPurpose();
+ if (noa_nod.CallPurposeCode.HasValue)
+ rnncp.CallPurposeCode = noa_nod.CallPurposeCode.Value;
+ rnncp.CallPurposeDescription = noa_nod.CallPurposeDescription;
+ choices[0] = rnncp;
+
+ if (noa_nod.ETAToKielCanal.HasValue)
+ {
+ choiceArray[1] = ItemsChoiceType.ETAToKielCanal;
+ choices[1] = noa_nod.ETAToKielCanal.Value;
+ }
+ if (noa_nod.ETAToPortOfCall.HasValue)
+ {
+ choiceArray[1] = ItemsChoiceType.ETAToPortOfCall;
+ choices[1] = noa_nod.ETAToPortOfCall.Value;
+ }
+ if (noa_nod.ETDFromKielCanal.HasValue)
+ {
+ choiceArray[2] = ItemsChoiceType.ETDFromKielCanal;
+ choices[2] = noa_nod.ETDFromKielCanal.Value;
+ }
+ if (noa_nod.ETDFromPortOfCall.HasValue)
+ {
+ choiceArray[2] = ItemsChoiceType.ETDFromPortOfCall;
+ choices[2] = noa_nod.ETDFromPortOfCall.Value;
+ }
+
+ item = rootNoaNod;
+ }
+ break;
}
+ #endregion
- ((RootTransit)root.Item).ETAKielCanal = aMessage.MessageCore.ETA.Value;
+ #region ATA
+ case Message.NotificationClass.ATA:
+ {
+ ATA ata = dbEntity as ATA;
+ if (ata != null)
+ {
+ RootATA rootATA = new RootATA();
+ rootType = RootType.DATA;
+ rootATA.ATAPortOfCall = ata.ATAPortOfCall.Value;
+ item = rootATA;
+ }
+ break;
+ }
+ #endregion
- break;
+ #region ATD
+ case Message.NotificationClass.ATD:
+ {
+ ATD atd = dbEntity as ATD;
+ if (atd != null)
+ {
+ RootATD rootATD = new RootATD();
+ rootType = RootType.DATA;
+ rootATD.ATDPortOfCall = atd.ATDPortOfCall.Value;
+ item = rootATD;
+ }
+ break;
+ }
+ #endregion
- case Message.NotificationClass.STAT:
-
+ #region BPOL
+ case Message.NotificationClass.BPOL:
+ {
+ BPOL bpol = dbEntity as BPOL;
+ if (bpol != null)
+ {
+ RootBPOL rootBPOL = new RootBPOL();
+ rootType = RootType.DATA;
+ RootBPOLPortOfItinerary[] poiArray = new RootBPOLPortOfItinerary[bpol.PortOfItineraries.Count];
+ rootBPOL.PortOfItinerary = poiArray;
- break;
+ for (int i = 0; i < bpol.PortOfItineraries.Count; i++)
+ {
+ RootBPOLPortOfItinerary port = new RootBPOLPortOfItinerary();
+ if (bpol.PortOfItineraries[i].PortOfItineraryETA.HasValue)
+ port.PortOfItineraryETA = bpol.PortOfItineraries[i].PortOfItineraryETA.Value;
+ port.PortOfItineraryName = bpol.PortOfItineraries[i].PortOfItineraryName;
+ poiArray[i] = port;
+ }
+
+ if (bpol.StowawaysOnBoard.HasValue)
+ rootBPOL.StowawayOnBoard = bpol.StowawaysOnBoard.Value ?
+ RootBPOLStowawayOnBoard.Y : RootBPOLStowawayOnBoard.N;
+
+ item = rootBPOL;
+ }
+ break;
+ }
+ #endregion
default:
- throw new NotImplementedException("sending message type not implemented yet!");
+ {
+ _log.ErrorFormat("DBH send message: message type {0} not implemented", aMessage.MessageNotificationClass);
+ break;
+ }
}
- // send object
-
-
-
+ // send object
+ string result = client.Root(version, timestamp, Properties.Settings.Default.Sender, senderReference, rootType,
+ item, itemChoiceType2, null, rp, null, null);
return false;
}
diff --git a/nsw/Source/bsmd.dbh/Response.cs b/nsw/Source/bsmd.dbh/Response.cs
index bd0faa62..a184c2a9 100644
--- a/nsw/Source/bsmd.dbh/Response.cs
+++ b/nsw/Source/bsmd.dbh/Response.cs
@@ -10,34 +10,74 @@
using System;
using System.Collections.Generic;
using bsmd.database;
+using log4net;
namespace bsmd.dbh
{
public class Response
{
- public static void ProcessResponse(response.Root response)
+ private static ILog _log = LogManager.GetLogger("dbh Response");
+
+ public static void ProcessResponse(response.Root response, string connectionString)
{
+ _log.InfoFormat("processing message type {0}, version {1}", response.Type, response.Version);
- switch(response.Type)
+ if (DBManager.Instance.Connect(connectionString))
{
- case dbh.response.RootType.VISIT:
- break;
- case dbh.response.RootType.TRANSIT:
+ // Status zu den jeweiligen Nachrichten. Bei uns sollte die Anzahl hier immer 1 sein, da wir die Dinger
+ // einzeln verschicken.
+ for (int i = 0; i < response.Messages.Length; i++)
+ {
+ switch (response.Messages[i].Type)
+ {
+ case dbh.response.RootMessageType.ERROR:
+ MessageError messageError = new MessageError();
+ messageError.ErrorText = response.Messages[i].Text;
+ // messageError.ErrorCode =
- break;
- case dbh.response.RootType.CANCEL:
- break;
- case dbh.response.RootType.RESET:
+ break;
+ case dbh.response.RootMessageType.VIOLATION:
- break;
- case dbh.response.RootType.DATA:
- break;
+ break;
+ case dbh.response.RootMessageType.WARNING:
+ case dbh.response.RootMessageType.INFO:
+ default:
+
+ break;
+
+ }
+
+
+ }
+
+ switch (response.Type)
+ {
+ case dbh.response.RootType.VISIT:
+
+ break;
+ case dbh.response.RootType.TRANSIT:
+
+ break;
+ case dbh.response.RootType.CANCEL:
+
+ break;
+ case dbh.response.RootType.RESET:
+
+ break;
+ case dbh.response.RootType.DATA:
+
+ break;
+ }
+ DBManager.Instance.Disconnect();
+ }
+ else
+ {
+ _log.Fatal("cannot connect to database");
}
-
}
}
diff --git a/nsw/Source/bsmd.dbh/app.config b/nsw/Source/bsmd.dbh/app.config
new file mode 100644
index 00000000..b02f5deb
--- /dev/null
+++ b/nsw/Source/bsmd.dbh/app.config
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+ https://edi-gate.dbh.de/test/bsmd-soap
+
+
+ 00007009
+
+
+
+
\ No newline at end of file
diff --git a/nsw/Source/bsmd.dbh/bsmd.dbh.csproj b/nsw/Source/bsmd.dbh/bsmd.dbh.csproj
index 06c9c83d..059c7f3a 100644
--- a/nsw/Source/bsmd.dbh/bsmd.dbh.csproj
+++ b/nsw/Source/bsmd.dbh/bsmd.dbh.csproj
@@ -41,6 +41,8 @@
+
+
@@ -60,8 +62,18 @@
+
+ True
+ True
+ Settings.settings
+
+
+ True
+ True
+ Reference.map
+
@@ -71,7 +83,45 @@
+
+
+ Designer
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+ Designer
+
+
+ MSDiscoCodeGenerator
+ Reference.cs
+
+
+
+
+
+
+
+
+
+
+ Dynamic
+ Web References\DBHWebReference\
+ E:\work\bsmd\nsw\dbh\answ-osis-extern.wsdl
+
+
+
+
+ Settings
+ bsmd_dbh_DBHWebReference_Dbh_Osis_Answ_Ws
+
+
+
+