ExportBulkWindow.xaml.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670
  1. using ivf_tl_CustomControls;
  2. using ivf_tl_Entity.Entity;
  3. using ivf_tl_Entity.Entity.balance;
  4. using ivf_tl_Entity.Entity.Result;
  5. using ivf_tl_Entity.Enums;
  6. using ivf_tl_Manage.Converts;
  7. using ivf_tl_Service.HttpProvider;
  8. using Newtonsoft.Json;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Reflection;
  13. using System.Reflection.Metadata;
  14. using System.Text;
  15. using System.Threading.Tasks;
  16. using System.Windows;
  17. using System.Windows.Controls;
  18. using System.Windows.Data;
  19. using System.Windows.Documents;
  20. using System.Windows.Input;
  21. using System.Windows.Media;
  22. using System.Windows.Media.Imaging;
  23. using System.Windows.Shapes;
  24. namespace ivf_tl_Manage.Win
  25. {
  26. /// <summary>
  27. /// ExportBulkWindow.xaml 的交互逻辑
  28. /// </summary>
  29. public partial class ExportBulkWindow : Window
  30. {
  31. private Dish CurrentDish;
  32. public List<DishPicAndVideo> DishPicAndVideoList { get; set; } = new List<DishPicAndVideo>();
  33. bool bb = false;
  34. public ExportBulkWindow(Dish newDish, List<DishPicAndVideo> dishPicAndVideos,bool IsCleanVideo)
  35. {
  36. InitializeComponent();
  37. DishPicAndVideoList = dishPicAndVideos;
  38. this.Owner = AppData.Instance.MainWindow;
  39. if (IsCleanVideo)
  40. {
  41. bb = true;
  42. this.ImageCustom_ExportVideo.Opacity = 0.5;
  43. this.ImageCustom_ExportVideo.MouseOverOpacityMask = 0;
  44. this._SourcePicImage.Opacity = 0.5;
  45. this._SourcePicImage.MouseOverOpacityMask = 0;
  46. }
  47. CurrentDish = newDish;
  48. centerX = 670 / 2.0;
  49. centerY = 670 / 2.0;
  50. angle = 360.00 / 16;
  51. AppData.Instance.SetImageSource(this.bigImag, LogoEnum.Circle);
  52. InitCustom();
  53. Closed += (s, e) => AppData.Instance.MainWindow.Activate();
  54. }
  55. private List<Image> ImageList = new List<Image>();
  56. private List<Ellipse> MaskList = new List<Ellipse>();
  57. private Dictionary<Image, EmbryoState> BackImageList = new Dictionary<Image, EmbryoState>();
  58. private List<Image> OperImageList = new List<Image>();
  59. private bool IsAutoAllChecked = false;
  60. private Brush deaeatForeground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D75AC"));
  61. private Brush noEmbryoForeground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#9B9B9B"));
  62. private Brush noPicForeground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D4D4D"));
  63. private double centerX, centerY;
  64. private double angle;
  65. private double angleOffset = 90;
  66. private int ellipseCount = 16;
  67. private int backImageRadius = 50;
  68. private int backImageBigRadius = 248;
  69. private int imageRadius = 40;
  70. private int imageBigRadius = 248;
  71. private int textBigRadius = 193;
  72. private int operRaius = 13;
  73. private int operBigRadius = 288;
  74. private int markRaius = 13;
  75. private int markBigRadius = 210;
  76. private void Cancel_Click(object sender, RoutedEventArgs e)
  77. {
  78. this.DialogResult = false;
  79. return;
  80. }
  81. private void _all_CheckBox_Checked(object sender, RoutedEventArgs e)
  82. {
  83. if (IsAutoAllChecked) return;
  84. if (!(sender is CheckBoxCustom source)) return;
  85. foreach (var item in ImageList)
  86. {
  87. item.Tag = true;
  88. }
  89. foreach (var item in MaskList)
  90. {
  91. item.Visibility = Visibility.Visible;
  92. }
  93. foreach (var item in BackImageList)
  94. {
  95. item.Key.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/ExportSelectedBackground.png", UriKind.Absolute));
  96. }
  97. foreach (var item in OperImageList)
  98. {
  99. item.Visibility = Visibility.Visible;
  100. }
  101. }
  102. private void _all_CheckBox_Unchecked(object sender, RoutedEventArgs e)
  103. {
  104. if (IsAutoAllChecked) return;
  105. if (!(sender is CheckBoxCustom source)) return;
  106. foreach (var item in ImageList)
  107. {
  108. item.Tag = false;
  109. }
  110. foreach (var item in MaskList)
  111. {
  112. item.Visibility = Visibility.Hidden;
  113. }
  114. foreach (var item in BackImageList)
  115. {
  116. switch (item.Value)
  117. {
  118. case EmbryoState.Freezing: //冷冻
  119. item.Key.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState1Icon.png", UriKind.Absolute));
  120. break;
  121. case EmbryoState.Transplant://移植
  122. item.Key.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState2Icon.png", UriKind.Absolute));
  123. break;
  124. case EmbryoState.Cancellation://作废
  125. item.Key.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState3Icon.png", UriKind.Absolute));
  126. break;
  127. case EmbryoState.Delete://删除
  128. item.Key.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState4Icon.png", UriKind.Absolute));
  129. break;
  130. default:
  131. item.Key.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoBackground.png", UriKind.Absolute));
  132. break;
  133. }
  134. //item.Key.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoBackground.png", UriKind.Absolute));
  135. }
  136. foreach (var item in OperImageList)
  137. {
  138. item.Visibility = Visibility.Hidden;
  139. }
  140. }
  141. private async void ExportPic_MouseUp(object sender, MouseButtonEventArgs e)
  142. {
  143. try
  144. {
  145. var ids = MaskList.Where(x => x.Visibility == Visibility.Visible).Select(x => (long)x.Tag).ToList();
  146. if (!ids.Any())
  147. {
  148. //ToastMessage("请先选择胚胎");
  149. ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0303"));
  150. return;
  151. }
  152. bool a1 = false;
  153. string error = null;
  154. foreach (var item in ids)
  155. {
  156. var currentem = CurrentDish.embryoList.FirstOrDefault(x => x.id == item);
  157. if (currentem == null) continue;
  158. var wellinfo = DishPicAndVideoList.FirstOrDefault(x => x.wellSn == currentem.wellSn);
  159. if (wellinfo == null)
  160. {
  161. if (string.IsNullOrEmpty(error)) error = currentem.wellSn.ToString();
  162. else error = $"{error}、{currentem.wellSn}";
  163. continue;
  164. }
  165. if (string.IsNullOrEmpty(wellinfo.lastPicture))
  166. {
  167. if (string.IsNullOrEmpty(error)) error = currentem.wellSn.ToString();
  168. else error = $"{error}、{currentem.wellSn}";
  169. continue;
  170. }
  171. a1 = true;
  172. }
  173. if (!string.IsNullOrEmpty(error))
  174. {
  175. //new MessageBoxWindow("提示", $"{error}号well未产生图片", this).ShowDialog();
  176. new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0304"), $"{KeyToStringConvert.GetLanguageStringByKey("0305")}{error} {KeyToStringConvert.GetLanguageStringByKey("0527")}", this).ShowDialog();
  177. if (!a1) return;
  178. }
  179. string name = $"{CurrentDish.wife}_{DateTime.Now.ToString("yy-MM-dd-HH-mm-ss")}.zip";
  180. string fileName = SaveFileName(name);
  181. if (string.IsNullOrEmpty(fileName)) return;
  182. AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
  183. {
  184. DownLoadUrl = $"/api/businessManage/pc/resource/downloadPictures?houseSn={CurrentDish.houseSn}&ids={string.Join(",", ids)}&pictureLayer={0}&tlSn={CurrentDish.tlSn}",
  185. NewFileFullName = fileName,
  186. FileName = name,
  187. });
  188. //ToastMessage("开始下载");
  189. ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0299"));
  190. }
  191. catch (Exception ex)
  192. {
  193. ExLog(ex, "ExportPic_MouseUp");
  194. new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0291"), ex.Message, this).ShowDialog();
  195. }
  196. }
  197. private void ExportVideo_MouseUp(object sender, MouseButtonEventArgs e)
  198. {
  199. try
  200. {
  201. var ids = MaskList.Where(x => x.Visibility == Visibility.Visible).Select(x => (long)x.Tag).ToList();
  202. if (!ids.Any())
  203. {
  204. //ToastMessage("请先选择胚胎");
  205. ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0303"));
  206. return;
  207. }
  208. var a1 = false;
  209. string error = null;
  210. foreach (var item in ids)
  211. {
  212. var currentem = CurrentDish.embryoList.FirstOrDefault(x => x.id == item);
  213. if (currentem == null) continue;
  214. var wellinfo = DishPicAndVideoList.FirstOrDefault(x => x.wellSn == currentem.wellSn);
  215. if (wellinfo == null)
  216. {
  217. if (string.IsNullOrEmpty(error)) error = currentem.wellSn.ToString();
  218. else error = $"{error}、{currentem.wellSn}";
  219. continue;
  220. }
  221. if ((wellinfo.videos.FirstOrDefault(x => x.pictureLayer == 0 && !string.IsNullOrEmpty(x.videoUrl) && x.videoUrl != AppData.Instance.CleanVideoString) == null))
  222. {
  223. if (string.IsNullOrEmpty(error)) error = currentem.wellSn.ToString();
  224. else error = $"{error}、{currentem.wellSn}";
  225. continue;
  226. }
  227. a1 = true;
  228. }
  229. a1 = true;
  230. if (!string.IsNullOrEmpty(error))
  231. {
  232. //new MessageBoxWindow("提示", $"{error}号well未产生视频", this).ShowDialog();
  233. new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0304"), $"{KeyToStringConvert.GetLanguageStringByKey("0306")}{error} {KeyToStringConvert.GetLanguageStringByKey("0527")}", this).ShowDialog();
  234. if (!a1) return;
  235. }
  236. string name = $"{CurrentDish.wife}_{DateTime.Now.ToString("yy-MM-dd-HH-mm-ss")}.zip";
  237. string fileName = SaveFileName(name);
  238. if (string.IsNullOrEmpty(fileName)) return;
  239. AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
  240. {
  241. DownLoadUrl = $"/api/businessManage/pc/resource/downloadVideos?houseSn={CurrentDish.houseSn}&id={CurrentDish.id}&ids={string.Join(",", ids)}&layer=0&tlSn={CurrentDish.tlSn}",
  242. NewFileFullName = fileName,
  243. FileName = name,
  244. });
  245. //ToastMessage("开始下载");
  246. ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0299"));
  247. }
  248. catch (Exception ex)
  249. {
  250. ExLog(ex, "ExportVideo_MouseUp");
  251. new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0291"), ex.Message, this).ShowDialog();
  252. }
  253. }
  254. public string SaveFileName(string fileName)
  255. {
  256. var dialog = new Microsoft.Win32.SaveFileDialog();
  257. dialog.FileName = fileName;
  258. dialog.DefaultExt = ".zip";
  259. dialog.Filter = "zip|*.zip";
  260. if (dialog.ShowDialog() != true)
  261. {
  262. return null;
  263. }
  264. return dialog.FileName;
  265. }
  266. private bool InitCustom()
  267. {
  268. try
  269. {
  270. List<PictureEntity> picList = new List<PictureEntity>();
  271. if (CurrentDish != null && CurrentDish.id > 0)
  272. {
  273. var pro = AppData.Instance.GetDishProvider();
  274. var wellIdList = CurrentDish.embryoList.Select(x => x.id).ToList();
  275. if (wellIdList.Any())
  276. {
  277. picList = pro.GetNewPicApi(CurrentDish.tlSn, CurrentDish.houseSn, wellIdList);
  278. }
  279. }
  280. EllipseGeometry ellipseGeometry = new EllipseGeometry(new Point(imageRadius, imageRadius), imageRadius, imageRadius);
  281. Embryo itemEmbryo = null;
  282. for (int i = 0; i < ellipseCount; i++)
  283. {
  284. TextBlock textBlock = new TextBlock();
  285. Image border = new Image();
  286. Image image = new Image();
  287. Image opImage = new Image();
  288. Image markImage = new Image();
  289. Ellipse maskBorder = new Ellipse();
  290. this._canvas.Children.Add(textBlock);
  291. this._canvas.Children.Add(border);
  292. this._canvas.Children.Add(markImage);
  293. this._canvas.Children.Add(maskBorder);
  294. this._canvas.Children.Add(image);
  295. this._canvas.Children.Add(opImage);
  296. Panel.SetZIndex(textBlock, 11);
  297. Panel.SetZIndex(border, 12);
  298. Panel.SetZIndex(image, 13);
  299. Panel.SetZIndex(markImage, 17);
  300. Panel.SetZIndex(maskBorder, 15);
  301. Panel.SetZIndex(opImage, 16);
  302. maskBorder.Width = imageRadius * 2;
  303. maskBorder.Height = imageRadius * 2;
  304. maskBorder.IsHitTestVisible = false;
  305. maskBorder.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D000000"));
  306. maskBorder.Visibility = Visibility.Hidden;
  307. textBlock.FontWeight = FontWeights.Medium;
  308. textBlock.FontSize = 14;
  309. textBlock.Width = 16;
  310. textBlock.Height = 22;
  311. textBlock.Text = $"{i + 1}";
  312. textBlock.TextAlignment = TextAlignment.Center;
  313. textBlock.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - 7);
  314. textBlock.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - 11);
  315. border.Width = backImageRadius * 2;
  316. border.Height = backImageRadius * 2;
  317. border.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * backImageBigRadius - backImageRadius);
  318. border.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * backImageBigRadius - backImageRadius);
  319. opImage.Width = operRaius * 2;
  320. opImage.Height = operRaius * 2;
  321. opImage.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * operBigRadius - operRaius);
  322. opImage.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * operBigRadius - operRaius);
  323. opImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/ExportSelectedOperIcon.png", UriKind.Absolute));
  324. opImage.Visibility = Visibility.Hidden;
  325. markImage.Width = markRaius * 2;
  326. markImage.Height = markRaius * 2;
  327. markImage.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * markBigRadius - markRaius);
  328. markImage.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * markBigRadius - markRaius);
  329. markImage.Visibility = Visibility.Collapsed;
  330. image.Width = imageRadius * 2;
  331. image.Height = imageRadius * 2;
  332. image.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageRadius);
  333. image.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageRadius);
  334. image.SetValue(Image.ClipProperty, ellipseGeometry);
  335. maskBorder.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageRadius);
  336. maskBorder.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageRadius);
  337. itemEmbryo = CurrentDish.embryoList.FirstOrDefault(x => x.wellSn == i + 1);
  338. if (itemEmbryo == null)//无胚胎
  339. {
  340. textBlock.Foreground = noEmbryoForeground;
  341. border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailNoEmbryoBackground.png", UriKind.Absolute));
  342. }
  343. else
  344. {
  345. markImage.Visibility = Visibility.Visible;
  346. switch ((EmbryoState)itemEmbryo.state)
  347. {
  348. case EmbryoState.Freezing: //冷冻
  349. markImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState1Icon.png", UriKind.Absolute));
  350. border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState1Icon.png", UriKind.Absolute));
  351. break;
  352. case EmbryoState.Transplant://移植
  353. markImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState2Icon.png", UriKind.Absolute));
  354. border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState2Icon.png", UriKind.Absolute));
  355. break;
  356. case EmbryoState.Cancellation://作废
  357. markImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState3Icon.png", UriKind.Absolute));
  358. border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState3Icon.png", UriKind.Absolute));
  359. break;
  360. case EmbryoState.Delete://删除
  361. markImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState4Icon.png", UriKind.Absolute));
  362. border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState4Icon.png", UriKind.Absolute));
  363. break;
  364. default:
  365. markImage.Visibility = Visibility.Collapsed;
  366. border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoBackground.png", UriKind.Absolute));
  367. break;
  368. }
  369. textBlock.Foreground = deaeatForeground;
  370. string imageUrl = null;
  371. var currentPic = picList.FirstOrDefault(x => x.wellSn == itemEmbryo.wellSn);
  372. if (currentPic != null) imageUrl = $"{AppData.Instance.BaseUrl}{currentPic.imageUrl.Replace(AppData.Instance.PicSuf, $"_80x80{AppData.Instance.PicSuf}")}?token={AppData.Instance.HttpServiceCall.GetToken()}";
  373. if (imageUrl != null)
  374. {
  375. image.Source = new BitmapImage(new Uri(imageUrl, UriKind.Absolute));
  376. }
  377. else
  378. {
  379. image.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoNoPic.png", UriKind.Absolute));
  380. }
  381. maskBorder.Tag = itemEmbryo.id;
  382. ImageList.Add(image);
  383. MaskList.Add(maskBorder);
  384. BackImageList.Add(border, (EmbryoState)itemEmbryo.state);
  385. OperImageList.Add(opImage);
  386. image.Tag = false;
  387. EmbryoState itemState = (EmbryoState)itemEmbryo.state;
  388. image.MouseUp += (s, e) =>
  389. {
  390. if (!(s is Image source)) return;
  391. bool newTag = !((bool)source.Tag);
  392. source.Tag = newTag;
  393. if (newTag)
  394. {
  395. maskBorder.Visibility = Visibility.Visible;
  396. opImage.Visibility = Visibility.Visible;
  397. border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/ExportSelectedBackground.png", UriKind.Absolute));
  398. var a = MaskList.FirstOrDefault(x => x.Visibility == Visibility.Hidden);
  399. if (a == null)
  400. {
  401. IsAutoAllChecked = true;
  402. this._all_CheckBox.IsChecked = true;
  403. IsAutoAllChecked = false;
  404. }
  405. }
  406. else
  407. {
  408. maskBorder.Visibility = Visibility.Hidden;
  409. opImage.Visibility = Visibility.Hidden;
  410. switch (itemState)
  411. {
  412. case EmbryoState.Freezing: //冷冻
  413. border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState1Icon.png", UriKind.Absolute));
  414. break;
  415. case EmbryoState.Transplant://移植
  416. border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState2Icon.png", UriKind.Absolute));
  417. break;
  418. case EmbryoState.Cancellation://作废
  419. border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState3Icon.png", UriKind.Absolute));
  420. break;
  421. case EmbryoState.Delete://删除
  422. border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState4Icon.png", UriKind.Absolute));
  423. break;
  424. default:
  425. border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoBackground.png", UriKind.Absolute));
  426. break;
  427. }
  428. //border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoBackground.png", UriKind.Absolute));
  429. IsAutoAllChecked = true;
  430. this._all_CheckBox.IsChecked = false;
  431. IsAutoAllChecked = false;
  432. }
  433. };
  434. }
  435. }
  436. return true;
  437. }
  438. catch (Exception ex)
  439. {
  440. ExLog(ex, "InitCustom");
  441. return false;
  442. }
  443. }
  444. private void ExLog(Exception ex, string name)
  445. {
  446. AppData.Instance.LogService.ExceptionLog(ex, $"ExportBulkWindow.{name}", LogEnum.RunException);
  447. }
  448. private void ErrorLog(string message, LogEnum logType)
  449. {
  450. AppData.Instance.LogService.TLLog($"ExportBulkWindow.{message}", logType);
  451. }
  452. private void ExportSourcePic_MouseUp(object sender, MouseButtonEventArgs e)
  453. {
  454. try
  455. {
  456. var ids = MaskList.Where(x => x.Visibility == Visibility.Visible).Select(x => (long)x.Tag).ToList();
  457. if (!ids.Any())
  458. {
  459. //ToastMessage("请先选择胚胎");
  460. ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0303"));
  461. return;
  462. }
  463. string name = $"{CurrentDish.wife}_{DateTime.Now.ToString("yy-MM-dd-HH-mm-ss")}.zip";
  464. string fileName = SaveFileName(name);
  465. if (string.IsNullOrEmpty(fileName)) return;
  466. AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
  467. {
  468. DownLoadUrl = $"/api/businessManage/pc/resource/downloadSourcePictures",
  469. NewFileFullName = fileName,
  470. FileName = name,
  471. Body = JsonConvert.SerializeObject(new { houseSn = CurrentDish.houseSn, ids = ids, pictureLayer = 0, tlSn = CurrentDish.tlSn }),
  472. });
  473. //ToastMessage("开始下载");
  474. ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0299"));
  475. }
  476. catch (Exception ex)
  477. {
  478. ExLog(ex, "ExportSourcePic_MouseUp");
  479. new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0291"), ex.Message, this).ShowDialog();
  480. }
  481. }
  482. private void ExportSourcePic_Click(object sender, RoutedEventArgs e)
  483. {
  484. if (bb) return;
  485. try
  486. {
  487. var ids = MaskList.Where(x => x.Visibility == Visibility.Visible).Select(x => (long)x.Tag).ToList();
  488. if (!ids.Any())
  489. {
  490. //ToastMessage("请先选择胚胎");
  491. ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0303"));
  492. return;
  493. }
  494. string name = $"{CurrentDish.wife}_{DateTime.Now.ToString("yy-MM-dd-HH-mm-ss")}.zip";
  495. string fileName = SaveFileName(name);
  496. if (string.IsNullOrEmpty(fileName)) return;
  497. AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
  498. {
  499. DownLoadUrl = $"/api/businessManage/pc/resource/downloadSourcePictures",
  500. NewFileFullName = fileName,
  501. FileName = name,
  502. Body = JsonConvert.SerializeObject(new { houseSn = CurrentDish.houseSn, ids = ids, pictureLayer = 0, tlSn = CurrentDish.tlSn }),
  503. });
  504. //ToastMessage("开始下载");
  505. ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0299"));
  506. }
  507. catch (Exception ex)
  508. {
  509. ExLog(ex, "ExportSourcePic_MouseUp");
  510. new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0291"), ex.Message, this).ShowDialog();
  511. }
  512. }
  513. private void ExportPic_Click(object sender, RoutedEventArgs e)
  514. {
  515. try
  516. {
  517. var ids = MaskList.Where(x => x.Visibility == Visibility.Visible).Select(x => (long)x.Tag).ToList();
  518. if (!ids.Any())
  519. {
  520. //ToastMessage("请先选择胚胎");
  521. ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0303"));
  522. return;
  523. }
  524. bool a1 = false;
  525. string error = null;
  526. foreach (var item in ids)
  527. {
  528. var currentem = CurrentDish.embryoList.FirstOrDefault(x => x.id == item);
  529. if (currentem == null) continue;
  530. var wellinfo = DishPicAndVideoList.FirstOrDefault(x => x.wellSn == currentem.wellSn);
  531. if (wellinfo == null)
  532. {
  533. if (string.IsNullOrEmpty(error)) error = currentem.wellSn.ToString();
  534. else error = $"{error}、{currentem.wellSn}";
  535. continue;
  536. }
  537. if (string.IsNullOrEmpty(wellinfo.lastPicture))
  538. {
  539. if (string.IsNullOrEmpty(error)) error = currentem.wellSn.ToString();
  540. else error = $"{error}、{currentem.wellSn}";
  541. continue;
  542. }
  543. a1 = true;
  544. }
  545. if (!string.IsNullOrEmpty(error))
  546. {
  547. //new MessageBoxWindow("提示", $"{error}号well未产生图片", this).ShowDialog();
  548. new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0304"), $"{KeyToStringConvert.GetLanguageStringByKey("0305")}{error} {KeyToStringConvert.GetLanguageStringByKey("0527")}", this).ShowDialog();
  549. if (!a1) return;
  550. }
  551. string name = $"{CurrentDish.wife}_{DateTime.Now.ToString("yy-MM-dd-HH-mm-ss")}.zip";
  552. string fileName = SaveFileName(name);
  553. if (string.IsNullOrEmpty(fileName)) return;
  554. AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
  555. {
  556. DownLoadUrl = $"/api/businessManage/pc/resource/downloadPictures?houseSn={CurrentDish.houseSn}&ids={string.Join(",", ids)}&pictureLayer={0}&tlSn={CurrentDish.tlSn}",
  557. NewFileFullName = fileName,
  558. FileName = name,
  559. });
  560. //ToastMessage("开始下载");
  561. ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0299"));
  562. }
  563. catch (Exception ex)
  564. {
  565. ExLog(ex, "ExportPic_MouseUp");
  566. new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0291"), ex.Message, this).ShowDialog();
  567. }
  568. }
  569. private void ExportVideo_Click(object sender, RoutedEventArgs e)
  570. {
  571. if (bb) return;
  572. try
  573. {
  574. var ids = MaskList.Where(x => x.Visibility == Visibility.Visible).Select(x => (long)x.Tag).ToList();
  575. if (!ids.Any())
  576. {
  577. //ToastMessage("请先选择胚胎");
  578. ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0303"));
  579. return;
  580. }
  581. var a1 = false;
  582. string error = null;
  583. foreach (var item in ids)
  584. {
  585. var currentem = CurrentDish.embryoList.FirstOrDefault(x => x.id == item);
  586. if (currentem == null) continue;
  587. var wellinfo = DishPicAndVideoList.FirstOrDefault(x => x.wellSn == currentem.wellSn);
  588. if (wellinfo == null)
  589. {
  590. if (string.IsNullOrEmpty(error)) error = currentem.wellSn.ToString();
  591. else error = $"{error}、{currentem.wellSn}";
  592. continue;
  593. }
  594. if ((wellinfo.videos.FirstOrDefault(x => x.pictureLayer == 0 && !string.IsNullOrEmpty(x.videoUrl)) == null))
  595. {
  596. if (string.IsNullOrEmpty(error)) error = currentem.wellSn.ToString();
  597. else error = $"{error}、{currentem.wellSn}";
  598. continue;
  599. }
  600. a1 = true;
  601. }
  602. if (!string.IsNullOrEmpty(error))
  603. {
  604. //new MessageBoxWindow("提示", $"{error}号well未产生视频", this).ShowDialog();
  605. new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0304"), $"{KeyToStringConvert.GetLanguageStringByKey("0306")}{error} {KeyToStringConvert.GetLanguageStringByKey("0527")}", this).ShowDialog();
  606. if (!a1) return;
  607. }
  608. string name = $"{CurrentDish.wife}_{DateTime.Now.ToString("yy-MM-dd-HH-mm-ss")}.zip";
  609. string fileName = SaveFileName(name);
  610. if (string.IsNullOrEmpty(fileName)) return;
  611. AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
  612. {
  613. DownLoadUrl = $"/api/businessManage/pc/resource/downloadVideos?houseSn={CurrentDish.houseSn}&id={CurrentDish.id}&ids={string.Join(",", ids)}&layer=0&tlSn={CurrentDish.tlSn}",
  614. NewFileFullName = fileName,
  615. FileName = name,
  616. });
  617. //ToastMessage("开始下载");
  618. ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0299"));
  619. }
  620. catch (Exception ex)
  621. {
  622. ExLog(ex, "ExportVideo_MouseUp");
  623. new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0291"), ex.Message, this).ShowDialog();
  624. }
  625. }
  626. private void ToastMessage(string mess)
  627. {
  628. new ToastMessageWindow(this, mess).Show();
  629. }
  630. }
  631. }