/// <summary> /// Event handler for the NewWindow event. /// </summary> /// <param name="sender">Events Service</param> /// <param name="e">The NewWindow event args</param> private void JetstreamService_NewWindow(object sender, NewWindowEventArgs e) { // lock so we process all events in order lock (_newWindowLock) { foreach (TersoSolutions.Jetstream.SDK.Application.Messages.JetstreamEvent m in e.Messages) { try { Debug.WriteLine("Jetstream Message: " + m.EventType); // now we can deserialize the XML message into the appropriate message switch (m.EventType.Trim().ToLower()) { case "aggregateevent": { AE.Jetstream message = (AE.Jetstream)m; ProcessAggregateEvent(message); break; } case "commandcompletionevent": { CCE.Jetstream message = (CCE.Jetstream)m; ProcessCommandCompletionEvent(message); break; } case "commandqueuedevent": { CQE.Jetstream message = (CQE.Jetstream)m; ProcessCommandQueuedEvent(message); break; } case "devicefailureevent": { DFE.Jetstream message = (DFE.Jetstream)m; ProcessDeviceFailureEvent(message); break; } case "devicerestoreevent": { DRE.Jetstream message = (DRE.Jetstream)m; ProcessDeviceRestoreEvent(message); break; } case "heartbeatevent": { HE.Jetstream message = (HE.Jetstream)m; ProcessHeartbeatEvent(message); break; } case "logentryevent": { LEE.Jetstream message = (LEE.Jetstream)m; ProcessLogEntryEvent(message); break; } case "logicaldeviceaddedevent": { LDAE.Jetstream message = (LDAE.Jetstream)m; ProcessLogicalDeviceAddedEvent(message); break; } case "logicaldeviceremovedevent": { LDRE.Jetstream message = (LDRE.Jetstream)m; ProcessLogicalDeviceRemovedEvent(message); break; } case "objectevent": { OE.Jetstream message = (OE.Jetstream)m; ProcessObjectEvent(message); break; } case "sensorreadingevent": { SRE.Jetstream message = (SRE.Jetstream)m; ProcessSensorReadingEvent(message); break; } default: { ProcessUnknownMessage(m.ToString()); break; } } } catch (Exception ex) { EventLog.WriteEntry("JetstreamSDK", ex.Message + "\n" + ex.StackTrace); } } } }
/// <summary> /// Method for processing a new <paramref name="commandCompletionEvent"/> /// </summary> /// <param name="commandCompletionEvent"> /// Deserialized CommandCompletionEvent message in the xsd.exe object model. /// </param> protected virtual void ProcessCommandCompletionEvent(CCE.Jetstream commandCompletionEvent) { }
public void CommandCompletionEventTest() { CCE.JetstreamHeader cqHeader = new CCE.JetstreamHeader(); CCE.Jetstream commandCompletionEvent = new CCE.Jetstream(); CCE.JetstreamCommandCompletionEvent ccEvent = new CCE.JetstreamCommandCompletionEvent(); ccEvent.CommandId = Convert.ToString(Guid.NewGuid()); CCE.JetstreamCommandCompletionEventDeviceExtensionList ccDevExtEvent = new CCE.JetstreamCommandCompletionEventDeviceExtensionList(); CCE.JetstreamCommandCompletionEventExceptionList ccEvntExpLst = new CCE.JetstreamCommandCompletionEventExceptionList(); CCE.JetstreamCommandCompletionEventDeviceExtensionListDeviceExtension[] devEpt = new CCE.JetstreamCommandCompletionEventDeviceExtensionListDeviceExtension[1]; devEpt[0] = new CCE.JetstreamCommandCompletionEventDeviceExtensionListDeviceExtension { Name = "NameWindCCEvt" + LogicalDeviceId, Value = "ValCC" + LogicalDeviceId }; CCE.JetstreamCommandCompletionEventOutputParameterList ccCompoutParamLst = new CCE.JetstreamCommandCompletionEventOutputParameterList(); CCE.JetstreamCommandCompletionEventExceptionListException[] ccEvtExplstExp = new CCE.JetstreamCommandCompletionEventExceptionListException[1]; ccEvtExplstExp[0] = new CCE.JetstreamCommandCompletionEventExceptionListException { Message = "WindMsg" + LogicalDeviceId, Name = "Name" + LogicalDeviceId }; CCE.JetstreamCommandCompletionEventOutputParameterListOutputParameter[] outparam = new CCE.JetstreamCommandCompletionEventOutputParameterListOutputParameter[1]; outparam[0] = new CCE.JetstreamCommandCompletionEventOutputParameterListOutputParameter { Name = "WindName" + LogicalDeviceId, Value = "Val" + LogicalDeviceId }; commandCompletionEvent.CommandCompletionEvent = ccEvent; commandCompletionEvent.CommandCompletionEvent.DeviceExtensionList = ccDevExtEvent; commandCompletionEvent.CommandCompletionEvent.DeviceExtensionList.DeviceExtension = devEpt; commandCompletionEvent.CommandCompletionEvent.ExceptionList = ccEvntExpLst; commandCompletionEvent.CommandCompletionEvent.ExceptionList.Exception = ccEvtExplstExp; commandCompletionEvent.CommandCompletionEvent.OutputParameterList = ccCompoutParamLst; commandCompletionEvent.CommandCompletionEvent.OutputParameterList.OutputParameter = outparam; # region window service string commandId = commandCompletionEvent.CommandCompletionEvent.CommandId; if (commandCompletionEvent.CommandCompletionEvent.DeviceExtensionList.DeviceExtension != null) { // collect and record each of the device extension name/value pairs foreach (var deviceExtension in commandCompletionEvent.CommandCompletionEvent.DeviceExtensionList.DeviceExtension) { //JetstreamEventRepository.RecordCommandCompletionEvent(commandId, "DeviceExtension", deviceExtension.Name, deviceExtension.Value); } } if (commandCompletionEvent.CommandCompletionEvent.ExceptionList.Exception != null) { // collect and record each of the exception name/value pairs foreach (var exception in commandCompletionEvent.CommandCompletionEvent.ExceptionList.Exception) { //JetstreamEventRepository.RecordCommandCompletionEvent(commandId, "Exception", exception.Name, exception.Message); } } if (commandCompletionEvent.CommandCompletionEvent.OutputParameterList.OutputParameter != null) { // collect and record each of the output parameter name/value pairs foreach (var outputParameter in commandCompletionEvent.CommandCompletionEvent.OutputParameterList.OutputParameter) { //JetstreamEventRepository.RecordCommandCompletionEvent(CommandId, "OutputParameter", outputParameter.Name, outputParameter.Value); } } #endregion }