using CommunityToolkit.Mvvm.ComponentModel;
using ivf_tl_Entity.DTO;
using ivf_tl_Entity.GlobalEntitys;
using ivf_tl_Entity.GlobalEnums;
using ivf_tl_Services;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ivf_tl_Operate.ViewModel
{
public partial class DetailPageViewModel : ObservableObject
{
public DishRecordViewModel ParentViewModel { get; set; } = null;
private void ExLog(Exception ex, string name)
{
AppData.Instance.LogHelper.ExceptionLog(ex, $"DetailPageViewModel.{name}", LogEnum.RunException);
}
private void ErrorLog(string mess, LogEnum logEnum)
{
AppData.Instance.LogHelper.TLLog($"DetailPageViewModel.{mess}", logEnum);
}
private void DebugLog(string mess, LogEnum logEnum)
{
AppData.Instance.LogHelper.TLLog($"DetailPageViewModel.{mess}", logEnum);
//Log4netHelper.WriteLog($"DetailPageViewModel.{mess}");
}
public DetailPageViewModel(ExHouse currentHouse, ExDish currentDish)
{
ExHouse = currentHouse;
ExDish = currentDish;
IsUpdata = true;
}
public void Init()
{
Stopwatch stopwatch = Stopwatch.StartNew();
DebugLog($"{ExDish.houseSn}号舱室详情界面数据初始化开始,{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")}", LogEnum.TakeTime);
var time1 = stopwatch.Elapsed;
QuickButtons = AppData.Instance.HttpHelper.GetQuickButtonsApi().Take(7).OrderBy(x => x.orderNum).ToList();
var time2 = stopwatch.Elapsed;
DebugLog($"读取快捷按钮完成,{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")},耗时:{(time2 - time1).TotalMilliseconds}毫秒", LogEnum.TakeTime);
var wellSn = ExDish.embryoList.Select(x => x.wellSn).ToList();
if (wellSn != null && wellSn.Any())
{
DishPicAndVideoList = AppData.Instance.HttpHelper.GetRecordDetailApi(ExDish.tlSn, ExDish.houseSn, ExDish.id, ExDish.embryoList.Select(x => x.wellSn).ToList());
time1 = stopwatch.Elapsed;
DebugLog($"获取图片、视频信息完成,{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")},耗时:{(time1 - time2).TotalMilliseconds}毫秒", LogEnum.TakeTime);
}
DebugLog($"{ExDish.houseSn}号舱室详情界面数据初始化完成,{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff")},总耗时:{stopwatch.Elapsed.TotalMilliseconds}毫秒", LogEnum.TakeTime);
stopwatch.Stop();
}
[ObservableProperty]
private ExHouse exHouse = null;
[ObservableProperty]
private ExDish exDish = null;
[ObservableProperty]
private ExEmbryo currentEmbryo = null;
///
/// 视频总时长
///
[ObservableProperty]
private double videoAllTime = 1;
///
/// 视频已播放时长
///
[ObservableProperty]
private double videoCurrentTime = 0;
///
/// 当前图层
///
[ObservableProperty]
private int currentFocal = 0;
[ObservableProperty]
private bool isUpdata = false;
[ObservableProperty]
private List quickButtons = new List();
public List DishPicAndVideoList { get; set; } = new List();
public DishPicAndVideo CurrentWellDishPicAndVideo { get; set; } = null;
public LayerPicAndVideo CurrentWellLayerPicAndVideo { get; set; } = null;
public DetailPic CurrentPic { get; set; } = null;
//public List QuickButtons { get; set; } = null;
public int MaxTotalLayer = -1;
}
}