Пример #1
0
        /// <summary>
        /// 创建并行节点
        /// </summary>
        /// <param name="setting"></param>
        /// <param name="displayName"></param>
        /// <param name="completionScript"></param>
        /// <param name="branchs"></param>
        /// <returns></returns>
        public static CustomParallel CreateCustomParallel(ActivitySetting setting
                                                          , string displayName
                                                          , string completionScript
                                                          , params Custom[] branchs)
        {
            var first = setting.FlowNodeIndex == Default_FlowNodeIndex;
            var p     = first ? new CustomParallel() : new CustomParallel(setting.FlowNodeIndex);

            if (first)
            {
                p.OnFlowNodeIndex = o => setting.SetFlowNodeIndex(o);
            }

            p.DisplayName = displayName;
            if (branchs != null)
            {
                branchs.ToList().ForEach(o => p.Branches.Add(o));
            }
            //HACK:【重要】并行节点完成脚本执行设置CompletionCondition
            if (!string.IsNullOrEmpty(completionScript))
            {
                p.CompletionCondition = new LambdaValue <bool>(o =>
                                                               o.Resolve <IScriptParser>().EvaluateRule(completionScript, o.GetExtension <DataFieldExtension>()));
            }
            return(p);
        }
Пример #2
0
        /// <summary>
        /// 创建人工节点
        /// </summary>
        /// <param name="setting"></param>
        /// <param name="displayName"></param>
        /// <param name="actioner"></param>
        /// <param name="humanResultTo"></param>
        /// <returns></returns>
        public static Human CreateHuman(ActivitySetting setting
                                        , string displayName
                                        , IActionersHelper actioner//Activity<string[]> actioner
                                        , Variable <string> humanResultTo)
        {
            //HACK:实现类似于K2的client event
            var first = setting.FlowNodeIndex == Default_FlowNodeIndex;
            var human = first
                ? new Human(actioner)
                : new Human(setting.FlowNodeIndex, actioner);

            if (first)
            {
                human.OnFlowNodeIndex = o => setting.SetFlowNodeIndex(o);
            }

            human.DisplayName = displayName;
            if (humanResultTo != null)
            {
                human.Result = new OutArgument <string>(humanResultTo);
            }
            return(human);
        }
Пример #3
0
        /// <summary>
        /// 创建SubProcess子流程节点
        /// </summary>
        /// <param name="setting"></param>
        /// <param name="displayName"></param>
        /// <param name="finishRule">节点完成规则</param>
        /// <param name="resultTo">节点执行结果输出到变量</param>
        /// <returns></returns>
        public static SubProcess CreateSubProcess(ActivitySetting setting
                                                  , string displayName
                                                  , IDictionary <string, string> finishRule
                                                  , Variable <string> resultTo)
        {
            var first = setting.FlowNodeIndex == Default_FlowNodeIndex;
            var sub   = first ? new SubProcess() : new SubProcess(setting.FlowNodeIndex);

            if (first)
            {
                sub.OnFlowNodeIndex = o => setting.SetFlowNodeIndex(o);
            }

            sub.DisplayName = displayName;
            sub.FinishRule  = finishRule;

            //设置节点执行结果输出到变量
            if (resultTo != null)
            {
                sub.Result = new OutArgument <string>(resultTo);
            }

            return(sub);
        }
Пример #4
0
        /// <summary>
        /// 创建Server节点
        /// </summary>
        /// <param name="setting"></param>
        /// <param name="displayName"></param>
        /// <param name="serverScript"></param>
        /// <param name="finishRule"></param>
        /// <param name="serverScriptResultTo"></param>
        /// <param name="serverResultTo"></param>
        /// <returns></returns>
        public static Server CreateServer(ActivitySetting setting
                                          , string displayName
                                          , string serverScript
                                          , IDictionary <string, string> finishRule
                                          , Variable <string> serverScriptResultTo
                                          , Variable <string> serverResultTo)
        {
            //HACK:实现类似于K2的server event
            var first  = setting.FlowNodeIndex == Default_FlowNodeIndex;
            var server = first ? new Server() : new Server(setting.FlowNodeIndex);

            if (first)
            {
                server.OnFlowNodeIndex = o => setting.SetFlowNodeIndex(o);
            }

            server.DisplayName = displayName;
            server.Script      = new InArgument <string>(serverScript);
            server.FinishRule  = finishRule;
            //设置脚本执行结果输出到变量
            if (serverScriptResultTo != null)
            {
                server.SetScriptResultTo(serverScriptResultTo);
            }
            if (serverScriptResultTo != null && string.IsNullOrEmpty(serverScriptResultTo.Name))
            {
                throw new InvalidOperationException("serverScriptResultTo必须是命名变量");
            }
            //设置节点执行结果输出到变量
            if (serverResultTo != null)
            {
                server.Result = new OutArgument <string>(serverResultTo);
            }

            return(server);
        }