Program.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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:\导出测试\testR18.rvt";
  27. //path = @"E:\导出测试\testR16.rvt";
  28. }
  29. #endif
  30. Console.WriteLine("start");
  31. #region 保存版本号
  32. //保存版本号
  33. var runPath = AppDomain.CurrentDomain.BaseDirectory;
  34. var revitVision = RevitVisionUtil.GetRevitVision(path);
  35. File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SelectorConst.RevitFileVisionFile), revitVision);
  36. #endregion
  37. #region 删除生成的Revit dll
  38. var loadingRevitPath = Path.Combine(runPath, SelectorConst.LoadingRevit);
  39. //先删除,后Copy,如果可以指定Revit的安装目录,不需要Copy
  40. #region Del RevitDll
  41. foreach (string loadingItem in File.ReadAllLines(loadingRevitPath))
  42. {
  43. string destFile = Path.Combine(runPath, $"{loadingItem}.dll");
  44. if(File.Exists(destFile))
  45. File.Delete(destFile);
  46. }
  47. #endregion
  48. #endregion
  49. #region 启动
  50. Process process = new Process();//AppDomain.CurrentDomain.BaseDirectory +
  51. process.StartInfo.FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ExportStart.exe");//执行的exe路径
  52. process.StartInfo.UseShellExecute = false;//不显示shell
  53. process.StartInfo.CreateNoWindow = true;//不创建窗口
  54. process.StartInfo.RedirectStandardInput = true;//打开流输入
  55. process.StartInfo.RedirectStandardOutput = true;//打开流输出
  56. process.StartInfo.RedirectStandardError = true;//打开错误流
  57. process.StartInfo.Arguments = "" + command + " \"" + path + "\"";//输入参数,多个参数使用空间分割,如果一个参数包含空格,使用""包括此参数
  58. process.Start();//执行
  59. string msg = process.StandardOutput.ReadToEnd();//读取输出
  60. process.WaitForExit();//等待执行完成
  61. process.Close();//结束
  62. #endregion
  63. Console.WriteLine("end");
  64. //Console.ReadKey();
  65. }
  66. }
  67. }