mengxiangge 4 anni fa
parent
commit
9b23323139

+ 19 - 7
Dispatcher/Client/Start/RevitCmdExecutor.cs

@@ -71,7 +71,6 @@ namespace Client.Start
                 //{
                 //    Console.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
                 //}
-                Thread.Sleep(15000);
                 msg = ReadResultString(resultFilePath);
                 
                 Console.WriteLine(DateTime.Now + " 命令执行完成:" + revitCmd);
@@ -133,16 +132,29 @@ namespace Client.Start
             Console.WriteLine(filePath);
             string str = "";
 
-   if (File.Exists(filePath))
+            Console.WriteLine("read file try times: ");
+            int retryTimes = 0;
+            while (!File.Exists(filePath) && retryTimes < 30)
             {
-                str = File.ReadAllText(filePath);
+                Thread.Sleep(10000);
+                retryTimes++;
+            }
+
+            if (File.Exists(filePath))
+            {
+                retryTimes = 0;
+                do
+                {
+                    Thread.Sleep(3000);
+                    str = File.ReadAllText(filePath);
+                    retryTimes++;
+                    Console.WriteLine("read file try times: " + retryTimes);
+                } while ((str == null || str.Length == 0) && retryTimes < 100);
 #if !DEBUG
                 File.Delete(filePath);
 #endif
-            }          
-
-
-
+            }
+            Console.WriteLine("read file try times: ");
             return str;
         }
     }

+ 24 - 2
Starter/StartVisionSelector/Program.cs

@@ -71,7 +71,9 @@ namespace StartVisionSelector
                 SaveFileErrorResult(param);
                 return;
             }
-           
+
+            string destination = GetObjectiveFilePath(param);
+            //File.WriteAllText(@"d:\error.txt", destination);
             File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SelectorConst.RevitFileVisionFile), revitVision);
 
             #endregion
@@ -116,7 +118,7 @@ namespace StartVisionSelector
                 while (process != null && !process.HasExited)
                 {
                     process.WaitForExit(60 * 1000); //等待执行完成
-                    if (!process.HasExited && File.Exists(path))
+                    if (!process.HasExited)  //  && File.Exists(destination)
                     {
                         Thread.Sleep(5000);
                         if (process != null && !process.HasExited)
@@ -143,6 +145,26 @@ namespace StartVisionSelector
             Environment.Exit(0);
             //Console.ReadKey();
         }
+
+        private static string GetObjectiveFilePath(string param)
+        {
+            Console.WriteLine(param);
+            string path = string.Empty;
+            try
+            {
+                var tempParam = param.Replace("\\\"", "\"");
+                JObject jObject = JObject.Parse(tempParam);
+                string key = @"ResultFileName";
+                path = jObject[key].ToString();
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine(e);
+            }
+
+            return path;
+        }
+
         /// <summary>
         /// 保存检查或导出的结果
         /// </summary>

+ 0 - 1
Starter/Starter/Program.cs

@@ -105,7 +105,6 @@ namespace ExportStart
         {
             try
             {
-
                 JObject jObject = JObject.Parse(param);
                 string key = "ResultFileName";
                 string path = jObject[key].ToString();