public static string ConvertToxmlString <T>(T para) { string tmp = XMLSerialization.Serialize(para); tmp = tmp.Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>", ""); tmp = tmp.Replace("<", "<"); tmp = tmp.Replace(">", ">"); tmp = tmp.Trim(); return(tmp); }
/// <summary> /// 类似Dot_2D数组xml转换成java服务器端识别的xml字符串 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="para"></param> /// <returns></returns> public static string convertToArrxmlString <T>(T para) { string tmp = XMLSerialization.Serialize(para); tmp = tmp.Replace("<?xml version=\"1.0\" encoding=\"utf-16\"?>", "").Trim(); int s = tmp.IndexOf(">"); int end = tmp.LastIndexOf("</"); int length = tmp.Length; string temp = tmp.Substring(s + 1, length - (length - end + s + 1)).Trim(); return(temp); }
/// <summary> ///保存更新到数据库 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Savebutton_Click(object sender, RoutedEventArgs e) { string StrUpp; if (Isedit) { if (IsFinancial) { for (int i = 0; i < FInx.Count; i++) { FinancialInfo f = new FinancialInfo(); f = this.grid.GetDataRow(FInx[i]) as FinancialInfo; uppFData.Add(f); } if (uppFData != null && uppFData.Count != 0) { StrUpp = XMLSerialization.Serialize(uppFData); ServiceClient.UppdateFinancialAsync(StrUpp); uppFData.Clear(); ServiceClient.UppdateFinancialCompleted += new EventHandler <UppdateFinancialCompletedEventArgs>(ServiceClient_UppdateFinancialCompleted); } } else { for (int i = 0; i < PInx.Count; i++) { prodectsInfo f = new prodectsInfo(); f = this.grid.GetDataRow(PInx[i]) as prodectsInfo; uppPData.Add(f); } if (uppPData != null && uppPData.Count != 0) { StrUpp = XMLSerialization.Serialize(uppPData); ServiceClient.UppdateprodectAsync(StrUpp); uppPData.Clear(); ServiceClient.UppdateprodectCompleted += new EventHandler <UppdateprodectCompletedEventArgs>(ServiceClient_UppdateprodectCompleted); } } } }
void SaerchByKey_SearchMarketBykeyCompleted(object sender, SearchMarketBykeyCompletedEventArgs e) { if (e.Error == null) { string tmp = e.Result; if (tmp == null) { MessageBox.Show("查询失败!"); return; } searchRlt = new List <marketsInfo>(); if (e.Result != "无信息!") { searchRlt = XMLSerialization.Desrialize(searchRlt, e.Result); if (searchRlt.Count <= 0) { MessageBox.Show("数据库无相关信息!"); return; } grid.DataSource = searchRlt; grid.AllowEditing = false; Marks.markLayer1 = this.markLayer; List <Point> Pnts = new List <Point>(); for (int i = 0; i < searchRlt.Count; i++) { Point pnt = new Point(searchRlt[i].X, searchRlt[i].Y); Pnts.Add(pnt); } Marks.PntList = Pnts; Marks.markets = searchRlt; Marks.mapContainer = this.mapContainer; shopMarks = Marks.AddMarks(); } else { MessageBox.Show("没有相关门店"); } } }
/// <summary> /// ID查询结果处理 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void SearchByID_SearchProdectsByIDCompleted(object sender, SearchDetailsByIDCompletedEventArgs e) { ServiceClient.SearchDetailsByIDCompleted -= SearchByID_SearchProdectsByIDCompleted; if (e.Error == null) { string tmp = e.Result; if (tmp == "") { MessageBox.Show("查询失败!"); return; } if (tmp != "无信息") { if (IsFinancial) { _fincials = new List <FinancialInfo>(); _fincials = XMLSerialization.Desrialize(_fincials, tmp); if (_fincials.Count <= 0) { MessageBox.Show("无相关信息!"); return; } showfinancial(); } else { _prodects = new List <prodectsInfo>(); _prodects = XMLSerialization.Desrialize(_prodects, tmp); if (_prodects.Count <= 0) { MessageBox.Show("无相关信息!"); return; } showProdects(); } } } }