115 lines
3.8 KiB
C#
115 lines
3.8 KiB
C#
using Aspose.Cells.Drawing;
|
|
using Prism.Services.Dialogs;
|
|
using SWS.CAD.ViewModels.myViewModelBase;
|
|
using SWS.Commons;
|
|
using SWS.Model;
|
|
using SWS.Service;
|
|
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.IO;
|
|
using System.Windows.Forms;
|
|
using Unity;
|
|
using DialogResult = System.Windows.Forms.DialogResult;
|
|
using MessageBox = System.Windows.Forms.MessageBox;
|
|
|
|
namespace SWS.CAD.ViewModels
|
|
{
|
|
public class DialogCheckInRecordViewModel : DialogBase, IDialogAware
|
|
{
|
|
DrawingServce _drawingService { get; set; }
|
|
AnnexesService _annexesService;
|
|
public DialogCheckInRecordViewModel()
|
|
{
|
|
title = "检入记录";
|
|
_drawingService = GlobalObject.container.Resolve<DrawingServce>();
|
|
_annexesService = GlobalObject.container.Resolve<AnnexesService>();
|
|
}
|
|
|
|
public string Title => "";
|
|
|
|
public event Action<IDialogResult> RequestClose;
|
|
|
|
public bool CanCloseDialog()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public void OnDialogClosed()
|
|
{
|
|
|
|
}
|
|
private ObservableCollection<ec_drawing_syn> _listData;
|
|
public ObservableCollection<ec_drawing_syn> listData
|
|
{
|
|
get { return _listData; }
|
|
set { _listData = value; RaisePropertyChanged(nameof(listData)); }
|
|
}
|
|
private ec_drawing_syn _selectData;
|
|
public ec_drawing_syn selectData
|
|
{
|
|
get { return _selectData; }
|
|
set { _selectData = value; RaisePropertyChanged(nameof(selectData)); }
|
|
}
|
|
|
|
private ec_drawing_file dwgFile;
|
|
public async void OnDialogOpened(IDialogParameters parameters)
|
|
{
|
|
dwgFile = parameters.GetValue<ec_drawing_file>(GlobalObject.dialogPar.info.ToString());
|
|
title = $"【{dwgFile.DrawingFileName}】的检入记录";
|
|
var list = await _drawingService.GetCheckInLog(dwgFile.DrawingFileID);
|
|
if (list != null)
|
|
{
|
|
listData=new ObservableCollection<ec_drawing_syn>(list);
|
|
}
|
|
}
|
|
public override async void ExecuteOKCommandAsync(object para)
|
|
{
|
|
if (selectData==null)
|
|
{
|
|
MessageBox.Show("请先选择要下载的数据!");
|
|
return;
|
|
}
|
|
|
|
#region 保存
|
|
SaveFileDialog saveDlg = new SaveFileDialog();
|
|
saveDlg.Filter = "图纸文件(*.dwg)|*.dwg";
|
|
saveDlg.FilterIndex = 1;
|
|
saveDlg.RestoreDirectory = true;
|
|
var dwgName = selectData.CreateTime?.ToString("yyyy-MM-dd HH.mm.ss") + "_" + selectData.DrawingFile;
|
|
saveDlg.FileName = dwgName;
|
|
if (saveDlg.ShowDialog() == DialogResult.OK)
|
|
{
|
|
var filePath = saveDlg.FileName;
|
|
if (File.Exists(filePath))
|
|
{ File.Delete(filePath); }
|
|
var dwgfileDto = await _annexesService.GetAnnexesFile(selectData.FolderId);
|
|
var msg = await _annexesService.DownloadFile(filePath, dwgfileDto.F_Id);
|
|
if (string.IsNullOrEmpty(msg))
|
|
{
|
|
MessageBox.Show("下载图纸文件成功!");
|
|
}
|
|
else { MessageBox.Show("下载图纸文件异常:"+msg); }
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
public override void ExecuteCloseCommand(object parameter)
|
|
{
|
|
if (parameter as string == "ClickNo")
|
|
{
|
|
Prism.Services.Dialogs.DialogResult res = new Prism.Services.Dialogs.DialogResult(ButtonResult.No);
|
|
RequestClose.Invoke(res);
|
|
}
|
|
else
|
|
{
|
|
RequestClose.Invoke(new Prism.Services.Dialogs.DialogResult(ButtonResult.Cancel));
|
|
}
|
|
this.Dispose();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|