123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- /* ==============================================================================
- * 功能描述:RevitCmdExecutor
- * 创 建 者:Garrett
- * 创建日期:2019/4/16 11:46:37
- * ==============================================================================*/
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Windows.Forms;
- namespace Client.Start
- {
- /// <summary>
- /// RevitCmdExecutor
- /// </summary>
- public class RevitCmdExecutor : IRevitCommandExcutor
- {
- public string ExecuteCmd(string revitCmd, string param, HashSet<string> filePathList)
- {
- //由revitCmd生成实体类
- //实体类传入参数、参考楼层列表
- //执行方法,返回执行结果
- Console.WriteLine("准备执行命令");
- Process process=new Process();//AppDomain.CurrentDomain.BaseDirectory +
- process.StartInfo.FileName = "ExportStart.exe";//执行的exe路径
- process.StartInfo.UseShellExecute = false;//不显示shell
- process.StartInfo.CreateNoWindow = true;//不创建窗口
- process.StartInfo.RedirectStandardInput = true;//打开流输入
- process.StartInfo.RedirectStandardOutput = true;//打开流输出
- process.StartInfo.RedirectStandardError = true;//打开错误流
- process.StartInfo.Arguments = "(" + revitCmd + " \"" + filePathList.First() + "\")";//输入参数,多个参数使用空间分割,如果一个参数包含空格,使用""包括此参数
- process.Start();//执行
- string msg = process.StandardOutput.ReadToEnd();//读取输出
- process.WaitForExit();//等待执行完成
- process.Close();//结束
-
- MessageBox.Show("命令执行完成 ");
- return msg;
- }
-
- }
- }
|