BidOpeningData.BidSupervisionSoapClient client = new BidOpeningData.BidSupervisionSoapClient(); Dictionary<string, string> param = new Dictionary<string, string>(); param.Add(CommonParam.ConnKey, DBConnHelper.GetConnectionKey(DBConnHelper.BusinessData)); param.Add(CommonParam.AppNo, SystemPlatformEnum.BackStage_Platform); param.Add(CommonParam.FunctionNo, ((int)SystemModuleEnum.BackStage_AssistQuery).ToString()); param.Add(CommonParam.Command, "FindBidOpeningList"); param.Add("PageIndex", "1"); param.Add("PageSize", "100000"); param.Add("BidOpenDateStart", Request.QueryString["BidOpenDateStart"]);//开始时间 param.Add("BidOpenDateEnd", Request.QueryString["BidOpenDateEnd"]);//结束时间 System.Data.DataSet ds = new System.Data.DataSet("QueryDataSet"); apiHelper.GetDataTable(param, ref ds, "QueryTable"); string queryXmlStr = ds.GetXml(); var aaa = client.GetBidOpeningList(queryXmlStr); List<BidOpeningData.BidOpeningInfo> lst = new List<BidOpeningData.BidOpeningInfo>(); //lst = aaa.ToList(); //过滤重复数据 lst = aaa.Distinct().ToList(); lst = lst.Where((x, i) => lst.FindIndex(z => z.BidSectionDataKey == x.BidSectionDataKey) == i).ToList(); XmlDocument xd = new XmlDocument(); using (StringWriter sw = new StringWriter()) { XmlSerializer xz = new XmlSerializer(lst.GetType()); xz.Serialize(sw, lst); xd.LoadXml(sw.ToString()); } //xd.LastChild.OuterXml param.Clear(); param.Add(CommonParam.ConnKey, DBConnHelper.GetConnectionKey(DBConnHelper.MaccoData)); param.Add(CommonParam.AppNo, SystemPlatformEnum.BackStage_Platform); param.Add(CommonParam.FunctionNo, "998020"); param.Add(CommonParam.Command, "DoSaveBidOpeningRecord"); param.Add("ArrayOfBidOpeningInfo", xd.LastChild.InnerXml.Replace(" xmlns="http://tempuri.org/"","")); var result = await apiHelper.HandleData(null, param);//提交信息 return JsonConvert.DeserializeObject(result).ToString();
PS:使用XmlSerializer序列化List对象成XML格式
XmlDocument xd = new XmlDocument(); using (StringWriter sw = new StringWriter()) { XmlSerializer xz = new XmlSerializer(lst.GetType());//lst为List数据 xz.Serialize(sw, lst); Console.WriteLine(sw.ToString()); xd.LoadXml(sw.ToString()); }