lu
2025-04-10 769b5a6f9c67bab1982f935b54dc0f26e7606972
DevApp/Gs.DevApp/UserControl/UCUpFile.cs
@@ -25,7 +25,19 @@
            btnUpSelect.Click += BtnUpSelect_Click;
            btnUp.Click += BtnUp_Click;
        }
        /// <summary>
        ///
        /// </summary>
        public string parentGuid
        {
            get;
            set;
        }
        /// <summary>
        ///
        /// </summary>
        public string parentGroup
        {
            get;
            set;
@@ -69,7 +81,7 @@
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async  void BtnUp_Click(object sender, EventArgs e)
        private async void BtnUp_Click(object sender, EventArgs e)
        {
            var WebApiUrl = ConfigurationSettings.AppSettings.Get("WebApiUrl");
            var address = WebApiUrl + "MesFile/UploadFile";
@@ -84,9 +96,8 @@
            if (UpChanged != null) UpChanged(this, e);
        }
        private async   Task UploadFileAsync(string url, string filePath)
        private async Task UploadFileAsync(string url, string filePath)
        {
            string _parentGuid = parentGuid;
            using (var httpClient = new HttpClient())
                try
@@ -98,7 +109,7 @@
                        using (var fs = File.OpenRead(filePath))
                        using (var streamContent = new StreamContent(fs))
                        {
                            form.Add(streamContent, "file", _parentGuid + "~" + Path.GetFileName(filePath));
                            form.Add(streamContent, "file", _parentGuid + "~" + Path.GetFileName(filePath) + "~" + parentGroup);
                            var response = await httpClient.PostAsync(url, form);
                            var responseString =
                                await response.Content.ReadAsStringAsync();
@@ -112,7 +123,7 @@
                    Gs.DevApp.ToolBox.MsgHelper.ShowError(ex.Message);
                }
        }
        #endregion