将数据库中的数据取出然后转换成为Xml形式的解析1.列表
2011-03-25 13:14 闫妍 阅读(365) 评论(0) 编辑 收藏 举报接口
协议
Request中的Body部分为
Response中的Body部分为
示例为
转换后的Xml
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 Common.Utils.Helper;
namespace Adapter.Impl
{
public class SelectInfoQueryProcess : IProcess
{
/// <summary>
/// 根据用户ID查询所关联用户的工单信息列表
/// </summary>
/// <param name="header"></param>
/// <param name="body"></param>
/// <returns></returns>
public Result<string> Process(string header, XElement body)
{
try
{
ISelectInfoDataProvider provider = DataProviderFactory.CreateSelectInfoDataProvider();
string customerID = body.Element("CustomerID").Value;
string currentPage = body.Element("CurrentPage").Value;
string pageSize = body.Element("PageSize").Value;
IList<SelectInfo> lstServiceInfo = provider.GetSelectInfoListByCustomerId(customerID,currentPage,pageSize);
XElement xeBody = new XElement("Body",
new XElement("CategoryListPage",
new XElement("ListCount", ""),
new XElement("ListType", ""),
new XElement("CategoryList", "")));
foreach (SelectInfo sObj in lstServiceInfo)
{
xeBody.Element("CategoryListPage").Element("CategoryList").Add(
new XElement("ListItem",
new XElement("WO_ID", sObj.WO_ID), //工单号
new XElement("WO_STATUS_NAME", sObj.WO_STATUS_NAME),//完成状态
new XElement("WO_STATUS", sObj.WO_STATUS),//完成状体编号
new XElement("TargetUri", "")));
}
return new Result<string> { Code = 200, Message = "", State = xeBody.ToString() };
}
catch (Exception ex)
{
LogHelper.Error("SelectInfoListQueryProcess $ Process", ex);
return new Result<string> { Code = (ushort)StatusCode._523, Message = "OA获取数据失败", State = string.Empty };
}
}
}
}