public IWorkflowExecutionResult Continue(WorkflowContextBase pendingWorkflow)
 {
     try
     {
         var wf = GetWorkflowInstance(pendingWorkflow);
         //restore state
         wf.RestoreState(pendingWorkflow);
         //Continue
         var status = wf.Continue(pendingWorkflow.PendingStep);
         if (status == WorkflowStatus.Completed)
         {
             //remove from list
             RemovePendingJob(pendingWorkflow);
         }
         return(new WorkflowExecutionResult {
             Context = pendingWorkflow, Status = status
         });
     }
     catch (Exception e)
     {
         log4net.LogManager.GetLogger(GetType()).Error($"Error continuing pending Workflow '{pendingWorkflow?.Name}' !", e);
         return(new WorkflowExecutionResult {
             Context = pendingWorkflow, Status = WorkflowStatus.Failed
         });
     }
 }
Exemple #2
0
 public void DeleteWorkflowContextBase(zAppDev.DotNet.Framework.Workflow.WorkflowContextBase workflowcontextbase, bool doNotCallDeleteForThis = false, bool isCascaded = false, object calledBy = null)
 {
     if (workflowcontextbase == null || workflowcontextbase.IsTransient())
     {
         return;
     }
     if (!doNotCallDeleteForThis)
     {
         Delete <zAppDev.DotNet.Framework.Workflow.WorkflowContextBase>(workflowcontextbase, isCascaded);
     }
 }
 private IWorkflowExecutionResult RemovePendingJob(WorkflowContextBase pendingWorkflow)
 {
     try
     {
         Builder.CreateWorkflowRepository().DeleteWorkflowContextBase(pendingWorkflow);
         return(new WorkflowExecutionResult {
             Context = pendingWorkflow, Status = WorkflowStatus.Completed
         });
     }
     catch (Exception e)
     {
         log4net.LogManager.GetLogger(GetType()).Error($"Error removing pending Workflow '{pendingWorkflow?.Name}' !", e);
         return(new WorkflowExecutionResult {
             Context = pendingWorkflow, Status = WorkflowStatus.Failed
         });
     }
 }
Exemple #4
0
 /// <summary>
 ///     Returns true if self and the provided entity have the same Id values
 ///     and the Ids are not of the default Id value
 /// </summary>
 protected bool HasSameNonDefaultIdAs(WorkflowContextBase compareTo)
 {
     return(!this.IsTransient() && !compareTo.IsTransient() && this.Id.Equals(compareTo.Id));
 }
Exemple #5
0
 /// <summary>
 /// Copies the current object to a new instance
 /// </summary>
 /// <param name="deep">Copy members that refer to objects external to this class (not dependent)</param>
 /// <param name="copiedObjects">Objects that should be reused</param>
 /// <param name="asNew">Copy the current object as a new one, ready to be persisted, along all its members.</param>
 /// <param name="reuseNestedObjects">If asNew is true, this flag if set, forces the reuse of all external objects.</param>
 /// <param name="copy">Optional - An existing [WorkflowContextBase] instance to use as the destination.</param>
 /// <returns>A copy of the object</returns>
 public virtual WorkflowContextBase Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, WorkflowContextBase copy = null)
 {
     if (copiedObjects == null)
     {
         copiedObjects = new Hashtable();
     }
     if (copy == null && copiedObjects.Contains(this))
     {
         return((WorkflowContextBase)copiedObjects[this]);
     }
     copy = copy ?? new WorkflowContextBase();
     if (!asNew)
     {
         copy.TransientId = this.TransientId;
         copy.Id          = this.Id;
     }
     copy.Name                = this.Name;
     copy.Error               = this.Error;
     copy.Expires             = this.Expires;
     copy.ExpirationDateTime  = this.ExpirationDateTime;
     copy.PendingSince        = this.PendingSince;
     copy.PendingJobCreatedBy = this.PendingJobCreatedBy;
     copy.PendingStep         = this.PendingStep;
     copy.Status              = this.Status;
     if (!copiedObjects.Contains(this))
     {
         copiedObjects.Add(this, copy);
     }
     if (deep && this.result != null)
     {
         if (!copiedObjects.Contains(this.result))
         {
             if (asNew && reuseNestedObjects)
             {
                 copy.Result = this.Result;
             }
             else if (asNew)
             {
                 copy.Result = this.Result.Copy(deep, copiedObjects, true);
             }
             else
             {
                 copy.result = this.result.Copy(deep, copiedObjects, false);
             }
         }
         else
         {
             if (asNew)
             {
                 copy.Result = (WorkflowExecutionResult)copiedObjects[this.Result];
             }
             else
             {
                 copy.result = (WorkflowExecutionResult)copiedObjects[this.Result];
             }
         }
     }
     return(copy);
 }
Exemple #6
0
 public abstract void RestoreState(WorkflowContextBase wfBase);
 private WorkflowImplementation GetWorkflowInstance(WorkflowContextBase pendingJob)
 {
     return(GetWorkflowInstance(pendingJob.Name));
 }