git_bsmd/nsw/Source/bsmd.dbh.ResponseService/ResponseService.svc.cs

87 lines
3.8 KiB
C#

using System;
using System.ServiceModel;
using log4net;
using bsmd.database;
namespace bsmd.dbh.ResponseService
{
[ServiceBehavior(AddressFilterMode = AddressFilterMode.Any, ValidateMustUnderstand = false)]
public class ResponseService : IResponseService
{
private readonly ILog _log = LogManager.GetLogger("dbh ResponseService");
public void root(string Version, string MessageId, string VisitId, string TransitId, DateTime Timestamp,
string SenderReference, bsmd.dbh.response.RootType Type,
bsmd.dbh.response.RootReportingClassesFull ReportingClassesFull,
bsmd.dbh.response.RootReportingClassesPartial ReportingClassesPartial,
bsmd.dbh.response.RootReportingClassesError RootReportingClassesError,
bsmd.dbh.response.RootReportingClassesResetted ReportingClassesResetted,
bsmd.dbh.response.RootReportingClassesNoChanges ReportingClassesNoChanges,
bsmd.dbh.response.Message[] Messages)
{
// Der Fehler hier aktuell ist dass alles funktioniert, außer dass "Messages" nicht
// richtig deserialisiert wird und immer in eine leere Collection mündet. Die anderen
// Parameter sind richtig gesetzt. Per trial and error sowohl List<RootMessage> als auch
// RootMessage[] Messages ausprobiert. Element ist immer da, aber leer! (müsste aber ein Element haben!)
_log.Info("dbh response received");
if (ReportingClassesFull == null) _log.InfoFormat("ReportingClassesFull null");
if (ReportingClassesPartial == null) _log.InfoFormat("ReportingClassesPartial null");
if (RootReportingClassesError == null) _log.InfoFormat("ReportingClassesError null");
if (ReportingClassesResetted == null) _log.InfoFormat("ReportingClassesResetted null");
if (Messages == null) { _log.InfoFormat("Messages null"); }
else
{
_log.InfoFormat(Messages.GetType().ToString());
_log.InfoFormat("{0} Message elements received", Messages.Length);
}
if (Version != null)
_log.InfoFormat("Version: {0}", Version);
else
_log.Warn("Version is null");
if (MessageId != null)
_log.InfoFormat("MessageId: {0}", MessageId);
else
_log.Warn("MessageId is null");
if (!VisitId.IsNullOrEmpty())
_log.InfoFormat("Visit-Id: {0}", VisitId);
if (!TransitId.IsNullOrEmpty())
_log.InfoFormat("Transit-Id: {0}", TransitId);
_log.InfoFormat("Timestamp: {0}", Timestamp);
if (SenderReference != null)
_log.InfoFormat("Sender-Reference: {0}", SenderReference);
_log.InfoFormat("Type: {0}", Type);
/*
if (Messages != null)
{
foreach (bsmd.dbh.response.RootMessage rootMessage in Messages)
{
_log.InfoFormat("Message type {0}: {1}", rootMessage.Type, rootMessage.Text);
}
}
*/
if (SenderReference.IsNullOrEmpty())
{
_log.ErrorFormat("No sender reference, cannot process message");
return;
}
_log.DebugFormat("processing {0}..", MessageId ?? "?");
Response.ProcessResponse(VisitId, TransitId, Timestamp, SenderReference, Type, Messages,
ReportingClassesFull, ReportingClassesPartial, RootReportingClassesError, ReportingClassesResetted, ReportingClassesNoChanges,
Properties.Settings.Default.DBConnectionString);
}
}
}