VmVerticalPipeCheck.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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.Extend;
  16. using SAGA.DotNetUtils.WPF;
  17. using SAGA.RevitUtils;
  18. namespace Saga.PlugIn.VerticalPipeCheck
  19. {
  20. /// <summary>
  21. /// VmVerticalPipeCheck
  22. /// </summary>
  23. public class VmVerticalPipeCheck:BaseViewModelStub
  24. {
  25. public VmVerticalPipeCheck()
  26. {
  27. SaveDir = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory));
  28. }
  29. #region Property
  30. private string m_UpFilePath;
  31. /// <summary>
  32. ///
  33. /// </summary>
  34. public string UpFilePath
  35. {
  36. get { return m_UpFilePath; }
  37. set
  38. {
  39. m_UpFilePath = value;
  40. NotifyPropertyChanged("UpFilePath");
  41. }
  42. }
  43. private string m_DownFilePath;
  44. /// <summary>
  45. ///
  46. /// </summary>
  47. public string DownFilePath
  48. {
  49. get { return m_DownFilePath; }
  50. set
  51. {
  52. m_DownFilePath = value;
  53. NotifyPropertyChanged("DownFilePath");
  54. }
  55. }
  56. private string m_SaveDir;
  57. /// <summary>
  58. /// 保存路径
  59. /// </summary>
  60. public string SaveDir
  61. {
  62. get { return m_SaveDir; }
  63. set
  64. {
  65. m_SaveDir = value;
  66. NotifyPropertyChanged("SaveDir");
  67. }
  68. }
  69. private string m_SavePath;
  70. /// <summary>
  71. /// 保存路径
  72. /// </summary>
  73. public string SavePath
  74. {
  75. get { return m_SavePath; }
  76. set
  77. {
  78. m_SavePath = value;
  79. NotifyPropertyChanged("SavePath");
  80. }
  81. }
  82. private ModelCheckState m_ModelCheckState;
  83. public ModelCheckState ModelCheckState
  84. {
  85. get { return m_ModelCheckState; }
  86. set
  87. {
  88. m_ModelCheckState = value;
  89. NotifyPropertyChanged(nameof(ModelCheckState));
  90. }
  91. }
  92. #endregion
  93. [Command]
  94. public void Execute(object param)
  95. {
  96. try
  97. {
  98. switch (ModelCheckState)
  99. {
  100. case ModelCheckState.Prepare:
  101. WpfSysCmd.DoEvent();
  102. ModelCheckState = ModelCheckState.Progress;
  103. string savePath = Path.Combine(SaveDir,
  104. $"{UpFilePath.GetFileName()}-{DownFilePath.GetFileName()}{"立管检查报告"}{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx");
  105. var tuple=VerticalPipeUtil.Execute(UpFilePath,DownFilePath,savePath);
  106. ModelCheckState = ModelCheckState.Ending;
  107. //为了Ending的界面显示,出问题注释掉
  108. SavePath = savePath;
  109. WinTipVPipeCheckComplete win = new WinTipVPipeCheckComplete(tuple?.Item1,tuple?.Item2);
  110. win.ShowDialog();
  111. WpfSysCmd.DoEvent();
  112. break;
  113. case ModelCheckState.Progress:
  114. break;
  115. case ModelCheckState.Ending:
  116. ModelCheckState = ModelCheckState.Prepare;
  117. DownFilePath = UpFilePath;
  118. UpFilePath = "";
  119. break;
  120. }
  121. }
  122. catch (Exception e)
  123. {
  124. MessageShow.Show(e);
  125. }
  126. }
  127. public bool CanExecute(object param)
  128. {
  129. switch (ModelCheckState)
  130. {
  131. case ModelCheckState.Prepare:
  132. if (string.IsNullOrEmpty(UpFilePath) || string.IsNullOrEmpty(DownFilePath) ||
  133. string.IsNullOrEmpty(SaveDir))
  134. return false;
  135. break;
  136. }
  137. return ModelCheckState.Progress != ModelCheckState;
  138. }
  139. [Command]
  140. public void OpenDir(object param)
  141. {
  142. try
  143. {
  144. System.Diagnostics.Process.Start("explorer.exe", SaveDir);
  145. }
  146. catch (Exception e)
  147. {
  148. MessageShow.Show(e);
  149. }
  150. }
  151. public bool CanOpenDir(object param)
  152. {
  153. return true;
  154. }
  155. }
  156. }