public static ExpressSet GetExpressSet() { ExpressSet expressSet = new ExpressSet(); XmlDocument xmlNode = ExpressHelper.GetXmlNode(); XmlNode xmlNode2 = xmlNode.SelectSingleNode("companys"); if (xmlNode2 != null) { expressSet.Key = xmlNode2.Attributes["Kuaidi100Key"].Value; expressSet.NewKey = xmlNode2.Attributes["Kuaidi100NewKey"].Value; expressSet.Url = xmlNode2.Attributes["Url"].Value; } return(expressSet); }
public static void DeleteExpress(string name) { XmlDocument xmlNode = ExpressHelper.GetXmlNode(); XmlNode xmlNode2 = xmlNode.SelectSingleNode("companys"); foreach (XmlNode xmlNode3 in xmlNode2.ChildNodes) { if (xmlNode3.Attributes["name"].Value == name) { xmlNode2.RemoveChild(xmlNode3); break; } } xmlNode.Save(ExpressHelper.path); }
public static ExpressCompanyInfo FindNodeByCode(string code) { ExpressCompanyInfo expressCompanyInfo = null; XmlDocument xmlNode = ExpressHelper.GetXmlNode(); string xpath = string.Format("//company[@TaobaoCode='{0}']", code); XmlNode xmlNode2 = xmlNode.SelectSingleNode(xpath); if (xmlNode2 != null) { expressCompanyInfo = new ExpressCompanyInfo(); expressCompanyInfo.Name = xmlNode2.Attributes["name"].Value; expressCompanyInfo.Kuaidi100Code = xmlNode2.Attributes["Kuaidi100Code"].Value; expressCompanyInfo.TaobaoCode = code; } return(expressCompanyInfo); }
public static IList <ExpressCompanyInfo> GetAllExpress() { IList <ExpressCompanyInfo> list = new List <ExpressCompanyInfo>(); XmlDocument xmlNode = ExpressHelper.GetXmlNode(); XmlNode xmlNode2 = xmlNode.SelectSingleNode("companys"); foreach (XmlNode xmlNode3 in xmlNode2.ChildNodes) { list.Add(new ExpressCompanyInfo { Name = xmlNode3.Attributes["name"].Value, Kuaidi100Code = xmlNode3.Attributes["Kuaidi100Code"].Value, TaobaoCode = xmlNode3.Attributes["TaobaoCode"].Value }); } return(list); }
public static void UpdateExpress(string oldcompanyname, string name, string kuaidi100Code, string taobaoCode) { XmlDocument xmlNode = ExpressHelper.GetXmlNode(); XmlNode xmlNode2 = xmlNode.SelectSingleNode("companys"); foreach (XmlNode xmlNode3 in xmlNode2.ChildNodes) { if (xmlNode3.Attributes["name"].Value == oldcompanyname) { xmlNode3.Attributes["name"].Value = name; xmlNode3.Attributes["Kuaidi100Code"].Value = kuaidi100Code; xmlNode3.Attributes["TaobaoCode"].Value = taobaoCode; break; } } xmlNode.Save(ExpressHelper.path); }
public static bool IsExitExpress(string name) { XmlDocument xmlNode = ExpressHelper.GetXmlNode(); XmlNode xmlNode2 = xmlNode.SelectSingleNode("companys"); bool result; foreach (XmlNode xmlNode3 in xmlNode2.ChildNodes) { if (xmlNode3.Attributes["name"].Value == name) { result = true; return(result); } } result = false; return(result); }
private static string GetContentByAPI(LogisticsTools logisticsTools, string key, string computer, string expressNo) { string result; if (logisticsTools == LogisticsTools.Kuaidiniao) { result = ExpressTrackingSetService.GetHiShopExpTrackInfo(ExpressHelper.FormatCompanyCodeByKuaidi100Code(computer), expressNo); } else { string text = ""; HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(string.Concat(new string[] { "http://api.kuaidi100.com/api?id=", key, "&com=", computer, "&nu=", expressNo })); httpWebRequest.Timeout = 8000; HttpWebResponse httpWebResponse; try { httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse(); } catch { result = text; return(result); } if (httpWebResponse.StatusCode == HttpStatusCode.OK) { Stream responseStream = httpWebResponse.GetResponseStream(); StreamReader streamReader = new StreamReader(responseStream, Encoding.GetEncoding("UTF-8")); text = streamReader.ReadToEnd(); text = text.Replace("&", ""); text = text.Replace(" ", ""); text = text.Replace("&", ""); } result = text; } return(result); }
public static string GetExpressData(string computer, string expressNo) { return(ExpressHelper.GetDataByKuaidi100(computer, expressNo)); }
public static string GetExpressData(LogisticsTools logisticsTools, string computer, string expressNo) { return(ExpressHelper.GetDataByKuaidi100(logisticsTools, computer, expressNo)); }