public static ExecutionRequestParameters Create(Guid processId, IEnumerable<ParameterDefinitionWithValue> parameters, ActivityDefinition activityToExecute, ConditionDefinition condition, bool isPreExecution) { List<ActionDefinitionForActivity> implementation = isPreExecution ? activityToExecute.PreExecutionImplemementation : activityToExecute.Implemementation; if (parameters == null) throw new ArgumentNullException("parameters"); var parametersList = parameters.ToList(); var methods = new List<MethodToExecuteInfo>(implementation.Count); var executionParameters = new ExecutionRequestParameters { ProcessId = processId, ConditionType = condition.Type, ConditionResultOnPreExecution = condition.ResultOnPreExecution, ConditionMethod = condition.Type == ConditionType.Action ? GetMethodToExecuteInfo(parametersList, ActionDefinition.Create(condition.Action, 0)) : null, }; methods.AddRange(implementation.Select(method => GetMethodToExecuteInfo(parametersList, method))); var parameters1 = new List<ParameterContainerInfo>(); parameters1.AddRange(parameters.Where(p => p.Name != DefaultDefinitions.ParameterExecutedActivityState.Name).Select(p => new ParameterContainerInfo() { Name = p.Name, Type = p.Type, Value = p.Value })); parameters1.Add(new ParameterContainerInfo{Name = DefaultDefinitions.ParameterExecutedActivityState.Name,Type = DefaultDefinitions.ParameterExecutedActivityState.Type,Value = activityToExecute.State}); executionParameters.ParameterContainer = parameters1.ToArray(); executionParameters.Methods = methods.ToArray(); executionParameters.ActivityName = activityToExecute.Name; return executionParameters; }
public static ExecutionParameters Create(Guid processId, IDictionary<string,object> parameters, ActivityDefinition activityToExecute) { if (activityToExecute.Implemementation.Count < 1) throw new InvalidOperationException(); var methods = new List<MethodToExecuteInfo>(activityToExecute.Implemementation.Count); var executionParameters = new ExecutionParameters { ProcessId = processId, Methods = methods, }; foreach (var action in activityToExecute.Implemementation) { var inputParameters = new List<MethodToExecuteParameterInfo>(action.InputParameters.Count); var outputParameters = new List<MethodToExecuteParameterInfo>(action.OutputParameters.Count); var method = new MethodToExecuteInfo { Type = action.Type.AssemblyQualifiedName, MethodName = action.MethodName, InputParameters = inputParameters, OutputParameters = outputParameters, Order = action.Order }; inputParameters.AddRange( action.InputParameters.Select( inParameter => new MethodToExecuteParameterInfo { Order = inParameter.Order, Value = parameters[inParameter.Name], Type = inParameter.ParameterDefinition.Type })); outputParameters.AddRange( action.OutputParameters.Select( outParameter => new MethodToExecuteParameterInfo { Order = outParameter.Order, Value = parameters.ContainsKey(outParameter.Name) ? parameters[outParameter.Name] : null, Type = outParameter.ParameterDefinition.Type })); methods.Add(method); } return executionParameters; }
public static TransitionDefinition Create(ActivityDefinition from, ActivityDefinition to) { return new TransitionDefinition() { Name = "Undefined", To = to, From = from, Classifier = TransitionClassifier.NotSpecified, Condition = ConditionDefinition.Always, Trigger = TriggerDefinition.Auto, RestrictionsList = new List<RestrictionDefinition>(), OnErrorsList = new List<OnErrorDefinition>() }; }
public static TransitionDefinition Create(ActivityDefinition from, ActivityDefinition to) { return(new TransitionDefinition() { Name = "Undefined", To = to, From = from, Classifier = TransitionClassifier.NotSpecified, Condition = ConditionDefinition.Always, Trigger = TriggerDefinition.Auto, RestrictionsList = new List <RestrictionDefinition>(), OnErrorsList = new List <OnErrorDefinition>() }); }
public static TransitionDefinition Create(string name, string clasifier, ActivityDefinition from, ActivityDefinition to, TriggerDefinition trigger, ConditionDefinition condition) { TransitionClassifier parsedClassifier; Enum.TryParse(clasifier, true, out parsedClassifier); return new TransitionDefinition() { Name = name, To = to, From = from, Classifier = parsedClassifier, Condition = condition ?? ConditionDefinition.Always, Trigger = trigger ?? TriggerDefinition.Auto, RestrictionsList = new List<RestrictionDefinition>(), OnErrorsList = new List<OnErrorDefinition>() }; }
public static TransitionDefinition Create(string name, string clasifier, ActivityDefinition from, ActivityDefinition to, TriggerDefinition trigger, ConditionDefinition condition) { TransitionClassifier parsedClassifier; Enum.TryParse(clasifier, true, out parsedClassifier); return(new TransitionDefinition() { Name = name, To = to, From = from, Classifier = parsedClassifier, Condition = condition ?? ConditionDefinition.Always, Trigger = trigger ?? TriggerDefinition.Auto, RestrictionsList = new List <RestrictionDefinition>(), OnErrorsList = new List <OnErrorDefinition>() }); }
/// <summary> /// 根据活动activity及命令类名称commandName,获取流转过程 /// </summary> /// <param name="activity"></param> /// <param name="commandName"></param> /// <returns></returns> public IEnumerable<TransitionDefinition> GetCommandTransitionForActivity(ActivityDefinition activity, string commandName) { return Transitions.Where(t => t.From == activity && t.Trigger.Type == TriggerType.Command && t.Trigger.Command.Name == commandName); }
public void SetActivityWithExecution(string identityId, string impersonatedIdentityId, IDictionary<string, object> parameters, ActivityDefinition activityToSet, ProcessInstance processInstance, bool doNotSetRunningStatus = false) { if (!doNotSetRunningStatus) { this.SetProcessNewStatus(processInstance, ProcessStatus.Running); } try { this.PersistenceProvider.FillSystemProcessParameters(processInstance); this.PersistenceProvider.FillPersistedProcessParameters(processInstance); foreach (KeyValuePair<string, object> parameter in parameters) { processInstance.SetParameter<object>(parameter.Key, parameter.Value, ParameterPurpose.Temporary); } if (string.IsNullOrEmpty(processInstance.CurrentCommand)) { processInstance.CurrentCommand = DefaultDefinitions.CommandSetState.Name; } processInstance.IdentityId = identityId; processInstance.ImpersonatedIdentityId = impersonatedIdentityId; } catch (Exception exception) { if (!doNotSetRunningStatus) { this.SetProcessNewStatus(processInstance, ProcessStatus.Idled); } throw; } try { processInstance.SetStartTransitionalProcessActivity(); IWorkflowBus bus = this.Bus; List<ConditionDefinition> conditionDefinitions = new List<ConditionDefinition>() { ConditionDefinition.Always }; bus.QueueExecution(ExecutionRequestParameters.Create(processInstance, activityToSet, conditionDefinitions)); } catch (Exception exception2) { Exception exception1 = exception2; if (!doNotSetRunningStatus) { this.SetProcessNewStatus(processInstance, ProcessStatus.Idled); } throw new Exception(string.Format("Workflow Id={0}", processInstance.ProcessId), exception1); } }
public static ExecutionRequestParameters Create(Guid processId, IEnumerable<ParameterDefinitionWithValue> parameters, ActivityDefinition activityToExecute, ConditionDefinition condition) { return Create(processId, parameters, activityToExecute, condition, false); }
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; }
/// <summary> /// 根据activity定义获取其开始的流转过程 /// </summary> /// <param name="activity"></param> /// <returns></returns> public IEnumerable <TransitionDefinition> GetPossibleTransitionsForActivity(ActivityDefinition activity) { return(Transitions.Where(t => t.From == activity)); }
/// <summary> /// 根据活动activity及命令类名称commandName,获取流转过程 /// </summary> /// <param name="activity"></param> /// <param name="commandName"></param> /// <returns></returns> public IEnumerable <TransitionDefinition> GetCommandTransitionForActivity(ActivityDefinition activity, string commandName) { return(Transitions.Where(t => t.From == activity && t.Trigger.Type == TriggerType.Command && t.Trigger.Command.Name == commandName)); }
/// <summary> /// 根据activity获取定时器类型流转过程 /// </summary> /// <param name="activity"></param> /// <returns></returns> public IEnumerable<TransitionDefinition> GetTimerTransitionForActivity(ActivityDefinition activity) { return Transitions.Where(t => t.From == activity && t.Trigger.Type == TriggerType.Timer); }
public static ExecutionRequestParameters Create(OptimaJet.Workflow.Core.Model.ProcessInstance processInstance, ActivityDefinition activityToExecute, List<ConditionDefinition> conditions) { return ExecutionRequestParameters.Create(processInstance, activityToExecute, conditions, false); }
private List<string> GetAllActorsForCommandTransitions(ProcessInstance processInstance, ActivityDefinition selectedActivity, List<TransitionClassifier> classifiers, List<string> transitionsToExclude) { List<string> strs = new List<string>(); this.PersistenceProvider.FillPersistedProcessParameters(processInstance); List<TransitionDefinition> list = processInstance.ProcessScheme.GetCommandTransitions(selectedActivity, ForkTransitionSearchType.NotFork).Where<TransitionDefinition>((TransitionDefinition ct) => { if (classifiers != null && !classifiers.Contains(ct.Classifier)) { return false; } return !transitionsToExclude.Contains(ct.Name); }).ToList<TransitionDefinition>(); foreach (TransitionDefinition transitionDefinition in list) { strs.AddRange(this.GetActors(processInstance, transitionDefinition)); } return strs; }
private void SetIdledStatus(ProcessInstance processInstance, ActivityDefinition newCurrentActivity) { this.SetProcessNewStatus(processInstance, (newCurrentActivity.IsFinal ? ProcessStatus.Finalized : ProcessStatus.Idled)); }
public void SetActivityWithoutExecution(ActivityDefinition activityToSet, ProcessInstance processInstance, bool doNotSetRunningStatus = false) { if (!doNotSetRunningStatus) { this.SetProcessNewStatus(processInstance, ProcessStatus.Running); } try { try { this.PersistenceProvider.FillSystemProcessParameters(processInstance); ActivityDefinition currentActivity = processInstance.CurrentActivity; ActivityDefinition activityDefinition = activityToSet; this.PersistenceProvider.UpdatePersistenceState(processInstance, TransitionDefinition.Create(currentActivity, activityDefinition)); } catch (Exception exception1) { Exception exception = exception1; throw new Exception(string.Format("Workflow Id={0}", processInstance.ProcessId), exception); } } finally { if (!doNotSetRunningStatus) { this.SetProcessNewStatus(processInstance, ProcessStatus.Idled); } } }
/// <summary> /// 根据activity获取,以其为开始的命令类流转过程 /// </summary> /// <param name="activity"></param> /// <returns></returns> public IEnumerable<TransitionDefinition> GetCommandTransitions(ActivityDefinition activity) { return Transitions.Where(t => t.From == activity && t.Trigger.Type == TriggerType.Command); }
/// <summary> /// 根据activity定义获取其开始的流转过程 /// </summary> /// <param name="activity"></param> /// <returns></returns> public IEnumerable<TransitionDefinition> GetPossibleTransitionsForActivity(ActivityDefinition activity) { return Transitions.Where(t => t.From == activity); }
public static ExecutionRequestParameters Create(OptimaJet.Workflow.Core.Model.ProcessInstance processInstance, ActivityDefinition activityToExecute, List<ConditionDefinition> conditions, bool isPreExecution) { List<ActionDefinitionReference> actionDefinitionReferences = (isPreExecution ? activityToExecute.PreExecutionImplementation : activityToExecute.Implementation); if (processInstance == null) { throw new ArgumentNullException("processInstance"); } ExecutionRequestParameters executionRequestParameter = new ExecutionRequestParameters() { ProcessInstance = processInstance, Conditions = conditions.ToArray(), Methods = actionDefinitionReferences.ToArray(), ActivityName = activityToExecute.Name, Activity = activityToExecute, ConditionsConcatenationType = ConcatenationType.And }; return executionRequestParameter; }
/// <summary> /// 根据activity获取,以其为开始的命令类流转过程 /// </summary> /// <param name="activity"></param> /// <returns></returns> public IEnumerable <TransitionDefinition> GetCommandTransitions(ActivityDefinition activity) { return(Transitions.Where(t => t.From == activity && t.Trigger.Type == TriggerType.Command)); }
public static ActivityDefinition Create(string name, string stateName, string isInitial, string isFinal, string isForSetState, string isAutoSchemeUpdate) { ActivityDefinition activityDefinition = new ActivityDefinition() { IsFinal = (string.IsNullOrEmpty(isFinal) ? false : bool.Parse(isFinal)), IsInitial = (string.IsNullOrEmpty(isInitial) ? false : bool.Parse(isInitial)), IsForSetState = (string.IsNullOrEmpty(isForSetState) ? false : bool.Parse(isForSetState)), IsAutoSchemeUpdate = (string.IsNullOrEmpty(isAutoSchemeUpdate) ? false : bool.Parse(isAutoSchemeUpdate)), Name = name, State = stateName, Implementation = new List<ActionDefinitionReference>(), PreExecutionImplementation = new List<ActionDefinitionReference>() }; return activityDefinition; }
/// <summary> /// 根据activity获取定时器类型流转过程 /// </summary> /// <param name="activity"></param> /// <returns></returns> public IEnumerable <TransitionDefinition> GetTimerTransitionForActivity(ActivityDefinition activity) { return(Transitions.Where(t => t.From == activity && t.Trigger.Type == TriggerType.Timer)); }
public static ActivityDefinition Create(string name, string stateName, bool isInitial, bool isFinal, bool isForSetState, bool isAutoSchemeUpdate) { ActivityDefinition activityDefinition = new ActivityDefinition() { IsFinal = isFinal, IsInitial = isInitial, IsForSetState = isForSetState, IsAutoSchemeUpdate = isAutoSchemeUpdate, Name = name, State = stateName, Implementation = new List<ActionDefinitionReference>(), PreExecutionImplementation = new List<ActionDefinitionReference>() }; return activityDefinition; }
public IEnumerable<TransitionDefinition> GetPossibleTransitionsForActivity(ActivityDefinition activity, ForkTransitionSearchType forkTransitionSearch = 0) { return this.Transitions.Where<TransitionDefinition>((TransitionDefinition t) => { if (t.From != activity) { return false; } return ProcessDefinition.ForkFilter(forkTransitionSearch, t); }); }
private void SetStateWithExecution(Guid identityId, Guid impersonatedIdentityId, IDictionary<string, object> parameters, ActivityDefinition activityToSet, ProcessInstance processInstance) { SetProcessNewStatus(processInstance, ProcessStatus.Running); IEnumerable<TransitionDefinition> transitions; try { PersistenceProvider.FillSystemProcessParameters(processInstance); PersistenceProvider.FillPersistedProcessParameters(processInstance); var parametersLocal = new List<ParameterDefinitionWithValue>(); foreach (var commandParameter in parameters) { var parameterDefinition = processInstance.ProcessScheme.GetParameterDefinition(commandParameter.Key); if (parameterDefinition != null) parametersLocal.Add(ParameterDefinition.Create(parameterDefinition, commandParameter.Value)); } parametersLocal.Add(ParameterDefinition.Create(DefaultDefinitions.ParameterCurrentCommand, (object) DefaultDefinitions.CommandSetState.Name)); parametersLocal.Add(ParameterDefinition.Create(DefaultDefinitions.ParameterIdentityId, identityId)); parametersLocal.Add(ParameterDefinition.Create(DefaultDefinitions.ParameterImpersonatedIdentityId, impersonatedIdentityId)); parametersLocal.Add(ParameterDefinition.Create(DefaultDefinitions.ParameterSchemeId, processInstance.SchemeId)); parametersLocal.ForEach(processInstance.AddParameter); } catch (Exception) { SetProcessNewStatus(processInstance, ProcessStatus.Idled); throw; } //TODO Убрать после обработки команд try { Bus.QueueExecution(ExecutionRequestParameters.Create(processInstance.ProcessId, processInstance.ProcessParameters, activityToSet, ConditionDefinition.Always)); } catch (Exception ex) { Logger.Log.Error(string.Format("Workflow Id={0}", processInstance.ProcessId), ex); SetProcessNewStatus(processInstance, ProcessStatus.Idled); throw; } }
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; }
public IEnumerable<TransitionDefinition> GetCommandTransitionForActivity(ActivityDefinition activity, string commandName, ForkTransitionSearchType forkTransitionSearch = 0) { return this.Transitions.Where<TransitionDefinition>((TransitionDefinition t) => { if (t.From != activity || t.Trigger.Type != TriggerType.Command || !(t.Trigger.Command.Name == commandName)) { return false; } return ProcessDefinition.ForkFilter(forkTransitionSearch, t); }); }
private void SetStateWithoutExecution(ActivityDefinition activityToSet, ProcessInstance processInstance) { SetProcessNewStatus(processInstance, ProcessStatus.Running); IEnumerable<TransitionDefinition> transitions; try { PersistenceProvider.FillSystemProcessParameters(processInstance); var from = processInstance.CurrentActivity; var to = activityToSet; PersistenceProvider.UpdatePersistenceState(processInstance, TransitionDefinition.Create(from, to)); } catch (Exception ex) { Logger.Log.Error(string.Format("Workflow Id={0}", processInstance.ProcessId), ex); throw; } finally { SetProcessNewStatus(processInstance, ProcessStatus.Idled); } }
public IEnumerable<TransitionDefinition> GetTimerTransitionForActivity(ActivityDefinition activity, ForkTransitionSearchType forkTransitionSearch = 0) { return this.Transitions.Where<TransitionDefinition>((TransitionDefinition t) => { if (t.From != activity || t.Trigger.Type != TriggerType.Timer) { return false; } return ProcessDefinition.ForkFilter(forkTransitionSearch, t); }); }
public WrongSubprocessMarkupException(ActivityDefinition activity, string errormessage, params object[] errormessageParameters) : base(string.Format("Wrong subprocesses markup. Error in activity {0}. {1}", activity.Name, string.Format(errormessage, errormessageParameters))) { }
public List<TransitionDefinition> FindTransitions(ActivityDefinition from, ActivityDefinition to) { return this.Transitions.Where<TransitionDefinition>((TransitionDefinition t) => { if (!t.From.Name.Equals(from.Name, StringComparison.InvariantCultureIgnoreCase)) { return false; } return t.To.Name.Equals(to.Name, StringComparison.InvariantCulture); }).ToList<TransitionDefinition>(); }