public IWorkflowExecutionResult ExecuteSchedule(WorkflowSchedule schedule)
        {
            _log.Debug("------------------------------------------------------");
            _log.DebugFormat("Executing Scheduled Activity: {0} - {1}", schedule.Workflow, schedule.Workflow);
            IWorkflowExecutionResult result = null;

            try
            {
                MiniSessionManager
                .ExecuteInUoW(manager =>
                {
                    result = WorkflowManager.Current.ExecuteWorkflow(schedule.Workflow);
                });
                schedule.IsLastExecutionSuccess = true;
                schedule.LastExecutionMessage   = "Executed Successfully";
            }
            catch (Exception ex)
            {
                _log.Error($"Error executing Scheduled Activity: {schedule.Workflow}", ex);
                schedule.IsLastExecutionSuccess = false;
                schedule.LastExecutionMessage   = $"{ex.Message} - {ex.StackTrace}";
                result = new WorkflowExecutionResult {
                    Status = WorkflowStatus.Failed
                };
            }
            schedule.LastExecution = DateTime.UtcNow;
            MiniSessionManager.ExecuteInUoW(manager =>
            {
                Builder.CreateCreateRepository(manager).Save(schedule);
            });
            _log.DebugFormat("Finished Executing Scheduled Activity: {0} - {1}", schedule.Workflow, schedule.Workflow);
            _log.Debug("------------------------------------------------------");
            return(result);
        }
 /// <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(WorkflowExecutionResult compareTo)
 {
     return(!IsTransient() && !compareTo.IsTransient() && WorkflowExecutionResultKey.Equals(compareTo.WorkflowExecutionResultKey));
 }
 /// <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 [WorkflowExecutionResult] instance to use as the destination.</param>
 /// <returns>A copy of the object</returns>
 public virtual WorkflowExecutionResult Copy(bool deep = false, Hashtable copiedObjects = null, bool asNew = false, bool reuseNestedObjects = false, WorkflowExecutionResult copy = null)
 {
     if (copiedObjects == null)
     {
         copiedObjects = new Hashtable();
     }
     if (copy == null && copiedObjects.Contains(this))
     {
         return((WorkflowExecutionResult)copiedObjects[this]);
     }
     copy = copy ?? new WorkflowExecutionResult();
     if (!asNew)
     {
         copy.TransientId = TransientId;
         copy.WorkflowExecutionResultKey = WorkflowExecutionResultKey;
     }
     copy.Status = Status;
     if (!copiedObjects.Contains(this))
     {
         copiedObjects.Add(this, copy);
     }
     if (deep && context != null)
     {
         if (!copiedObjects.Contains(context))
         {
             if (asNew && reuseNestedObjects)
             {
                 copy.Context = Context;
             }
             else if (asNew)
             {
                 copy.Context = Context.Copy(deep, copiedObjects, true);
             }
             else
             {
                 copy.context = context.Copy(deep, copiedObjects, false);
             }
         }
         else
         {
             if (asNew)
             {
                 copy.Context = (WorkflowContextBase)copiedObjects[Context];
             }
             else
             {
                 copy.context = (WorkflowContextBase)copiedObjects[Context];
             }
         }
     }
     return(copy);
 }