Zwischenstand (Umbau HIS-Nord Response Parsing auf XDocument / XElement (LinqToXML)
This commit is contained in:
parent
b46b3606ac
commit
362f0f4285
Binary file not shown.
@ -83,6 +83,8 @@ namespace SendNSWMessageService
|
|||||||
if (DBManager.Instance.Connect(Properties.Settings.Default.ConnectionString))
|
if (DBManager.Instance.Connect(Properties.Settings.Default.ConnectionString))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
bsmd.hisnord.Response.ReadAnswers();
|
||||||
|
|
||||||
// Datenbank auf zu sendende Objekte überprüfen und laden
|
// Datenbank auf zu sendende Objekte überprüfen und laden
|
||||||
|
|
||||||
List<MessageCore> coresMarkedForSending = DBManager.Instance.GetMessageCoresByStatus(MessageCore.BSMDStatus.TOSEND);
|
List<MessageCore> coresMarkedForSending = DBManager.Instance.GetMessageCoresByStatus(MessageCore.BSMDStatus.TOSEND);
|
||||||
@ -271,7 +273,7 @@ namespace SendNSWMessageService
|
|||||||
|
|
||||||
// Auf erhaltene Visit-Ids prüfen (HIS-NORD)
|
// Auf erhaltene Visit-Ids prüfen (HIS-NORD)
|
||||||
// TODO
|
// TODO
|
||||||
bsmd.hisnord.Response.ReadAnswers();
|
// bsmd.hisnord.Response.ReadAnswers();
|
||||||
|
|
||||||
DBManager.Instance.Disconnect();
|
DBManager.Instance.Disconnect();
|
||||||
|
|
||||||
|
|||||||
23
nsw/Source/bsmd.hisnord/NSWResponse.cs
Normal file
23
nsw/Source/bsmd.hisnord/NSWResponse.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Xml;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace bsmd.hisnord
|
||||||
|
{
|
||||||
|
|
||||||
|
public class NSWResponse
|
||||||
|
{
|
||||||
|
public NSWResponse(XElement xml)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -94,5 +94,17 @@ namespace bsmd.hisnord.Properties {
|
|||||||
this["AnswerArchiveDir"] = value;
|
this["AnswerArchiveDir"] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Configuration.DefaultSettingValueAttribute("E:\\svnlager\\BSMD\\nsw\\HIS-NORD\\Transmitter-Tool\\ANSWERS_CORRUPT")]
|
||||||
|
public string AnswerCorruptDir {
|
||||||
|
get {
|
||||||
|
return ((string)(this["AnswerCorruptDir"]));
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
this["AnswerCorruptDir"] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,5 +20,8 @@
|
|||||||
<Setting Name="AnswerArchiveDir" Type="System.String" Scope="User">
|
<Setting Name="AnswerArchiveDir" Type="System.String" Scope="User">
|
||||||
<Value Profile="(Default)">E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\ANSWERS_DONE</Value>
|
<Value Profile="(Default)">E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\ANSWERS_DONE</Value>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<Setting Name="AnswerCorruptDir" Type="System.String" Scope="User">
|
||||||
|
<Value Profile="(Default)">E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\ANSWERS_CORRUPT</Value>
|
||||||
|
</Setting>
|
||||||
</Settings>
|
</Settings>
|
||||||
</SettingsFile>
|
</SettingsFile>
|
||||||
@ -8,6 +8,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using log4net;
|
using log4net;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
namespace bsmd.hisnord
|
namespace bsmd.hisnord
|
||||||
{
|
{
|
||||||
@ -21,9 +22,74 @@ namespace bsmd.hisnord
|
|||||||
{
|
{
|
||||||
foreach (string answerFile in Directory.GetFiles(Properties.Settings.Default.AnswerDir))
|
foreach (string answerFile in Directory.GetFiles(Properties.Settings.Default.AnswerDir))
|
||||||
{
|
{
|
||||||
|
bool isOK = true;
|
||||||
|
|
||||||
|
// Informationen aus dem Dateinamen
|
||||||
|
// Meldetyp_Referenz_ID_Timestamp.xml
|
||||||
|
string bareFileName = Path.GetFileNameWithoutExtension(answerFile);
|
||||||
|
string[] fileNameElems = bareFileName.Split('_');
|
||||||
|
|
||||||
|
if (fileNameElems.Length < 4)
|
||||||
|
{
|
||||||
|
_log.WarnFormat("ANSWER file {0}.xml has an invalid file name", bareFileName);
|
||||||
|
isOK = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int prozessStatus;
|
||||||
|
if (!Int32.TryParse(fileNameElems[fileNameElems.Length - 1], out prozessStatus))
|
||||||
|
{
|
||||||
|
_log.WarnFormat("ANSWER file {0}.xml has no process status at the end (2..6)", bareFileName);
|
||||||
|
isOK = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int timestampMilliSecs;
|
||||||
|
if (!Int32.TryParse(fileNameElems[fileNameElems.Length - 2], out timestampMilliSecs))
|
||||||
|
{
|
||||||
|
_log.WarnFormat("ANSWER file {0}.xml has no readable timestamp", bareFileName);
|
||||||
|
isOK = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string refId = fileNameElems[fileNameElems.Length - 3];
|
||||||
|
string meldeTyp = fileNameElems[fileNameElems.Length - 4];
|
||||||
|
if (fileNameElems.Length == 5)
|
||||||
|
meldeTyp = string.Format("{0}_{1}", fileNameElems[fileNameElems.Length - 5], meldeTyp);
|
||||||
|
|
||||||
// TODO: klären was man hier liest: reguläre Antwort oder Schnittstellenfehler
|
// TODO: klären was man hier liest: reguläre Antwort oder Schnittstellenfehler
|
||||||
VisitIdResponse visitIdResponse = ReadVisitId(answerFile);
|
// XML Linq statt Serialisierung
|
||||||
|
try
|
||||||
|
{
|
||||||
|
XElement xml = XElement.Load(answerFile);
|
||||||
|
|
||||||
|
// declare Namespaces
|
||||||
|
XNamespace ns1 = "http://api.national-single-window.de/visitIdRequest";
|
||||||
|
XNamespace ns6 = "http://api.national-single-window.de/receipt";
|
||||||
|
//XNamespace ns15 = "http://api.national-single-window.de/statusForClientRequestId";
|
||||||
|
XNamespace soap = "http://schemas.xmlsoap.org/soap/envelope/";
|
||||||
|
XNamespace ns15 = "http://api.national-single-window.de/visitIdResponse";
|
||||||
|
|
||||||
|
if(xml.Descendants("SystemError").Count() > 0)
|
||||||
|
{
|
||||||
|
// Fehlernachricht
|
||||||
|
SystemError systemError = new SystemError(xml);
|
||||||
|
|
||||||
|
// Speichern
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// NSW Rückmeldung
|
||||||
|
NSWResponse nswResponse = new NSWResponse(xml);
|
||||||
|
|
||||||
|
// Rückmeldung auswerten
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
if (visitIdResponse != null)
|
if (visitIdResponse != null)
|
||||||
{
|
{
|
||||||
_log.InfoFormat("HIS-NORD: Visit-ID {0} delivered for Core {1}", visitIdResponse.VisitId, visitIdResponse.ClientRequestId);
|
_log.InfoFormat("HIS-NORD: Visit-ID {0} delivered for Core {1}", visitIdResponse.VisitId, visitIdResponse.ClientRequestId);
|
||||||
@ -58,48 +124,28 @@ namespace bsmd.hisnord
|
|||||||
{
|
{
|
||||||
_log.WarnFormat("Client request id is null in {0}", answerFile);
|
_log.WarnFormat("Client request id is null in {0}", answerFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
// archive file
|
|
||||||
File.Move(answerFile, Path.Combine(Properties.Settings.Default.AnswerArchiveDir, Path.GetFileName(answerFile)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static VisitIdResponse ReadVisitId (string filename)
|
|
||||||
{
|
|
||||||
VisitIdResponse visitIdResponse = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
XmlSerializer serializer = new XmlSerializer(typeof(bsmd.hisnord.dataset));
|
|
||||||
using (FileStream fs = new FileStream(filename, FileMode.Open))
|
|
||||||
{
|
|
||||||
// aus dem Gewühl die Antwort fischen..
|
|
||||||
dataset aDataSet = (dataset)serializer.Deserialize(fs);
|
|
||||||
if (aDataSet != null)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < aDataSet.Items.Length; i++)
|
|
||||||
{
|
|
||||||
if (aDataSet.Items[i] is Envelope)
|
|
||||||
{
|
|
||||||
Envelope anEnvelope = (Envelope)aDataSet.Items[i];
|
|
||||||
if (anEnvelope.Body.Length > 0)
|
|
||||||
{
|
|
||||||
visitIdResponse = anEnvelope.Body[0].VisitIdResponse;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
catch(Exception ex)
|
catch(Exception ex)
|
||||||
{
|
{
|
||||||
_log.ErrorFormat("Exception occurred during deserialization: {0}", ex.Message);
|
_log.WarnFormat("Exception deserializing ANSWER file: {0}", ex.ToString());
|
||||||
|
isOK = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return visitIdResponse;
|
if(isOK)
|
||||||
|
{
|
||||||
|
// archive file
|
||||||
|
File.Move(answerFile, Path.Combine(Properties.Settings.Default.AnswerArchiveDir, Path.GetFileName(answerFile)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
File.Move(answerFile, Path.Combine(Properties.Settings.Default.AnswerCorruptDir, Path.GetFileName(answerFile)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,217 +1,64 @@
|
|||||||
//------------------------------------------------------------------------------
|
using System;
|
||||||
// <auto-generated>
|
using System.Linq;
|
||||||
// Dieser Code wurde von einem Tool generiert.
|
using System.Xml;
|
||||||
// Laufzeitversion:4.0.30319.42000
|
using System.Xml.Linq;
|
||||||
//
|
|
||||||
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
|
||||||
// der Code erneut generiert wird.
|
|
||||||
// </auto-generated>
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
using System.Xml.Serialization;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Dieser Quellcode wurde automatisch generiert von xsd, Version=4.6.1055.0.
|
|
||||||
//
|
|
||||||
|
|
||||||
namespace bsmd.hisnord
|
namespace bsmd.hisnord
|
||||||
{
|
{
|
||||||
|
public class SystemError
|
||||||
/// <remarks/>
|
|
||||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
|
|
||||||
[System.SerializableAttribute()]
|
|
||||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
|
||||||
[System.ComponentModel.DesignerCategoryAttribute("code")]
|
|
||||||
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
|
|
||||||
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
|
|
||||||
public partial class SystemError
|
|
||||||
{
|
{
|
||||||
|
private DateTime? _errorAt;
|
||||||
|
private string _meldeTyp;
|
||||||
|
private string _referenceId;
|
||||||
|
private int _processStatus;
|
||||||
|
private string _importFileName;
|
||||||
|
private int _errorCode;
|
||||||
|
private string _errorMessage;
|
||||||
|
private string _errorDescription;
|
||||||
|
|
||||||
private string errorAtField;
|
public SystemError(XElement xml)
|
||||||
|
|
||||||
private string meldetypeField;
|
|
||||||
|
|
||||||
private string referenceIdField;
|
|
||||||
|
|
||||||
private string processStatusField;
|
|
||||||
|
|
||||||
private string transmissionRepeatedAtField;
|
|
||||||
|
|
||||||
private string importFilenameField;
|
|
||||||
|
|
||||||
private string visitIdField;
|
|
||||||
|
|
||||||
private string errorCodeField;
|
|
||||||
|
|
||||||
private string errorMessageField;
|
|
||||||
|
|
||||||
private string errorDescriptionField;
|
|
||||||
|
|
||||||
/// <remarks/>
|
|
||||||
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
|
|
||||||
public string ErrorAt
|
|
||||||
{
|
{
|
||||||
get
|
if(xml.Descendants("ErrorAt").Count() > 0)
|
||||||
{
|
{
|
||||||
return this.errorAtField;
|
_errorAt = DateTime.Parse(xml.Descendants("ErrorAt").First().Value);
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this.errorAtField = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <remarks/>
|
_meldeTyp = xml.Descendants("MeldeType").First()?.Value;
|
||||||
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
|
_referenceId = xml.Descendants("ReferenceId").First()?.Value;
|
||||||
public string Meldetype
|
if(xml.Descendants("ProcessStatus").Count() > 0)
|
||||||
{
|
{
|
||||||
get
|
_processStatus = Int32.Parse(xml.Descendants("ProcessStatus").First().Value);
|
||||||
{
|
|
||||||
return this.meldetypeField;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this.meldetypeField = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <remarks/>
|
_importFileName = xml.Descendants("ImportFilename").First()?.Value;
|
||||||
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
|
if(xml.Descendants("ErrorCode").Count() > 0)
|
||||||
public string ReferenceId
|
|
||||||
{
|
{
|
||||||
get
|
_errorCode = Int32.Parse(xml.Descendants("ErrorCode").First().Value);
|
||||||
{
|
|
||||||
return this.referenceIdField;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this.referenceIdField = value;
|
|
||||||
}
|
}
|
||||||
|
_errorMessage = xml.Descendants("ErrorMessage").First()?.Value;
|
||||||
|
_errorDescription = xml.Descendants("ErrorDescription").First()?.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <remarks/>
|
#region Properties
|
||||||
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
|
|
||||||
public string ProcessStatus
|
public DateTime? ErrorAt { get { return _errorAt; } }
|
||||||
{
|
|
||||||
get
|
public string MeldeTyp { get { return _meldeTyp; } }
|
||||||
{
|
|
||||||
return this.processStatusField;
|
public string ReferenceId { get { return _referenceId; } }
|
||||||
}
|
|
||||||
set
|
public int ProcessStatus { get { return _processStatus; } }
|
||||||
{
|
|
||||||
this.processStatusField = value;
|
public string ImportFileName { get { return _importFileName; } }
|
||||||
}
|
|
||||||
|
public int ErrorCode { get { return _errorCode; } }
|
||||||
|
|
||||||
|
public string ErrorMessage { get { return _errorMessage; } }
|
||||||
|
|
||||||
|
public string ErrorDescription { get { return _errorDescription; } }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <remarks/>
|
|
||||||
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
|
|
||||||
public string TransmissionRepeatedAt
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return this.transmissionRepeatedAtField;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this.transmissionRepeatedAtField = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <remarks/>
|
|
||||||
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
|
|
||||||
public string ImportFilename
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return this.importFilenameField;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this.importFilenameField = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <remarks/>
|
|
||||||
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
|
|
||||||
public string VisitId
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return this.visitIdField;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this.visitIdField = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <remarks/>
|
|
||||||
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
|
|
||||||
public string ErrorCode
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return this.errorCodeField;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this.errorCodeField = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <remarks/>
|
|
||||||
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
|
|
||||||
public string ErrorMessage
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return this.errorMessageField;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this.errorMessageField = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <remarks/>
|
|
||||||
[System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified)]
|
|
||||||
public string ErrorDescription
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return this.errorDescriptionField;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this.errorDescriptionField = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <remarks/>
|
|
||||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.6.1055.0")]
|
|
||||||
[System.SerializableAttribute()]
|
|
||||||
[System.Diagnostics.DebuggerStepThroughAttribute()]
|
|
||||||
[System.ComponentModel.DesignerCategoryAttribute("code")]
|
|
||||||
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
|
|
||||||
[System.Xml.Serialization.XmlRootAttribute(Namespace = "", IsNullable = false)]
|
|
||||||
public partial class NewDataSet
|
|
||||||
{
|
|
||||||
|
|
||||||
private SystemError[] itemsField;
|
|
||||||
|
|
||||||
/// <remarks/>
|
|
||||||
[System.Xml.Serialization.XmlElementAttribute("SystemError")]
|
|
||||||
public SystemError[] Items
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return this.itemsField;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
this.itemsField = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -25,6 +25,9 @@
|
|||||||
<setting name="AnswerArchiveDir" serializeAs="String">
|
<setting name="AnswerArchiveDir" serializeAs="String">
|
||||||
<value>E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\ANSWERS_DONE</value>
|
<value>E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\ANSWERS_DONE</value>
|
||||||
</setting>
|
</setting>
|
||||||
|
<setting name="AnswerCorruptDir" serializeAs="String">
|
||||||
|
<value>E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\ANSWERS_CORRUPT</value>
|
||||||
|
</setting>
|
||||||
</bsmd.hisnord.Properties.Settings>
|
</bsmd.hisnord.Properties.Settings>
|
||||||
</userSettings>
|
</userSettings>
|
||||||
</configuration>
|
</configuration>
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user