From 770c671fb4ad9bf3691b1250bc10f9c4087edf97 Mon Sep 17 00:00:00 2001
From: lu <99954486@qq.com>
Date: 星期五, 06 十二月 2024 08:25:13 +0800
Subject: [PATCH] 修改进度条

---
 DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs |   92 +++++++++++++++++++++++++---------------------
 1 files changed, 50 insertions(+), 42 deletions(-)

diff --git a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
index ff0354f..b9d75dd 100644
--- a/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
+++ b/DevApp/Gs.DevApp/ToolBox/UtilityHelper.cs
@@ -26,6 +26,7 @@
 using Newtonsoft.Json.Linq;
 using static System.Windows.Forms.Control;
 
+
 namespace Gs.DevApp.ToolBox
 {
     /// <summary>
@@ -64,35 +65,35 @@
         /// <param name="meth">鏂规硶鍚嶇О</param>
         /// <param name="param">鍙傛暟</param>
         /// <returns></returns>
-        public static async Task<string> HttpPostAsync(string url, string meth, string param)
-        {
-            if (string.IsNullOrEmpty(url))
-                url = WebApiUrl;
-            url += meth;
-            var request = (HttpWebRequest)WebRequest.Create(url);
-            request.Method = "POST";
-            request.ContentType = "application/json";
-            request.Headers.Add("token", GetBasicAuthTicket());
-            request.Accept = "*/*";
-            request.Timeout = 15000;
-            request.AllowAutoRedirect = false;
-            request.ServicePoint.Expect100Continue = false;
-            HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
-            request.CachePolicy = noCachePolicy;
-            using (Stream requestStream = await request.GetRequestStreamAsync())
-            {
-                byte[] dataBytes = Encoding.UTF8.GetBytes(param);
-                await requestStream.WriteAsync(dataBytes, 0, dataBytes.Length);
-            }
+        //public static async Task<string> HttpPostAsync(string url, string meth, string param)
+        //{
+        //    if (string.IsNullOrEmpty(url))
+        //        url = WebApiUrl;
+        //    url += meth;
+        //    var request = (HttpWebRequest)WebRequest.Create(url);
+        //    request.Method = "POST";
+        //    request.ContentType = "application/json";
+        //    request.Headers.Add("token", GetBasicAuthTicket());
+        //    request.Accept = "*/*";
+        //    request.Timeout = 15000;
+        //    request.AllowAutoRedirect = false;
+        //    request.ServicePoint.Expect100Continue = false;
+        //    HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
+        //    request.CachePolicy = noCachePolicy;
+        //    using (Stream requestStream = await request.GetRequestStreamAsync())
+        //    {
+        //        byte[] dataBytes = Encoding.UTF8.GetBytes(param);
+        //        await requestStream.WriteAsync(dataBytes, 0, dataBytes.Length);
+        //    }
 
-            using (WebResponse response = await request.GetResponseAsync())
-            {
-                using (StreamReader reader = new StreamReader(response.GetResponseStream()))
-                {
-                    return await reader.ReadToEndAsync();
-                }
-            }
-        }
+        //    using (WebResponse response = await request.GetResponseAsync())
+        //    {
+        //        using (StreamReader reader = new StreamReader(response.GetResponseStream()))
+        //        {
+        //            return await reader.ReadToEndAsync();
+        //        }
+        //    }
+        //}
 
         /// <summary>
         ///     httpPost璁块棶鏈嶅姟
@@ -103,24 +104,28 @@
         /// <returns></returns>
         public static string HttpPost(string url, string meth, string param)
         {
-            if (string.IsNullOrEmpty(url))
-                url = WebApiUrl;
-            url += meth;
-            var request = (HttpWebRequest)WebRequest.Create(url);
-            request.Method = "POST";
-            request.ContentType = "application/json";
-            request.Headers.Add("token", GetBasicAuthTicket());
-            request.Accept = "*/*";
-            request.Timeout = 15000;
-            request.AllowAutoRedirect = false;
-            request.ServicePoint.Expect100Continue = false;
-            HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
-            request.CachePolicy = noCachePolicy;
+            DevExpress.Utils.WaitDialogForm wdf = new DevExpress.Utils.WaitDialogForm("鎷煎懡鍔犺浇涓紝璇风◢鍚�..."+ meth, "鍙嬫儏鎻愮ず");
+            HttpWebRequest request = null;
             StreamWriter requestStream = null;
             WebResponse response = null;
             string responseStr = null;
             try
             {
+                if (string.IsNullOrEmpty(url))
+                    url = WebApiUrl;
+                url += meth;
+                request = (HttpWebRequest)WebRequest.Create(url);
+                request.Method = "POST";
+                request.ContentType = "application/json";
+                request.Headers.Add("token", GetBasicAuthTicket());
+                request.Accept = "*/*";
+                request.Timeout = 15000;
+                request.AllowAutoRedirect = false;
+                request.ServicePoint.Expect100Continue = false;
+                wdf.SetCaption("鍔犺浇杩涘害锛�10/100锛�");
+                HttpRequestCachePolicy noCachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
+                request.CachePolicy = noCachePolicy;
+                wdf.SetCaption("鍔犺浇杩涘害锛�20/100锛�");
                 requestStream = new StreamWriter(request.GetRequestStream());
                 requestStream.Write(param);
                 requestStream.Close();
@@ -133,9 +138,11 @@
                     //File.WriteAllText(Server.MapPath("~/") + @"\test.txt", responseStr); 
                     reader.Close();
                 }
+                wdf.SetCaption("鍔犺浇杩涘害锛�80/100锛�");
             }
             catch (Exception ex)
             {
+                wdf.Close();
                 LogHelper.Debug(url, param + ":" + ex.Message);
                 throw ex;
             }
@@ -145,7 +152,8 @@
                 requestStream = null;
                 response = null;
             }
-
+            wdf.SetCaption("鍔犺浇杩涘害锛�90/100锛�");
+            wdf.Close();
             return responseStr;
         }
 

--
Gitblit v1.9.3