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); } }
private void SetCustomStatus(Guid processId, ProcessStatus status, bool createIfnotDefined = false) { using (SqlConnection connection = new SqlConnection(ConnectionString)) { var instanceStatus = WorkflowProcessInstanceStatus.SelectByKey(connection, processId); if (instanceStatus == null) { if (!createIfnotDefined) { throw new StatusNotDefinedException(); } instanceStatus = new WorkflowProcessInstanceStatus() { Id = processId, Lock = Guid.NewGuid(), Status = ProcessStatus.Initialized.Id }; instanceStatus.Insert(connection); } else { var oldLock = instanceStatus.Lock; instanceStatus.Status = status.Id; instanceStatus.Lock = Guid.NewGuid(); var cnt = WorkflowProcessInstanceStatus.ChangeStatus(connection, instanceStatus, oldLock); if (cnt != 1) { throw new ImpossibleToSetStatusException(); } } } }