public Save ( |
||
settings | ||
Résultat | void |
private static void WriteBackAbortMessage(WorkflowHandlerBase stateContent, string abortMessage) { try { var state = stateContent.WorkflowStatus; if (state == WorkflowStatusEnum.Completed) { return; } // if a system message has already been persisted to the workflow content, don't overwrite it if (!string.IsNullOrEmpty(stateContent.SystemMessages)) { return; } var times = 3; while (true) { try { stateContent.SystemMessages = abortMessage; stateContent.DisableObserver(typeof(WorkflowNotificationObserver)); Debug.WriteLine("##WF> Workflow aborted. Reason: " + abortMessage + ". InstanceId: " + stateContent.WorkflowInstanceGuid); using (new SystemAccount()) stateContent.Save(SenseNet.ContentRepository.SavingMode.KeepVersion); break; } catch (NodeIsOutOfDateException ne) { if (--times == 0) { throw new NodeIsOutOfDateException("Node is out of date after 3 trying", ne); } var msg = "InstanceManager: Saving system message caused NodeIsOutOfDateException. Trying again."; Logger.WriteVerbose(msg); Debug.WriteLine("##WF> ERROR " + msg); stateContent = (WorkflowHandlerBase)Node.LoadNodeByVersionId(stateContent.VersionId); } catch (Exception e) { var msg = String.Format("InstanceManager: Cannot write back a system message to the workflow state content. InstanceId: {0}. Path: {1}. Message: {2}. InstanceId: {3}." , stateContent.Id, stateContent.Path, abortMessage, stateContent.WorkflowInstanceGuid); Debug.WriteLine("##WF> ERROR " + msg); Logger.WriteWarning(Logger.EventId.NotDefined, msg, properties: new Dictionary <string, object> { { "Exception", e } }); break; } } } catch (Exception e) { WriteError("WriteBackAbortMessage#2", e); throw; } }
//=========================================================================================================== Operations public static Guid Start(WorkflowHandlerBase workflowInstance) { var wfApp = CreateWorkflowApplication(workflowInstance, WorkflowApplicationCreationPurpose.StartNew, null); var id = wfApp.Id; workflowInstance.WorkflowStatus = WorkflowStatusEnum.Running; workflowInstance.DisableObserver(typeof(WorkflowNotificationObserver)); using (new SystemAccount()) workflowInstance.Save(); Debug.WriteLine("##WF> Starting id: " + id); wfApp.Run(); return(id); }
//=========================================================================================================== Operations public static Guid Start(WorkflowHandlerBase workflowInstance) { try { var wfApp = CreateWorkflowApplication(workflowInstance, WorkflowApplicationCreationPurpose.StartNew, null); var id = wfApp.Id; workflowInstance.WorkflowStatus = WorkflowStatusEnum.Running; workflowInstance.DisableObserver(typeof(WorkflowNotificationObserver)); using (new SystemAccount()) workflowInstance.Save(); wfApp.Run(); return(id); } catch (Exception e) { WriteError("Start", e); throw; } }
private static void WriteBackAbortMessage(WorkflowHandlerBase stateContent, string abortMessage) { var state = stateContent.WorkflowStatus; if (state == WorkflowStatusEnum.Completed) return; // if a system message has already been persisted to the workflow content, don't overwrite it if (!string.IsNullOrEmpty(stateContent.SystemMessages)) return; var times = 3; while (true) { try { stateContent.SystemMessages = abortMessage; stateContent.DisableObserver(typeof(WorkflowNotificationObserver)); using (new SystemAccount()) stateContent.Save(SenseNet.ContentRepository.SavingMode.KeepVersion); break; } catch (NodeIsOutOfDateException ne) { if (--times == 0) throw new NodeIsOutOfDateException("Node is out of date after 3 trying", ne); var msg = "InstanceManager: Saving system message caused NodeIsOutOfDateException. Trying again."; Logger.WriteVerbose(msg); Debug.WriteLine("##WF> " + msg); stateContent = (WorkflowHandlerBase)Node.LoadNodeByVersionId(stateContent.VersionId); } catch (Exception e) { var msg = String.Format("InstanceManager: Cannot write back a system message to the workflow state content. InstanceId: {0}. Path: {1}. Message: {2}" , stateContent.Id, stateContent.Path, abortMessage); Debug.WriteLine("##WF> " + msg); Logger.WriteWarning(msg, Logger.EmptyCategoryList, new Dictionary<string, object> { { "Exception", e } }); break; } } }
//=========================================================================================================== Operations public static Guid Start(WorkflowHandlerBase workflowInstance) { var wfApp = CreateWorkflowApplication(workflowInstance, WorkflowApplicationCreationPurpose.StartNew, null); var id = wfApp.Id; workflowInstance.WorkflowStatus = WorkflowStatusEnum.Running; workflowInstance.DisableObserver(typeof(WorkflowNotificationObserver)); using (new SystemAccount()) workflowInstance.Save(); Debug.WriteLine("##WF> Starting id: " + id); wfApp.Run(); return id; }