/// <summary> /// Processes queued event data messages by calling the delegates registered for the respective events. /// </summary> /// <param name="eventData">Event message received from the server.</param> private void ProcessEventData(IProcEventData eventData) { switch (eventData.Type) { case "NodeEventArgs": { // Get the node arguments from the document. NodeEventArgs nodeArgs = eventData.ToNodeEventArgs(); // Determine the type of event that occurred. switch (( EventType )Enum.Parse(typeof(EventType), nodeArgs.EventData)) { case EventType.NodeChanged: { if (onChangedNodeEvent != null) { Delegate[] cbList = onChangedNodeEvent.GetInvocationList(); foreach (IProcEventHandler cb in cbList) { try { cb(nodeArgs); } catch (Exception ex) { ReportError(new ApplicationException("Removing subscriber because of exception", ex)); onChangedNodeEvent -= cb; } } } break; } case EventType.NodeCreated: { if (onCreatedNodeEvent != null) { Delegate[] cbList = onCreatedNodeEvent.GetInvocationList(); foreach (IProcEventHandler cb in cbList) { try { cb(nodeArgs); } catch (Exception ex) { ReportError(new ApplicationException("Removing subscriber because of exception", ex)); onCreatedNodeEvent -= cb; } } } break; } case EventType.NodeDeleted: { if (onDeletedNodeEvent != null) { Delegate[] cbList = onDeletedNodeEvent.GetInvocationList(); foreach (IProcEventHandler cb in cbList) { try { cb(nodeArgs); } catch (Exception ex) { ReportError(new ApplicationException("Removing subscriber because of exception", ex)); onDeletedNodeEvent -= cb; } } } break; } } break; } case "CollectionSyncEventArgs": { if (onCollectionSyncEvent != null) { // Get the collection sync arguments from the document. CollectionSyncEventArgs collectionArgs = eventData.ToCollectionSyncEventArgs(); Delegate[] cbList = onCollectionSyncEvent.GetInvocationList(); foreach (IProcEventHandler cb in cbList) { try { cb(collectionArgs); } catch (Exception ex) { ReportError(new ApplicationException("Removing subscriber because of exception", ex)); onCollectionSyncEvent -= cb; } } } break; } case "FileSyncEventArgs": { if (onFileSyncEvent != null) { // Get the file sync arguments from the document. FileSyncEventArgs fileArgs = eventData.ToFileSyncEventArgs(); Delegate[] cbList = onFileSyncEvent.GetInvocationList(); foreach (IProcEventHandler cb in cbList) { try { cb(fileArgs); } catch (Exception ex) { ReportError(new ApplicationException("Removing subscriber because of exception", ex)); onFileSyncEvent -= cb; } } } break; } case "NotifyEventArgs": { if (onNotifyEvent != null) { // Get the notify arguments from the document. NotifyEventArgs notifyArgs = eventData.ToNotifyEventArgs(); Delegate[] cbList = onNotifyEvent.GetInvocationList(); foreach (IProcEventHandler cb in cbList) { try { cb(notifyArgs); } catch (Exception ex) { ReportError(new ApplicationException("Removing subscriber because of exception", ex)); onNotifyEvent -= cb; } } } break; } } }
/// <summary> /// Translates the information in the NotifyEventArgs object into the IProcEventData object. /// </summary> /// <param name="args">NotifyEventArgs containing the notify event information.</param> private void FromNotifyEventArgs(NotifyEventArgs args) { AddData(new IProcEventNameValue(NMA_TypeTag, args.EventData)); AddData(new IProcEventNameValue(NMA_TimeTag, args.TimeStamp.Ticks.ToString())); AddData(new IProcEventNameValue(NMA_MessageTag, args.Message)); }