From ff9bbf334afed3757b53ca82ef351b9d20691595 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Thu, 23 Apr 2015 06:02:43 +0000 Subject: [PATCH] work in progres --- REDIRECT.txt | 33 ++ Stundensheet.xlsx | Bin 12166 -> 12441 bytes nsw/Source/SQL/Update_1.1_To_1.2.sql | 7 + nsw/Source/SendNSWMessageService/App.config | 2 +- .../SendNSWMessageService/NSWSendService.cs | 24 +- .../Properties/Settings.Designer.cs | 35 +++ .../Properties/Settings.settings | 9 + nsw/Source/bsmd.EMailReceiveService.sln | 34 ++ .../bsmd.EMailReceiveService/App.config | 30 ++ .../EmailReceiveService.Designer.cs | 37 +++ .../EmailReceiveService.cs | 151 +++++++++ .../bsmd.EMailReceiveService/Program.cs | 35 +++ .../Properties/AssemblyInfo.cs | 18 ++ .../Properties/Settings.Designer.cs | 86 +++++ .../Properties/Settings.settings | 21 ++ .../bsmd.EMailReceiveService.csproj | 103 ++++++ .../bsmd.EMailReceiveService/packages.config | 5 + .../bsmd.EMailReceiveService/readme.txt | 11 + nsw/Source/bsmd.database/DBManager.cs | 65 +++- nsw/Source/bsmd.database/DatabaseEntity.cs | 18 +- nsw/Source/bsmd.database/IMessageClass.cs | 2 +- nsw/Source/bsmd.database/Message.cs | 31 +- nsw/Source/bsmd.database/MessageCore.cs | 30 +- .../Properties/AssemblyProductInfo.cs | 4 +- .../Properties/AssemblyProjectInfo.cs | 2 +- nsw/Source/bsmd.database/bsmd.database.csproj | 1 - nsw/Source/bsmd.dbh.ResponseService.v12.suo | Bin 89600 -> 75264 bytes .../IResponseService.cs | 27 +- .../Properties/AssemblyInfo.cs | 21 +- .../ResponseService.svc | 2 +- .../ResponseService.svc.cs | 19 +- .../bsmd.dbh.ResponseService/Web.config | 15 +- .../bsmd.dbh.ResponseService.csproj | 35 ++- .../bsmd.dbh.ResponseService/log4net.config | 22 ++ nsw/Source/bsmd.dbh/NSWResponse.cs | 3 +- nsw/Source/bsmd.dbh/NSWResponse.xsd | 296 ++++++++++++++++++ nsw/Source/bsmd.dbh/Request.cs | 242 +++++++++++--- nsw/Source/bsmd.dbh/Response.cs | 66 +++- nsw/Source/bsmd.dbh/app.config | 18 ++ nsw/Source/bsmd.dbh/bsmd.dbh.csproj | 50 +++ nsw/Source/bsmd.dbh/readme.txt | 8 + .../bsmd.herberg.FormService/App.config | 6 + .../bsmd.herberg.FormService/FormService.cs | 45 ++- .../Properties/Settings.Designer.cs | 24 ++ .../Properties/Settings.settings | 6 + nsw/Source/bsmd.herberg.FormService/Util.cs | 29 ++ .../bsmd.herberg.FormService.csproj | 1 + nsw/dbh/NSWRequest.xsd | 247 +++++++++++---- 48 files changed, 1714 insertions(+), 262 deletions(-) create mode 100644 REDIRECT.txt create mode 100644 nsw/Source/SQL/Update_1.1_To_1.2.sql create mode 100644 nsw/Source/SendNSWMessageService/Properties/Settings.Designer.cs create mode 100644 nsw/Source/SendNSWMessageService/Properties/Settings.settings create mode 100644 nsw/Source/bsmd.EMailReceiveService.sln create mode 100644 nsw/Source/bsmd.EMailReceiveService/App.config create mode 100644 nsw/Source/bsmd.EMailReceiveService/EmailReceiveService.Designer.cs create mode 100644 nsw/Source/bsmd.EMailReceiveService/EmailReceiveService.cs create mode 100644 nsw/Source/bsmd.EMailReceiveService/Program.cs create mode 100644 nsw/Source/bsmd.EMailReceiveService/Properties/AssemblyInfo.cs create mode 100644 nsw/Source/bsmd.EMailReceiveService/Properties/Settings.Designer.cs create mode 100644 nsw/Source/bsmd.EMailReceiveService/Properties/Settings.settings create mode 100644 nsw/Source/bsmd.EMailReceiveService/bsmd.EMailReceiveService.csproj create mode 100644 nsw/Source/bsmd.EMailReceiveService/packages.config create mode 100644 nsw/Source/bsmd.EMailReceiveService/readme.txt create mode 100644 nsw/Source/bsmd.dbh.ResponseService/log4net.config create mode 100644 nsw/Source/bsmd.dbh/NSWResponse.xsd create mode 100644 nsw/Source/bsmd.dbh/app.config create mode 100644 nsw/Source/bsmd.dbh/readme.txt create mode 100644 nsw/Source/bsmd.herberg.FormService/Util.cs 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 b6e40248c2a1681c11214cc4b159f578ab194019..ea4af98a16591b08b092966e7c8fdb3f1b8c6dce 100644 GIT binary patch delta 2880 zcmV-G3%~S+UzuUB1Q!bR?!66i1^@u;8Iw>G8GkV@cx`NqSxa-`Mi9QID*r*H({8E) zNFW|AU<)DR>|v`?aW*;2Fc{SWB9d(H=GUitrbnY`N#po{q4jmo*N^EQhUKU4m$UaO ziZaWuD?b>Fd{12W`60VLul%on?tY#7URkBrLwe4yV&(r3rT=OD^H0mSy!ck0gs42Q zaDOdV{;8^Ncf(=1KZ#3P4)UA0!jofOT+#|Y7SF@-R*3W~f~1bzn52!BkL5`ZSteU-h6tvH`o{ymuW%75f4_#T!R z)@wB1>-Bar8ow9bQ(B5`e*QZ$gXln1y{-cl^K;BE$4 z*`siS(v=SmfU}tX*Y#*Qe1-7u2@xv07aHB?qHsZc%KZxvy zJEac(HS}jT=AjESuQ5XiLLG_FihqQM;Os$SF!?8P^U>nFGyy8`ILctkXbD0L!%@I&Bm|()HYiF5?zw(naIqt_H-8LDnGXvV zU4poLAV}>)$ZRA8=q?Yg-RA*pxDF3c$~*{Ib;g8oxj>NGg^0C{N)$~8<8ZR5|4aa_3@p0n zZ%_&ufLg5EOu+jLVIb8t#xxAoZV00K$pl&*-^~P=vqot##BSY=@J5Q?l)VED~+Sopzi>h9;lnff`kIiLyo;Ymk#J8LH{d*uYM-6-Cz+haFX% zJch15aNxOyr$20+!U*J~Nf<+u6;Yy>qAKl8KMt4uKTnanpQpi#kYmk#DpGyl?K8d!Xh?=L?Mhfk@q#L~y^LVn9#Tw+K$>&j< zCL!GQiEX&GjS_ivp%13=T)MbR!m&Oz@{WH``1%aJU?s96Kz(oxBkSZE1QE;C1JeKt z?C2VdXOqFisDIhv$7a{^YZIy-2t%?yjJAdXV(O>HyxfypGGH8KfP?^QKblEllk0A> zq3V2Ya)9Y4rwkZ!tgsSVL6HmlT5E`nts{1--?`}lr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$p z=ZGc*MW96^E4|Cnd%21iC~}@_$?HZ#j*j5avbep;gkhqw@M;?a)>q)7K+=v0lcT-& zhGFc)9u#*;aOfaz8>_evrQKn}#TVZJP6@fk3OtwGbKC)AGZN7WDaD91-?r`nQedb- zf%Xp5gyMfcuLrB#)d#&YajME6P1xxacgmJx5J&gHRim+O+oYZKF+zTdKh`gA{i<=L zyIToBMJ5Fk7PxP0k>P0(4p(#M*Wt$73gqK4=vR7D^l=9W$S4G0L)^2nnLRz1D^zqh zjLAcs(vmFLJY{M6*^Rt--vt^P>NNOYBAv(NE+!GPk`gvwFghik0YmP~Pf+{ - 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 44ba1f920c77ac78ed6e9571d0d46e0192df3311..bdb608528803fecff6eef01a3acf38c87a3f57f7 100644 GIT binary patch delta 10101 zcmeHM33yahmVUREP?ZF-Cl#_4p;!W>Qk6XcvQ!qfkU$bi)IzAFDj|~1R0YCjqK$%p zNODIWE;tNgE6CVjx}jTbO|b2u)lq2|XqRqiTgP^A00+87gv@_lEvY1c*k5;l-+Ujp zzQ69h=bd}rUCuf8-21v-Qg*$m*ft|`VyjiQISe6?&fyTmWZ-d6dbt^>qVQ7n!dWNNW5o+;F)i4Vz-GetyqtHPFm3JDKJ zt_C7q_07lw0Dm9|7y|?Xqk%Xe6nFs80O5cZfEX!7pgaz^jG8aJBP(%@JMTAD+6P?Y?sJa&%5}!gzZn(S z=?5v)C3+(bm2w(BGHLjf)9@*G51*!S`0(lZSkQ+LpQeRm((t1IdY2M;7=U7TRnTaK zvxwTjz~49pz8V9)WFsU|2dGS)-Qp^5MgEYh+>N{k;In0RIN; zcG34Bf67&U8u>G>@;>Cx0sDb}chN`&;isrS5A?d|KSO>9I1Kz8_yzESAan{ZqVN*% zOWcnf$Ncn3HJ{1$L`=zUlDIPw#~ z?|={Se&Hh&J_bGkeh>TsI0>8r+>PD&=b-%;@CEQ^;7j1Yfz!ZO!2bYefV03k;A_C$ z)}8;=MZ1XnTT%#m@E!8Yt}@jr^@Pq=kO6yamHF{@|4!!1FZg%*Ou>^6X7bge?`E_4 zMOgw%h2_WazKB%iU+`#+L`#!sdC>}0CTQ8-!j#{jcAvzR?rC`mv$-hLK#UxovP=pW`=>K-YQ3BIZQyzQ?s$Wyfk=B ztZg3z)T!7=%i-8J_`#l|1woHZ zHYv`T--W%4_D{(+@yEM!!+4iGo@KbrC*?tm{4s!1C3@B>ERcFey|fDsl$+5 z5R8IB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ax9DvATGk1JvM~x8warcI*EP$XR>*>@a=Qfv&ds(! zG{|95utvMV)6m=^d##WugB4E5Ww9_KpR_^*Jo4`lolqpVS>RXl$po;;Whvk`R5U2k z8!F{{36Lzm9SxG^X(yS_O~ zJ|73kf%EUTLqcq@dIs3dPV*--=7S1=zUr?Z{64Z!H3>Wi^hJU4Y&1--s6XY z^4P}wywNwOCxWUT<2px}+?WV^sgHT /// 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 + + + +