private void SetTable() { try { DataTable dt = CreateTable(); if (Session["passcar"] != null) { System.Collections.Generic.List <string> liststr = Session["passcar"] as System.Collections.Generic.List <string>; listMq.Clear(); foreach (string mqstr in liststr) { if (mqstr.Substring(0, 11) == "<<< MESSAGE") { int mqstart = mqstr.IndexOf("{"); Json json = new Json(mqstr.Substring(mqstart)); System.Collections.Hashtable carhs = json["car"] as System.Collections.Hashtable; carhs.Add("layoutId", json["layoutId"]); carhs.Add("alarmTime", json["alarmTime"]); listMq.Add(carhs); } } dt = settable(); dt.DefaultView.Sort = "col7 desc"; dt = dt.DefaultView.ToTable(); StorePassCar.DataSource = dt; StorePassCar.DataBind(); if (dt.Rows.Count > 0) { string surl1 = dt.Rows[0][27].ToString(); string surl2 = dt.Rows[0][28].ToString(); string hpzl = dt.Rows[0][5].ToString(); string hpzlms = dt.Rows[0][6].ToString(); string hphm = dt.Rows[0][4].ToString(); string gwsj = dt.Rows[0][7].ToString(); string xlsd = dt.Rows[0][19].ToString(); string kkmc = dt.Rows[0][3].ToString(); string fxmc = dt.Rows[0][17].ToString(); string cjjg = dt.Rows[0][26].ToString(); string msg = GetHtml(hpzl, hphm, hpzlms, gwsj, xlsd, kkmc, fxmc, cjjg); ApplyImage(surl1, surl2); ApplyText(msg); } } } catch (Exception ex) { ILog.WriteErrorLog(ex.Message); logManager.InsertLogError("TgsPassCarAmply.aspx-SetTable", ex.Message + ";" + ex.StackTrace, "SetTable has an exception"); } }
/// <summary> /// xml文件解析 /// </summary> /// <param name="xmlStr">xml字符串</param> public void CXmlToDataTable(string xmlStr) { try { DataTable dt = CreateTable(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlStr); XmlNodeList listNodes = xmlDoc.SelectNodes("Message/Body/Return/passcarinfolist/passcarinfo"); dt = settableweb(listNodes); dt.DefaultView.Sort = "col7 desc"; dt = dt.DefaultView.ToTable(); StorePassCar.DataSource = dt; StorePassCar.DataBind(); if (dt.Rows.Count > 0) { string surl1 = dt.Rows[0][27].ToString(); string surl2 = dt.Rows[0][28].ToString(); string hpzl = dt.Rows[0][5].ToString(); string hpzlms = dt.Rows[0][6].ToString(); string hphm = dt.Rows[0][4].ToString(); string gwsj = dt.Rows[0][7].ToString(); string xlsd = dt.Rows[0][19].ToString(); string kkmc = dt.Rows[0][3].ToString(); string fxmc = dt.Rows[0][17].ToString(); string cjjg = dt.Rows[0][26].ToString(); string msg = GetHtml(hpzl, hphm, hpzlms, gwsj, xlsd, kkmc, fxmc, cjjg); ApplyImage(surl1, surl2); ApplyText(msg); } } catch (Exception ex) { ILog.WriteErrorLog(ex.Message); logManager.InsertLogError("TgsPassCarAmply.aspx-CXmlToDataTable", ex.Message + ";" + ex.StackTrace, "CXmlToDataTable has an exception"); } }