文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>将数据库中的数据取出然后转换成为Xml形式的解析2.详情

将数据库中的数据取出然后转换成为Xml形式的解析2.详情

时间:2011-03-25  来源:闫妍

接口

协议

Request的body部分

Response的Body部分

示例部分

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Adapter.WebUI.Interface;
using Common.Utils;
using System.Xml.Linq;
using Adapter.DataProvider.Interface;
using Adapter.DataProvider.Common;
using System.Reflection;
using Common.Utils.Helper;

namespace Adapter.Impl
{
    public class WorkCardInfoDetailViewProcess : IProcess
    {
        /// <summary>
        /// 根据上岗证ID获取上岗证详情
        /// </summary>
        /// <param name="header"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public Result<string> Process(string header, XElement body)
        {
            try
            {
                IWorkCardInfoDataProvider provider = DataProviderFactory.CreateWorkCardInfoDataProvider();
                string workCardID = body.Element("WorkCardID").Value;
                WorkCardInfo obj = provider.GetWorkCardInfoByWorkCardId(workCardID);

                XElement xeBody = new XElement("Body",
                    new XElement("MultipleDetailPage",
                    new XElement("Title", ""),
                    new XElement("Uri", ""),
                    new XElement("ListType", ""),
                    new XElement("ActionState", ""),
                    new XElement("GroupList", new XElement("GroupItem", ""))));

                if (obj == null) return new Result<string> { Code = 200, Message = "", State = xeBody.ToString() };

                List<string> lstField = new List<string> { "NET_EMPLOYEE_INFO_ID", "WORK_CARD_INFO_ID", "DESCC", "WORK_CARD_LEVEL", "WORK_CARD_LEVEL", "REDUCE_NUM",
                                                            "REMAIN_NUM","END_TIME"};

                lstField.ForEach(h =>
                {
                    PropertyInfo propertyInfo = obj.GetType().GetProperty(h);
                    if (propertyInfo != null)
                    {
                        object o = propertyInfo.GetValue(obj, null);
                        xeBody.Element("MultipleDetailPage").Element("GroupList").Element("GroupItem").Add(new XElement(propertyInfo.Name, o.ToString()));
                    }
                });

                return new Result<string> { Code = 200, Message = "", State = xeBody.ToString() };

            }
            catch (Exception ex)
            {
                LogHelper.Error("WorkCardInfoDetailViewProcess $ Process", ex);
                return new Result<string> { Code = (ushort)StatusCode._523, Message = "获取数据失败", State = string.Empty };
            }
        }
    }
}

相关阅读 更多 +
排行榜 更多 +
找茬脑洞的世界安卓版

找茬脑洞的世界安卓版

休闲益智 下载
滑板英雄跑酷2手游

滑板英雄跑酷2手游

休闲益智 下载
披萨对对看下载

披萨对对看下载

休闲益智 下载