ServiceHelper.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739
  1. using Newtonsoft.Json;
  2. using Newtonsoft.Json.Linq;
  3. using PDF_Master.Properties;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Management;
  9. using System.Net;
  10. using System.Runtime.InteropServices;
  11. using System.Security.Cryptography;
  12. using System.Text;
  13. using System.Threading.Tasks;
  14. namespace PDF_Master.Helper
  15. {
  16. /// <summary>
  17. /// 注册登陆相关的工具类
  18. /// </summary>
  19. ///
  20. public static class ServiceHelper
  21. {
  22. public static bool IsLogin=false;
  23. public static string ALLPassword = "";
  24. public static string access_token = "";
  25. public static string outemail = "";
  26. public static string outcode = "";
  27. public static string outregister = "";
  28. public static string outlogin = "";
  29. public static string code = "";
  30. public static string okcode = "";
  31. public static string remsg = "";
  32. public static string state = "";
  33. public static string AppCode = "com.brother.pdfreaderprofree.windows";
  34. public static string RequestHost = "http://139.196.160.101:8081";
  35. //验证邮箱
  36. public static string OKemailUrl = "/pdf-office-sso/auth/validUser";
  37. //验证验证码
  38. public static string OKcodeUrl = "/pdf-office-sso/auth/isEmailCodeValid";
  39. //发送验证码
  40. public static string GetcodeUrl = "/pdf-office-sso/auth/getVerifyCode";
  41. //注册邮箱
  42. public static string registerUrl = "/pdf-office-sso/auth/emailRegister";
  43. //登录
  44. public static string LoginUrl = "/pdf-office-sso/auth/emailLogin";
  45. //登出
  46. public static string LogoutUrl = "/pdf-office-sso/user/logout";
  47. //注销
  48. public static string UseroutUrl = "/pdf-office-sso/user/logOffForUser";
  49. //重置密码
  50. public static string RebirthUrl = "/pdf-office-sso/auth/resetPassword";
  51. //获取用户信息
  52. public static string GetUserUrl = "/pdf-office-sso/user/me";
  53. /// <summary>
  54. /// 用于检查网络是否可以连接互联网,true表示连接成功,false表示连接失败
  55. /// </summary>
  56. /// <returns></returns>
  57. [DllImport("wininet.dll")]
  58. private extern static bool InternetGetConnectedState(int Description, int ReservedValue);
  59. public static bool IsConnectInternet()
  60. {
  61. int Description = 0;
  62. return InternetGetConnectedState(Description, 0);
  63. }
  64. private static string computerInfo;
  65. /// <summary>
  66. /// 电脑品牌信息
  67. /// </summary>
  68. public static string ComputerInfo
  69. {
  70. get {
  71. if (computerInfo == null)
  72. {
  73. computerInfo = GetComputerInfo();
  74. }
  75. return computerInfo;
  76. }
  77. set { computerInfo = value; }
  78. }
  79. private static string systemInfo;
  80. /// <summary>
  81. /// 系统信息
  82. /// </summary>
  83. public static string SystemInfo
  84. {
  85. get
  86. {
  87. if (systemInfo == null)
  88. {
  89. systemInfo = GetSystemInfo();
  90. }
  91. return systemInfo;
  92. }
  93. set { systemInfo = value; }
  94. }
  95. private static string GetSystemInfo()
  96. {
  97. try
  98. {
  99. string s = "";
  100. SelectQuery sq = new SelectQuery("Win32_OperatingSystem");
  101. ManagementObjectSearcher mos = new ManagementObjectSearcher(sq);
  102. ManagementObjectCollection moc = mos.Get();
  103. foreach (ManagementObject mo in moc)
  104. {
  105. s = mo.Properties["Version"].Value.ToString();
  106. }
  107. moc.Dispose();
  108. sq = null;
  109. return s;
  110. }
  111. catch { return ""; }
  112. }
  113. private static string GetComputerInfo()
  114. {
  115. try
  116. {
  117. string s = "";
  118. System.Windows.Controls.TextBox text = new System.Windows.Controls.TextBox();
  119. SelectQuery sq = new SelectQuery("Win32_ComputerSystem");
  120. ManagementObjectSearcher mos = new ManagementObjectSearcher(sq);
  121. ManagementObjectCollection moc = mos.Get();
  122. foreach (ManagementObject mo in moc)
  123. {
  124. s = mo.Properties["Manufacturer"].Value + " " + mo.Properties["Model"].Value;
  125. }
  126. moc.Dispose();
  127. sq = null;
  128. return s;
  129. }
  130. catch { return ""; }
  131. }
  132. /// <summary>
  133. /// 操作系统生成的UUID,用于获取虚拟机用户的设备识别码
  134. /// </summary>
  135. /// <returns></returns>
  136. public static string GetUUID()
  137. {
  138. string systemId = null;
  139. using (ManagementObjectSearcher mos = new ManagementObjectSearcher("select * from Win32_ComputerSystemProduct"))
  140. {
  141. foreach (var item in mos.Get())
  142. {
  143. systemId = item["UUID"].ToString();
  144. }
  145. }
  146. return systemId;
  147. }
  148. /// <summary>
  149. /// 主板编号
  150. /// </summary>
  151. /// <returns></returns>
  152. public static string GetBoardId()
  153. {
  154. var st = string.Empty;
  155. var mos = new ManagementObjectSearcher("Select * from Win32_BaseBoard");
  156. foreach (var o in mos.Get())
  157. {
  158. var mo = (ManagementObject)o;
  159. st = mo["SerialNumber"].ToString();
  160. }
  161. return st;
  162. }
  163. /// <summary>
  164. /// 获取设备唯一ID
  165. /// </summary>
  166. /// <returns></returns>
  167. public static string GetDeviceSerialNumber()
  168. {
  169. StringBuilder DeviceBuilder = new StringBuilder();
  170. bool IsVirtual = false;
  171. string boardId = GetBoardId();
  172. string uuid = GetUUID();
  173. //判断是否是虚拟机用户
  174. if (boardId.ToLower() == "" || boardId.ToLower() == "none")
  175. {
  176. if (string.IsNullOrEmpty(uuid) || uuid.ToLower() == "none")
  177. return string.Empty;
  178. else
  179. IsVirtual = true;
  180. }
  181. //真实机器用户 用主板id作为唯一识别码
  182. if (!IsVirtual)
  183. {
  184. DeviceBuilder.Append(boardId);
  185. }
  186. else
  187. {
  188. DeviceBuilder.Append(uuid);
  189. }
  190. MD5 md5 = MD5.Create();
  191. List<byte> charbytes = new List<byte>();
  192. foreach (char code in DeviceBuilder.ToString().ToArray())
  193. {
  194. charbytes.Add((byte)code);
  195. }
  196. byte[] md5Array = md5.ComputeHash(charbytes.ToArray());
  197. DeviceBuilder = new StringBuilder();
  198. foreach (var code in md5Array)
  199. {
  200. DeviceBuilder.Append(code.ToString("X2"));
  201. }
  202. return DeviceBuilder.ToString();
  203. }
  204. //超时同步为20秒
  205. public static String GetUser()
  206. {
  207. HttpWebResponse response = null;
  208. ServicePointManager.DefaultConnectionLimit = 200;
  209. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(RequestHost + GetUserUrl+"");
  210. request.Method = "Get";
  211. request.Headers.Add("Authorization", $"Bearer {Settings.Default.AppProperties.LoginToken}");
  212. request.ContentType = "text/html;charset=UTF-8";
  213. //request.Accept = "application/vnd.api+json;version=1";
  214. request.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
  215. request.Timeout = 20000;
  216. request.ServicePoint.Expect100Continue = false;
  217. try
  218. {
  219. response = (HttpWebResponse)request.GetResponse();
  220. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  221. {
  222. string responseData = reader.ReadToEnd();
  223. Console.WriteLine(responseData);
  224. reader.Close();
  225. JObject jobject = (JObject)JsonConvert.DeserializeObject(responseData);
  226. if (response != null)
  227. {
  228. response.Close();
  229. }
  230. if (request != null)
  231. {
  232. request.Abort();
  233. }
  234. Console.WriteLine(responseData);
  235. JToken jToken;
  236. if(jobject.TryGetValue("msg" ,out jToken)==false)
  237. {
  238. App.IsLogin = true;
  239. Settings.Default.UserDate.Email= jobject["email"].ToObject<string>().ToLower();
  240. App.mainWindowViewModel.Useremailchar = Settings.Default.UserDate.Email.Substring(0, 1);
  241. return "ture";
  242. }
  243. else
  244. {
  245. return "false";
  246. }
  247. }
  248. }
  249. catch (System.Net.WebException e)
  250. {
  251. Console.WriteLine(e.Message);
  252. if (Settings.Default.AppProperties.LoginToken == "")
  253. return "No Token";
  254. else if(e.Message== "远程服务器返回错误: (401) 未经授权。")
  255. {
  256. return "401";
  257. }
  258. else return "300";
  259. }
  260. }
  261. public static String Ok_email(string intemail,string validType)
  262. {
  263. HttpWebResponse response = null;
  264. ServicePointManager.DefaultConnectionLimit = 200;
  265. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(RequestHost + OKemailUrl);
  266. request.Method = "Post";
  267. request.ContentType = "application/json";
  268. //request.Accept = "application/vnd.api+json;version=1";
  269. request.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
  270. request.Timeout = 20000;
  271. request.ServicePoint.Expect100Continue = false;
  272. StringWriter sw = new StringWriter();
  273. using (JsonWriter writer = new JsonTextWriter(sw))
  274. {
  275. writer.WriteStartObject();
  276. writer.WritePropertyName("appId");
  277. writer.WriteValue(16);
  278. writer.WritePropertyName("platformType");
  279. writer.WriteValue(0);
  280. writer.WritePropertyName("username");
  281. writer.WriteValue(intemail);
  282. writer.WritePropertyName("validType");
  283. writer.WriteValue(validType);
  284. writer.WriteEndObject();
  285. }
  286. try
  287. {
  288. string postBody = sw.ToString();
  289. using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
  290. {
  291. writer.Write(postBody);
  292. writer.Close();
  293. }
  294. response = (HttpWebResponse)request.GetResponse();
  295. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  296. {
  297. string responseData = reader.ReadToEnd();
  298. Console.WriteLine(responseData);
  299. reader.Close();
  300. JObject jobject = (JObject)JsonConvert.DeserializeObject(responseData);
  301. //outemail = jobject["msg"].ToObject<string>().ToLower();
  302. if (response != null)
  303. {
  304. response.Close();
  305. }
  306. if (request != null)
  307. {
  308. request.Abort();
  309. }
  310. return jobject["code"].ToObject<string>().ToLower();
  311. }
  312. }
  313. catch
  314. {
  315. return "300";
  316. }
  317. }
  318. //⑤报错
  319. public static void Get_code(string action, string email)
  320. {
  321. string post = $"?action={action}&appId=16&receiver={email}&type=0";
  322. HttpWebResponse response = null;
  323. ServicePointManager.DefaultConnectionLimit = 200;
  324. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(RequestHost + GetcodeUrl + post);
  325. request.Method = "Get";
  326. request.ContentType = "text/html;charset=UTF-8";
  327. //request.Accept = "application/vnd.api+json;version=1";
  328. request.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
  329. request.Timeout = 20000;
  330. request.ServicePoint.Expect100Continue = false;
  331. try
  332. {
  333. response = (HttpWebResponse)request.GetResponse();
  334. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  335. {
  336. string responseData = reader.ReadToEnd();
  337. Console.WriteLine(responseData);
  338. reader.Close();
  339. JObject jobject = (JObject)JsonConvert.DeserializeObject(responseData);
  340. if (response != null)
  341. {
  342. response.Close();
  343. }
  344. if (request != null)
  345. {
  346. request.Abort();
  347. }
  348. }
  349. }
  350. catch
  351. {
  352. }
  353. }
  354. public static String Ok_code(string email, string code, string type)
  355. {
  356. string post = $"?account={email}&code={code}&type={type}&appId=16";
  357. HttpWebResponse response = null;
  358. ServicePointManager.DefaultConnectionLimit = 200;
  359. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(RequestHost + OKcodeUrl + post);
  360. request.Method = "Get";
  361. request.ContentType = "text/html;charset=UTF-8";
  362. //request.Accept = "application/vnd.api+json;version=1";
  363. request.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
  364. request.Timeout = 20000;
  365. request.ServicePoint.Expect100Continue = false;
  366. try
  367. {
  368. response = (HttpWebResponse)request.GetResponse();
  369. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  370. {
  371. string responseData = reader.ReadToEnd();
  372. Console.WriteLine(responseData);
  373. reader.Close();
  374. JObject jobject = (JObject)JsonConvert.DeserializeObject(responseData);
  375. if (response != null)
  376. {
  377. response.Close();
  378. }
  379. if (request != null)
  380. {
  381. request.Abort();
  382. }
  383. return jobject["code"].ToObject<string>().ToLower();
  384. }
  385. }
  386. catch
  387. {
  388. return "300";
  389. }
  390. }
  391. public static String Register_email(string intemail, string intpassword, string intcode, string uuid)
  392. {
  393. HttpWebResponse response = null;
  394. ServicePointManager.DefaultConnectionLimit = 200;
  395. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(RequestHost + registerUrl);
  396. request.Method = "Post";
  397. request.ContentType = "application/json";
  398. //request.Accept = "application/vnd.api+json;version=1";
  399. request.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
  400. request.Timeout = 20000;
  401. request.ServicePoint.Expect100Continue = false;
  402. StringWriter sw = new StringWriter();
  403. using (JsonWriter writer = new JsonTextWriter(sw))
  404. {
  405. writer.WriteStartObject();
  406. writer.WritePropertyName("appId");
  407. writer.WriteValue(16);
  408. writer.WritePropertyName("deviceSign");
  409. writer.WriteValue(uuid);
  410. writer.WritePropertyName("password");
  411. writer.WriteValue(intpassword);
  412. writer.WritePropertyName("platformType");
  413. writer.WriteValue(0);
  414. writer.WritePropertyName("username");
  415. writer.WriteValue(intemail);
  416. writer.WritePropertyName("verifyCode");
  417. writer.WriteValue(intcode);
  418. writer.WriteEndObject();
  419. }
  420. try
  421. {
  422. string postBody = sw.ToString();
  423. using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
  424. {
  425. writer.Write(postBody);
  426. writer.Close();
  427. }
  428. response = (HttpWebResponse)request.GetResponse();
  429. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  430. {
  431. string responseData = reader.ReadToEnd();
  432. Console.WriteLine(responseData);
  433. reader.Close();
  434. JObject jobject = (JObject)JsonConvert.DeserializeObject(responseData);
  435. if (response != null)
  436. {
  437. response.Close();
  438. }
  439. if (request != null)
  440. {
  441. request.Abort();
  442. }
  443. if (jobject["code"].ToObject<string>().ToLower() == "200")
  444. {
  445. App.IsLogin =true;
  446. access_token = jobject["result"]["access_token"].ToObject<string>().ToLower();
  447. Settings.Default.AppProperties.LoginToken = jobject["result"]["access_token"].ToObject<string>().ToLower();
  448. Settings.Default.Save();
  449. GetUser();
  450. }
  451. return jobject["code"].ToObject<string>().ToLower();
  452. }
  453. }
  454. catch
  455. {
  456. return "300";
  457. }
  458. }
  459. public static String Login(string intemail, string intpassword, string uuid)
  460. {
  461. string postBody = $"?appId=16&deviceSign={uuid}&email={intemail}&password={intpassword}&platformType=0";
  462. HttpWebResponse response = null;
  463. ServicePointManager.DefaultConnectionLimit = 200;
  464. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(RequestHost + LoginUrl + postBody);
  465. request.Method = "Post";
  466. request.ContentType = "application/x-www-form-urlencoded";
  467. //request.Accept = "application/vnd.api+json;version=1";
  468. request.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
  469. request.Timeout = 20000;
  470. request.ServicePoint.Expect100Continue = false;
  471. try
  472. {
  473. response = (HttpWebResponse)request.GetResponse();
  474. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  475. {
  476. string responseData = reader.ReadToEnd();
  477. Console.WriteLine(responseData);
  478. reader.Close();
  479. JObject jobject = (JObject)JsonConvert.DeserializeObject(responseData);
  480. if (response != null)
  481. {
  482. response.Close();
  483. }
  484. if (request != null)
  485. {
  486. request.Abort();
  487. }
  488. if (jobject["code"].ToObject<string>().ToLower() == "200")
  489. {
  490. App.IsLogin = true;
  491. access_token = jobject["result"]["access_token"].ToObject<string>().ToLower();
  492. Settings.Default.AppProperties.LoginToken = jobject["result"]["access_token"].ToObject<string>().ToLower();
  493. Settings.Default.Save();
  494. GetUser();
  495. }
  496. return jobject["code"].ToObject<string>().ToLower();
  497. }
  498. }
  499. catch
  500. {
  501. return "300";
  502. }
  503. }
  504. //⑤报错
  505. public static void Logout(string uuid)
  506. {
  507. string postBody = $"?deviceSign={uuid}&appId=16";
  508. HttpWebResponse response = null;
  509. ServicePointManager.DefaultConnectionLimit = 200;
  510. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(RequestHost + LogoutUrl + postBody);
  511. request.Method = "Post";
  512. request.Headers.Add("Authorization", $"Bearer {Settings.Default.AppProperties.LoginToken}");
  513. request.ContentType = "application/x-www-form-urlencoded";
  514. //request.Accept = "application/vnd.api+json;version=1";
  515. request.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
  516. request.Timeout = 20000;
  517. request.ServicePoint.Expect100Continue = false;
  518. try
  519. {
  520. response = (HttpWebResponse)request.GetResponse();
  521. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  522. {
  523. string responseData = reader.ReadToEnd();
  524. Console.WriteLine(responseData);
  525. reader.Close();
  526. JObject jobject = (JObject)JsonConvert.DeserializeObject(responseData);
  527. App.IsLogin = false;
  528. if (response != null)
  529. {
  530. response.Close();
  531. }
  532. if (request != null)
  533. {
  534. request.Abort();
  535. }
  536. }
  537. }
  538. catch
  539. {
  540. }
  541. }
  542. public static String Usergout(string code)
  543. {
  544. string postBody = $"?code={code}";
  545. HttpWebResponse response = null;
  546. ServicePointManager.DefaultConnectionLimit = 200;
  547. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(RequestHost + UseroutUrl + postBody);
  548. request.Method = "Post";
  549. request.Headers.Add("Authorization", $"Bearer {Settings.Default.AppProperties.LoginToken}");
  550. request.ContentType = "application/x-www-form-urlencoded";
  551. //request.Accept = "application/vnd.api+json;version=1";
  552. request.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
  553. request.Timeout = 20000;
  554. request.ServicePoint.Expect100Continue = false;
  555. try
  556. {
  557. response = (HttpWebResponse)request.GetResponse();
  558. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  559. {
  560. string responseData = reader.ReadToEnd();
  561. Console.WriteLine(responseData);
  562. reader.Close();
  563. JObject jobject = (JObject)JsonConvert.DeserializeObject(responseData);
  564. if (response != null)
  565. {
  566. response.Close();
  567. }
  568. if (request != null)
  569. {
  570. request.Abort();
  571. }
  572. return jobject["code"].ToObject<string>().ToLower();
  573. }
  574. }
  575. catch
  576. {
  577. return "300";
  578. }
  579. }
  580. public static String Rebirth(string intemail, string firstpassword, string secondPassword, string intcode)
  581. {
  582. HttpWebResponse response = null;
  583. ServicePointManager.DefaultConnectionLimit = 200;
  584. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(RequestHost + RebirthUrl);
  585. request.Method = "Post";
  586. request.ContentType = "application/json";
  587. //request.Accept = "application/vnd.api+json;version=1";
  588. request.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
  589. request.Timeout = 20000;
  590. request.ServicePoint.Expect100Continue = false;
  591. StringWriter sw = new StringWriter();
  592. using (JsonWriter writer = new JsonTextWriter(sw))
  593. {
  594. writer.WriteStartObject();
  595. writer.WritePropertyName("account");
  596. writer.WriteValue(intemail);
  597. writer.WritePropertyName("appId");
  598. writer.WriteValue(16);
  599. writer.WritePropertyName("firstPassword");
  600. writer.WriteValue(firstpassword);
  601. writer.WritePropertyName("platformType");
  602. writer.WriteValue(0);
  603. writer.WritePropertyName("secondPassword");
  604. writer.WriteValue(secondPassword);
  605. writer.WritePropertyName("verifyCode");
  606. writer.WriteValue(intcode);
  607. writer.WriteEndObject();
  608. }
  609. try
  610. {
  611. string postBody = sw.ToString();
  612. using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
  613. {
  614. writer.Write(postBody);
  615. writer.Close();
  616. }
  617. response = (HttpWebResponse)request.GetResponse();
  618. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  619. {
  620. string responseData = reader.ReadToEnd();
  621. Console.WriteLine(responseData);
  622. reader.Close();
  623. JObject jobject = (JObject)JsonConvert.DeserializeObject(responseData);
  624. if (response != null)
  625. {
  626. response.Close();
  627. }
  628. if (request != null)
  629. {
  630. request.Abort();
  631. }
  632. return jobject["code"].ToObject<string>().ToLower();
  633. }
  634. }
  635. catch
  636. {
  637. return "300";
  638. }
  639. }
  640. }
  641. }