Program.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 dllsPath = Path.Combine(Directory.GetParent(runPath).Parent.FullName, "Dlls");
  39. var loadingRevitPath = Path.Combine(dllsPath, SelectorConst.LoadingRevit);
  40. //先删除,后Copy,如果可以指定Revit的安装目录,不需要Copy
  41. #region Del RevitDll
  42. foreach (string loadingItem in File.ReadAllLines(loadingRevitPath))
  43. {
  44. string destFile = Path.Combine(runPath, $"{loadingItem}.dll");
  45. if(File.Exists(destFile))
  46. File.Delete(destFile);
  47. }
  48. #endregion
  49. #endregion
  50. #region 启动
  51. Process process = new Process();//AppDomain.CurrentDomain.BaseDirectory +
  52. process.StartInfo.FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ExportStart.exe");//执行的exe路径
  53. process.StartInfo.UseShellExecute = false;//不显示shell
  54. process.StartInfo.CreateNoWindow = true;//不创建窗口
  55. process.StartInfo.RedirectStandardInput = true;//打开流输入
  56. process.StartInfo.RedirectStandardOutput = true;//打开流输出
  57. process.StartInfo.RedirectStandardError = true;//打开错误流
  58. process.StartInfo.Arguments = "" + command + " \"" + path + "\"";//输入参数,多个参数使用空间分割,如果一个参数包含空格,使用""包括此参数
  59. process.Start();//执行
  60. string msg = process.StandardOutput.ReadToEnd();//读取输出
  61. process.WaitForExit();//等待执行完成
  62. process.Close();//结束
  63. #endregion
  64. Console.WriteLine("end");
  65. //Console.ReadKey();
  66. }
  67. }
  68. }