/// <summary> /// Receives tracking events. Instance terminated events are written to the event log. /// </summary> protected override void Send(TrackingRecord record) { WorkflowTrackingRecord instanceTrackingRecord = record as WorkflowTrackingRecord; if ((null == instanceTrackingRecord) || (TrackingWorkflowEvent.Terminated != instanceTrackingRecord.TrackingWorkflowEvent)) { return; } // Create an EventLog instance and assign its source. EventLog log = new EventLog(); log.Source = sourceValue; // Write an informational entry to the event log. TrackingWorkflowTerminatedEventArgs terminatedEventArgs = instanceTrackingRecord.EventArgs as TrackingWorkflowTerminatedEventArgs; StringBuilder message = new StringBuilder(512); message.AppendLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, "Workflow instance {0} has been terminated.", parametersValue.InstanceId.ToString())); message.AppendLine(); if (null != terminatedEventArgs.Exception) { message.AppendLine(terminatedEventArgs.Exception.ToString()); } log.WriteEntry(message.ToString(), EventLogEntryType.Warning); }
static void WriteTerminatedEventArgs(string eventDescription, TrackingWorkflowTerminatedEventArgs terminatedEventArgs, DateTime eventDataTime) { Console.WriteLine("\nTerminated Event Arguments Read From Tracking Database:\n"); Console.WriteLine("EventDataTime: " + eventDataTime.ToString()); Console.WriteLine("EventDescription: " + eventDescription); if (null != terminatedEventArgs.Exception) { Console.WriteLine("TerminatedEventArgs Exception Message: " + terminatedEventArgs.Exception.Message.ToString()); } }
private void NotifyChannels(TrackingWorkflowEvent evt, WorkflowExecutor.WorkflowExecutionEventArgs e, WorkflowExecutor exec) { DateTime utcNow = DateTime.UtcNow; int nextEventOrderId = this._broker.GetNextEventOrderId(); foreach (TrackingChannelWrapper wrapper in this._channels) { WorkflowExecutor.WorkflowExecutionTerminatingEventArgs args2; WorkflowTrackingRecord record; EventArgs eventArgs = null; switch (evt) { case TrackingWorkflowEvent.Exception: { WorkflowExecutor.WorkflowExecutionExceptionEventArgs args3 = (WorkflowExecutor.WorkflowExecutionExceptionEventArgs)e; eventArgs = new TrackingWorkflowExceptionEventArgs(args3.Exception, args3.CurrentPath, args3.OriginalPath, args3.ContextGuid, args3.ParentContextGuid); goto Label_00BC; } case TrackingWorkflowEvent.Terminated: args2 = (WorkflowExecutor.WorkflowExecutionTerminatingEventArgs)e; if (args2.Exception == null) { break; } eventArgs = new TrackingWorkflowTerminatedEventArgs(args2.Exception); goto Label_00BC; case TrackingWorkflowEvent.Suspended: eventArgs = new TrackingWorkflowSuspendedEventArgs(((WorkflowExecutor.WorkflowExecutionSuspendingEventArgs)e).Error); goto Label_00BC; default: goto Label_00BC; } eventArgs = new TrackingWorkflowTerminatedEventArgs(args2.Error); Label_00BC: record = new WorkflowTrackingRecord(evt, utcNow, nextEventOrderId, eventArgs); if (wrapper.GetTrackingProfile(exec).TryTrackInstanceEvent(evt, record)) { wrapper.TrackingChannel.Send(record); } } }
protected void Page_Load(object sender, EventArgs e) { SqlTrackingQueryOptions options = new SqlTrackingQueryOptions(); options.WorkflowStatus = WorkflowStatus.Running; SqlTrackingQuery query = new SqlTrackingQuery(ConfigurationManager.ConnectionStrings["workflows"].ConnectionString); IList <SqlTrackingWorkflowInstance> workflows = query.GetWorkflows(options); foreach (SqlTrackingWorkflowInstance workflow in workflows) { foreach (WorkflowTrackingRecord workflowEvent in workflow.WorkflowEvents) { TrackingWorkflowTerminatedEventArgs args = workflowEvent.EventArgs as TrackingWorkflowTerminatedEventArgs; if (args != null) { Response.Write(workflow.WorkflowInstanceId + ": " + args.Exception.Message); } } } }