/// <summary> /// 获取账号的流量,余额等信息 /// </summary> /// <param name="username"></param> /// <param name="passowrd"></param> public async Task <Models.InfoCenterAccountInfo> GetAccountBasicInfo(string username, string passowrd) { Models.InfoCenterAccountInfo accountinfo = new Models.InfoCenterAccountInfo(); try { var re = await _httpService.SendRequst(checkcodeUri, HttpMethod.Get); int index = re.IndexOf("checkcode=\""); if (index <= 0) { return(accountinfo); } string checkcode = ""; while (re[index + "checkcode=\"".Length] != '\"') { checkcode += re[index + "checkcode=\"".Length]; index++; } //好像没啥意义。。 await _httpService.SendRequst(randomcodeUri, HttpMethod.Get); Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("account", username); parameters.Add("password", passowrd); parameters.Add("checkcode", checkcode); await _httpService.SendRequst(manageUri, HttpMethod.Post, parameters);//登录管理中心 re = await _httpService.SendRequst(accountUri, HttpMethod.Get); var json = Newtonsoft.Json.Linq.JObject.Parse(re); //dynamic json = Newtonsoft.Json.JsonConvert.DeserializeObject(re); var totalFlu = (string)json["note"]["leftFlow"]; var service = (string)json["note"]["service"]; var leftmoney = (string)json["note"]["leftmoeny"]; var flutype = (string)json["note"]["welcome"]; accountinfo.TotalFlu = totalFlu + "MB"; accountinfo.Balance = leftmoney; accountinfo.FluPackageType = flutype; } catch { } try { var re = await _httpService.SendRequst(loginUri, HttpMethod.Get); string usedflu = FindInHtml(re, "flow='", false); accountinfo.UsedFlu = usedflu + "MB"; } catch { } return(accountinfo); }
/// <summary> /// 获取账号的流量,余额等信息 /// </summary> /// <param name="username"></param> /// <param name="passowrd"></param> public async Task <Models.InfoCenterAccountInfo> GetAccountBasicInfo(string username, string passowrd) { Models.InfoCenterAccountInfo accountinfo = new Models.InfoCenterAccountInfo(); double allFlu = 0; double leftFlu = 0; try { var status = await LoginAccountCenter(username, passowrd); if (status == false) { return(accountinfo); } var re = await _accountCenterHttpService.SendRequst(accountUri, HttpMethod.Get); var json = Newtonsoft.Json.Linq.JObject.Parse(re); //dynamic json = Newtonsoft.Json.JsonConvert.DeserializeObject(re); var totalFlu = (string)json["note"]["leftFlow"]; var service = (string)json["note"]["service"]; var leftmoney = (string)json["note"]["leftmoeny"]; var flutype = (string)json["note"]["welcome"]; accountinfo.TotalFlu = AutoAdjustUnit(double.Parse(totalFlu)); allFlu = double.Parse(totalFlu); accountinfo.Balance = leftmoney; accountinfo.FluPackageType = flutype; } catch { } try { var re = await _accountCenterHttpService.SendRequst(loginUri, HttpMethod.Get); string usedflu = FindInHtml(re, "flow='", false); accountinfo.UsedFlu = AutoAdjustUnit(double.Parse(usedflu)); leftFlu = allFlu - double.Parse(usedflu); if (leftFlu < 0) { leftFlu = 0; accountinfo.LeftFlu = 0 + "MB"; } else { accountinfo.LeftFlu = AutoAdjustUnit(leftFlu); } if (allFlu <= 0) { accountinfo.FluPercent = 0; } else { var value = leftFlu / allFlu; accountinfo.FluPercent = value > 1 ? 1 : value; } } catch { } return(accountinfo); }