示例#1
0
		public WorkflowErrorEventArgs(OptimaJet.Workflow.Core.Model.ProcessInstance processInstance, OptimaJet.Workflow.Core.Persistence.ProcessStatus processStatus, TransitionDefinition executedTransition, System.Exception exception)
		{
			this.ProcessInstance = processInstance;
			this.ProcessStatus = processStatus;
			this.ExecutedTransition = executedTransition;
			this.Exception = exception;
		}
示例#2
0
 public static ExecutionRequestParameters Create(Guid processId, IEnumerable<ParameterDefinitionWithValue> parameters, TransitionDefinition transition, bool isPreExecution)
 {
     var ret = Create(processId, parameters, transition.To, transition.Condition, isPreExecution);
     ret.TransitionName = transition.Name;
     ret.ActivityName = transition.To.Name;
     return ret;
 }
示例#3
0
		private static void AddActivitiesAndTransitions(ProcessDefinition processDefinition, List<ActivityDefinition> activities, List<TransitionDefinition> transitions, TransitionDefinition startingTransition, List<string> finalActivities, int cutoffNestingLevel)
		{
			if (transitions.Any<TransitionDefinition>((TransitionDefinition t) => t.Name.Equals(startingTransition.Name, StringComparison.InvariantCulture)))
			{
				return;
			}
			ActivityDefinition to = startingTransition.To;
			if (startingTransition.ForkType == TransitionForkType.ForkEnd)
			{
				int? nestingLevel = to.NestingLevel;
				if ((nestingLevel.GetValueOrDefault() > cutoffNestingLevel ? false : nestingLevel.HasValue))
				{
					TransitionDefinition transitionDefinition = startingTransition.Clone() as TransitionDefinition;
					transitionDefinition.IsFork = false;
					transitions.Add(transitionDefinition);
					if (!activities.Any<ActivityDefinition>((ActivityDefinition a) => a.Name.Equals(to.Name, StringComparison.InvariantCulture)))
					{
						ActivityDefinition activityDefinition = ActivityDefinition.Create(to.Name, to.State, false, true, false, false);
						activities.Add(activityDefinition);
						finalActivities.Add(to.Name);
					}
					return;
				}
			}
			transitions.Add(startingTransition);
			if (!activities.Any<ActivityDefinition>((ActivityDefinition a) => a.Name.Equals(to.Name, StringComparison.InvariantCulture)))
			{
				activities.Add(to.Clone() as ActivityDefinition);
			}
			foreach (TransitionDefinition possibleTransitionsForActivity in processDefinition.GetPossibleTransitionsForActivity(startingTransition.To, ForkTransitionSearchType.Both))
			{
				SubprocessUtils.AddActivitiesAndTransitions(processDefinition, activities, transitions, possibleTransitionsForActivity, finalActivities, cutoffNestingLevel);
			}
		}
示例#4
0
        public static WorkflowCommand Create(Guid processId, TransitionDefinition transitionDefinition)
        {
            if (transitionDefinition.Trigger.Type != TriggerType.Command || transitionDefinition.Trigger.Command == null)
                throw new InvalidOperationException();

            var parametrs = new List<CommandParameter>(transitionDefinition.Trigger.Command.InputParameters.Count);
            parametrs.AddRange(
                transitionDefinition.Trigger.Command.InputParameters.Select(
                    p => new CommandParameter {Name = p.Key, Type = p.Value.Type, Value = null}));

            return new WorkflowCommand
                       {
                           CommandName = transitionDefinition.Trigger.Command.Name,
                           Parameters = parametrs,
                           ProcessId = processId,
                           ValidForActivityName = transitionDefinition.From.Name
                       };
        }
示例#5
0
		private static bool ForkFilter(ForkTransitionSearchType forkTransitionSearch, TransitionDefinition t)
		{
			if (forkTransitionSearch == ForkTransitionSearchType.Both || t.IsFork && forkTransitionSearch == ForkTransitionSearchType.Fork)
			{
				return true;
			}
			if (t.IsFork)
			{
				return false;
			}
			return forkTransitionSearch == ForkTransitionSearchType.NotFork;
		}
示例#6
0
 public static ExecutionRequestParameters Create(Guid processId, IEnumerable<ParameterDefinitionWithValue> parameters, TransitionDefinition transition)
 {
     return Create( processId,  parameters,  transition, false);
 }
示例#7
0
		public static TransitionDefinition Create(ActivityDefinition from, ActivityDefinition to)
		{
			TransitionDefinition transitionDefinition = new TransitionDefinition()
			{
				Name = "Undefined",
				To = to,
				From = from,
				Classifier = TransitionClassifier.NotSpecified,
				Conditions = new List<ConditionDefinition>()
				{
					ConditionDefinition.Always
				},
				Trigger = TriggerDefinition.Auto,
				Restrictions = new List<RestrictionDefinition>(),
				ConditionsConcatenationType = ConcatenationType.And,
				AllowConcatenationType = ConcatenationType.And,
				RestrictConcatenationType = ConcatenationType.And
			};
			return transitionDefinition;
		}
示例#8
0
		public static TransitionDefinition Create(string name, string clasifier, string allowRestrictionsConcatenationType, string denyRestrictionsConcatenationType, string conditionsConcatenationType, string isFork, string mergeViaSetState, string disableParentStateControl, ActivityDefinition from, ActivityDefinition to, TriggerDefinition trigger, List<ConditionDefinition> conditions)
		{
			TransitionClassifier transitionClassifier;
			Enum.TryParse<TransitionClassifier>(clasifier, true, out transitionClassifier);
			TransitionDefinition transitionDefinition = new TransitionDefinition()
			{
				Name = name,
				To = to,
				From = from,
				Classifier = transitionClassifier,
				Conditions = conditions ?? new List<ConditionDefinition>()
				{
					ConditionDefinition.Always
				},
				Trigger = trigger ?? TriggerDefinition.Auto,
				Restrictions = new List<RestrictionDefinition>(),
				IsFork = (string.IsNullOrEmpty(isFork) ? false : bool.Parse(isFork)),
				MergeViaSetState = (string.IsNullOrEmpty(mergeViaSetState) ? false : bool.Parse(mergeViaSetState)),
				DisableParentStateControl = (string.IsNullOrEmpty(disableParentStateControl) ? false : bool.Parse(disableParentStateControl)),
				AllowConcatenationType = (string.IsNullOrEmpty(allowRestrictionsConcatenationType) ? ConcatenationType.And : (ConcatenationType)Enum.Parse(typeof(ConcatenationType), allowRestrictionsConcatenationType, true)),
				RestrictConcatenationType = (string.IsNullOrEmpty(denyRestrictionsConcatenationType) ? ConcatenationType.And : (ConcatenationType)Enum.Parse(typeof(ConcatenationType), denyRestrictionsConcatenationType, true)),
				ConditionsConcatenationType = (string.IsNullOrEmpty(conditionsConcatenationType) ? ConcatenationType.And : (ConcatenationType)Enum.Parse(typeof(ConcatenationType), conditionsConcatenationType, true))
			};
			return transitionDefinition;
		}
示例#9
0
 /// <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 WrongSubprocessMarkupException(TransitionDefinition transition, string errormessage, params object[] errormessageParameters) : base(string.Format("Wrong subprocesses markup. Error in transition {0}. {1}", transition.Name, string.Format(errormessage, errormessageParameters)))
		{
		}
示例#11
0
 private bool ValidateActor(ProcessInstance processInstance, string identityId, TransitionDefinition transition)
 {
     bool flag;
     if (!transition.Restrictions.Any<RestrictionDefinition>())
     {
         return true;
     }
     bool flag1 = false;
     int ınt32 = 0;
     List<RestrictionDefinition>.Enumerator enumerator = transition.Restrictions.GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             RestrictionDefinition current = enumerator.Current;
             bool flag2 = this.CheckIdentity(processInstance, identityId, current.Actor.Rule, current.Actor.Value);
             if (flag2 && current.Type == RestrictionType.Restrict)
             {
                 ınt32++;
                 if (transition.RestrictConcatenationType == ConcatenationType.Or)
                 {
                     flag = false;
                     return flag;
                 }
             }
             if (current.Type != RestrictionType.Allow)
             {
                 continue;
             }
             if (flag2 || transition.AllowConcatenationType != ConcatenationType.And)
             {
                 if (!flag2)
                 {
                     continue;
                 }
                 flag1 = true;
             }
             else
             {
                 flag = false;
                 return flag;
             }
         }
         int ınt321 = transition.Restrictions.Count<RestrictionDefinition>((RestrictionDefinition r) => r.Type == RestrictionType.Restrict);
         if (transition.RestrictConcatenationType == ConcatenationType.And && ınt321 > 0 && ınt32 == ınt321)
         {
             return false;
         }
         return flag1;
     }
     finally
     {
         ((IDisposable)enumerator).Dispose();
     }
     return flag;
 }
示例#12
0
        private IEnumerable<Guid> GetActors(Guid processId, TransitionDefinition transition)
        {
            if (transition.Restrictions.Count() < 1)
                return new List<Guid>();

            List<Guid> result = null;
            //TODO Здесь возможно обрабатывать случай - запрещено только одному
            foreach (var restrictionDefinition in transition.Restrictions.Where(r=>r.Type == RestrictionType.Allow))
            {
                var allowed = new List<Guid>();
                var actorDefinitionIsIdentity = restrictionDefinition.Actor as ActorDefinitionIsIdentity;
                if (actorDefinitionIsIdentity != null)
                    allowed.Add(actorDefinitionIsIdentity.IdentityId);

                var actorDefinitionIsInRole = restrictionDefinition.Actor as ActorDefinitionIsInRole;
                if (actorDefinitionIsInRole != null)
                    allowed.AddRange(RoleProvider.GetAllInRole(actorDefinitionIsInRole.RoleId));

                var actorDefinitionExecute = restrictionDefinition.Actor as ActorDefinitionExecuteRule;
                if (actorDefinitionExecute != null && actorDefinitionExecute.Parameters.Count < 1)
                    allowed.AddRange(RuleProvider.GetIdentitiesForRule(processId, actorDefinitionExecute.RuleName));
                else if (actorDefinitionExecute != null && actorDefinitionExecute.Parameters.Count > 0)
                    allowed.AddRange(RuleProvider.GetIdentitiesForRule(processId, actorDefinitionExecute.RuleName, actorDefinitionExecute.Parameters));

                if (result == null || result.Count() < 1)
                    result = allowed;
                else
                    result = result.Intersect(allowed).ToList();
            }

            if (result == null)
                return new List<Guid>();
            if (result.Count() < 1)
                return result;

            foreach (var restrictionDefinition in transition.Restrictions.Where(r => r.Type == RestrictionType.Restrict))
            {
                var restricted = new List<Guid>();
                var actorDefinitionIsIdentity = restrictionDefinition.Actor as ActorDefinitionIsIdentity;
                if (actorDefinitionIsIdentity != null)
                    restricted.Add(actorDefinitionIsIdentity.IdentityId);

                var actorDefinitionIsInRole = restrictionDefinition.Actor as ActorDefinitionIsInRole;
                if (actorDefinitionIsInRole != null)
                    restricted.AddRange(RoleProvider.GetAllInRole(actorDefinitionIsInRole.RoleId));

                var actorDefinitionExecute = restrictionDefinition.Actor as ActorDefinitionExecuteRule;
                if (actorDefinitionExecute != null && actorDefinitionExecute.Parameters.Count < 1)
                    restricted.AddRange(RuleProvider.GetIdentitiesForRule(processId, actorDefinitionExecute.RuleName));
                else if (actorDefinitionExecute != null && actorDefinitionExecute.Parameters.Count > 0)
                    restricted.AddRange(RuleProvider.GetIdentitiesForRule(processId, actorDefinitionExecute.RuleName, actorDefinitionExecute.Parameters));

                result.RemoveAll(p=>restricted.Contains(p));
                if (result.Count() < 1)
                    return result;
            }

            return result;
        }
示例#13
0
        private bool ValidateActor(Guid processId, Guid identityId, TransitionDefinition transition)
        {
            if (transition.Restrictions.Count() < 1)
                return true;

            foreach (var restrictionDefinition in transition.Restrictions)
            {
                var actorDefinitionIsIdentity = restrictionDefinition.Actor as ActorDefinitionIsIdentity;
                if (actorDefinitionIsIdentity != null)
                {
                    if ((actorDefinitionIsIdentity.IdentityId != identityId &&
                         restrictionDefinition.Type == RestrictionType.Allow) ||
                        (actorDefinitionIsIdentity.IdentityId == identityId &&
                         restrictionDefinition.Type == RestrictionType.Restrict))
                        return false;
                    continue;
                }

                var actorDefinitionIsInRole = restrictionDefinition.Actor as ActorDefinitionIsInRole;
                if (actorDefinitionIsInRole != null)
                {
                    if ((restrictionDefinition.Type == RestrictionType.Allow &&
                         !RoleProvider.IsInRole(identityId, actorDefinitionIsInRole.RoleId)) ||
                        (restrictionDefinition.Type == RestrictionType.Restrict &&
                         RoleProvider.IsInRole(identityId, actorDefinitionIsInRole.RoleId)))
                        return false;
                    continue;
                }

                var actorDefinitionExecute = restrictionDefinition.Actor as ActorDefinitionExecuteRule;
                if (actorDefinitionExecute != null && actorDefinitionExecute.Parameters.Count < 1)
                {
                    if ((restrictionDefinition.Type == RestrictionType.Allow &&
                         !RuleProvider.CheckRule(processId, identityId, actorDefinitionExecute.RuleName)) ||
                        (restrictionDefinition.Type == RestrictionType.Restrict &&
                         RuleProvider.CheckRule(processId, identityId, actorDefinitionExecute.RuleName)))
                        return false;
                    continue;
                }
                if (actorDefinitionExecute != null && actorDefinitionExecute.Parameters.Count > 0)
                {
                    if ((restrictionDefinition.Type == RestrictionType.Allow &&
                         !RuleProvider.CheckRule(processId, identityId, actorDefinitionExecute.RuleName,
                                                 actorDefinitionExecute.Parameters)) ||
                        (restrictionDefinition.Type == RestrictionType.Restrict &&
                         RuleProvider.CheckRule(processId, identityId, actorDefinitionExecute.RuleName,
                                                actorDefinitionExecute.Parameters)))
                        return false;
                    continue;
                }
            }

            return true;
        }
示例#14
0
		public static WorkflowCommand Create(Guid processId, TransitionDefinition transitionDefinition, ProcessDefinition processDefinition)
		{
			if (transitionDefinition.Trigger.Type != TriggerType.Command || transitionDefinition.Trigger.Command == null)
			{
				throw new InvalidOperationException();
			}
			List<CommandParameter> commandParameters = new List<CommandParameter>(transitionDefinition.Trigger.Command.InputParameters.Count);
			commandParameters.AddRange(
				from p in transitionDefinition.Trigger.Command.InputParameters
				select new CommandParameter()
				{
					ParameterName = p.Name,
					TypeName = p.Parameter.Type.AssemblyQualifiedName,
					LocalizedName = processDefinition.GetLocalizedParameterName(p.Name, CultureInfo.CurrentCulture),
					Value = null
				});
			WorkflowCommand workflowCommand = new WorkflowCommand()
			{
				CommandName = transitionDefinition.Trigger.Command.Name,
				LocalizedName = processDefinition.GetLocalizedCommandName(transitionDefinition.Trigger.Command.Name, CultureInfo.CurrentCulture),
				Parameters = commandParameters,
				ProcessId = processId,
				ValidForActivityName = transitionDefinition.From.Name,
				ValidForStateName = transitionDefinition.From.State,
				Classifier = transitionDefinition.Classifier
			};
			return workflowCommand;
		}
		public static ExecutionRequestParameters Create(OptimaJet.Workflow.Core.Model.ProcessInstance processInstance, TransitionDefinition transition, bool isPreExecution)
		{
			ExecutionRequestParameters name = ExecutionRequestParameters.Create(processInstance, transition.To, transition.Conditions, isPreExecution);
			name.TransitionName = transition.Name;
			name.ActivityName = transition.To.Name;
			name.ConditionsConcatenationType = transition.ConditionsConcatenationType;
			return name;
		}
		public static ExecutionRequestParameters Create(OptimaJet.Workflow.Core.Model.ProcessInstance processInstance, TransitionDefinition transition)
		{
			return ExecutionRequestParameters.Create(processInstance, transition, false);
		}
示例#17
0
 private IEnumerable<string> GetActors(ProcessInstance processInstance, TransitionDefinition transition)
 {
     IEnumerable<string> strs;
     List<string> strs1;
     if (!transition.Restrictions.Any<RestrictionDefinition>())
     {
         return new List<string>();
     }
     List<string> strs2 = null;
     foreach (RestrictionDefinition restrictionDefinition in
         from r in transition.Restrictions
         where r.Type == RestrictionType.Allow
         select r)
     {
         List<string> strs3 = new List<string>();
         strs3.AddRange(this.GetIdentities(processInstance, restrictionDefinition.Actor.Rule, restrictionDefinition.Actor.Value));
         if (strs2 == null)
         {
             strs1 = strs3;
         }
         else
         {
             strs1 = (transition.AllowConcatenationType == ConcatenationType.And ? strs2.Intersect<string>(strs3).ToList<string>() : strs2.Concat<string>(strs3).Distinct<string>().ToList<string>());
         }
         strs2 = strs1;
     }
     if (strs2 == null)
     {
         return new List<string>();
     }
     if (!strs2.Any<string>())
     {
         return strs2;
     }
     if (transition.RestrictConcatenationType != ConcatenationType.Or)
     {
         List<string> strs4 = new List<string>();
         foreach (RestrictionDefinition restrictionDefinition1 in
             from r in transition.Restrictions
             where r.Type == RestrictionType.Restrict
             select r)
         {
             strs4.AddRange(this.GetIdentities(processInstance, restrictionDefinition1.Actor.Rule, restrictionDefinition1.Actor.Value));
         }
         strs2.RemoveAll((string p) => strs4.Contains(p));
     }
     else
     {
         using (IEnumerator<RestrictionDefinition> enumerator = (
             from r in transition.Restrictions
             where r.Type == RestrictionType.Restrict
             select r).GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 RestrictionDefinition current = enumerator.Current;
                 List<string> strs5 = new List<string>();
                 strs5.AddRange(this.GetIdentities(processInstance, current.Actor.Rule, current.Actor.Value));
                 strs2.RemoveAll((string p) => strs5.Contains(p));
                 if (strs2.Any<string>())
                 {
                     continue;
                 }
                 strs = strs2;
                 return strs;
             }
             return strs2;
         }
         return strs;
     }
     return strs2;
 }
示例#18
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;
     }
 }