Пример #1
0
        /// <summary>
        /// 返回“失败”的消息包
        /// </summary>
        /// <param name="ex">异常信息</param>
        /// <returns></returns>
        public string ReturnFailure(Exception ex)
        {
            // 复制当前的消息对象
            string Error = string.Empty;

            if (ex.InnerException != null && ex.InnerException.Message != null)
            {
                Error = ex.InnerException.Message;
            }
            else if (ex.Message != null)
            {
                Error = ex.Message;
            }
            else
            {
                Error = ex.ToString();
            }
            MessageSerialXml returnResutlXml = MessageSerialXml.DeSerialClassFromXML(MessageSerialXml.SerialClassToXML(serialXmlObject));

            returnResutlXml.Head.Date            = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            returnResutlXml.Head.MsgID           = serialXmlObject.Head.MsgID + "+RET";
            returnResutlXml.Head.StateCode       = "999";
            returnResutlXml.Head.StateDesription = Error;
            returnResutlXml.Head.DataDefine      = new _DataDefine();
            returnResutlXml.Data = new _Data();
            return(MessageSerialXml.SerialClassToXML(returnResutlXml));
        }
Пример #2
0
        public MessagePackage(string interfaceCode, string desc)
        {
            string      xmlPath = @"Configs\TaskConfig.xml";
            XmlDocument xmlDoc  = new XmlDocument();

            xmlDoc.Load(xmlPath);
            string taskConfigXml = xmlDoc.OuterXml;

            // 读取与当前任务相关的配置
            xmlDoc.LoadXml(taskConfigXml);
            string  xpath    = "/Configuration/TaskList/Task[@No = '" + interfaceCode + "']";
            XmlNode taskNode = xmlDoc.SelectSingleNode(xpath);

            if (taskNode == null)
            {
                throw new Exception("找不到接口代码为:" + interfaceCode + "的配置.");
            }
            string Description = taskNode.Attributes["Description"].Value;
            string XmlPath     = @"Configs\Xml\" + taskNode.Attributes["xmlFile"].Value;

            xmlDoc.Load(XmlPath);
            string xml = xmlDoc.OuterXml;

            this.serialXmlObject = MessageSerialXml.DeSerialClassFromXML(xmlDoc.OuterXml);
        }
Пример #3
0
        /// <summary>
        /// 返回“成功”的消息包
        /// </summary>
        /// <returns></returns>
        public string ReturnSuccess()
        {
            // 复制当前的消息对象
            MessageSerialXml returnResutlXml = MessageSerialXml.DeSerialClassFromXML(MessageSerialXml.SerialClassToXML(serialXmlObject));

            returnResutlXml.Head.Date            = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            returnResutlXml.Head.MsgID           = serialXmlObject.Head.MsgID + "+RET";
            returnResutlXml.Head.StateCode       = "000";
            returnResutlXml.Head.StateDesription = "成功";
            returnResutlXml.Head.DataDefine      = new _DataDefine();
            returnResutlXml.Data = new _Data();
            return(MessageSerialXml.SerialClassToXML(returnResutlXml));
        }
Пример #4
0
 public MessagePackage(string xml)
 {
     // 加载接口对应的消息包结构
     this.serialXmlObject = MessageSerialXml.DeSerialClassFromXML(xml);
 }
Пример #5
0
        /// <summary>
        /// 获取反馈内容的消息头信息
        /// </summary>
        /// <param name="xml">反馈的XML</param>
        /// <returns></returns>
        public _Head ResultXml(string xml)
        {
            MessageSerialXml messageSerXml = MessageSerialXml.DeSerialClassFromXML(xml);

            return(messageSerXml.Head);
        }