Example #1
0
        /// <summary>
        /// Forwards the workflow events.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void workflowHost_WorkflowEvent(object sender, HostEventArgs e)
        {
            lastTimeActive = DateTime.Now;

            // Assume that event is wired-up, otherwise it won't work anyway
            WorkflowEvent(this, e);
        }
Example #2
0
        /// <summary>
        /// Finished the execution of a job and records the results in the registry.
        /// </summary>
        /// <param name="workflowInstanceId"></param>
        /// <param name="eventType"></param>
        private void FinishJob(Job job, HostEventArgs e)
        {
            using (Context context = ContextManager.Instance.CreateContext(ConnectionMode.AutoOpen, TransactionMode.AutoCommit))
            {
                context.JobGuid     = job.Guid;
                context.ContextGuid = contextGuid;

                JobInstance ji = new JobInstance(context);
                ji.Guid = job.Guid;
                ji.Load();

                // Update execution status, error message and finish time
                switch (e.EventType)
                {
                case WorkflowEventType.Completed:
                    ji.JobExecutionStatus = JobExecutionState.Completed;
                    break;

                case WorkflowEventType.Cancelled:
                    ji.JobExecutionStatus = JobExecutionState.Cancelled;
                    break;

                case WorkflowEventType.TimedOut:
                    ji.JobExecutionStatus = JobExecutionState.TimedOut;
                    break;

                case WorkflowEventType.Persisted:
                    ji.JobExecutionStatus = JobExecutionState.Persisted;
                    break;

                case WorkflowEventType.Failed:
                    ji.JobExecutionStatus = JobExecutionState.Failed;
                    ji.ExceptionMessage   = e.ExceptionMessage;
                    break;
                }

                // Update registry
                ji.DateFinished = DateTime.Now;
                ji.Save();

                ji.ReleaseLock(false);
                ji.RescheduleIfRecurring();

                // Do local bookkeeping
                lock (runningJobs)
                {
                    lock (Cluster.Queues[job.QueueGuid].Jobs)
                    {
                        Cluster.Queues[job.QueueGuid].Jobs.Remove(job.Guid);
                    }

                    runningJobs.Remove(job.WorkflowInstanceId);
                }

                if (interactive)
                {
                    Console.WriteLine("Finishing job: {0}", ji.Guid);
                }
            }
        }
Example #3
0
        /// <summary>
        /// Handles events raised by any AppDomainHost
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void adh_WorkflowEvent(object sender, HostEventArgs e)
        {
            // Find job by e.InstanceId
            Job job;

            lock (runningJobs)
            {
                job = runningJobs[e.InstanceId];
            }

            FinishJob(job, e);
        }
Example #4
0
        /// <summary>
        /// Finished the execution of a job and records the results in the registry.
        /// </summary>
        /// <param name="workflowInstanceId"></param>
        /// <param name="eventType"></param>
        private void FinishJob(Job job, HostEventArgs e)
        {
            using (Context context = ContextManager.Instance.CreateContext(ConnectionMode.AutoOpen, TransactionMode.AutoCommit))
            {
                context.JobGuid = job.Guid;
                context.ContextGuid = contextGuid;

                JobInstance ji = new JobInstance(context);
                ji.Guid = job.Guid;
                ji.Load();

                // Update execution status, error message and finish time
                switch (e.EventType)
                {
                    case WorkflowEventType.Completed:
                        ji.JobExecutionStatus = JobExecutionState.Completed;
                        break;
                    case WorkflowEventType.Cancelled:
                        ji.JobExecutionStatus = JobExecutionState.Cancelled;
                        break;
                    case WorkflowEventType.TimedOut:
                        ji.JobExecutionStatus = JobExecutionState.TimedOut;
                        break;
                    case WorkflowEventType.Persisted:
                        ji.JobExecutionStatus = JobExecutionState.Persisted;
                        break;
                    case WorkflowEventType.Failed:
                        ji.JobExecutionStatus = JobExecutionState.Failed;
                        ji.ExceptionMessage = e.ExceptionMessage;
                        break;
                }

                // Update registry
                ji.DateFinished = DateTime.Now;
                ji.Save();

                ji.ReleaseLock(false);
                ji.RescheduleIfRecurring();

                // Do local bookkeeping
                lock (runningJobs)
                {
                    lock (Cluster.Queues[job.QueueGuid].Jobs)
                    {
                        Cluster.Queues[job.QueueGuid].Jobs.Remove(job.Guid);
                    }

                    runningJobs.Remove(job.WorkflowInstanceId);
                }

                if (interactive)
                {
                    Console.WriteLine("Finishing job: {0}", ji.Guid);
                }
            }
        }
Example #5
0
        /// <summary>
        /// Handles events raised by any AppDomainHost
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void adh_WorkflowEvent(object sender, HostEventArgs e)
        {
            // Find job by e.InstanceId
            Job job;
            lock (runningJobs)
            {
                job = runningJobs[e.InstanceId];
            }

            FinishJob(job, e);
        }
Example #6
0
        /// <summary>
        /// Forwards the workflow events.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void workflowHost_WorkflowEvent(object sender, HostEventArgs e)
        {
            lastTimeActive = DateTime.Now;

            // Assume that event is wired-up, otherwise it won't work anyway
            WorkflowEvent(this, e);
        }