Exemplo n.º 1
0
        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 (MySqlConnection connection = new MySqlConnection(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);
            }
        }
Exemplo n.º 2
0
 public void DeleteProcess(Guid processId)
 {
     using (MySqlConnection connection = new MySqlConnection(ConnectionString))
     {
         WorkflowProcessInstance.Delete(connection, processId);
         WorkflowProcessInstanceStatus.Delete(connection, processId);
         WorkflowProcessInstancePersistence.DeleteByProcessId(connection, processId);
         WorkflowProcessTransitionHistory.DeleteByProcessId(connection, processId);
         WorkflowProcessTimer.DeleteByProcessId(connection, processId);
     }
 }
Exemplo n.º 3
0
        public void DeleteProcess(Guid processId)
        {
            using (var connection = new MySqlConnection(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();
                }
            }
        }
Exemplo n.º 4
0
 public List <ProcessHistoryItem> GetProcessHistory(Guid processId)
 {
     using (var connection = new MySqlConnection(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());
     }
 }