MarkProvider.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using ivf_tl_Entity.ControlEntity;
  2. using ivf_tl_Entity.Entity.balance;
  3. using ivf_tl_Entity.Entity.Mark;
  4. using ivf_tl_Entity.Entity.Result;
  5. using ivf_tl_Entity.Enums;
  6. using Newtonsoft.Json;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Collections.ObjectModel;
  10. namespace ivf_tl_Service.HttpProvider
  11. {
  12. public class MarkProvider
  13. {
  14. LogService LogService { get; set; }
  15. HttpServiceCall httpServiceCall1 { get; set; }
  16. public MarkProvider(HttpServiceCall _httpServiceCall, LogService _logService)
  17. {
  18. httpServiceCall1 = _httpServiceCall;
  19. LogService = _logService;
  20. }
  21. private void ExLog(Exception ex, string name)
  22. {
  23. LogService.ExceptionLog(ex, $"MarkProvider.{name}", LogEnum.RunException);
  24. }
  25. private void ErrorLog(string message, LogEnum logType)
  26. {
  27. LogService.TLLog($"MarkProvider.{message}", logType);
  28. }
  29. public Dish GetMarkResultByRecordIdApi(long id)
  30. {
  31. string funcName = "GetMarkResultByRecordIdApi";
  32. try
  33. {
  34. string url = "/api/businessManage/pc/embryoMark/getMarkResultByRecordId";
  35. Dictionary<string, string> body = new Dictionary<string, string>();
  36. body.Add("id", id.ToString());
  37. string resultString = httpServiceCall1.callWebService(url, body);
  38. if (string.IsNullOrEmpty(resultString)) return new Dish();
  39. ResultEntity<Dish> rs = JsonConvert.DeserializeObject<ResultEntity<Dish>>(resultString);
  40. if (!rs.success)
  41. {
  42. ErrorLog($"{funcName}接口返回失败 {resultString}", LogEnum.RunError);
  43. return null;
  44. }
  45. if (rs.data != null) return rs.data;
  46. ErrorLog($"{funcName}接口返回成功但是无数据 {resultString}", LogEnum.RunError);
  47. return new Dish();
  48. }
  49. catch (Exception ex)
  50. {
  51. ExLog(ex, funcName);
  52. return new Dish();
  53. }
  54. }
  55. }
  56. }