123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- /* ==============================================================================
- * 功能描述:DataCheckContext
- * 创 建 者:Garrett
- * 创建日期:2018/11/29 14:43:26
- * ==============================================================================*/
- using Autodesk.Revit.DB;
- using SAGA.DotNetUtils.Extend;
- using SAGA.DotNetUtils.WPF;
- using SAGA.RevitUtils;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using Saga.PlugIn.CreateFacility;
- namespace Saga.PlugIn.ModelCheck
- {
- /// <summary>
- /// DataCheckContext
- /// </summary>
- public class VMModelCheck : BaseViewModelStub
- {
- public VMModelCheck(Document doc)
- {
- m_Doc = doc;
- ModelFilePath = doc.PathName;
- SaveDir = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
- CheckItems = CheckOperation.GetModeCheckItems();
- ModelCheckState = ModelCheckState.Prepare;
- CurrentIndex = 1;
- }
- private Document m_Doc;
- private string m_ModelFilePath;
- /// <summary>
- /// 模型文件地址
- /// </summary>
- public string ModelFilePath
- {
- get { return m_ModelFilePath; }
- set
- {
- m_ModelFilePath = value;
- NotifyPropertyChanged("ModelFilePath");
- }
- }
- private List<ICheckBase> m_CheckItems;
- /// <summary>
- /// 检查项
- /// </summary>
- public List<ICheckBase> CheckItems
- {
- get { return m_CheckItems; }
- set
- {
- m_CheckItems = value;
- NotifyPropertyChanged("CheckItems");
- }
- }
- private ModelCheckState m_ModelCheckState;
- public ModelCheckState ModelCheckState
- {
- get { return m_ModelCheckState; }
- set
- {
- m_ModelCheckState = value;
- NotifyPropertyChanged(nameof(ModelCheckState));
- }
- }
- 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 int m_CurrentIndex;
- /// <summary>
- /// 检查进度
- /// </summary>
- public int CurrentIndex
- {
- get { return m_CurrentIndex; }
- set
- {
- m_CurrentIndex = value;
- NotifyPropertyChanged("CurrentIndex");
- }
- }
- [Command]
- public void Execute(object param)
- {
- try
- {
- switch (ModelCheckState)
- {
- case ModelCheckState.Prepare:
- CheckItems.ForEach(t => t.ModelCheckState = ModelCheckState.Progress);
- ModelCheckState = ModelCheckState.Progress;
- string savePath = Path.Combine(SaveDir,
- $"{ModelFilePath.GetFileName()}{"模型规范检查报告"}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx");
- CheckOperation.Execute(CheckItems, m_Doc, savePath, this);
- ModelCheckState = ModelCheckState.Ending;
- //为了Ending的界面显示,出问题注释掉
- SavePath = savePath;
- WinTipCheckComplete win = new WinTipCheckComplete();
- win.ShowDialog();
- break;
- case ModelCheckState.Progress:
- break;
- case ModelCheckState.Ending:
- System.Diagnostics.Process.Start("explorer.exe", SaveDir);
- break;
- }
- }
- catch (Exception e)
- {
- MessageShow.Show(e);
- }
- }
- public bool CanExecute(object param)
- {
- return ModelCheckState.Progress != ModelCheckState;
- }
- }
- public enum ModelCheckState
- {
- Prepare,
- Progress,
- Ending
- }
- }
|