SVN r553
SVN-Revision: r553
This commit is contained in:
@@ -1983,6 +1983,23 @@ namespace Lskj.PubBomImport
|
||||
}
|
||||
if (!string.IsNullOrEmpty(token))
|
||||
{
|
||||
string selectSql = $"select * from P_fm_FileTab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{idValue}' and dllcoid = '1000202') and speciesno = '{speciesno}' and sname = '{name.Replace(" ", "")}'";
|
||||
DataTable deleteTable = BaseImpl.GetDataTableResult(selectSql);
|
||||
if (deleteTable != null && deleteTable.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow deleteRow in deleteTable.Rows)
|
||||
{
|
||||
string field = HttpUtility.UrlEncode(deleteRow["fileId"] + "");
|
||||
string webpath = HttpUtility.UrlEncode(deleteRow["webpath"] + "");
|
||||
//删除文件
|
||||
string deleteUrl = "{0}Api/FileUploadApi.ashx?fileId={1}&filename={2}&method={3}";
|
||||
deleteUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, field, webpath, "DoDelete");
|
||||
HttpHelper.Setting("application/x-www-form-urlencoded", null, null);
|
||||
Dictionary<string, string> deleteHeaderDic = new Dictionary<string, string>();
|
||||
deleteHeaderDic.Add("Authorization", $"Bearer {token}");
|
||||
HttpWebResponse deleteWebResponse = HttpHelper.Post(deleteUrl, fileStream, null, deleteHeaderDic, out string deleteResult);
|
||||
}
|
||||
}
|
||||
postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, "1000202", HttpUtility.UrlEncode(idValue), "file", fileBytes.Length, 0, HttpUtility.UrlEncode(name), "DoWebUpload", speciesno);
|
||||
HttpTools.setting("application/x-www-form-urlencoded", null, null);
|
||||
string result = "";
|
||||
@@ -1992,7 +2009,7 @@ namespace Lskj.PubBomImport
|
||||
HttpWebResponse webResponse = HttpTools.Post(postUrl, fileStream, null, headerDic, HttpTools.Method.POST, out cookieCollection, out result);
|
||||
if (webResponse != null && !string.IsNullOrEmpty(result))
|
||||
{
|
||||
JObject jsonObject = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(result);
|
||||
JObject jsonObject = (JObject)JsonConvert.DeserializeObject(result);
|
||||
string isSuccess = jsonObject["success"] + "";
|
||||
if (isSuccess.Equals("True", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
@@ -2092,7 +2109,23 @@ namespace Lskj.PubBomImport
|
||||
}
|
||||
if (!string.IsNullOrEmpty(token))
|
||||
{
|
||||
//DeleteFileExists(token, name, Model.ModuleCode, idValue, speciesno);
|
||||
string selectSql = $"select * from P_fm_FileTab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{idValue}' and dllcoid = '1000202') and speciesno = '{speciesno}' and sname = '{name.Replace(" ", "")}'";
|
||||
DataTable deleteTable = BaseImpl.GetDataTableResult(selectSql);
|
||||
if (deleteTable != null && deleteTable.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow deleteRow in deleteTable.Rows)
|
||||
{
|
||||
string field = HttpUtility.UrlEncode(deleteRow["fileId"] + "");
|
||||
string webpath = HttpUtility.UrlEncode(deleteRow["webpath"] + "");
|
||||
//删除文件
|
||||
string deleteUrl = "{0}Api/FileUploadApi.ashx?fileId={1}&filename={2}&method={3}";
|
||||
deleteUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, field, webpath, "DoDelete");
|
||||
HttpHelper.Setting("application/x-www-form-urlencoded", null, null);
|
||||
Dictionary<string, string> deleteHeaderDic = new Dictionary<string, string>();
|
||||
deleteHeaderDic.Add("Authorization", $"Bearer {token}");
|
||||
HttpWebResponse deleteWebResponse = HttpHelper.Post(deleteUrl, fileStream, null, deleteHeaderDic, out string deleteResult);
|
||||
}
|
||||
}
|
||||
postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, "1000202", HttpUtility.UrlEncode(idValue), "file", fileBytes.Length, 0, HttpUtility.UrlEncode(name), "DoWebUpload", speciesno);
|
||||
HttpTools.setting("application/x-www-form-urlencoded", null, null);
|
||||
string result = "";
|
||||
@@ -2145,39 +2178,4 @@ namespace Lskj.PubBomImport
|
||||
throw new Exception($"文件{Path.GetFileName(filePath)}上传失败\r\n{ex.Message}");
|
||||
isUpload = false;
|
||||
}
|
||||
msg = returnMsg;
|
||||
outFileId = fileId;
|
||||
return isUpload;
|
||||
}
|
||||
/// <summary>
|
||||
/// 删除已经存在的附件
|
||||
/// </summary>
|
||||
private void DeleteFileExists(string token, string filename, string moduleid, string idValue, string speciesno)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrEmpty(token))
|
||||
{
|
||||
DataTable fileTable = BaseImpl.GetDataTableResult($"select * from P_fm_FileTab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{idValue}' and dllcoid = '{moduleid}') and speciesno = '{speciesno}' and sname = '{filename.Replace(" ", "")}'");
|
||||
if (fileTable != null && fileTable.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow deleteRow in fileTable.Rows)
|
||||
{
|
||||
string field = HttpUtility.UrlEncode(deleteRow["fileId"] + "");
|
||||
string webpath = HttpUtility.UrlEncode(deleteRow["webpath"] + "");
|
||||
//删除文件
|
||||
string postUrl = "{0}Api/FileUploadApi.ashx?fileId={1}&filename={2}&method={3}";
|
||||
postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, field, 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))
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
msg = returnM
|
||||
Reference in New Issue
Block a user