public void DeleteProcess(Guid processId) { using (NpgsqlConnection connection = new NpgsqlConnection(ConnectionString)) { WorkflowProcessInstance.Delete(connection, processId); WorkflowProcessInstanceStatus.Delete(connection, processId); WorkflowProcessInstancePersistence.DeleteByProcessId(connection, processId); WorkflowProcessTransitionHistory.DeleteByProcessId(connection, processId); WorkflowProcessTimer.DeleteByProcessId(connection, processId); } }
public void DeleteProcess(Guid processId) { using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); using (var transaction = connection.BeginTransaction()) { WorkflowProcessInstance.Delete(connection, processId, transaction); WorkflowProcessInstanceStatus.Delete(connection, processId, transaction); WorkflowProcessInstancePersistence.DeleteByProcessId(connection, processId, transaction); WorkflowProcessTransitionHistory.DeleteByProcessId(connection, processId, transaction); WorkflowProcessTimer.DeleteByProcessId(connection, processId, null, transaction); transaction.Commit(); } } }
/// <summary> /// 序列化TransitionDefinition的内容到WorkflowProcessTransitionHistory /// </summary> /// <param name="processInstance"></param> /// <param name="transition"></param> public void UpdatePersistenceState(ProcessInstance processInstance, TransitionDefinition transition) { using (WorkflowPersistenceModelDataContext workflowPersistenceModelDataContext = base.CreateContext()) { WorkflowProcessTransitionHistory entity = new WorkflowProcessTransitionHistory { ActorIdentityId = Guid.NewGuid(), ExecutorIdentityId = Guid.NewGuid(), Id = Guid.NewGuid(), IsFinalised = false, ProcessId = processInstance.ProcessId, FromActivityName = transition.From.Name, FromStateName = transition.From.State, ToActivityName = transition.To.Name, ToStateName = transition.To.State, TransitionClassifier = transition.Classifier.ToString(), TransitionTime = DateTime.Now }; workflowPersistenceModelDataContext.WorkflowProcessTransitionHistories.InsertOnSubmit(entity); workflowPersistenceModelDataContext.SubmitChanges(); } }
public List <ProcessHistoryItem> GetProcessHistory(Guid processId) { using (var connection = new SqlConnection(ConnectionString)) { return(WorkflowProcessTransitionHistory.SelectByProcessId(connection, processId) .Select(hi => new ProcessHistoryItem { ActorIdentityId = hi.ActorIdentityId, ExecutorIdentityId = hi.ExecutorIdentityId, FromActivityName = hi.FromActivityName, FromStateName = hi.FromStateName, IsFinalised = hi.IsFinalised, ProcessId = hi.ProcessId, ToActivityName = hi.ToActivityName, ToStateName = hi.ToStateName, TransitionClassifier = (TransitionClassifier)Enum.Parse(typeof(TransitionClassifier), hi.TransitionClassifier), TransitionTime = hi.TransitionTime, TriggerName = hi.TriggerName }) .ToList()); } }
public void UpdatePersistenceState(ProcessInstance processInstance, TransitionDefinition transition) { var paramIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterIdentityId.Name); var paramImpIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterImpersonatedIdentityId.Name); var identityId = paramIdentityId == null ? string.Empty : (string)paramIdentityId.Value; var impIdentityId = paramImpIdentityId == null ? identityId : (string)paramImpIdentityId.Value; using (OracleConnection connection = new OracleConnection(ConnectionString)) { WorkflowProcessInstance inst = WorkflowProcessInstance.SelectByKey(connection, processInstance.ProcessId); if (inst != null) { if (!string.IsNullOrEmpty(transition.To.State)) { inst.StateName = transition.To.State; } inst.ActivityName = transition.To.Name; inst.PreviousActivity = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousState = transition.From.State; } if (transition.Classifier == TransitionClassifier.Direct) { inst.PreviousActivityForDirect = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousStateForDirect = transition.From.State; } } else if (transition.Classifier == TransitionClassifier.Reverse) { inst.PreviousActivityForReverse = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousStateForReverse = transition.From.State; } } inst.Update(connection); } var history = new WorkflowProcessTransitionHistory() { ActorIdentityId = impIdentityId, ExecutorIdentityId = identityId, Id = Guid.NewGuid(), IsFinalised = false, ProcessId = processInstance.ProcessId, FromActivityName = transition.From.Name, FromStateName = transition.From.State, ToActivityName = transition.To.Name, ToStateName = transition.To.State, TransitionClassifier = transition.Classifier.ToString(), TransitionTime = _runtime.RuntimeDateTimeNow, TriggerName = string.IsNullOrEmpty(processInstance.ExecutedTimer) ? processInstance.CurrentCommand : processInstance.ExecutedTimer }; history.Insert(connection); WorkflowProcessTransitionHistory.Commit(connection); } }
/// <summary> /// 序列化TransitionDefinition的内容到WorkflowProcessTransitionHistory /// </summary> /// <param name="processInstance"></param> /// <param name="transition"></param> public void UpdatePersistenceState(ProcessInstance processInstance, TransitionDefinition transition) { using (WorkflowPersistenceModelDataContext workflowPersistenceModelDataContext = base.CreateContext()) { WorkflowProcessTransitionHistory entity = new WorkflowProcessTransitionHistory { ActorIdentityId = Guid.NewGuid(), ExecutorIdentityId = Guid.NewGuid(), Id = Guid.NewGuid(), IsFinalised = false, ProcessId = processInstance.ProcessId, FromActivityName = transition.From.Name, FromStateName = transition.From.State, ToActivityName = transition.To.Name, ToStateName = transition.To.State, TransitionClassifier = transition.Classifier.ToString(), TransitionTime = DateTime.Now }; workflowPersistenceModelDataContext.WorkflowProcessTransitionHistories.InsertOnSubmit(entity); workflowPersistenceModelDataContext.SubmitChanges(); } }
public void UpdatePersistenceState(ProcessInstance processInstance, TransitionDefinition transition) { var paramIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterIdentityId.Name); var paramImpIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterImpersonatedIdentityId.Name); string identityId = paramIdentityId == null || paramIdentityId.Value == null ? string.Empty : paramIdentityId.Value.ToString(); string impIdentityId = paramImpIdentityId == null || paramImpIdentityId.Value == null ? identityId : paramImpIdentityId.Value.ToString(); using (var context = CreateContext()) { WorkflowProcessInstance inst = context.WorkflowProcessInstances.FirstOrDefault(c => c.Id == processInstance.ProcessId); if (inst != null) { if (!string.IsNullOrEmpty(transition.To.State)) { inst.StateName = transition.To.State; } inst.ActivityName = transition.To.Name; inst.PreviousActivity = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousState = transition.From.State; } if (transition.Classifier == TransitionClassifier.Direct) { inst.PreviousActivityForDirect = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousStateForDirect = transition.From.State; } } else if (transition.Classifier == TransitionClassifier.Reverse) { inst.PreviousActivityForReverse = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousStateForReverse = transition.From.State; } } inst.ParentProcessId = processInstance.ParentProcessId; inst.RootProcessId = processInstance.RootProcessId; } var history = new WorkflowProcessTransitionHistory() { ActorIdentityId = impIdentityId, ExecutorIdentityId = identityId, Id = Guid.NewGuid(), IsFinalised = false, //TODO Зачем на м финализед тут???? ProcessId = processInstance.ProcessId, FromActivityName = transition.From.Name, FromStateName = transition.From.State, ToActivityName = transition.To.Name, ToStateName = transition.To.State, TransitionClassifier = transition.Classifier.ToString(), TransitionTime = _runtime.RuntimeDateTimeNow, TriggerName = string.IsNullOrEmpty(processInstance.ExecutedTimer) ? processInstance.CurrentCommand : processInstance.ExecutedTimer }; context.WorkflowProcessTransitionHistories.InsertOnSubmit(history); context.SubmitChanges(); } }
public void UpdatePersistenceState(ProcessInstance processInstance, TransitionDefinition transition) { var paramIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterIdentityId.Name); var paramImpIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterImpersonatedIdentityId.Name); string identityId = paramIdentityId == null ? string.Empty : (string)paramIdentityId.Value; string impIdentityId = paramImpIdentityId == null ? identityId : (string)paramImpIdentityId.Value; using (var session = Store.OpenSession()) { WorkflowProcessInstance inst = session.Load <WorkflowProcessInstance>(processInstance.ProcessId); if (inst != null) { if (!string.IsNullOrEmpty(transition.To.State)) { inst.StateName = transition.To.State; } inst.ActivityName = transition.To.Name; inst.PreviousActivity = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousState = transition.From.State; } if (transition.Classifier == TransitionClassifier.Direct) { inst.PreviousActivityForDirect = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousStateForDirect = transition.From.State; } } else if (transition.Classifier == TransitionClassifier.Reverse) { inst.PreviousActivityForReverse = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousStateForReverse = transition.From.State; } } } var history = new WorkflowProcessTransitionHistory() { ActorIdentityId = impIdentityId, ExecutorIdentityId = identityId, Id = Guid.NewGuid(), IsFinalised = false, ProcessId = processInstance.ProcessId, FromActivityName = transition.From.Name, FromStateName = transition.From.State, ToActivityName = transition.To.Name, ToStateName = transition.To.State, TransitionClassifier = transition.Classifier.ToString(), TransitionTime = _runtime.RuntimeDateTimeNow, TriggerName = string.IsNullOrEmpty(processInstance.ExecutedTimer) ? processInstance.CurrentCommand : processInstance.ExecutedTimer }; session.Store(history); session.SaveChanges(); } }
public void UpdatePersistenceState(ProcessInstance processInstance, TransitionDefinition transition) { var paramIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterIdentityId.Name); var paramImpIdentityId = processInstance.GetParameter(DefaultDefinitions.ParameterImpersonatedIdentityId.Name); var identityId = paramIdentityId == null ? string.Empty : (string)paramIdentityId.Value; var impIdentityId = paramImpIdentityId == null ? identityId : (string)paramImpIdentityId.Value; var dbcoll = Store.GetCollection <WorkflowProcessInstance>(MongoDBConstants.WorkflowProcessInstanceCollectionName); WorkflowProcessInstance inst = dbcoll.FindOneById(processInstance.ProcessId); if (inst != null) { if (!string.IsNullOrEmpty(transition.To.State)) { inst.StateName = transition.To.State; } inst.ActivityName = transition.To.Name; inst.PreviousActivity = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousState = transition.From.State; } if (transition.Classifier == TransitionClassifier.Direct) { inst.PreviousActivityForDirect = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousStateForDirect = transition.From.State; } } else if (transition.Classifier == TransitionClassifier.Reverse) { inst.PreviousActivityForReverse = transition.From.Name; if (!string.IsNullOrEmpty(transition.From.State)) { inst.PreviousStateForReverse = transition.From.State; } } dbcoll.Save(inst); } var history = new WorkflowProcessTransitionHistory() { ActorIdentityId = impIdentityId, ExecutorIdentityId = identityId, Id = Guid.NewGuid(), IsFinalised = false, ProcessId = processInstance.ProcessId, FromActivityName = transition.From.Name, FromStateName = transition.From.State, ToActivityName = transition.To.Name, ToStateName = transition.To.State, TransitionClassifier = transition.Classifier.ToString(), TransitionTime = _runtime.RuntimeDateTimeNow, TriggerName = string.IsNullOrEmpty(processInstance.ExecutedTimer) ? processInstance.CurrentCommand : processInstance.ExecutedTimer }; var dbcollTransition = Store.GetCollection <WorkflowProcessTransitionHistory>(MongoDBConstants.WorkflowProcessTransitionHistoryCollectionName); dbcollTransition.Insert(history); }
partial void DeleteWorkflowProcessTransitionHistory(WorkflowProcessTransitionHistory instance);
partial void InsertWorkflowProcessTransitionHistory(WorkflowProcessTransitionHistory instance);