示例#1
0
        protected override void ResolveRequestBody(XmlNode node)
        {
            TDeviceTagValueRWReqBody request =
                TDeviceTagValueRWReqBody.LoadFromXMLNode(node);

            if (request != null)
            {
                bodyRequest = request;
            }
        }
示例#2
0
 public TDeviceTagValueRWContent()
 {
     bodyResponse = new TDeviceTagValueRWRspBody();
     bodyRequest  = new TDeviceTagValueRWReqBody();
 }
示例#3
0
        public static TDeviceTagValueRWReqBody LoadFromXMLNode(XmlNode node)
        {
            // 筛选出第一个 Parameters 节点,其余的 Parameters 节点忽略
            XmlNode paramNode = null;

            foreach (XmlNode child in node.ChildNodes)
            {
                if (child.Name == "Parameters")
                {
                    paramNode = child;
                    break;
                }
            }
            // 如果不存在 Parameters 节点,则返回 null 值
            if (paramNode == null)
            {
                Exception error = new Exception();
                error.Data["ErrCode"] = "900001";
                error.Data["ErrText"] = string.Format("XML 节点 [{0}] 是空节点", paramNode.Name);
                throw error;
            }

            // 筛选出第一个 Param 节点并解析生成 TDeviceTagValueRWReqBody 对象,其余节点忽略
            TDeviceTagValueRWReqBody rlt = null;

            foreach (XmlNode child in paramNode.ChildNodes)
            {
                if (child.Name == "Param")
                {
                    rlt = new TDeviceTagValueRWReqBody();
                    rlt = IRAPXMLUtils.LoadValueFromXMLNode(child, rlt) as TDeviceTagValueRWReqBody;
                    break;
                }
            }
            // 如果不存在 Param 节点,则返回 null 值
            if (rlt == null)
            {
                Exception error = new Exception();
                error.Data["ErrCode"] = "900001";
                error.Data["ErrText"] = string.Format("XML 节点 [{0}] 中没有找到 Param 节点", paramNode.Name);
                throw error;
            }

            foreach (XmlNode child in paramNode.ChildNodes)
            {
                if (child.Name == "ParamXML")
                {
                    foreach (XmlNode actionType in child.ChildNodes)
                    {
                        if (actionType.Name == "Write")
                        {
                            rlt.WriteTags.LoadFromXMLNode(actionType);
                        }
                        if (actionType.Name == "Read")
                        {
                            rlt.ReadTags.LoadFromXMLNode(actionType);
                        }
                        if (actionType.Name == "Flag")
                        {
                            rlt.FlagTags.LoadFromXMLNode(actionType);
                        }
                    }
                }
            }

            return(rlt);
        }