private string GetNodeName() { if (this._template != null) { ActivitySetting activitySetting = this._template.Connection.Activity; if (activitySetting.NewNameNode != null) { return(activitySetting.NewNameNode); } TemplateNodeLocaleInfo lang = this.Language; if (lang != null) { return(lang.Text); } } return(this._nodeDefinition.TemplateNode.Title); }
/// <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; }
/// <summary> /// 创建SubProcess子流程节点 /// </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> /// <param name="nexts"></param> /// <param name="defaultFlowNode"></param> /// <returns></returns> public static FlowStep CreateSubProcess(ActivitySetting setting , string displayName , IDictionary<string, string> finishRule , Variable<string> resultTo , IDictionary<string, FlowNode> nexts , FlowNode defaultFlowNode) { var server = CreateSubProcess(setting, displayName, finishRule, resultTo); var step = new FlowStep(); step.Action = server; if (nexts == null && defaultFlowNode == null) return step; //设置finish cases var flowSwitch = new FlowSwitch<string>(o => resultTo.Get(o)); if (defaultFlowNode != null) flowSwitch.Default = defaultFlowNode; if (nexts != null) nexts.ToList().ForEach(o => flowSwitch.Cases.Add(o.Key, o.Value)); step.Next = flowSwitch; return step; }
/// <summary> /// 创建并行节点 /// </summary> /// <param name="setting"></param> /// <param name="displayName"></param> /// <param name="completionScript"></param> /// <param name="next"></param> /// <param name="branchs"></param> /// <returns></returns> public static FlowStep CreateParallel(ActivitySetting setting , string displayName , string completionScript , FlowNode next , params Custom[] branchs) { return new FlowStep() { Action = CreateCustomParallel(setting, displayName, completionScript, branchs), Next = next }; }
/// <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; }
/// <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; }
/// <summary> /// 创建人工节点 /// </summary> /// <param name="setting"></param> /// <param name="displayName"></param> /// <param name="actioner"></param> /// <param name="humanResultTo"></param> /// <param name="nexts"></param> /// <param name="defaultFlowNode"></param> /// <returns></returns> public static FlowStep CreateHuman(ActivitySetting setting , string displayName , IActionersHelper actioner//Activity<string[]> actioner , Variable<string> humanResultTo , IDictionary<string, FlowNode> nexts , FlowNode defaultFlowNode) { var human = CreateHuman(setting, displayName, actioner, humanResultTo); var step = new FlowStep(); step.Action = human; if (nexts == null && defaultFlowNode == null) return step; //设置finish cases //HACK:在进入switch之前就已经计算出任务结果 var flowSwitch = new FlowSwitch<string>(o => humanResultTo.Get(o)); if (defaultFlowNode != null) flowSwitch.Default = defaultFlowNode; if (nexts != null) nexts.ToList().ForEach(o => flowSwitch.Cases.Add(o.Key, o.Value)); step.Next = flowSwitch; return step; }
/// <summary> /// 创建人工节点 /// </summary> /// <param name="setting"></param> /// <param name="displayName"></param> /// <param name="actioner"></param> /// <param name="humanResultTo"></param> /// <param name="nexts"></param> /// <returns></returns> public static FlowStep CreateHuman(ActivitySetting setting , string displayName , Expression<Func<ActivityContext, string[]>> actioner , Variable<string> humanResultTo , IDictionary<string, FlowNode> nexts , FlowNode defaultFlowNode) { return null; //return CreateHuman(setting // , displayName // , new Taobao.Activities.Expressions.LambdaValue<string[]>(actioner) // , humanResultTo // , nexts // , defaultFlowNode); }
/// <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; }