/* ============================================================================== * 功能描述:DataCheckContext * 创 建 者:Garrett * 创建日期:2018/11/29 14:43:26 * ==============================================================================*/ using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; using Autodesk.Revit.DB; using SAGA.DotNetUtils.Extend; using SAGA.DotNetUtils.WPF; using SAGA.RevitUtils; namespace Saga.PlugIn.ModelCheck { /// /// DataCheckContext /// public class VMModelCheck:BaseViewModelStub { public VMModelCheck(Document doc) { m_Doc = doc; ModelFilePath = doc.PathName; SavePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)); CheckItems = CheckOperation.GetModeCheckItems(); ModelCheckState = ModelCheckState.Prepare; } private Document m_Doc; private string m_ModelFilePath; /// /// 模型文件地址 /// public string ModelFilePath { get { return m_ModelFilePath; } set { m_ModelFilePath = value; NotifyPropertyChanged("ModelFilePath"); } } private List m_CheckItems; /// /// 检查项 /// public List 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_SavePath; /// /// 保存路径 /// public string SavePath { get { return m_SavePath; } set { m_SavePath = value; NotifyPropertyChanged("SavePath"); } } [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(SavePath, $"{ModelFilePath.GetFileName()}{"模型规范检查报告"}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx"); CheckOperation.Execute(CheckItems, m_Doc, savePath); ModelCheckState = ModelCheckState.Ending; break; case ModelCheckState.Progress: break; case ModelCheckState.Ending: System.Diagnostics.Process.Start("explorer.exe", SavePath); break; } } catch (Exception e) { MessageShow.Show(e); } } public bool CanExecute(object param) { return ModelCheckState.Progress!=ModelCheckState; } } public enum ModelCheckState { Prepare, Progress, Ending } }