Program.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using SAGA.DotNetUtils.Revit;
  2. using System;
  3. using System.Diagnostics;
  4. using System.IO;
  5. namespace StartVisionSelector
  6. {
  7. public class Program
  8. {
  9. public static void Main(string[] args)
  10. {
  11. string command = null;
  12. string path = null;
  13. if (args.Length > 0)
  14. {
  15. command = args[0];
  16. }
  17. if (args.Length > 1)
  18. {
  19. path = args[1];
  20. }
  21. #if DEBUG
  22. if (string.IsNullOrWhiteSpace(command))
  23. {
  24. command = "DataExport";
  25. path = @"E:\导出测试\testR17.rvt";
  26. path = @"E:\导出测试\TestEmptyR17.rvt";
  27. path= @"E:\导出测试\延庆园-B1.rvt";
  28. //path = @"E:\导出测试\testR18.rvt";
  29. //path = @"E:\导出测试\testR16.rvt";
  30. }
  31. #endif
  32. Console.WriteLine("start");
  33. #region 保存版本号
  34. //保存版本号
  35. var runPath = AppDomain.CurrentDomain.BaseDirectory;
  36. var revitVision = RevitVisionUtil.GetRevitVision(path);
  37. File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SelectorConst.RevitFileVisionFile), revitVision);
  38. #endregion
  39. #region 删除生成的Revit dll
  40. var loadingRevitPath = Path.Combine(runPath, SelectorConst.LoadingRevit);
  41. //先删除,后Copy,如果可以指定Revit的安装目录,不需要Copy
  42. #region Del RevitDll
  43. foreach (string loadingItem in File.ReadAllLines(loadingRevitPath))
  44. {
  45. string destFile = Path.Combine(runPath, $"{loadingItem}.dll");
  46. if(File.Exists(destFile))
  47. File.Delete(destFile);
  48. }
  49. #endregion
  50. #endregion
  51. #region 启动
  52. Process process = new Process();//AppDomain.CurrentDomain.BaseDirectory +
  53. process.StartInfo.FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ExportStart.exe");//执行的exe路径
  54. process.StartInfo.UseShellExecute = false;//不显示shell
  55. process.StartInfo.CreateNoWindow = true;//不创建窗口
  56. process.StartInfo.RedirectStandardInput = true;//打开流输入
  57. process.StartInfo.RedirectStandardOutput = true;//打开流输出
  58. process.StartInfo.RedirectStandardError = true;//打开错误流
  59. process.StartInfo.Arguments = "" + command + " \"" + path + "\"";//输入参数,多个参数使用空间分割,如果一个参数包含空格,使用""包括此参数
  60. process.Start();//执行
  61. string msg = process.StandardOutput.ReadToEnd();//读取输出
  62. process.WaitForExit();//等待执行完成
  63. process.Close();//结束
  64. #endregion
  65. Console.WriteLine("end");
  66. //Console.ReadKey();
  67. }
  68. }
  69. }