예제 #1
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="nodeId">节点ID</param>
        public ResponseJumpNode(string nodeId)
        {
            //参数检查
            if (NodeIdValidator.IsValid(nodeId) == false)
            {
                throw new ArgumentException("节点ID格式不正确", "nodeId");
            }

            this.NodeId = nodeId;
        }
예제 #2
0
        //-----------Control-----------

        #region 构造函数

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="tipText">提示信息</param>
        /// <param name="nodeId">要跳转的节点ID</param>
        public DefaultDoneHandler(string tipText, string nodeId)
        {
            //参数检查
            if (NodeIdValidator.IsValid(nodeId) == false)
            {
                throw new ArgumentException("节点ID格式不正确", "nodeId");
            }

            this.TipText = tipText;
            this.NodeId  = nodeId;
        }
예제 #3
0
            /// <summary>
            /// 创建
            /// </summary>
            /// <param name="targetNodeID"></param>
            /// <param name="matchText"></param>
            /// <param name="IgnoreCase"></param>
            /// <returns></returns>
            public static TextMenuItem CreateItem(string targetNodeID, string matchText, bool IgnoreCase = true)
            {
                //参数检查
                if (NodeIdValidator.IsValid(targetNodeID) == false)
                {
                    throw new ArgumentException("节点ID格式不正确", "nodeId");
                }

                TextMenuItem result = new TextMenuItem();

                result.JumpResult    = new ResponseJumpNode(targetNodeID);
                result.TextFullMatch = new TextFullMatchHandler(matchText, IgnoreCase);
                return(result);
            }
예제 #4
0
        //---------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);
            }
        }