版博士V2.0程序
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 

79 рядки
2.5 KiB

  1. using AssistClient.Utils;
  2. using Newtonsoft.Json.Linq;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. namespace AssistClient
  10. {
  11. public static class WebApi
  12. {
  13. private static bool debug=false;
  14. /// <summary>
  15. /// date,sn
  16. /// </summary>
  17. /// <param name="req"></param>
  18. /// <returns></returns>
  19. /// <exception cref="Exception"></exception>
  20. public static JObject getDefectFromSN(JObject req)
  21. {
  22. if (debug)
  23. {
  24. //JObject data = new JObject()
  25. //{
  26. // {$"Defect_{sn}_1_X111_Y222",JArray.Parse(File.ReadAllText(@"d:\\test.json")) },
  27. //};
  28. //return new JObject()
  29. //{
  30. // {"code",200},
  31. // {"data",data},
  32. //};
  33. }
  34. JObject resp = HttpUtil.postSync($"http://{Config.ServerIP}:{Config.ServerPort}" + "/api/get_defect_from_sn", req.ToString());
  35. if (!resp.Value<bool>("success"))//框架库内
  36. throw new Exception(resp.Value<string>("data"));//框架库内
  37. //成功接收返回
  38. JObject obj = JObject.Parse(resp.Value<string>("data"));
  39. //if (obj.Value<int>("code") != 200)
  40. // throw new Exception(resp.Value<string>("data"));
  41. return obj;
  42. }
  43. /// <summary>
  44. /// date,sn,file_name
  45. /// </summary>
  46. /// <param name="file_name"></param>
  47. /// <returns></returns>
  48. /// <exception cref="Exception"></exception>
  49. public static JObject getDefectBmpBase64(JObject req)
  50. {
  51. if (debug)
  52. {
  53. //return new JObject()
  54. //{
  55. // {"code",200},
  56. // {"data",Convert.ToBase64String(File.ReadAllBytes(Config.Defect_SavePath+"\\"+ file_name))},
  57. //};
  58. }
  59. JObject resp = HttpUtil.postSync($"http://{Config.ServerIP}:{Config.ServerPort}" + "/api/get_defect_pic", req.ToString());
  60. if (!resp.Value<bool>("success"))//框架库内
  61. throw new Exception(resp.Value<string>("data"));//框架库内
  62. //成功接收返回
  63. JObject obj = JObject.Parse(resp.Value<string>("data"));
  64. //if (obj.Value<int>("code") != 200)
  65. // throw new Exception(resp.Value<string>("data"));
  66. return obj;
  67. }
  68. }
  69. }