VmVerticalPipeCheck.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* ==============================================================================
  2. * 功能描述:VmVerticalPipeCheck
  3. * 创 建 者:Garrett
  4. * 创建日期:2019/11/5 15:25:33
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using FWindSoft.Wpf;
  13. using Saga.PlugIn.CreateFacility;
  14. using Saga.PlugIn.ModelCheck;
  15. using SAGA.DotNetUtils.WPF;
  16. using SAGA.RevitUtils;
  17. namespace Saga.PlugIn.VerticalPipeCheck
  18. {
  19. /// <summary>
  20. /// VmVerticalPipeCheck
  21. /// </summary>
  22. public class VmVerticalPipeCheck:BaseViewModelStub
  23. {
  24. #region Property
  25. private string m_UpFilePath;
  26. /// <summary>
  27. ///
  28. /// </summary>
  29. public string UpFilePath
  30. {
  31. get { return m_UpFilePath; }
  32. set
  33. {
  34. m_UpFilePath = value;
  35. NotifyPropertyChanged("UpFilePath");
  36. }
  37. }
  38. private string m_DownFilePath;
  39. /// <summary>
  40. ///
  41. /// </summary>
  42. public string DownFilePath
  43. {
  44. get { return m_DownFilePath; }
  45. set
  46. {
  47. m_DownFilePath = value;
  48. NotifyPropertyChanged("DownFilePath");
  49. }
  50. }
  51. private string m_SaveDir;
  52. /// <summary>
  53. /// 保存路径
  54. /// </summary>
  55. public string SaveDir
  56. {
  57. get { return m_SaveDir; }
  58. set
  59. {
  60. m_SaveDir = value;
  61. NotifyPropertyChanged("SaveDir");
  62. }
  63. }
  64. private string m_SavePath;
  65. /// <summary>
  66. /// 保存路径
  67. /// </summary>
  68. public string SavePath
  69. {
  70. get { return m_SavePath; }
  71. set
  72. {
  73. m_SavePath = value;
  74. NotifyPropertyChanged("SavePath");
  75. }
  76. }
  77. private ModelCheckState m_ModelCheckState;
  78. public ModelCheckState ModelCheckState
  79. {
  80. get { return m_ModelCheckState; }
  81. set
  82. {
  83. m_ModelCheckState = value;
  84. NotifyPropertyChanged(nameof(ModelCheckState));
  85. }
  86. }
  87. #endregion
  88. [Command]
  89. public void Execute(object param)
  90. {
  91. try
  92. {
  93. switch (ModelCheckState)
  94. {
  95. case ModelCheckState.Prepare:
  96. WpfSysCmd.DoEvent();
  97. ModelCheckState = ModelCheckState.Progress;
  98. string savePath = Path.Combine(SaveDir,
  99. $"{"模型规范检查报告"}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx");
  100. var tuple=VerticalPipeUtil.Execute(UpFilePath,DownFilePath,savePath);
  101. ModelCheckState = ModelCheckState.Ending;
  102. //为了Ending的界面显示,出问题注释掉
  103. SavePath = savePath;
  104. WinTipVPipeCheckComplete win = new WinTipVPipeCheckComplete(tuple?.Item1,tuple?.Item2);
  105. win.ShowDialog();
  106. WpfSysCmd.DoEvent();
  107. break;
  108. case ModelCheckState.Progress:
  109. break;
  110. case ModelCheckState.Ending:
  111. System.Diagnostics.Process.Start("explorer.exe", SaveDir);
  112. break;
  113. }
  114. }
  115. catch (Exception e)
  116. {
  117. MessageShow.Show(e);
  118. }
  119. }
  120. public bool CanExecute(object param)
  121. {
  122. return ModelCheckState.Progress != ModelCheckState;
  123. }
  124. }
  125. }