//云打码解码 private string YUDMDecode(Image img, out int resultId) { StringBuilder pCodeResult = new StringBuilder(new string(' ', 30)); if (YunDaMaPassword.Equals("") || YunDaMaUserName.Equals("")) { YunDaMaUserName = AppConfigRWTool.ReadSetting("YunDaMaUserName"); YunDaMaPassword = AppConfigRWTool.ReadSetting("YunDaMaPasswordMd5"); } //保存文件到本地 string jpgPath = System.Environment.CurrentDirectory + "\\Source\\code.jpg"; if (!Directory.Exists(System.Environment.CurrentDirectory + "\\Source")) //若文件夹不存在则新建文件夹 { Directory.CreateDirectory(System.Environment.CurrentDirectory + "\\Source"); //新建文件夹 } img.Save(jpgPath, img.RawFormat); //解码 resultId = YunDaMaTool.YDM_EasyDecodeByPath(YunDaMaUserName, YunDaMaPassword, YunDaMaAppId, YunDaMaAppKey, jpgPath, YunDaMaCodeType, YunDaMaTimeOut, pCodeResult); if (resultId > 0) { return(pCodeResult.ToString()); } else { return(""); } }
//更新Cookies public string UpdateCookies(out bool IsSuccess) { IsSuccess = true; this.forcedpin = false; string recode = this.End(); if (recode.Equals("0")) { return("Cookies更新成功"); } else { this.forcedpin = true; //五次尝试,失败后不再尝试登录 for (int i = 0; i < 5; i++) { Image image = this.Start(); //解码 string code = this.YUDMDecode(image, out int resultId); if (code.Equals("")) { continue; } //云打码解码登录 string result = this.End(code); if (result.Equals("0")) { return(String.Format("云打码解码第{0}次更新Cookies成功", (i + 1).ToString())); } else { //登陆失败,验证码解码失败回报 YunDaMaTool.YDM_EasyReport(YunDaMaUserName, YunDaMaPassword, YunDaMaAppId, YunDaMaAppKey, resultId, false); } } IsSuccess = false; return("更新Cookies失败"); } }