ServiceHelper.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  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.WritePropertyName("model");
  419. writer.WriteValue("windows");
  420. writer.WriteEndObject();
  421. }
  422. try
  423. {
  424. string postBody = sw.ToString();
  425. using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
  426. {
  427. writer.Write(postBody);
  428. writer.Close();
  429. }
  430. response = (HttpWebResponse)request.GetResponse();
  431. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  432. {
  433. string responseData = reader.ReadToEnd();
  434. Console.WriteLine(responseData);
  435. reader.Close();
  436. JObject jobject = (JObject)JsonConvert.DeserializeObject(responseData);
  437. if (response != null)
  438. {
  439. response.Close();
  440. }
  441. if (request != null)
  442. {
  443. request.Abort();
  444. }
  445. if (jobject["code"].ToObject<string>().ToLower() == "200")
  446. {
  447. App.IsLogin =true;
  448. access_token = jobject["result"]["access_token"].ToObject<string>().ToLower();
  449. Settings.Default.AppProperties.LoginToken = jobject["result"]["access_token"].ToObject<string>().ToLower();
  450. Settings.Default.Save();
  451. GetUser();
  452. }
  453. return jobject["code"].ToObject<string>().ToLower();
  454. }
  455. }
  456. catch
  457. {
  458. return "300";
  459. }
  460. }
  461. public static String Login(string intemail, string intpassword, string uuid)
  462. {
  463. string postBody = $"?appId=16&deviceSign={uuid}&email={intemail}&password={intpassword}&platformType=0&model=windows";
  464. HttpWebResponse response = null;
  465. ServicePointManager.DefaultConnectionLimit = 200;
  466. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(RequestHost + LoginUrl + postBody);
  467. request.Method = "Post";
  468. request.ContentType = "application/x-www-form-urlencoded";
  469. //request.Accept = "application/vnd.api+json;version=1";
  470. request.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
  471. request.Timeout = 20000;
  472. request.ServicePoint.Expect100Continue = false;
  473. try
  474. {
  475. response = (HttpWebResponse)request.GetResponse();
  476. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  477. {
  478. string responseData = reader.ReadToEnd();
  479. Console.WriteLine(responseData);
  480. reader.Close();
  481. JObject jobject = (JObject)JsonConvert.DeserializeObject(responseData);
  482. if (response != null)
  483. {
  484. response.Close();
  485. }
  486. if (request != null)
  487. {
  488. request.Abort();
  489. }
  490. if (jobject["code"].ToObject<string>().ToLower() == "200")
  491. {
  492. App.IsLogin = true;
  493. access_token = jobject["result"]["access_token"].ToObject<string>().ToLower();
  494. Settings.Default.AppProperties.LoginToken = jobject["result"]["access_token"].ToObject<string>().ToLower();
  495. Settings.Default.Save();
  496. GetUser();
  497. }
  498. return jobject["code"].ToObject<string>().ToLower();
  499. }
  500. }
  501. catch
  502. {
  503. return "300";
  504. }
  505. }
  506. //⑤报错
  507. public static void Logout(string uuid)
  508. {
  509. string postBody = $"?deviceSign={uuid}&appId=16";
  510. HttpWebResponse response = null;
  511. ServicePointManager.DefaultConnectionLimit = 200;
  512. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(RequestHost + LogoutUrl + postBody);
  513. request.Method = "Post";
  514. request.Headers.Add("Authorization", $"Bearer {Settings.Default.AppProperties.LoginToken}");
  515. request.ContentType = "application/x-www-form-urlencoded";
  516. //request.Accept = "application/vnd.api+json;version=1";
  517. request.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
  518. request.Timeout = 20000;
  519. request.ServicePoint.Expect100Continue = false;
  520. try
  521. {
  522. response = (HttpWebResponse)request.GetResponse();
  523. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  524. {
  525. string responseData = reader.ReadToEnd();
  526. Console.WriteLine(responseData);
  527. reader.Close();
  528. JObject jobject = (JObject)JsonConvert.DeserializeObject(responseData);
  529. App.IsLogin = false;
  530. if (response != null)
  531. {
  532. response.Close();
  533. }
  534. if (request != null)
  535. {
  536. request.Abort();
  537. }
  538. }
  539. }
  540. catch
  541. {
  542. }
  543. }
  544. public static String Usergout(string code)
  545. {
  546. string postBody = $"?code={code}&appId=16";
  547. HttpWebResponse response = null;
  548. ServicePointManager.DefaultConnectionLimit = 200;
  549. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(RequestHost + UseroutUrl + postBody);
  550. request.Method = "Post";
  551. request.Headers.Add("Authorization", $"Bearer {Settings.Default.AppProperties.LoginToken}");
  552. request.ContentType = "application/x-www-form-urlencoded";
  553. //request.Accept = "application/vnd.api+json;version=1";
  554. request.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
  555. request.Timeout = 20000;
  556. request.ServicePoint.Expect100Continue = false;
  557. try
  558. {
  559. response = (HttpWebResponse)request.GetResponse();
  560. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  561. {
  562. string responseData = reader.ReadToEnd();
  563. Console.WriteLine(responseData);
  564. reader.Close();
  565. JObject jobject = (JObject)JsonConvert.DeserializeObject(responseData);
  566. if (response != null)
  567. {
  568. response.Close();
  569. }
  570. if (request != null)
  571. {
  572. request.Abort();
  573. }
  574. return jobject["code"].ToObject<string>().ToLower();
  575. }
  576. }
  577. catch
  578. {
  579. return "300";
  580. }
  581. }
  582. public static String Rebirth(string intemail, string firstpassword, string secondPassword, string intcode)
  583. {
  584. HttpWebResponse response = null;
  585. ServicePointManager.DefaultConnectionLimit = 200;
  586. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(RequestHost + RebirthUrl);
  587. request.Method = "Post";
  588. request.ContentType = "application/json";
  589. //request.Accept = "application/vnd.api+json;version=1";
  590. request.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
  591. request.Timeout = 20000;
  592. request.ServicePoint.Expect100Continue = false;
  593. StringWriter sw = new StringWriter();
  594. using (JsonWriter writer = new JsonTextWriter(sw))
  595. {
  596. writer.WriteStartObject();
  597. writer.WritePropertyName("account");
  598. writer.WriteValue(intemail);
  599. writer.WritePropertyName("appId");
  600. writer.WriteValue(16);
  601. writer.WritePropertyName("firstPassword");
  602. writer.WriteValue(firstpassword);
  603. writer.WritePropertyName("platformType");
  604. writer.WriteValue(0);
  605. writer.WritePropertyName("secondPassword");
  606. writer.WriteValue(secondPassword);
  607. writer.WritePropertyName("verifyCode");
  608. writer.WriteValue(intcode);
  609. writer.WriteEndObject();
  610. }
  611. try
  612. {
  613. string postBody = sw.ToString();
  614. using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
  615. {
  616. writer.Write(postBody);
  617. writer.Close();
  618. }
  619. response = (HttpWebResponse)request.GetResponse();
  620. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  621. {
  622. string responseData = reader.ReadToEnd();
  623. Console.WriteLine(responseData);
  624. reader.Close();
  625. JObject jobject = (JObject)JsonConvert.DeserializeObject(responseData);
  626. if (response != null)
  627. {
  628. response.Close();
  629. }
  630. if (request != null)
  631. {
  632. request.Abort();
  633. }
  634. return jobject["code"].ToObject<string>().ToLower();
  635. }
  636. }
  637. catch
  638. {
  639. return "300";
  640. }
  641. }
  642. }
  643. }