Browse Source

AI帮助类-增加代码健壮性,修改正式环境链接

liyijie 1 năm trước cách đây
mục cha
commit
77207c3da8
1 tập tin đã thay đổi với 20 bổ sung4 xóa
  1. 20 4
      PDF Office/Helper/ChatGTPAIHelper.cs

+ 20 - 4
PDF Office/Helper/ChatGTPAIHelper.cs

@@ -29,12 +29,13 @@ namespace PDF_Master.Helper
 #if DEBUG
         //测试环境
         //纠错重写
+        
         private static string host = "https://ai.compdf.com";
         //百度翻译
         private static string translate = "http://101.132.103.13:8030";
 #else
         //纠错重写
-        private static string host ="http://prod-cn.your-api-server.com";
+        private static string host = "https://ai.compdf.com";
         //百度翻译
         private static string translate ="https://api-server.compdf.com";
 #endif
@@ -179,6 +180,10 @@ namespace PDF_Master.Helper
                     return Code;
                 }
             }
+            catch
+            {
+                return "300";
+            }
         }
 
         public static string HttpDownloadFile(string url, string path)
@@ -351,6 +356,10 @@ namespace PDF_Master.Helper
                     return Code;
                 }
             }
+            catch
+            {
+                return "300";
+            }
 
         }
 
@@ -440,6 +449,10 @@ namespace PDF_Master.Helper
                 }
                 else return "300";
             }
+            catch
+            {
+                return "300";
+            }
 
         }
 
@@ -460,7 +473,6 @@ namespace PDF_Master.Helper
             request.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
             request.Timeout = 60000;
             request.ServicePoint.Expect100Continue = false;
-            request.KeepAlive = false;
             var formData = new MultipartFormDataContent();
             formData.Add(new StringContent("2"), "project_id");
             formData.Add(new StringContent("1.0.1"), "version");
@@ -497,9 +509,8 @@ namespace PDF_Master.Helper
             request.Method = "Post";
             //request.Accept = "application/vnd.api+json;version=1";
             request.UserAgent = "Apifox/1.0.0 (https://www.apifox.cn)";
-            request.Timeout = 20000;
+            request.Timeout = 60000;
             request.ServicePoint.Expect100Continue = false;
-            request.KeepAlive = false;
             var formData = new MultipartFormDataContent();
             formData.Add(new StringContent("2"), "project_id");
             formData.Add(new StringContent("1.0.1"), "version");
@@ -616,6 +627,11 @@ namespace PDF_Master.Helper
                 clossProcess();
                 return null;
             }
+            catch {
+                ChatGPTCode = "300";
+                clossProcess();
+            }
+            clossProcess();
             return repsonseData;
         }