فهرست منبع

mxg:延长http请求的超时时间,修改为5分钟

mengxiangge 5 سال پیش
والد
کامیت
360f915f83

+ 4 - 0
.gitignore

@@ -24,3 +24,7 @@
 /Executer/MBIRevitBase/obj/Debug
 /Starter/Starter/obj/Debug
 /Starter/StartVisionSelector/obj/Debug
+/Executer/MBIRevitBase/obj/Release
+/Executer/OutputDll
+/Starter/Starter/obj/Release
+/Starter/StartVisionSelector/obj/Release

+ 1 - 1
Dispatcher/Client/Client.csproj

@@ -26,7 +26,7 @@
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
+    <OutputPath>..\..\OutputDll\</OutputPath>
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>

+ 12 - 5
Dispatcher/Client/Start/RevitCmdExecutor.cs

@@ -50,16 +50,18 @@ namespace Client.Start
                 msg = ReadResultString(resultFilePath);
                 Console.WriteLine(DateTime.Now + " 命令执行完成:" + revitCmd);
                 //执行完成后,删除文件
+#if !DEBUG
                 foreach (var f in filePathList)
                 {
                     File.Delete(f);
                 }
+#endif
             }
             catch (Exception e)
             {
-                Console.WriteLine(e.Message+"\r\n"+e.StackTrace);
+                Console.WriteLine(e.Message + "\r\n" + e.StackTrace);
             }
-         
+
             return msg;
         }
         /// <summary>
@@ -91,7 +93,7 @@ namespace Client.Start
         private string GetReusltFileName()
         {
             string localPath = System.Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
-            string fileName = "Result_" + Guid.NewGuid().ToString()+".txt";
+            string fileName = "Result_" + Guid.NewGuid().ToString() + ".txt";
             return Path.Combine(localPath, "RevitService", fileName);
         }
         /// <summary>
@@ -102,8 +104,13 @@ namespace Client.Start
         private string ReadResultString(string filePath)
         {
             Console.WriteLine(filePath);
-            string str = File.ReadAllText(filePath);
-            File.Delete(filePath);
+            string str = "";
+            if (File.Exists(filePath))
+            {
+                str = File.ReadAllText(filePath);
+                File.Delete(filePath);
+            }
+
             return str;
         }
     }

+ 1 - 1
Dispatcher/NettyClient/NettyClient.csproj

@@ -25,7 +25,7 @@
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
+    <OutputPath>..\..\OutputDll\</OutputPath>
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>

+ 10 - 4
Executer/DataExport/RevitToJBim/MBI/MBIDocument.cs

@@ -26,7 +26,7 @@ namespace RevitToJBim.MBI
         public string MBIName { get; set; }
         public string ModelId { get; set; }
         public string PlanName { get; set; }
-        public Dictionary<string, List<BimObject>> Elements { get;private set; }
+        public Dictionary<string, List<BimObject>> Elements { get; private set; }
         /// <summary>
         /// 附加元素Elements信息
         /// </summary>
@@ -43,12 +43,18 @@ namespace RevitToJBim.MBI
             Elements = dic;
         }
 
-        public static MBIDocument CreateDocument(Document document,string param)
+        public static MBIDocument CreateDocument(Document document, string param)
         {
             MBIDocument dto = new MBIDocument();
-            JObject jObject=JObject.Parse(param);
-            dto.MBIName = jObject.GetValueEx("MBIName");//待读取
+            JObject jObject = JObject.Parse(param);
+#if DEBUG
+            dto.MBIName = "Pj1101010015";//待读取
+            dto.ModelId = "6d8642d9d92a11e98e2d2108fa0baa21";
+#else
+             dto.MBIName = jObject.GetValueEx("MBIName");//待读取
             dto.ModelId = jObject.GetValueEx("ModelId");
+#endif
+
             dto.PlanName = document.GetUseView()?.Name;
             return dto;
         }

+ 2 - 0
Executer/DataExport/RevitToJBim/MbiExport.cs

@@ -47,7 +47,9 @@ namespace RevitToJBim
                 //保存到本地
                 string fileName = DateTime.Now.ToString("yyyyMMddHHmmss");
                 string path = Path.Combine( $"{document.PathName}_{fileName}.json");
+#if DEBUG
                 File.WriteAllText(path, json.ToString());
+#endif
 
             }
             catch (Exception ex)

+ 1 - 1
Executer/DataExport/RevitToJBim/RevitToJBim.csproj

@@ -25,7 +25,7 @@
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
+    <OutputPath>..\..\..\OutputDll\</OutputPath>
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>

+ 1 - 1
Executer/MBIRevitBase/MBIRevitBase.csproj

@@ -25,7 +25,7 @@
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
+    <OutputPath>..\..\OutputDll\</OutputPath>
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>

+ 6 - 1
Executer/MBIRevitBase/Services/UploadService.cs

@@ -14,6 +14,7 @@ using System.Threading.Tasks;
 using MBIRevitBase.Config;
 using MBIRevitBase.Tools;
 using Polly;
+using Polly.Retry;
 
 namespace MBIRevitBase.Services
 {
@@ -43,9 +44,13 @@ namespace MBIRevitBase.Services
         {
             try
             {
-                
+#if DEBUG
+                var waitAndRetryPolicy = Policy.Handle<Exception>().WaitAndRetry(1,
+                    (i, t) => TimeSpan.FromSeconds(5), ReportError);
+#else
                 var waitAndRetryPolicy = Policy.Handle<Exception>().WaitAndRetry(4,
                     (i, t) => TimeSpan.FromSeconds(5*60), ReportError);
+#endif
                 return waitAndRetryPolicy.Execute<BResult>(()=> UploadExportFileRetry<BResult>(result));
             }
             catch (Exception e)

+ 2 - 0
Executer/MBIRevitBase/Tools/HttpUtils.cs

@@ -74,6 +74,8 @@ namespace MBIRevitBase.Tools
         {
             using (HttpClient client = CreateClient())
             {
+                //超时时间设置为5分钟
+                client.Timeout = new TimeSpan(0,5,0);
                 string boundary = string.Format("{0}{1}", WebKitFormBoundary, DateTime.Now.Ticks.ToString("x"));
                 MultipartFormDataContent content = new MultipartFormDataContent(boundary);
                 #region Stream请求

+ 1 - 1
Starter/StartVisionSelector/StartVisionSelector.csproj

@@ -24,7 +24,7 @@
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
     <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
+    <OutputPath>..\..\OutputDll\</OutputPath>
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>

+ 3 - 2
Starter/Starter/Program.cs

@@ -39,7 +39,7 @@ namespace ExportStart
                 command = "DataExport";
                 path = @"E:\导出测试\testR17.rvt";
                 path = @"E:\导出测试\延庆园-B1.rvt";
-                path = @"E:\导出测试\365.rvt";
+                path = @"E:\导出测试\366.rvt";
                 JObject jObject=new JObject();
                 jObject.Add("ResultFileName", @"C:\Users\SAGACLOUD\AppData\Local\RevitService\Result_e26be2fd-2097-462b-bdd0-a2a86b616928.txt");
                 param = jObject.ToString();
@@ -69,8 +69,9 @@ namespace ExportStart
                         result=Export(doc,param);
                         break;
                 }
-
+#if !DEBUG
                 SaveResult(param, result);
+#endif
                 RevitCoreContext.Instance.Stop();
             }
             Console.WriteLine("ExportStart End");