Exemplo n.º 1
0
 private void CreateSubprocess(ProcessInstance parentProcessInstance, TransitionDefinition startTransition, ProcessInstancesTree processInstancesTree)
 {
     Guid processId = parentProcessInstance.ProcessId;
     Guid guid = Guid.NewGuid();
     ProcessInstancesTree nodeById = processInstancesTree.GetNodeById(processId, true);
     if (nodeById.HaveChildWithName(startTransition.Name))
     {
         return;
     }
     ProcessInstancesTree processInstancesTree1 = new ProcessInstancesTree(guid, startTransition.Name);
     nodeById.AddChild(processInstancesTree1);
     this.SaveProcessInstancesTree(nodeById);
     try
     {
         ProcessInstance processInstance = this.Builder.CreateNewSubprocess(guid, parentProcessInstance, startTransition);
         this.InitCreatedProcess(processInstance.IdentityId, processInstance.ImpersonatedIdentityId, processInstance, processInstancesTree1);
     }
     catch (Exception exception)
     {
         nodeById.RemoveChild(processInstancesTree1);
         throw;
     }
 }
Exemplo n.º 2
0
 private void DropProcesses(List<Guid> ids, ProcessInstancesTree processInstancesTree)
 {
     if (!ids.Any<Guid>())
     {
         return;
     }
     List<Guid> guids = new List<Guid>();
     foreach (Guid id in ids)
     {
         guids.Add(id);
         ProcessInstancesTree nodeById = processInstancesTree.GetNodeById(id, true);
         List<Guid> allChildrenIds = nodeById.GetAllChildrenIds(1, null);
         if (allChildrenIds.Any<Guid>())
         {
             guids.AddRange(allChildrenIds);
         }
         nodeById.Remove();
     }
     Guid[] array = guids.Distinct<Guid>().ToArray<Guid>();
     this.PersistenceProvider.DeleteProcess(array);
 }
Exemplo n.º 3
0
        private List<WorkflowCommand> GetCommands(ProcessInstance processInstance, IEnumerable<string> identityIds, string commandNameFilter, string mainIdentityId, ProcessInstancesTree processInstancesTree)
        {
            List<TransitionDefinition> transitionDefinitions;
            List<string> list;
            if (!string.IsNullOrWhiteSpace(mainIdentityId))
            {
                List<string> strs = new List<string>()
				{
					mainIdentityId
				};
                list = identityIds.Except<string>(strs).ToList<string>();
            }
            else
            {
                list = identityIds.ToList<string>();
            }
            List<string> strs1 = list;
            Guid processId = processInstance.ProcessId;
            ActivityDefinition activityDefinition = processInstance.ProcessScheme.FindActivity(processInstance.CurrentActivityName);
            transitionDefinitions = (!string.IsNullOrEmpty(commandNameFilter) ? (
                from c in processInstance.ProcessScheme.GetCommandTransitions(activityDefinition, ForkTransitionSearchType.Both)
                where c.Trigger.Command.Name == commandNameFilter
                select c).ToList<TransitionDefinition>() : processInstance.ProcessScheme.GetCommandTransitions(activityDefinition, ForkTransitionSearchType.Both).ToList<TransitionDefinition>());
            List<WorkflowCommand> workflowCommands = new List<WorkflowCommand>();
            foreach (TransitionDefinition transitionDefinition in transitionDefinitions.OrderBy<TransitionDefinition, int>((TransitionDefinition t) =>
            {
                if (t.Classifier == TransitionClassifier.Direct)
                {
                    return 0;
                }
                if (t.Classifier != TransitionClassifier.Reverse)
                {
                    return 2;
                }
                return 1;
            }).ThenBy<TransitionDefinition, string>((TransitionDefinition t) => t.Trigger.Command.Name))
            {
                if (transitionDefinition.ForkType == TransitionForkType.ForkStart && processInstancesTree.GetNodeById(processId, true).HaveChildWithName(transitionDefinition.Name))
                {
                    continue;
                }
                List<string> list1 = null;
                if (!string.IsNullOrWhiteSpace(mainIdentityId) && this.ValidateActor(processInstance, mainIdentityId, transitionDefinition))
                {
                    list1 = new List<string>()
					{
						mainIdentityId
					};
                }
                if (list1 == null)
                {
                    list1 = (
                        from id in strs1
                        where this.ValidateActor(processInstance, id, transitionDefinition)
                        select id).ToList<string>();
                }
                if (!list1.Any<string>())
                {
                    continue;
                }
                WorkflowCommand workflowCommand = WorkflowCommand.Create(processId, transitionDefinition, processInstance.ProcessScheme);
                foreach (string str in list1)
                {
                    workflowCommand.AddIdentity(str);
                }
                workflowCommands.Add(workflowCommand);
            }
            return workflowCommands;
        }