public static bool MakeLogin(string userName, string passWord, string validateCode,out string errorMsg) { bool loginFlg = false; errorMsg = string.Empty; //string postString = "action=second&Username=13472553885&Password=leifengren&validatenum={0}"; string postString = "action=second&Username={0}&Password={1}&validatenum={2}"; HttpService web = new HttpService(); string htmlContent = string.Empty; web.TargetUrl = string.Concat(Consts.URL_DEFAULT, Consts.URL_POST_LOGIN); web.Encode = Encoding.GetEncoding("gb2312"); web.RefererUrl = Consts.URL_DEFAULT; web.PostData = string.Format(postString, userName, passWord, validateCode); web.PostHttpUseSession(ref htmlContent); if (htmlContent.IndexOf("login_ar") != -1) { MyService.MyInfo = HtmlParser.GetBaseInfo(htmlContent); loginFlg = true; } else if (htmlContent.IndexOf("login_un") != -1) { loginFlg = false; errorMsg = HtmlParser.GetLoginErrorMessage(htmlContent); } return loginFlg; }
/// <summary> /// 查询某地区某运营商充值价格 /// </summary> /// <param name="provinceID">省ID</param> /// <param name="netID">运营商ID(中移动:0,中联通:1)</param> /// <returns>某地区某运营商充值价格</returns> public static string SearchPrice(string provinceID, string netID) { string priceHtml = string.Empty; HttpService web = new HttpService(); web.TargetUrl = Consts.URL_DEFAULT + string.Format(Consts.URL_SEARCH_PRICE, provinceID, netID); web.Encode = Encoding.GetEncoding("gb2312"); web.RefererUrl = Consts.URL_DEFAULT; string htmlContent = web.GetHttpUseSession(); HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(htmlContent); HtmlNodeCollection tables = htmlDoc.DocumentNode.SelectNodes("//table"); foreach (HtmlNode table in tables) { string strWidth = table.GetAttributeValue("width", ""); string strBorder = table.GetAttributeValue("border", ""); string strCellpadding = table.GetAttributeValue("cellpadding", ""); string strCellspacing = table.GetAttributeValue("cellspacing", ""); string strBgcolor = table.GetAttributeValue("bgcolor", ""); if (strWidth == "100%" && strBorder == "0" && strCellpadding == "0" && strCellspacing == "1" && strBgcolor == "#CEDDF2") { priceHtml = table.OuterHtml; } } return priceHtml; }
/// <summary> /// 查询充值状态 /// </summary> /// <param name="statusID">状态类别</param> /// <returns>所有指定状态类别的订单状态信息</returns> public static List<ChargeStatus> SearchStatus(string statusID) { List<ChargeStatus> resultStatus = new List<ChargeStatus>(); string priceHtml = string.Empty; string postString = "phone=&starttime=&finishtime=&state={0}&tradeid=&Submit="; HttpService web = new HttpService(); web.TargetUrl = Consts.URL_DEFAULT + Consts.URL_STATUS; web.Encode = Encoding.GetEncoding("gb2312"); web.RefererUrl = Consts.URL_DEFAULT; web.PostData = string.Format(postString, statusID); string htmlContent = string.Empty; web.PostHttpUseSession(ref htmlContent); HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlDocument(); htmlDoc.LoadHtml(htmlContent); HtmlNodeCollection tables = htmlDoc.DocumentNode.SelectNodes("//table"); foreach (HtmlNode table in tables) { if (table.GetAttributeValue("width", "") == "100%" && table.GetAttributeValue("border", "") == "0" && table.GetAttributeValue("cellpadding", "") == "0" && table.GetAttributeValue("cellspacing", "") == "1" && table.GetAttributeValue("bgcolor", "") == "#CEDDF2") { priceHtml = table.OuterHtml; HtmlNodeCollection trs = table.SelectNodes("tr"); foreach (HtmlNode tr in trs) { if (tr.GetAttributeValue("bgcolor", "") == "#FAFBFF") { HtmlNodeCollection tds = tr.SelectNodes("td"); ChargeStatus item = new ChargeStatus(); item.BackCode = StringUtil.CutEmptyChar(tds[0].InnerHtml); item.BookTime = StringUtil.CutEmptyChar(tds[1].InnerHtml); item.TelophoneNo = StringUtil.CutEmptyChar(tds[2].InnerHtml); item.ProductName = StringUtil.CutEmptyChar(tds[3].InnerHtml); item.ProductPrice = StringUtil.CutEmptyChar(tds[4].InnerHtml); item.Status = StringUtil.CutEmptyChar(tds[5].InnerHtml); resultStatus.Add(item); } } break; } } return resultStatus; }
private void picValidate_DoubleClick(object sender, EventArgs e) { HttpService web = new HttpService(); picValidate.Image = web.GetCheckCode(); }
private void FrmLogin_Load(object sender, EventArgs e) { HttpService web = new HttpService(); picValidate.Image = web.GetCheckCode(); }