InspectionService.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using Blue;
  2. using LitJson;
  3. using Newtonsoft.Json;
  4. using Newtonsoft.Json.Linq;
  5. using UnityEngine;
  6. public class InspectionService : IInspectionService
  7. {
  8. public InspectionInfo InspectionInfo { get; private set; }
  9. public void OnInit()
  10. {
  11. }
  12. public void Get()
  13. {
  14. CoroutineSystem.Instance.StartCoroutine(
  15. HttpTool.Instance.SendHttp(HttpActionLang.inspection_begin, "", message =>
  16. {
  17. JObject jobject = JObject.Parse(message);
  18. if (jobject["code"].ToString() == "200" && !string.IsNullOrWhiteSpace(jobject["data"].ToString()))
  19. {
  20. Debug.LogError("data:" + jobject["data"].ToString());
  21. InspectionInfo = JsonConvert.DeserializeObject<InspectionInfo>(jobject["data"].ToString());
  22. /*
  23. Debug.LogError($"ID:{InspectionInfo.id}");
  24. foreach (var item in InspectionInfo.items)
  25. {
  26. Debug.LogError($"key:{item.Key},Value:{item.Value}");
  27. }
  28. Debug.LogError($"Steps:{InspectionInfo.steps.Count}");
  29. foreach (var item in InspectionInfo.steps)
  30. {
  31. Debug.LogError($"key:{item.Key}");
  32. Debug.LogError($"normal:{item.Value.normal}");
  33. Debug.LogError($"lable:{item.Value.label}");
  34. Debug.LogError($"images:{item.Value.images}");
  35. }
  36. */
  37. }
  38. }));
  39. }
  40. public void Set(int ItemID,bool Normal,string Label,int InspectionId)
  41. {
  42. JsonData data = new JsonData();
  43. data["itemId"] = ItemID;
  44. data["normal"] = Normal;
  45. data["label"] = Label;
  46. data["inspectionId"] = InspectionId;
  47. CoroutineSystem.Instance.StartCoroutine(HttpTool.Instance.SendHttp(HttpActionLang.inspection_step, data.ToJson(), message =>
  48. {
  49. JObject jobject = JObject.Parse(message);
  50. if (jobject["code"].ToString() == "200" && !string.IsNullOrWhiteSpace(jobject["data"].ToString()))
  51. {
  52. //Debug.LogError($"Message:{message}+finished:{jobject["data"]["finished"]}");
  53. }
  54. }));
  55. }
  56. }