repaired message return handling

This commit is contained in:
Daniel Schick 2022-11-15 18:44:38 +01:00
parent 7bfa85e96d
commit 0ae84839d1
6 changed files with 72 additions and 9 deletions

View File

@ -92,14 +92,19 @@ namespace bsmd.dbh
foreach (string inputFile in Directory.GetFiles(Properties.Settings.Default.IncomingFolder)) foreach (string inputFile in Directory.GetFiles(Properties.Settings.Default.IncomingFolder))
{ {
string justFilename = Path.GetFileName(inputFile);
// lokale Dateien verarbeiten // lokale Dateien verarbeiten
if (!ResponseUtil.Read(inputFile)) if (!ResponseUtil.Read(inputFile))
{ {
_log.ErrorFormat("Error reading input file {0}", inputFile); _log.ErrorFormat("Error reading input file {0}", justFilename);
string errorPath = Path.Combine(Properties.Settings.Default.IncomingErrorFolder, justFilename);
File.Move(inputFile, errorPath);
} }
else else
{ {
File.Move(inputFile, Properties.Settings.Default.IncomingArchiveFolder); _log.InfoFormat("Incoming file {0} processed", justFilename);
string archivePath = Path.Combine(Properties.Settings.Default.IncomingArchiveFolder, justFilename);
File.Move(inputFile, archivePath);
} }
// remote Dateien löschen // remote Dateien löschen
bsmd.dakosy.SFtp.RemoveProcessedFile(Properties.Settings.Default.RemoteOutgoingFolder, Path.GetFileName(inputFile)); bsmd.dakosy.SFtp.RemoveProcessedFile(Properties.Settings.Default.RemoteOutgoingFolder, Path.GetFileName(inputFile));

View File

@ -94,5 +94,14 @@ namespace bsmd.dbh.Properties {
return ((string)(this["SFTPSessionName"])); return ((string)(this["SFTPSessionName"]));
} }
} }
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string IncomingErrorFolder {
get {
return ((string)(this["IncomingErrorFolder"]));
}
}
} }
} }

View File

@ -26,5 +26,8 @@
<Setting Name="SFTPSessionName" Type="System.String" Scope="Application"> <Setting Name="SFTPSessionName" Type="System.String" Scope="Application">
<Value Profile="(Default)">dbh</Value> <Value Profile="(Default)">dbh</Value>
</Setting> </Setting>
<Setting Name="IncomingErrorFolder" Type="System.String" Scope="Application">
<Value Profile="(Default)" />
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -29,7 +29,7 @@ namespace bsmd.dbh
root.SourceDocumentVersion = "7.0"; root.SourceDocumentVersion = "7.0";
root.Timestamp = DateTime.Now; root.Timestamp = DateTime.Now;
root.Sender = Properties.Settings.Default.Sender; root.Sender = Properties.Settings.Default.Sender;
root.SenderReference = "N"; root.SenderReference = message.Id.ToString();
bsmd.database.ReportingParty reportingParty = DBManager.Instance.GetReportingPartyDict()[core.DefaultReportingPartyId.Value]; bsmd.database.ReportingParty reportingParty = DBManager.Instance.GetReportingPartyDict()[core.DefaultReportingPartyId.Value];
Request.ReportingParty rp = new Request.ReportingParty(); Request.ReportingParty rp = new Request.ReportingParty();
rp.RPCity = reportingParty.City; rp.RPCity = reportingParty.City;

View File

@ -34,7 +34,7 @@ namespace bsmd.dbh
return result; return result;
} }
string fileSeqString = m.Groups[0].Value; string fileSeqString = m.Groups[1].Value;
if(!Int32.TryParse(fileSeqString, out int fileSeqNum)) if(!Int32.TryParse(fileSeqString, out int fileSeqNum))
{ {
@ -57,7 +57,7 @@ namespace bsmd.dbh
return result; return result;
} }
bsmd.dbh.Response.Root root; bsmd.dbh.Response.Root root = null;
try try
{ {
@ -66,14 +66,57 @@ namespace bsmd.dbh
{ {
root = (bsmd.dbh.Response.Root) serializer.Deserialize(s); root = (bsmd.dbh.Response.Root) serializer.Deserialize(s);
} }
if(Guid.TryParse(root.SenderReference, out Guid refGuid))
{
if (!sentMessage.Id.Equals(refGuid))
_log.WarnFormat("sender ref {0} does not match sent message id {1}", refGuid, sentMessage.Id);
}
else
{
_log.WarnFormat("sender ref {0} is no guid", root.SenderReference);
}
switch(sentMessage.MessageNotificationClass)
{
case Message.NotificationClass.VISIT:
if(root.Type == Response.RootType.VISIT)
{
if(aCore.VisitId.IsNullOrEmpty() && !root.VisitId.IsNullOrEmpty())
{
aCore.VisitId = root.VisitId;
_log.InfoFormat("Received Visit-Id {0} for core {1}", root.VisitId, aCore.Id);
}
}
break;
case Message.NotificationClass.TRANSIT:
if (root.Type == Response.RootType.TRANSIT)
{
if (aCore.TransitId.IsNullOrEmpty() && !root.TransitId.IsNullOrEmpty())
{
aCore.TransitId = root.TransitId;
_log.InfoFormat("Received Transit-Id {0} for core {1}", root.TransitId, aCore.Id);
}
}
break;
default:
break;
}
if (!(aCore.Cancelled ?? false))
aCore.BSMDStatusInternal = MessageCore.BSMDStatus.RESPONDED;
DBManager.Instance.Save(aCore);
result = true;
} }
catch(Exception ex) catch(Exception ex)
{ {
_log.ErrorFormat("Failed to deserialize: {0}", ex.Message); _log.ErrorFormat("Failed to deserialize return message: {0}", ex.Message);
return result; return result;
} }
return result; return result;
} }

View File

@ -31,6 +31,9 @@
<setting name="SFTPSessionName" serializeAs="String"> <setting name="SFTPSessionName" serializeAs="String">
<value>dbh</value> <value>dbh</value>
</setting> </setting>
<setting name="IncomingErrorFolder" serializeAs="String">
<value />
</setting>
</bsmd.dbh.Properties.Settings> </bsmd.dbh.Properties.Settings>
</applicationSettings> </applicationSettings>
</configuration> </configuration>