将数据库中的数据取出然后转换成为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 };
}
}
}
}