SVN-Revision: r774
This commit is contained in:
wyf
2025-06-23 08:20:49 +00:00
parent ae88a3fd69
commit e14d5798e8
+57 -73
View File
@@ -2970,63 +2970,73 @@ namespace Lskj.Control.Model
if (isTip) MessageUtil.Show(ResourceKeys.SaveSuccess); if (isTip) MessageUtil.Show(ResourceKeys.SaveSuccess);
#endregion #endregion
#region #region
string idValue = primaryValue; try
if (SystemModel != null && !string.IsNullOrWhiteSpace(SystemModel.AttachmentAssociated))
{ {
idValue = GetControlValue(SystemModel.AttachmentAssociated); string idValue = primaryValue;
} if (SystemModel != null && !string.IsNullOrWhiteSpace(SystemModel.AttachmentAssociated))
List<ControlModel> uploadModels = ControlModels.Where(n => n.FileUploadControl).ToList();
foreach (ControlModel uploadModel in uploadModels)
{
BaseUserControl uploadControl = FindControl(uploadModel);
if (uploadControl != null && uploadControl is LabelRemarkEdit labelRemarkEdit && !string.IsNullOrEmpty(labelRemarkEdit.filepath) && File.Exists(labelRemarkEdit.filepath))
{ {
string filePath = labelRemarkEdit.filepath; idValue = GetControlValue(SystemModel.AttachmentAssociated);
string token = UploadFileUtil.Login(SystemInfo.Instance.OAUrl); }
if (!string.IsNullOrEmpty(token)) ControlModel uploadModel = ControlModels.Where(n => n.FileUploadControl).FirstOrDefault();
if (uploadModel != null)
{
BaseUserControl uploadControl = FindControl(uploadModel);
if (uploadControl != null && uploadControl is LabelRemarkEdit labelRemarkEdit && !string.IsNullOrEmpty(labelRemarkEdit.filepath) && File.Exists(labelRemarkEdit.filepath))
{ {
string speciesno = "010106"; string filePath = labelRemarkEdit.filepath;
GetFileCodeInfo(Path.GetFileNameWithoutExtension(filePath), out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC); string token = UploadFileUtil.Login(SystemInfo.Instance.OAUrl);
byte[] fileBytes = UploadFileUtil.ConvertFileToBytes(filePath); if (!string.IsNullOrEmpty(token))
string fileStream = Convert.ToBase64String(fileBytes);
string selectSql = $"select * from P_fm_FileTab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{idValue}' and dllcoid = '{Model.ModuleCode}') and speciesno = '{speciesno}' and sname like '{sourceCode}%'";
DataTable deleteTable = BaseImpl.GetDataTableResult(selectSql);
if (deleteTable != null && deleteTable.Rows.Count > 0)
{ {
foreach (DataRow deleteRow in deleteTable.Rows) string speciesno = "010106";
GetFileCodeInfo(Path.GetFileNameWithoutExtension(filePath), out string sourceCode, out string sourceName, out string sourceBB, out int sourceBC);
byte[] fileBytes = UploadFileUtil.ConvertFileToBytes(filePath);
string fileStream = Convert.ToBase64String(fileBytes);
string selectSql = $"select * from P_fm_FileTab where parentid in (select dirid from P_fm_DirectoryTab where pid = '{idValue}' and dllcoid = '{Model.ModuleCode}') and speciesno = '{speciesno}' and sname like '{sourceCode}%'";
DataTable deleteTable = BaseImpl.GetDataTableResult(selectSql);
if (deleteTable != null && deleteTable.Rows.Count > 0)
{ {
string field = HttpUtility.UrlEncode(deleteRow["fileId"] + ""); foreach (DataRow deleteRow in deleteTable.Rows)
string webpath = HttpUtility.UrlEncode(deleteRow["webpath"] + ""); {
//删除文件 string field = HttpUtility.UrlEncode(deleteRow["fileId"] + "");
string deleteUrl = "{0}Api/FileUploadApi.ashx?fileId={1}&filename={2}&method={3}"; string webpath = HttpUtility.UrlEncode(deleteRow["webpath"] + "");
deleteUrl = string.Format(deleteUrl, SystemInfo.Instance.OAUrl, field, webpath, "DoDelete"); //删除文件
HttpHelper.Setting("application/x-www-form-urlencoded", null, null); string deleteUrl = "{0}Api/FileUploadApi.ashx?fileId={1}&filename={2}&method={3}";
Dictionary<string, string> deleteHeaderDic = new Dictionary<string, string>(); deleteUrl = string.Format(deleteUrl, SystemInfo.Instance.OAUrl, field, webpath, "DoDelete");
deleteHeaderDic.Add("Authorization", $"Bearer {token}"); HttpHelper.Setting("application/x-www-form-urlencoded", null, null);
HttpHelper.Post(deleteUrl, fileStream, null, deleteHeaderDic, out string deleteResult); Dictionary<string, string> deleteHeaderDic = new Dictionary<string, string>();
deleteHeaderDic.Add("Authorization", $"Bearer {token}");
HttpHelper.Post(deleteUrl, fileStream, null, deleteHeaderDic, out string deleteResult);
}
}
string postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&idValue={2}&speciesno={8}&folder={3}&totsize={4}&position={5}&filename={6}&method={7}&confirm=1";
postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, Model.ModuleCode, HttpUtility.UrlEncode(idValue), "file", fileBytes.Length, 0, HttpUtility.UrlEncode(Path.GetFileName(filePath)), "DoWebUpload", speciesno);
bool isUpload = UploadFileUtil.UploadFile(token, postUrl, fileStream, out string fileId, out string rtnMsg);
if (!isUpload)
{
throw new Exception($"自动上传失败\r\n{rtnMsg}");
}
else
{
string updateSql = $"update QMS_wenjiangenggaitab set fileId = '{fileId}' where qms_wjgg_billdocument_id = '{primaryValue}'";
SqlHelper.ExecuteNonQuery(updateSql);
} }
}
string postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&idValue={2}&speciesno={8}&folder={3}&totsize={4}&position={5}&filename={6}&method={7}&confirm=1";
postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, Model.ModuleCode, HttpUtility.UrlEncode(idValue), "file", fileBytes.Length, 0, HttpUtility.UrlEncode(Path.GetFileName(filePath)), "DoWebUpload", speciesno);
bool isUpload = UploadFileUtil.UploadFile(token, postUrl, fileStream, out string fileId, out string rtnMsg);
if (!isUpload)
{
MessageUtil.Show($"自动上传失败\r\n{rtnMsg}");
return false;
} }
else else
{ {
string updateSql = $"update {SystemModel.MenuTable} set fileId = '{fileId}' where {SystemModel.ParmaryKey} = '{primaryValue}'"; throw new Exception($"登录失败,自动上传失败");
BaseImpl.ExecSqlValue(updateSql);
} }
} }
else
{
MessageUtil.Show($"登录失败,自动上传失败");
return false;
}
} }
} }
catch (Exception ex)
{
MessageUtil.Show(ex.Message);
if (isAdd)
{
BaseImpl.ExecSqlValue($"delete QMS_wenjiangenggaitab where qms_wjgg_billdocument_Id = '{primaryValue}'");
}
return false;
}
#endregion #endregion
#region #region
if (SystemModel != null && !string.IsNullOrEmpty(SystemModel.AfterSaveExec)) if (SystemModel != null && !string.IsNullOrEmpty(SystemModel.AfterSaveExec))
@@ -4593,14 +4603,14 @@ namespace Lskj.Control.Model
baseControl.EditText = dataRow["sname"] + ""; baseControl.EditText = dataRow["sname"] + "";
VerControl.EditText = dataRow["Ver"] + ""; VerControl.EditText = dataRow["Ver"] + "";
fileidControl.EditText = dataRow["fileid"] + ""; fileidControl.EditText = dataRow["fileid"] + "";
string IsLatest=dataRow["IsLatest"] + ""; string IsLatest = dataRow["IsLatest"] + "";
if (IsLatest.Equals("False")) if (IsLatest.Equals("False"))
{ {
MessageUtil.Show("当前变更的版本低于历史版本,请检查!"); MessageUtil.Show("当前变更的版本低于历史版本,请检查!");
labelRemarkEdit.EditText = string.Empty; labelRemarkEdit.EditText = string.Empty;
} }
} }
// 手动触发关联,有可能单据打开后直接点击新增按钮此时文本框值未改变,不会触发关联和计算 // 手动触发关联,有可能单据打开后直接点击新增按钮此时文本框值未改变,不会触发关联和计算
this.SetUnionAncCalcControl(labelRemarkEdit); this.SetUnionAncCalcControl(labelRemarkEdit);
} }
@@ -5957,30 +5967,4 @@ namespace Lskj.Control.Model
LabelDateEdit dateEdit = controlObj as LabelDateEdit; LabelDateEdit dateEdit = controlObj as LabelDateEdit;
value = dateEdit.TextEdit.EditValue == null ? dateEdit.EditText : dateEdit.TextEdit.DateTime.ToString("yyyy-MM-dd"); value = dateEdit.TextEdit.EditValue == null ? dateEdit.EditText : dateEdit.TextEdit.DateTime.ToString("yyyy-MM-dd");
} }
else if (controlObj is LabelCheckEdit) else if
{
LabelCheckEdit checkEdit = controlObj as LabelCheckEdit;
value = checkEdit.EditText;
}
else if (controlObj is LabelComboxEdit)
{
LabelComboxEdit autoEdit = controlObj as LabelComboxEdit;
value = autoEdit.EditValue;
}
else if (controlObj is LabelTextEdit)
{
LabelTextEdit textIntEdit = controlObj as LabelTextEdit;
if (textIntEdit != null) value = string.IsNullOrEmpty(textIntEdit.EditText) ? "0" : textIntEdit.EditText;
}
defaultValue = defaultValue.Replace(item, value);
}
}
}
return defaultValue;
}
}
}