예제 #1
0
파일: Blocks.cs 프로젝트: ljxu1/DWKit
        public override void RegisterFinal(ProcessDefinition pd, List <WorkflowBlock> blocks)
        {
            base.RegisterFinal(pd, blocks);

            //transitions
            var commands = this["Commands"] as List <SimpleCommand>;

            if (commands != null)
            {
                var restrictions = new List <RestrictionDefinition>();
                if (this["_actorRestrictions"] is ActorDefinition)
                {
                    restrictions.Add(RestrictionDefinition.Create(RestrictionType.Allow, (ActorDefinition)this["_actorRestrictions"]));
                }

                foreach (var c in commands)
                {
                    var pdCommand = pd.Commands.Where(pdc => pdc.Name == c.Name).FirstOrDefault();
                    if (pdCommand == null)
                    {
                        pdCommand = CommandDefinition.Create(c.Name);

                        ParameterDefinition pdParameterComment = pd.Parameters.Where(p => p.Name == "Comment").FirstOrDefault();
                        if (pdParameterComment == null)
                        {
                            pdParameterComment = ParameterDefinition.Create("Comment", typeof(string), ParameterPurpose.Temporary, null);
                            pd.Parameters.Add(pdParameterComment);
                        }

                        pdCommand.InputParameters.Add(new ParameterDefinitionReference()
                        {
                            Name      = "Comment",
                            Parameter = pdParameterComment
                        });
                        pd.Commands.Add(pdCommand);
                    }

                    pd.Transitions.Add(new TransitionDefinition()
                    {
                        Name       = string.Format("{0}_{1}_{2}", Name, c.ToBlock.Name, c.Name),
                        Classifier = c.Classifier,
                        From       = (ActivityDefinition)this["_currentActivity"],
                        To         = (ActivityDefinition)c.ToBlock["_currentActivity"],
                        Trigger    = new TriggerDefinition(TriggerType.Command)
                        {
                            Command = pdCommand
                        },
                        Conditions = new List <ConditionDefinition>()
                        {
                            ConditionDefinition.Always
                        },
                        Restrictions = restrictions
                    });
                }
            }
        }
예제 #2
0
        public override IEnumerable <CommandDefinition> ParseCommands(XElement schemeMedium, IEnumerable <ParameterDefinition> parameterDefinitions)
        {
            if (schemeMedium == null)
            {
                throw new ArgumentNullException("schemeMedium");
            }
            if (parameterDefinitions == null)
            {
                throw new ArgumentNullException("parameterDefinitions");
            }
            var commandsElement = schemeMedium.SingleOrDefault("Commands");

            if (commandsElement == null)
            {
                throw new ArgumentNullException("");
            }

            var parameterDefinitionsList = parameterDefinitions.ToList();

            var commands = new List <CommandDefinition>();

            foreach (var element in commandsElement.Elements().ToList())
            {
                var command = CommandDefinition.Create(GetName(element));

                foreach (var xmlInputParameter in element.Elements("InputParameters").Single().Elements())
                {
                    var parameterRef = parameterDefinitionsList.Single(pd => pd.Name == GetNameRef(xmlInputParameter));
                    command.AddParameterRef(GetName(xmlInputParameter), parameterRef);
                }

                commands.Add(command);
            }

            return(commands);
        }
예제 #3
0
파일: Blocks.cs 프로젝트: ljxu1/DWKit
        public override void RegisterFinal(ProcessDefinition pd, List <WorkflowBlock> blocks)
        {
            //transitions
            var commands = this["Commands"] as List <SimpleCommand>;

            if (commands != null)
            {
                var restrictions = new List <RestrictionDefinition>();
                if (this["_actorRestrictions"] is ActorDefinition)
                {
                    restrictions.Add(RestrictionDefinition.Create(RestrictionType.Allow, (ActorDefinition)this["_actorRestrictions"]));
                }

                foreach (var c in commands)
                {
                    var pdCommand = pd.Commands.Where(pdc => pdc.Name == c.Name).FirstOrDefault();
                    if (pdCommand == null)
                    {
                        pdCommand = CommandDefinition.Create(c.Name);
                        pd.Commands.Add(pdCommand);
                    }

                    if (c.Classifier == TransitionClassifier.Direct)
                    {
                        //CA
                        pd.Transitions.Add(new TransitionDefinition()
                        {
                            Name       = string.Format("{0}_{1}_{2}", Name, c.ToBlock.Name, c.Name),
                            Classifier = c.Classifier,
                            From       = (ActivityDefinition)this["_currentActivity"],
                            To         = (ActivityDefinition)this["_currentActivity"],
                            Trigger    = new TriggerDefinition(TriggerType.Command)
                            {
                                Command = pdCommand
                            },
                            Conditions = new List <ConditionDefinition>()
                            {
                                ConditionDefinition.Always
                            },
                            Restrictions = restrictions
                        });

                        //AC
                        pd.Transitions.Add(new TransitionDefinition()
                        {
                            Name       = string.Format("{0}_{1}_{2}", Name, c.ToBlock.Name, "Auto"),
                            Classifier = c.Classifier,
                            From       = (ActivityDefinition)this["_currentActivity"],
                            To         = (ActivityDefinition)c.ToBlock["_currentActivity"],
                            Trigger    = new TriggerDefinition(TriggerType.Auto),
                            Conditions = new List <ConditionDefinition>()
                            {
                                ConditionDefinition.Create("Action", ActionDefinitionReference.Create("BudgetItemIsLegalEntitySignsComplete", "0", Name), "false", "true")
                            }
                        });
                    }
                    else
                    {
                        pd.Transitions.Add(new TransitionDefinition()
                        {
                            Name       = string.Format("{0}_{1}_{2}", Name, c.ToBlock.Name, c.Name),
                            Classifier = c.Classifier,
                            From       = (ActivityDefinition)this["_currentActivity"],
                            To         = (ActivityDefinition)c.ToBlock["_currentActivity"],
                            Trigger    = new TriggerDefinition(TriggerType.Command)
                            {
                                Command = pdCommand
                            },
                            Conditions = new List <ConditionDefinition>()
                            {
                                ConditionDefinition.Always
                            },
                            Restrictions = restrictions
                        });
                    }
                }
            }
        }