private void OnActivityStatusChanged(object sender, WorkflowExecutor.ActivityStatusChangeEventArgs eventArgs)
 {
     if (!this.isZombie && this.isAttached)
     {
         try
         {
             lock (this.eventLock)
             {
                 if (eventArgs.Activity.ExecutionStatus != ActivityExecutionStatus.Executing)
                 {
                     IWorkflowCoreRuntime workflowCoreRuntime = (IWorkflowCoreRuntime)sender;
                     Guid scheduleTypeId = this.GetScheduleTypeId(workflowCoreRuntime);
                     if (eventArgs.Activity.ExecutionStatus == ActivityExecutionStatus.Executing)
                     {
                         this.EnumerateEventHandlersForActivity(scheduleTypeId, eventArgs.Activity);
                     }
                     this.controllerConduit.BeforeActivityStatusChanged(this.programId, scheduleTypeId, workflowCoreRuntime.InstanceID, eventArgs.Activity.QualifiedName, this.GetHierarchicalId(eventArgs.Activity), eventArgs.Activity.ExecutionStatus, this.GetContextId(eventArgs.Activity));
                     this.controllerConduit.ActivityStatusChanged(this.programId, scheduleTypeId, workflowCoreRuntime.InstanceID, eventArgs.Activity.QualifiedName, this.GetHierarchicalId(eventArgs.Activity), eventArgs.Activity.ExecutionStatus, this.GetContextId(eventArgs.Activity));
                 }
             }
         }
         catch
         {
         }
     }
 }
Exemple #2
0
        internal void ActivityStatusChange(object sender, WorkflowExecutor.ActivityStatusChangeEventArgs e)
        {
            WorkflowTrace.Tracking.TraceInformation("TrackingListener::ActivityStatusChange - Received Activity Status Change Event for activity {0}", new object[] { e.Activity.QualifiedName });
            if (sender == null)
            {
                throw new ArgumentNullException("sender");
            }
            if (!typeof(WorkflowExecutor).IsInstanceOfType(sender))
            {
                throw new ArgumentException("sender");
            }
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }
            WorkflowExecutor exec = (WorkflowExecutor)sender;

            if ((this._channels == null) || (this._channels.Count <= 0))
            {
                WorkflowTrace.Tracking.TraceEvent(TraceEventType.Error, 0, ExecutionStringManager.NoChannels);
            }
            else
            {
                Activity activity = e.Activity;
                if (this.SubscriptionRequired(activity, exec))
                {
                    Guid empty       = Guid.Empty;
                    Guid contextGuid = Guid.Empty;
                    this.GetContext(activity, exec, out contextGuid, out empty);
                    DateTime utcNow           = DateTime.UtcNow;
                    int      nextEventOrderId = this._broker.GetNextEventOrderId();
                    foreach (TrackingChannelWrapper wrapper in this._channels)
                    {
                        ActivityTrackingRecord record = new ActivityTrackingRecord(activity.GetType(), activity.QualifiedName, contextGuid, empty, activity.ExecutionStatus, utcNow, nextEventOrderId, null);
                        if (wrapper.GetTrackingProfile(exec).TryTrackActivityEvent(activity, activity.ExecutionStatus, exec, record))
                        {
                            wrapper.TrackingChannel.Send(record);
                        }
                    }
                }
            }
        }