|
@@ -11,6 +11,7 @@ using System.IO;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
using System.Windows.Forms;
|
|
using System.Windows.Forms;
|
|
using Newtonsoft.Json.Linq;
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
+using System.Threading;
|
|
|
|
|
|
namespace Client.Start
|
|
namespace Client.Start
|
|
{
|
|
{
|
|
@@ -19,7 +20,7 @@ namespace Client.Start
|
|
/// </summary>
|
|
/// </summary>
|
|
public class RevitCmdExecutor : IRevitCommandExcutor
|
|
public class RevitCmdExecutor : IRevitCommandExcutor
|
|
{
|
|
{
|
|
- public string ExecuteCmd(string revitCmd, string param, HashSet<string> filePathList)
|
|
|
|
|
|
+ public string ExecuteCmd(string revitCmd, string param, HashSet<string> filePathList, string taskId)
|
|
{
|
|
{
|
|
string msg = null;
|
|
string msg = null;
|
|
try
|
|
try
|
|
@@ -36,7 +37,7 @@ namespace Client.Start
|
|
process.StartInfo.RedirectStandardInput = true;//打开流输入
|
|
process.StartInfo.RedirectStandardInput = true;//打开流输入
|
|
process.StartInfo.RedirectStandardOutput = true;//打开流输出
|
|
process.StartInfo.RedirectStandardOutput = true;//打开流输出
|
|
process.StartInfo.RedirectStandardError = true;//打开错误流
|
|
process.StartInfo.RedirectStandardError = true;//打开错误流
|
|
- string resultFilePath = GetReusltFileName();
|
|
|
|
|
|
+ string resultFilePath = GetReusltFileName(taskId, revitCmd);
|
|
string newParam = AddResultFileNameToParam(param, resultFilePath);
|
|
string newParam = AddResultFileNameToParam(param, resultFilePath);
|
|
Console.WriteLine(filePathList.First());
|
|
Console.WriteLine(filePathList.First());
|
|
//输入参数,多个参数使用空间分割,如果一个参数包含空格,使用""包括此参数
|
|
//输入参数,多个参数使用空间分割,如果一个参数包含空格,使用""包括此参数
|
|
@@ -45,11 +46,32 @@ namespace Client.Start
|
|
"\"" + newParam + "\"" + " " +
|
|
"\"" + newParam + "\"" + " " +
|
|
"\"" + filePathList.First() + "\"";
|
|
"\"" + filePathList.First() + "\"";
|
|
process.Start();//执行
|
|
process.Start();//执行
|
|
|
|
+ process.WaitForExit();
|
|
//string msg = process.StandardOutput.ReadToEnd();//读取输出
|
|
//string msg = process.StandardOutput.ReadToEnd();//读取输出
|
|
- process.WaitForExit(60*60*1000);//等待执行完成
|
|
|
|
- //process.Close();//结束
|
|
|
|
- if(!process.HasExited)
|
|
|
|
- process.Kill();
|
|
|
|
|
|
+ //try
|
|
|
|
+ //{
|
|
|
|
+ // while (process != null && !process.HasExited)
|
|
|
|
+ // {
|
|
|
|
+ // process.WaitForExit(60 * 1000); //等待执行完成
|
|
|
|
+ // if (!process.HasExited && File.Exists(resultFilePath))
|
|
|
|
+ // {
|
|
|
|
+ // Thread.Sleep(5000);
|
|
|
|
+ // if (process != null && !process.HasExited)
|
|
|
|
+ // {
|
|
|
|
+ // //process.Close();
|
|
|
|
+ // //process = null;
|
|
|
|
+ // //process.Kill();
|
|
|
|
+ // //process.Dispose();
|
|
|
|
+
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+ //catch(Exception ex)
|
|
|
|
+ //{
|
|
|
|
+ // Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
|
|
|
|
+ //}
|
|
|
|
+ Thread.Sleep(15000);
|
|
msg = ReadResultString(resultFilePath);
|
|
msg = ReadResultString(resultFilePath);
|
|
|
|
|
|
Console.WriteLine(DateTime.Now + " 命令执行完成:" + revitCmd);
|
|
Console.WriteLine(DateTime.Now + " 命令执行完成:" + revitCmd);
|
|
@@ -94,10 +116,11 @@ namespace Client.Start
|
|
/// 生成 结果的保存文件名
|
|
/// 生成 结果的保存文件名
|
|
/// </summary>
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
- private string GetReusltFileName()
|
|
|
|
|
|
+ private string GetReusltFileName(string taskId, string revitCmd)
|
|
{
|
|
{
|
|
string localPath = System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
|
string localPath = System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
|
- string fileName = "Result_" + Guid.NewGuid().ToString() + ".txt";
|
|
|
|
|
|
+ // string fileName = "Result_" + Guid.NewGuid().ToString() + ".txt";
|
|
|
|
+ string fileName = "Result_" + taskId + revitCmd + ".txt";
|
|
return Path.Combine(localPath, "RevitService", fileName);
|
|
return Path.Combine(localPath, "RevitService", fileName);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <summary>
|