123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- /* ==============================================================================
- * 功能描述:VmVerticalPipeCheck
- * 创 建 者:Garrett
- * 创建日期:2019/11/5 15:25:33
- * ==============================================================================*/
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using FWindSoft.Revit;
- using FWindSoft.Wpf;
- using Saga.PlugIn.CreateFacility;
- using Saga.PlugIn.ModelCheck;
- using SAGA.DotNetUtils.Extend;
- using SAGA.DotNetUtils.WPF;
- using SAGA.RevitUtils;
- namespace Saga.PlugIn.VerticalPipeCheck
- {
- /// <summary>
- /// VmVerticalPipeCheck
- /// </summary>
- public class VmVerticalPipeCheck:BaseViewModelStub
- {
- public VmVerticalPipeCheck()
- {
- SaveDir = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
- }
- #region Property
- private string m_UpFilePath;
- /// <summary>
- ///
- /// </summary>
- public string UpFilePath
- {
- get { return m_UpFilePath; }
- set
- {
- m_UpFilePath = value;
- NotifyPropertyChanged("UpFilePath");
- }
- }
- private string m_DownFilePath;
- /// <summary>
- ///
- /// </summary>
- public string DownFilePath
- {
- get { return m_DownFilePath; }
- set
- {
- m_DownFilePath = value;
- NotifyPropertyChanged("DownFilePath");
- }
- }
- private string m_SaveDir;
- /// <summary>
- /// 保存路径
- /// </summary>
- public string SaveDir
- {
- get { return m_SaveDir; }
- set
- {
- m_SaveDir = value;
- NotifyPropertyChanged("SaveDir");
- }
- }
- private string m_SavePath;
- /// <summary>
- /// 保存路径
- /// </summary>
- public string SavePath
- {
- get { return m_SavePath; }
- set
- {
- m_SavePath = value;
- NotifyPropertyChanged("SavePath");
- }
- }
- private ModelCheckState m_ModelCheckState;
- public ModelCheckState ModelCheckState
- {
- get { return m_ModelCheckState; }
- set
- {
- m_ModelCheckState = value;
- NotifyPropertyChanged(nameof(ModelCheckState));
- }
- }
- #endregion
- [Command]
- public void Execute(object param)
- {
- try
- {
- switch (ModelCheckState)
- {
- case ModelCheckState.Prepare:
- ModelCheckState = ModelCheckState.Progress;
- //刷新界面
- WpfSysCmd.DoEvent();
- string savePath = Path.Combine(SaveDir,
- $"{UpFilePath.GetFileName()}-{DownFilePath.GetFileName()}{"立管检查报告"}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx");
- //为了Ending的界面显示,出问题注释掉
- SavePath = savePath;
- var taskHandler = RevitHandlerFactory.CreateOnceHandler((a) =>
- {
- var tuple = VerticalPipeUtil.Execute(UpFilePath, DownFilePath, savePath);
- ModelCheckState = ModelCheckState.Ending;
- WinTipVPipeCheckComplete win = new WinTipVPipeCheckComplete(tuple?.Item1, tuple?.Item2);
- win.ShowDialog();
- return HandlerResult.Successed;
- });
- taskHandler.Execute(RevitCore.UIApp);
- break;
- case ModelCheckState.Progress:
- break;
- case ModelCheckState.Ending:
- ModelCheckState = ModelCheckState.Prepare;
- DownFilePath = UpFilePath;
- UpFilePath = "";
- break;
- }
- }
- catch (Exception e)
- {
- MessageShow.Show(e);
- }
- }
- public bool CanExecute(object param)
- {
- switch (ModelCheckState)
- {
- case ModelCheckState.Prepare:
- if (string.IsNullOrEmpty(UpFilePath) || string.IsNullOrEmpty(DownFilePath) ||
- string.IsNullOrEmpty(SaveDir))
- return false;
- break;
- }
- return ModelCheckState.Progress != ModelCheckState;
- }
- [Command]
- public void OpenDir(object param)
- {
- try
- {
- System.Diagnostics.Process.Start("explorer.exe", SaveDir);
- }
- catch (Exception e)
- {
- MessageShow.Show(e);
- }
- }
- public bool CanOpenDir(object param)
- {
- return true;
- }
- }
- }
|