From b084bd77d01a94c8f0a2d20c86a1f45ba7c8a23c Mon Sep 17 00:00:00 2001 From: lu <99954486@qq.com> Date: 星期六, 19 四月 2025 14:08:05 +0800 Subject: [PATCH] 页面跳转 --- DevApp/Gs.DevApp/UserControl/UCUpFile.cs | 64 +++++++++++++++++++------------- 1 files changed, 38 insertions(+), 26 deletions(-) diff --git a/DevApp/Gs.DevApp/UserControl/UCUpFile.cs b/DevApp/Gs.DevApp/UserControl/UCUpFile.cs index 5ea7d68..e67278a 100644 --- a/DevApp/Gs.DevApp/UserControl/UCUpFile.cs +++ b/DevApp/Gs.DevApp/UserControl/UCUpFile.cs @@ -1,16 +1,8 @@ -锘縰sing DevExpress.Utils.DirectXPaint; -using DevExpress.XtraEditors; -using Gs.DevApp.ToolBox; +锘縰sing Gs.DevApp.ToolBox; using System; -using System.Collections.Generic; -using System.ComponentModel; using System.Configuration; -using System.Data; -using System.Drawing; using System.IO; -using System.Linq; using System.Net.Http; -using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -25,7 +17,19 @@ btnUpSelect.Click += BtnUpSelect_Click; btnUp.Click += BtnUp_Click; } + + /// <summary> + /// + /// </summary> public string parentGuid + { + get; + set; + } + /// <summary> + /// + /// </summary> + public string parentGroup { get; set; @@ -35,7 +39,7 @@ /// 鏀瑰彉浜嬩欢 /// </summary> public event EventHandler UpChanged; - + #region 鏂囦欢涓婁紶 /// <summary> @@ -74,7 +78,8 @@ var WebApiUrl = ConfigurationSettings.AppSettings.Get("WebApiUrl"); var address = WebApiUrl + "MesFile/UploadFile"; var filePath = txtUpUrl.Text.Trim(); - if (string.IsNullOrEmpty(filePath)) { + if (string.IsNullOrEmpty(filePath)) + { Gs.DevApp.ToolBox.MsgHelper.ShowError("璇烽�夋嫨浣犻渶瑕佷笂浼犵殑鏂囦欢锛�"); return; } @@ -85,25 +90,32 @@ private async Task UploadFileAsync(string url, string filePath) { - UcLoading _loading = new UcLoading(); string _parentGuid = parentGuid; using (var httpClient = new HttpClient()) - using (var form = new MultipartFormDataContent()) - { - httpClient.DefaultRequestHeaders.Add("token", - UtilityHelper.GetBasicAuthTicket()); - using (var fs = File.OpenRead(filePath)) - using (var streamContent = new StreamContent(fs)) + try { - form.Add(streamContent, "file", _parentGuid + "~" + Path.GetFileName(filePath)); - var response = await httpClient.PostAsync(url, form); - var responseString = - await response.Content.ReadAsStringAsync(); - // MessageBox.Show(responseString); - txtUpUrl.Text = ""; + using (var form = new MultipartFormDataContent()) + { + httpClient.DefaultRequestHeaders.Add("token", + UtilityHelper.GetBasicAuthTicket()); + using (var fs = File.OpenRead(filePath)) + using (var streamContent = new StreamContent(fs)) + { + form.Add(streamContent, "file", _parentGuid + "~" + Path.GetFileName(filePath) + "~" + parentGroup); + var response = await httpClient.PostAsync(url, form); + var responseString = + await response.Content.ReadAsStringAsync(); + // MessageBox.Show(responseString); + txtUpUrl.Text = ""; + } + } } - } - _loading.Close(); + catch (Exception ex) + { + Gs.DevApp.ToolBox.MsgHelper.ShowError(ex.Message); + + } + } #endregion -- Gitblit v1.9.3