diff --git a/插件库/Lskj.PubArtworkDynamic/Control/ModuleGrid.cs b/插件库/Lskj.PubArtworkDynamic/Control/ModuleGrid.cs index 04298b0..3ee9208 100644 --- a/插件库/Lskj.PubArtworkDynamic/Control/ModuleGrid.cs +++ b/插件库/Lskj.PubArtworkDynamic/Control/ModuleGrid.cs @@ -420,22 +420,51 @@ namespace Lskj.PubArtworkDynamic.Control bool isDelete = false; try { - //删除文件 - //string postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&idValue={2}&folder={3}&filename={4}&method={5}"; - string postUrl = "{0}Api/FileUploadApi.ashx?fileId={1}&filename={2}&method={3}"; - //postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, this.Model.ModuleCode, "", "UploadFilesTemp", rowItem["name"], "DoDelete"); - postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, rowItem["fileId"], rowItem["webpath"], "DoDelete"); - HttpTools.setting("application/x-www-form-urlencoded", null, null); - string result = ""; - CookieCollection cookieCollection = null; - HttpWebResponse webResponse = HttpTools.Post(postUrl, "", null, HttpTools.Method.POST, out cookieCollection, out result); - if (webResponse != null && !string.IsNullOrEmpty(result)) + string token = ""; + string loginUrl = $"{SystemInfo.Instance.OAUrl}/Api/SysUserAjaxApi.ashx"; + HttpTools.setting("application/x-www-form-urlencoded", null, null, HttpTools.Encode.UTF8); + Dictionary loginPmsDic = new Dictionary(); + loginPmsDic.Add("method", "Login"); + loginPmsDic.Add("username", ERPInfo.Instance.UserName); + loginPmsDic.Add("password", ERPInfo.Instance.InPassWord); + HttpWebResponse loginResponse = HttpTools.Post(loginUrl, "", loginPmsDic, HttpTools.Method.POST, out CookieCollection loginCookie, out string loginResult); + if (loginResponse != null && !string.IsNullOrEmpty(loginResult)) { - JObject jsonObject = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(result); - string isSuccess = jsonObject["success"] + ""; - if (isSuccess.Equals("True", StringComparison.CurrentCultureIgnoreCase)) + JObject jObject = JsonConvert.DeserializeObject(loginResult); + if (jObject.ContainsKey("success")) { - isDelete = true; + if ((jObject["success"] + "").Equals("True")) + { + if (jObject.ContainsKey("token")) + { + token = jObject["token"] + ""; + } + } + } + } + if (!string.IsNullOrEmpty(token)) + { + //删除文件 + //string postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&idValue={2}&folder={3}&filename={4}&method={5}"; + string postUrl = "{0}Api/FileUploadApi.ashx?fileId={1}&filename={2}&method={3}"; + //postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, this.Model.ModuleCode, "", "UploadFilesTemp", rowItem["name"], "DoDelete"); + postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, rowItem["fileId"], rowItem["webpath"], "DoDelete"); + HttpTools.setting("application/x-www-form-urlencoded", null, null); + string result = ""; + CookieCollection cookieCollection = null; + HttpWebResponse webResponse = HttpTools.Post(postUrl, "", null, HttpTools.Method.POST, out cookieCollection, out result); + if (webResponse != null && !string.IsNullOrEmpty(result)) + { + JObject jsonObject = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(result); + string isSuccess = jsonObject["success"] + ""; + if (isSuccess.Equals("True", StringComparison.CurrentCultureIgnoreCase)) + { + isDelete = true; + } + else + { + isDelete = false; + } } else {