示例#1
0
 private WorkflowStatus CreateStatus(WorkflowStatusType status, string desc)
 {
     return(new WorkflowStatus
     {
         Status = status.ToString(),
         Description = desc
     });
 }
示例#2
0
 protected override WorkflowStatusType HandleWorklistFailure(CloudCoreDB db, long instanceId, int? activityId, string msg, int maxRetries, int retries)
 {
     StatusResult = base.HandleWorklistFailure(db, instanceId, activityId, msg, maxRetries, retries);
     return StatusResult;
 }
示例#3
0
        /// <summary>
        /// Complete Workflow
        /// </summary>
        /// <param name="workflowOid">Workflow Oid</param>
        /// <param name="workflowStatusType">Workflow status</param>
        /// <param name="result">Result</param>
        /// <param name="message">Custom message</param>
        public void CompleteWorkflow(Guid workflowOid, WorkflowStatusType workflowStatusType, string result, string message)
        {
            WorkflowDefinition wfd;

            using (var uofw = new FlowTasksUnitOfWork())
            {
                wfd = uofw.WorkflowDefinitions.First(w => w.WorkflowOid == workflowOid, w => w.WorkflowStatus,
                                                     w => w.WorkflowCode);

                var status = workflowStatusType.ToString();
                var wfs    = uofw.WorkflowStatuses.First(s => s.Status == status);

                // Only workflow in progress
                if (wfd.WorkflowStatus.Status != WorkflowStatusType.InProgress.ToString())
                {
                    return;
                }

                // Only complete the children if status is terminated or aborted ie user intervention
                if (workflowStatusType != WorkflowStatusType.Completed)
                {
                    var wfdChilds = uofw.WorkflowDefinitions.Find(w => w.WorkflowParentDefinitionId == wfd.WorkflowDefinitionId);

                    foreach (var child in wfdChilds)
                    {
                        CompleteWorkflow(child.WorkflowOid, workflowStatusType, result, string.Empty);
                    }
                }

                var tkd = uofw.TaskDefinitions.Find(t => t.WorkflowDefinition.WorkflowOid == workflowOid);
                foreach (var t in tkd)
                {
                    _task.CompleteTask(t.TaskOid, Properties.Resources.TASK_TERMINATED, string.Empty);
                }

#if DELETE_IN_PARAMETERS
                /*
                 *  if you use this you will not been able to restart a wf and bring it to
                 *  the existing step
                 */
                var wfInParm = uofw.WorkflowInParameters.Find(wip => wip.WorkflowDefinitionId == wfd.WorkflowDefinitionId, p => p.Property)
                               .Select(wip => wip.Property).ToList();

                var wfProp = uofw.WorkflowProperties.Find(p => p.WorkflowCode.Code == wfd.WorkflowCode.Code, p => p.Property)
                             .Select(p => p.Property).ToList();

                var wfOutParam = uofw.WorkflowOutParameters.Find(p => p.WorkflowDefinitionId == wfd.WorkflowDefinitionId, p => p.Property)
                                 .Select(p => p.Property).ToList();

                // Delete all the property a part from the ones in :
                // WorkflowProperties and WorkflowOutParameters
                // I need those properties when I want to manualy restart
                // the workflow
                foreach (var p in wfInParm)
                {
                    if (!wfProp.Contains(p) && !wfOutParam.Contains(p))
                    {
                        uofw.Properties.Delete(p);
                    }
                }
#endif
                wfd.WorkflowStatus = wfs;
                wfd.CompletedOn    = DateTime.Now;

                uofw.Commit();
            }

            _tracer.Trace(workflowOid, ActionTrace.WorkflowCompleted, wfd.WorkflowCode.Code,
                          result, string.Empty, string.Format(Properties.Resources.WF_COMPLETED,
                                                              workflowStatusType.ToString() + (string.IsNullOrWhiteSpace(message) ? string.Empty : " - " + message)), TraceEventType.Activity);
        }