DetailPageViewModel.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using CommunityToolkit.Mvvm.ComponentModel;
  2. using ivf_tl_Entity.DTO;
  3. using ivf_tl_Entity.GlobalEntitys;
  4. using ivf_tl_Entity.GlobalEnums;
  5. using ivf_tl_Services;
  6. using Newtonsoft.Json;
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Diagnostics;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. namespace ivf_tl_Operate.ViewModel
  14. {
  15. public partial class DetailPageViewModel : ObservableObject
  16. {
  17. public DishRecordViewModel ParentViewModel { get; set; } = null;
  18. private void ExLog(Exception ex, string name)
  19. {
  20. AppData.Instance.LogHelper.ExceptionLog(ex, $"DetailPageViewModel.{name}", LogEnum.RunException);
  21. }
  22. private void ErrorLog(string mess, LogEnum logEnum)
  23. {
  24. AppData.Instance.LogHelper.TLLog($"DetailPageViewModel.{mess}", logEnum);
  25. }
  26. private void DebugLog(string mess, LogEnum logEnum)
  27. {
  28. AppData.Instance.LogHelper.TLLog($"DetailPageViewModel.{mess}", logEnum);
  29. //Log4netHelper.WriteLog($"DetailPageViewModel.{mess}");
  30. }
  31. public DetailPageViewModel(ExHouse currentHouse, ExDish currentDish)
  32. {
  33. ExHouse = currentHouse;
  34. ExDish = currentDish;
  35. IsUpdata = true;
  36. }
  37. public void Init()
  38. {
  39. Stopwatch stopwatch = Stopwatch.StartNew();
  40. DebugLog($"{ExDish.houseSn}号舱室详情界面数据初始化开始,{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}", LogEnum.TakeTime);
  41. var time1 = stopwatch.Elapsed;
  42. QuickButtons = AppData.Instance.HttpHelper.GetQuickButtonsApi().Take(7).OrderBy(x => x.orderNum).ToList();
  43. var time2 = stopwatch.Elapsed;
  44. DebugLog($"读取快捷按钮完成,{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")},耗时:{(time2 - time1).TotalMilliseconds}毫秒", LogEnum.TakeTime);
  45. var wellSn = ExDish.embryoList.Select(x => x.wellSn).ToList();
  46. if (wellSn != null && wellSn.Any())
  47. {
  48. DishPicAndVideoList = AppData.Instance.HttpHelper.GetRecordDetailApi(ExDish.tlSn, ExDish.houseSn, ExDish.id, ExDish.embryoList.Select(x => x.wellSn).ToList());
  49. time1 = stopwatch.Elapsed;
  50. DebugLog($"获取图片、视频信息完成,{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")},耗时:{(time1 - time2).TotalMilliseconds}毫秒", LogEnum.TakeTime);
  51. }
  52. DebugLog($"{ExDish.houseSn}号舱室详情界面数据初始化完成,{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")},总耗时:{stopwatch.Elapsed.TotalMilliseconds}毫秒", LogEnum.TakeTime);
  53. stopwatch.Stop();
  54. }
  55. [ObservableProperty]
  56. private ExHouse exHouse = null;
  57. [ObservableProperty]
  58. private ExDish exDish = null;
  59. [ObservableProperty]
  60. private ExEmbryo currentEmbryo = null;
  61. /// <summary>
  62. /// 视频总时长
  63. /// </summary>
  64. [ObservableProperty]
  65. private double videoAllTime = 1;
  66. /// <summary>
  67. /// 视频已播放时长
  68. /// </summary>
  69. [ObservableProperty]
  70. private double videoCurrentTime = 0;
  71. /// <summary>
  72. /// 当前图层
  73. /// </summary>
  74. [ObservableProperty]
  75. private int currentFocal = 0;
  76. [ObservableProperty]
  77. private bool isUpdata = false;
  78. [ObservableProperty]
  79. private List<ButtonEntity> quickButtons = new List<ButtonEntity>();
  80. public List<DishPicAndVideo> DishPicAndVideoList { get; set; } = new List<DishPicAndVideo>();
  81. public DishPicAndVideo CurrentWellDishPicAndVideo { get; set; } = null;
  82. public LayerPicAndVideo CurrentWellLayerPicAndVideo { get; set; } = null;
  83. public DetailPic CurrentPic { get; set; } = null;
  84. //public List<ButtonEntity> QuickButtons { get; set; } = null;
  85. public int MaxTotalLayer = -1;
  86. }
  87. }