| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670 |
- using ivf_tl_CustomControls;
- using ivf_tl_Entity.Entity;
- using ivf_tl_Entity.Entity.balance;
- using ivf_tl_Entity.Entity.Result;
- using ivf_tl_Entity.Enums;
- using ivf_tl_Manage.Converts;
- using ivf_tl_Service.HttpProvider;
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Reflection;
- using System.Reflection.Metadata;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace ivf_tl_Manage.Win
- {
- /// <summary>
- /// ExportBulkWindow.xaml 的交互逻辑
- /// </summary>
- public partial class ExportBulkWindow : Window
- {
- private Dish CurrentDish;
- public List<DishPicAndVideo> DishPicAndVideoList { get; set; } = new List<DishPicAndVideo>();
- bool bb = false;
- public ExportBulkWindow(Dish newDish, List<DishPicAndVideo> dishPicAndVideos,bool IsCleanVideo)
- {
- InitializeComponent();
- DishPicAndVideoList = dishPicAndVideos;
- this.Owner = AppData.Instance.MainWindow;
- if (IsCleanVideo)
- {
- bb = true;
- this.ImageCustom_ExportVideo.Opacity = 0.5;
- this.ImageCustom_ExportVideo.MouseOverOpacityMask = 0;
- this._SourcePicImage.Opacity = 0.5;
- this._SourcePicImage.MouseOverOpacityMask = 0;
- }
- CurrentDish = newDish;
- centerX = 670 / 2.0;
- centerY = 670 / 2.0;
- angle = 360.00 / 16;
- AppData.Instance.SetImageSource(this.bigImag, LogoEnum.Circle);
- InitCustom();
- Closed += (s, e) => AppData.Instance.MainWindow.Activate();
- }
- private List<Image> ImageList = new List<Image>();
- private List<Ellipse> MaskList = new List<Ellipse>();
- private Dictionary<Image, EmbryoState> BackImageList = new Dictionary<Image, EmbryoState>();
- private List<Image> OperImageList = new List<Image>();
- private bool IsAutoAllChecked = false;
- private Brush deaeatForeground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D75AC"));
- private Brush noEmbryoForeground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#9B9B9B"));
- private Brush noPicForeground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D4D4D"));
- private double centerX, centerY;
- private double angle;
- private double angleOffset = 90;
- private int ellipseCount = 16;
- private int backImageRadius = 50;
- private int backImageBigRadius = 248;
- private int imageRadius = 40;
- private int imageBigRadius = 248;
- private int textBigRadius = 193;
- private int operRaius = 13;
- private int operBigRadius = 288;
- private int markRaius = 13;
- private int markBigRadius = 210;
- private void Cancel_Click(object sender, RoutedEventArgs e)
- {
- this.DialogResult = false;
- return;
- }
- private void _all_CheckBox_Checked(object sender, RoutedEventArgs e)
- {
- if (IsAutoAllChecked) return;
- if (!(sender is CheckBoxCustom source)) return;
- foreach (var item in ImageList)
- {
- item.Tag = true;
- }
- foreach (var item in MaskList)
- {
- item.Visibility = Visibility.Visible;
- }
- foreach (var item in BackImageList)
- {
- item.Key.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/ExportSelectedBackground.png", UriKind.Absolute));
- }
- foreach (var item in OperImageList)
- {
- item.Visibility = Visibility.Visible;
- }
- }
- private void _all_CheckBox_Unchecked(object sender, RoutedEventArgs e)
- {
- if (IsAutoAllChecked) return;
- if (!(sender is CheckBoxCustom source)) return;
- foreach (var item in ImageList)
- {
- item.Tag = false;
- }
- foreach (var item in MaskList)
- {
- item.Visibility = Visibility.Hidden;
- }
- foreach (var item in BackImageList)
- {
- switch (item.Value)
- {
- case EmbryoState.Freezing: //冷冻
- item.Key.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState1Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Transplant://移植
- item.Key.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState2Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Cancellation://作废
- item.Key.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState3Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Delete://删除
- item.Key.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState4Icon.png", UriKind.Absolute));
- break;
- default:
- item.Key.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoBackground.png", UriKind.Absolute));
- break;
- }
- //item.Key.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoBackground.png", UriKind.Absolute));
- }
- foreach (var item in OperImageList)
- {
- item.Visibility = Visibility.Hidden;
- }
- }
- private async void ExportPic_MouseUp(object sender, MouseButtonEventArgs e)
- {
- try
- {
- var ids = MaskList.Where(x => x.Visibility == Visibility.Visible).Select(x => (long)x.Tag).ToList();
- if (!ids.Any())
- {
- //ToastMessage("请先选择胚胎");
- ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0303"));
- return;
- }
- bool a1 = false;
- string error = null;
- foreach (var item in ids)
- {
- var currentem = CurrentDish.embryoList.FirstOrDefault(x => x.id == item);
- if (currentem == null) continue;
- var wellinfo = DishPicAndVideoList.FirstOrDefault(x => x.wellSn == currentem.wellSn);
- if (wellinfo == null)
- {
- if (string.IsNullOrEmpty(error)) error = currentem.wellSn.ToString();
- else error = $"{error}、{currentem.wellSn}";
- continue;
- }
- if (string.IsNullOrEmpty(wellinfo.lastPicture))
- {
- if (string.IsNullOrEmpty(error)) error = currentem.wellSn.ToString();
- else error = $"{error}、{currentem.wellSn}";
- continue;
- }
- a1 = true;
- }
- if (!string.IsNullOrEmpty(error))
- {
- //new MessageBoxWindow("提示", $"{error}号well未产生图片", this).ShowDialog();
- new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0304"), $"{KeyToStringConvert.GetLanguageStringByKey("0305")}{error} {KeyToStringConvert.GetLanguageStringByKey("0527")}", this).ShowDialog();
- if (!a1) return;
- }
- string name = $"{CurrentDish.wife}_{DateTime.Now.ToString("yy-MM-dd-HH-mm-ss")}.zip";
- string fileName = SaveFileName(name);
- if (string.IsNullOrEmpty(fileName)) return;
- AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
- {
- DownLoadUrl = $"/api/businessManage/pc/resource/downloadPictures?houseSn={CurrentDish.houseSn}&ids={string.Join(",", ids)}&pictureLayer={0}&tlSn={CurrentDish.tlSn}",
- NewFileFullName = fileName,
- FileName = name,
- });
- //ToastMessage("开始下载");
- ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0299"));
- }
- catch (Exception ex)
- {
- ExLog(ex, "ExportPic_MouseUp");
- new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0291"), ex.Message, this).ShowDialog();
- }
- }
- private void ExportVideo_MouseUp(object sender, MouseButtonEventArgs e)
- {
- try
- {
- var ids = MaskList.Where(x => x.Visibility == Visibility.Visible).Select(x => (long)x.Tag).ToList();
- if (!ids.Any())
- {
- //ToastMessage("请先选择胚胎");
- ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0303"));
- return;
- }
- var a1 = false;
- string error = null;
- foreach (var item in ids)
- {
- var currentem = CurrentDish.embryoList.FirstOrDefault(x => x.id == item);
- if (currentem == null) continue;
- var wellinfo = DishPicAndVideoList.FirstOrDefault(x => x.wellSn == currentem.wellSn);
- if (wellinfo == null)
- {
- if (string.IsNullOrEmpty(error)) error = currentem.wellSn.ToString();
- else error = $"{error}、{currentem.wellSn}";
- continue;
- }
- if ((wellinfo.videos.FirstOrDefault(x => x.pictureLayer == 0 && !string.IsNullOrEmpty(x.videoUrl) && x.videoUrl != AppData.Instance.CleanVideoString) == null))
- {
- if (string.IsNullOrEmpty(error)) error = currentem.wellSn.ToString();
- else error = $"{error}、{currentem.wellSn}";
- continue;
- }
- a1 = true;
- }
- a1 = true;
- if (!string.IsNullOrEmpty(error))
- {
- //new MessageBoxWindow("提示", $"{error}号well未产生视频", this).ShowDialog();
- new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0304"), $"{KeyToStringConvert.GetLanguageStringByKey("0306")}{error} {KeyToStringConvert.GetLanguageStringByKey("0527")}", this).ShowDialog();
- if (!a1) return;
- }
- string name = $"{CurrentDish.wife}_{DateTime.Now.ToString("yy-MM-dd-HH-mm-ss")}.zip";
- string fileName = SaveFileName(name);
- if (string.IsNullOrEmpty(fileName)) return;
- AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
- {
- DownLoadUrl = $"/api/businessManage/pc/resource/downloadVideos?houseSn={CurrentDish.houseSn}&id={CurrentDish.id}&ids={string.Join(",", ids)}&layer=0&tlSn={CurrentDish.tlSn}",
- NewFileFullName = fileName,
- FileName = name,
- });
- //ToastMessage("开始下载");
- ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0299"));
- }
- catch (Exception ex)
- {
- ExLog(ex, "ExportVideo_MouseUp");
- new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0291"), ex.Message, this).ShowDialog();
- }
- }
- public string SaveFileName(string fileName)
- {
- var dialog = new Microsoft.Win32.SaveFileDialog();
- dialog.FileName = fileName;
- dialog.DefaultExt = ".zip";
- dialog.Filter = "zip|*.zip";
- if (dialog.ShowDialog() != true)
- {
- return null;
- }
- return dialog.FileName;
- }
- private bool InitCustom()
- {
- try
- {
- List<PictureEntity> picList = new List<PictureEntity>();
- if (CurrentDish != null && CurrentDish.id > 0)
- {
- var pro = AppData.Instance.GetDishProvider();
- var wellIdList = CurrentDish.embryoList.Select(x => x.id).ToList();
- if (wellIdList.Any())
- {
- picList = pro.GetNewPicApi(CurrentDish.tlSn, CurrentDish.houseSn, wellIdList);
- }
- }
- EllipseGeometry ellipseGeometry = new EllipseGeometry(new Point(imageRadius, imageRadius), imageRadius, imageRadius);
- Embryo itemEmbryo = null;
- for (int i = 0; i < ellipseCount; i++)
- {
- TextBlock textBlock = new TextBlock();
- Image border = new Image();
- Image image = new Image();
- Image opImage = new Image();
- Image markImage = new Image();
- Ellipse maskBorder = new Ellipse();
- this._canvas.Children.Add(textBlock);
- this._canvas.Children.Add(border);
- this._canvas.Children.Add(markImage);
- this._canvas.Children.Add(maskBorder);
- this._canvas.Children.Add(image);
- this._canvas.Children.Add(opImage);
- Panel.SetZIndex(textBlock, 11);
- Panel.SetZIndex(border, 12);
- Panel.SetZIndex(image, 13);
- Panel.SetZIndex(markImage, 17);
- Panel.SetZIndex(maskBorder, 15);
- Panel.SetZIndex(opImage, 16);
- maskBorder.Width = imageRadius * 2;
- maskBorder.Height = imageRadius * 2;
- maskBorder.IsHitTestVisible = false;
- maskBorder.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#4D000000"));
- maskBorder.Visibility = Visibility.Hidden;
- textBlock.FontWeight = FontWeights.Medium;
- textBlock.FontSize = 14;
- textBlock.Width = 16;
- textBlock.Height = 22;
- textBlock.Text = $"{i + 1}";
- textBlock.TextAlignment = TextAlignment.Center;
- textBlock.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - 7);
- textBlock.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * textBigRadius - 11);
- border.Width = backImageRadius * 2;
- border.Height = backImageRadius * 2;
- border.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * backImageBigRadius - backImageRadius);
- border.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * backImageBigRadius - backImageRadius);
- opImage.Width = operRaius * 2;
- opImage.Height = operRaius * 2;
- opImage.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * operBigRadius - operRaius);
- opImage.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * operBigRadius - operRaius);
- opImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/ExportSelectedOperIcon.png", UriKind.Absolute));
- opImage.Visibility = Visibility.Hidden;
- markImage.Width = markRaius * 2;
- markImage.Height = markRaius * 2;
- markImage.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * markBigRadius - markRaius);
- markImage.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * markBigRadius - markRaius);
- markImage.Visibility = Visibility.Collapsed;
- image.Width = imageRadius * 2;
- image.Height = imageRadius * 2;
- image.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageRadius);
- image.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageRadius);
- image.SetValue(Image.ClipProperty, ellipseGeometry);
- maskBorder.SetValue(Canvas.LeftProperty, centerX + Math.Cos(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageRadius);
- maskBorder.SetValue(Canvas.TopProperty, centerY + Math.Sin(((angle * i + angleOffset) * (Math.PI)) / 180) * imageBigRadius - imageRadius);
- itemEmbryo = CurrentDish.embryoList.FirstOrDefault(x => x.wellSn == i + 1);
- if (itemEmbryo == null)//无胚胎
- {
- textBlock.Foreground = noEmbryoForeground;
- border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailNoEmbryoBackground.png", UriKind.Absolute));
- }
- else
- {
- markImage.Visibility = Visibility.Visible;
- switch ((EmbryoState)itemEmbryo.state)
- {
- case EmbryoState.Freezing: //冷冻
- markImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState1Icon.png", UriKind.Absolute));
- border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState1Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Transplant://移植
- markImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState2Icon.png", UriKind.Absolute));
- border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState2Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Cancellation://作废
- markImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState3Icon.png", UriKind.Absolute));
- border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState3Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Delete://删除
- markImage.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/EmbryoState4Icon.png", UriKind.Absolute));
- border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState4Icon.png", UriKind.Absolute));
- break;
- default:
- markImage.Visibility = Visibility.Collapsed;
- border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoBackground.png", UriKind.Absolute));
- break;
- }
- textBlock.Foreground = deaeatForeground;
- string imageUrl = null;
- var currentPic = picList.FirstOrDefault(x => x.wellSn == itemEmbryo.wellSn);
- if (currentPic != null) imageUrl = $"{AppData.Instance.BaseUrl}{currentPic.imageUrl.Replace(AppData.Instance.PicSuf, $"_80x80{AppData.Instance.PicSuf}")}?token={AppData.Instance.HttpServiceCall.GetToken()}";
- if (imageUrl != null)
- {
- image.Source = new BitmapImage(new Uri(imageUrl, UriKind.Absolute));
- }
- else
- {
- image.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoNoPic.png", UriKind.Absolute));
- }
- maskBorder.Tag = itemEmbryo.id;
- ImageList.Add(image);
- MaskList.Add(maskBorder);
- BackImageList.Add(border, (EmbryoState)itemEmbryo.state);
- OperImageList.Add(opImage);
- image.Tag = false;
- EmbryoState itemState = (EmbryoState)itemEmbryo.state;
- image.MouseUp += (s, e) =>
- {
- if (!(s is Image source)) return;
- bool newTag = !((bool)source.Tag);
- source.Tag = newTag;
- if (newTag)
- {
- maskBorder.Visibility = Visibility.Visible;
- opImage.Visibility = Visibility.Visible;
- border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/ExportSelectedBackground.png", UriKind.Absolute));
- var a = MaskList.FirstOrDefault(x => x.Visibility == Visibility.Hidden);
- if (a == null)
- {
- IsAutoAllChecked = true;
- this._all_CheckBox.IsChecked = true;
- IsAutoAllChecked = false;
- }
- }
- else
- {
- maskBorder.Visibility = Visibility.Hidden;
- opImage.Visibility = Visibility.Hidden;
- switch (itemState)
- {
- case EmbryoState.Freezing: //冷冻
- border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState1Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Transplant://移植
- border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState2Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Cancellation://作废
- border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState3Icon.png", UriKind.Absolute));
- break;
- case EmbryoState.Delete://删除
- border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoState4Icon.png", UriKind.Absolute));
- break;
- default:
- border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoBackground.png", UriKind.Absolute));
- break;
- }
- //border.Source = new BitmapImage(new Uri("pack://application:,,,/ivf_tl_Manage;component/Resources/Images/DetailEmbryoBackground.png", UriKind.Absolute));
- IsAutoAllChecked = true;
- this._all_CheckBox.IsChecked = false;
- IsAutoAllChecked = false;
- }
- };
- }
- }
- return true;
- }
- catch (Exception ex)
- {
- ExLog(ex, "InitCustom");
- return false;
- }
- }
- private void ExLog(Exception ex, string name)
- {
- AppData.Instance.LogService.ExceptionLog(ex, $"ExportBulkWindow.{name}", LogEnum.RunException);
- }
- private void ErrorLog(string message, LogEnum logType)
- {
- AppData.Instance.LogService.TLLog($"ExportBulkWindow.{message}", logType);
- }
- private void ExportSourcePic_MouseUp(object sender, MouseButtonEventArgs e)
- {
- try
- {
- var ids = MaskList.Where(x => x.Visibility == Visibility.Visible).Select(x => (long)x.Tag).ToList();
- if (!ids.Any())
- {
- //ToastMessage("请先选择胚胎");
- ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0303"));
- return;
- }
- string name = $"{CurrentDish.wife}_{DateTime.Now.ToString("yy-MM-dd-HH-mm-ss")}.zip";
- string fileName = SaveFileName(name);
- if (string.IsNullOrEmpty(fileName)) return;
- AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
- {
- DownLoadUrl = $"/api/businessManage/pc/resource/downloadSourcePictures",
- NewFileFullName = fileName,
- FileName = name,
- Body = JsonConvert.SerializeObject(new { houseSn = CurrentDish.houseSn, ids = ids, pictureLayer = 0, tlSn = CurrentDish.tlSn }),
- });
- //ToastMessage("开始下载");
- ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0299"));
- }
- catch (Exception ex)
- {
- ExLog(ex, "ExportSourcePic_MouseUp");
- new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0291"), ex.Message, this).ShowDialog();
- }
- }
- private void ExportSourcePic_Click(object sender, RoutedEventArgs e)
- {
- if (bb) return;
- try
- {
- var ids = MaskList.Where(x => x.Visibility == Visibility.Visible).Select(x => (long)x.Tag).ToList();
- if (!ids.Any())
- {
- //ToastMessage("请先选择胚胎");
- ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0303"));
- return;
- }
- string name = $"{CurrentDish.wife}_{DateTime.Now.ToString("yy-MM-dd-HH-mm-ss")}.zip";
- string fileName = SaveFileName(name);
- if (string.IsNullOrEmpty(fileName)) return;
- AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
- {
- DownLoadUrl = $"/api/businessManage/pc/resource/downloadSourcePictures",
- NewFileFullName = fileName,
- FileName = name,
- Body = JsonConvert.SerializeObject(new { houseSn = CurrentDish.houseSn, ids = ids, pictureLayer = 0, tlSn = CurrentDish.tlSn }),
- });
- //ToastMessage("开始下载");
- ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0299"));
- }
- catch (Exception ex)
- {
- ExLog(ex, "ExportSourcePic_MouseUp");
- new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0291"), ex.Message, this).ShowDialog();
- }
- }
- private void ExportPic_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- var ids = MaskList.Where(x => x.Visibility == Visibility.Visible).Select(x => (long)x.Tag).ToList();
- if (!ids.Any())
- {
- //ToastMessage("请先选择胚胎");
- ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0303"));
- return;
- }
- bool a1 = false;
- string error = null;
- foreach (var item in ids)
- {
- var currentem = CurrentDish.embryoList.FirstOrDefault(x => x.id == item);
- if (currentem == null) continue;
- var wellinfo = DishPicAndVideoList.FirstOrDefault(x => x.wellSn == currentem.wellSn);
- if (wellinfo == null)
- {
- if (string.IsNullOrEmpty(error)) error = currentem.wellSn.ToString();
- else error = $"{error}、{currentem.wellSn}";
- continue;
- }
- if (string.IsNullOrEmpty(wellinfo.lastPicture))
- {
- if (string.IsNullOrEmpty(error)) error = currentem.wellSn.ToString();
- else error = $"{error}、{currentem.wellSn}";
- continue;
- }
- a1 = true;
- }
- if (!string.IsNullOrEmpty(error))
- {
- //new MessageBoxWindow("提示", $"{error}号well未产生图片", this).ShowDialog();
- new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0304"), $"{KeyToStringConvert.GetLanguageStringByKey("0305")}{error} {KeyToStringConvert.GetLanguageStringByKey("0527")}", this).ShowDialog();
- if (!a1) return;
- }
- string name = $"{CurrentDish.wife}_{DateTime.Now.ToString("yy-MM-dd-HH-mm-ss")}.zip";
- string fileName = SaveFileName(name);
- if (string.IsNullOrEmpty(fileName)) return;
- AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
- {
- DownLoadUrl = $"/api/businessManage/pc/resource/downloadPictures?houseSn={CurrentDish.houseSn}&ids={string.Join(",", ids)}&pictureLayer={0}&tlSn={CurrentDish.tlSn}",
- NewFileFullName = fileName,
- FileName = name,
- });
- //ToastMessage("开始下载");
- ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0299"));
- }
- catch (Exception ex)
- {
- ExLog(ex, "ExportPic_MouseUp");
- new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0291"), ex.Message, this).ShowDialog();
- }
- }
- private void ExportVideo_Click(object sender, RoutedEventArgs e)
- {
- if (bb) return;
- try
- {
- var ids = MaskList.Where(x => x.Visibility == Visibility.Visible).Select(x => (long)x.Tag).ToList();
- if (!ids.Any())
- {
- //ToastMessage("请先选择胚胎");
- ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0303"));
- return;
- }
- var a1 = false;
- string error = null;
- foreach (var item in ids)
- {
- var currentem = CurrentDish.embryoList.FirstOrDefault(x => x.id == item);
- if (currentem == null) continue;
- var wellinfo = DishPicAndVideoList.FirstOrDefault(x => x.wellSn == currentem.wellSn);
- if (wellinfo == null)
- {
- if (string.IsNullOrEmpty(error)) error = currentem.wellSn.ToString();
- else error = $"{error}、{currentem.wellSn}";
- continue;
- }
- if ((wellinfo.videos.FirstOrDefault(x => x.pictureLayer == 0 && !string.IsNullOrEmpty(x.videoUrl)) == null))
- {
- if (string.IsNullOrEmpty(error)) error = currentem.wellSn.ToString();
- else error = $"{error}、{currentem.wellSn}";
- continue;
- }
- a1 = true;
- }
- if (!string.IsNullOrEmpty(error))
- {
- //new MessageBoxWindow("提示", $"{error}号well未产生视频", this).ShowDialog();
- new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0304"), $"{KeyToStringConvert.GetLanguageStringByKey("0306")}{error} {KeyToStringConvert.GetLanguageStringByKey("0527")}", this).ShowDialog();
- if (!a1) return;
- }
- string name = $"{CurrentDish.wife}_{DateTime.Now.ToString("yy-MM-dd-HH-mm-ss")}.zip";
- string fileName = SaveFileName(name);
- if (string.IsNullOrEmpty(fileName)) return;
- AppData.Instance.MainWindowViewModel.DownLoadStart(new ivf_tl_Entity.Entity.DownLoad.DownLoadEntity
- {
- DownLoadUrl = $"/api/businessManage/pc/resource/downloadVideos?houseSn={CurrentDish.houseSn}&id={CurrentDish.id}&ids={string.Join(",", ids)}&layer=0&tlSn={CurrentDish.tlSn}",
- NewFileFullName = fileName,
- FileName = name,
- });
- //ToastMessage("开始下载");
- ToastMessage(KeyToStringConvert.GetLanguageStringByKey("0299"));
- }
- catch (Exception ex)
- {
- ExLog(ex, "ExportVideo_MouseUp");
- new MessageBoxWindow(KeyToStringConvert.GetLanguageStringByKey("0291"), ex.Message, this).ShowDialog();
- }
- }
- private void ToastMessage(string mess)
- {
- new ToastMessageWindow(this, mess).Show();
- }
- }
- }
|