소스 검색

人工智能帮助你类-增加等待时间

liyijie 1 년 전
부모
커밋
0679c97e4b
1개의 변경된 파일7개의 추가작업 그리고 4개의 파일을 삭제
  1. 7 4
      PDF Office/Helper/ChatGTPAIHelper.cs

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

@@ -71,11 +71,13 @@ namespace PDF_Master.Helper
         public async static Task<string> fileKeyTranslate(string content, string filename)
         {
 
-            HttpWebResponse response = null;
             ServicePointManager.DefaultConnectionLimit = 200;
             HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(Uri_fileKeytranslate);
             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.ServicePoint.Expect100Continue = false;
             var formData = new MultipartFormDataContent();
             byte[] data = File.ReadAllBytes(@content);
             MemoryStream stream = new MemoryStream(data);
@@ -132,7 +134,7 @@ namespace PDF_Master.Helper
             }
             catch (WebException ex)
             {
-                Console.WriteLine("HTTP异常:" + ex.Message);
+                Trace.WriteLine("HTTP异常:" + ex.Message);
                 return "Code" + "300";
             }
         }
@@ -257,9 +259,10 @@ namespace PDF_Master.Helper
                     return jobject["code"].ToObject<string>().ToLower();
                 }
             }
-            catch
+            catch(WebException ex)
             {
                 clossProcess();
+                Trace.WriteLine("HTTP异常:" + ex.Message);
                 return "300";
             }