private void SetCustomStatus(Guid processId, ProcessStatus status, bool createIfnotDefined = false) { using (OracleConnection connection = new OracleConnection(ConnectionString)) { var instanceStatus = WorkflowProcessInstanceStatus.SelectByKey(connection, processId); if (instanceStatus == null) { if (!createIfnotDefined) { throw new StatusNotDefinedException(); } instanceStatus = new WorkflowProcessInstanceStatus() { Id = processId, LOCKFLAG = Guid.NewGuid(), Status = ProcessStatus.Initialized.Id }; instanceStatus.Insert(connection); } else { instanceStatus.Status = ProcessStatus.Initialized.Id; instanceStatus.Update(connection); } WorkflowProcessInstanceStatus.Commit(connection); } }
public void SetWorkflowRunning(ProcessInstance processInstance) { using (OracleConnection connection = new OracleConnection(ConnectionString)) { var instanceStatus = WorkflowProcessInstanceStatus.SelectByKey(connection, processInstance.ProcessId); if (instanceStatus == null) { throw new StatusNotDefinedException(); } if (instanceStatus.Status == ProcessStatus.Running.Id) { throw new ImpossibleToSetStatusException(); } instanceStatus.LOCKFLAG = Guid.NewGuid(); instanceStatus.Status = ProcessStatus.Running.Id; instanceStatus.Update(connection); WorkflowProcessInstanceStatus.Commit(connection); } }