/// <summary> /// 支持直接跳转到指定的节点 /// </summary> /// <param name="targetNodeID">指定的节点</param> /// <returns></returns> public IResponseMessage JumpToTargetnode(string openId, string targetNodeID) { if (FirstLoaded == false) { //初始化 FirstLoaded = true; this.Loaded(); } //##创建节点 NodeInstanceService newNode = this.CreateServicInstance(targetNodeID); if (newNode == null) { return(null); } else { //替换当前节点 CurrentNode = newNode; //处理附加的行为 if (CurrentNode.DealingHandler != null) { DealingHandlerAdditionalBehaviorAttribute attribute = Attribute.GetCustomAttribute(CurrentNode.DealingHandler.GetType(), typeof(DealingHandlerAdditionalBehaviorAttribute)) as DealingHandlerAdditionalBehaviorAttribute; if (attribute != null) { //忽略 呈现ReadyMessage流程 if (attribute.AdditionalBehavior.HasFlag(DealingHandlerAdditionalBehaviorType.IgnoreReadyMessage)) { CurrentNode.NodeStatus = NodeStatusTypes.Dealing; } } } //执行 IResponseMessage ret = ProcessData(openId, DataTypes.InputAll, null); return(ret); } }
//---------Control--------- #region 处理数据 /// <summary> /// 处理数据 /// </summary> /// <param name="openId">OpenID</param> /// <param name="inputType">输入的类型</param> /// <param name="rawData">Raw格式的数据</param> /// <returns>响应结果</returns> public IResponseMessage HanderData(string openId, DataTypes inputType, object rawData) { if (FirstLoaded == false) { //初始化 FirstLoaded = true; this.Loaded(); //##创建初始节点 CurrentNode = this.CreateServicInstance(ConstString.ROOT_NODE_ID); } //##任意时刻都采纳的指令 if (rawData != null && rawData.ToString() == "0") { CurrentNode = this.CreateServicInstance(ConstString.ROOT_NODE_ID); } //处理数据,如果响应结果为“跳转节点”,则继续进行处理;否则,返回结果到外部。 IResponseMessage ret = ProcessData(openId, inputType, rawData); if (ret is ResponseJumpNode) { ResponseJumpNode jumpResult = ret as ResponseJumpNode; if (NodeIdValidator.IsValid(jumpResult.NodeId) == false) { throw new ArgumentException("节点ID格式不正确", "nodeId"); } CurrentNode = this.CreateServicInstance(jumpResult.NodeId); //如果无法创建 if (CurrentNode == null) { return(null); } //处理附加的行为 #region 流程特性 DealingHandlerAdditionalBehaviorAttribute if (CurrentNode.NodeStatus == NodeStatusTypes.Created && CurrentNode.DealingHandler != null) { DealingHandlerAdditionalBehaviorAttribute attribute = Attribute.GetCustomAttribute(CurrentNode.DealingHandler.GetType(), typeof(DealingHandlerAdditionalBehaviorAttribute)) as DealingHandlerAdditionalBehaviorAttribute; if (attribute != null) { //忽略 呈现ReadyMessage流程 if (attribute.AdditionalBehavior.HasFlag(DealingHandlerAdditionalBehaviorType.IgnoreReadyMessage)) { CurrentNode.NodeStatus = NodeStatusTypes.Dealing; } } } #endregion return(ProcessData(openId, inputType, rawData)); } else { return(ret); } }