initialize
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
#region Namespace
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Asm.As.Oib.Client.CustomExtensions;
|
||||
using com.itac.mes.tools;
|
||||
using com.itac.mes.proxy.business;
|
||||
using com.itac.oib.traceability.contracts.data;
|
||||
using OibClient = Asm.As.Oib.Client;
|
||||
using SiplaceNS = www.siplace.com.OIB._2009._03.Traceability.Contracts.Data;
|
||||
#endregion
|
||||
|
||||
namespace Itac.Oib
|
||||
{
|
||||
/// <summary>
|
||||
/// Receiver class for the TraceService events
|
||||
/// </summary>
|
||||
public class TraceabilityReceiver : IDisposable, IReceiver
|
||||
{
|
||||
#region Fields
|
||||
|
||||
OIBEventHandler _eventHandler;
|
||||
readonly OibClient.OibTraceabilityEvents _oibTraceabilityEvents;
|
||||
readonly OperatorNotificationManager _operatorNotificationManager;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public TraceabilityReceiver(OibClient.OibTraceabilityEvents oibTraceEvents, OIBEventHandler eventHandler, OperatorNotificationManager operatorNotificationManager)
|
||||
{
|
||||
if (oibTraceEvents == null) throw new ArgumentNullException("oibTraceEvents");
|
||||
if (eventHandler == null) throw new ArgumentNullException("eventHandler");
|
||||
if (operatorNotificationManager == null) throw new ArgumentNullException("operatorNotificationManager");
|
||||
|
||||
_oibTraceabilityEvents = oibTraceEvents;
|
||||
_eventHandler = eventHandler;
|
||||
_operatorNotificationManager = operatorNotificationManager;
|
||||
|
||||
oibTraceEvents.TraceabilityData = TraceDataReceived;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Start/Stop
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_oibTraceabilityEvents.Start();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
_oibTraceabilityEvents.Stop();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Handling of events
|
||||
|
||||
|
||||
public bool TraceDataReceived(SiplaceNS.TraceabilityData traceabilityData)
|
||||
{
|
||||
try
|
||||
{
|
||||
LogHandler.log(Constants.LOGGER, TraceEventType.Information, "ITraceabilityOibService.NewTraceabilityData");
|
||||
if (_eventHandler != null)
|
||||
{
|
||||
|
||||
TraceabilityData itacTraceData = TraceabilityDataMapper.get(traceabilityData);
|
||||
BoardProducedResponse result = _eventHandler.boardProduced(itacTraceData);
|
||||
if (result.BoardValidationResult == 2)
|
||||
{
|
||||
LogHandler.log(Constants.LOGGER, TraceEventType.Information, "received the RC_TRCDATA_REJECTED return code");
|
||||
try
|
||||
{
|
||||
_operatorNotificationManager.TraceDataRejected("Die letzte Station wurde gestoppt, da iTac die Tracedaten als fehlerhaft erkannt hat.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHandler.log(Constants.LOGGER, TraceEventType.Error, "calling OperatorNotificationManager failed", ex);
|
||||
}
|
||||
}
|
||||
else if (result.BoardValidationReason.StartsWith("RC_TRCDATA_REJECTED:"))
|
||||
{
|
||||
string message = result.BoardValidationReason.Replace("RC_TRCDATA_REJECTED:", "");
|
||||
LogHandler.log(Constants.LOGGER, TraceEventType.Information, "received the RC_TRCDATA_REJECTED return code with additional l message text " + message);
|
||||
try
|
||||
{
|
||||
_operatorNotificationManager.TraceDataRejected(message);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHandler.log(Constants.LOGGER, TraceEventType.Error, "calling OperatorNotificationManager failed", ex);
|
||||
}
|
||||
}
|
||||
//response.BoardValidationResult = 2;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHandler.log(Constants.LOGGER, TraceEventType.Warning, "calling ITraceabilityOibService.NewTraceabilityData not performed");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// der letzte Aufruf schlug fehl!!
|
||||
LogHandler.log(Constants.LOGGER, TraceEventType.Error, "calling NewTraceabilityData in eventHandler failed", e);
|
||||
}
|
||||
// response.BoardValidationResult = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region IDisposeable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_oibTraceabilityEvents != null)
|
||||
_oibTraceabilityEvents.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user