SVN r308
SVN-Revision: r308
This commit is contained in:
@@ -31,6 +31,7 @@ using Microsoft.Win32;
|
|||||||
using DevExpress.XtraEditors;
|
using DevExpress.XtraEditors;
|
||||||
using DevExpress.XtraTreeList.Nodes;
|
using DevExpress.XtraTreeList.Nodes;
|
||||||
using DevExpress.XtraTreeList;
|
using DevExpress.XtraTreeList;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Lskj.PubArtwork
|
namespace Lskj.PubArtwork
|
||||||
{
|
{
|
||||||
@@ -1324,17 +1325,15 @@ namespace Lskj.PubArtwork
|
|||||||
OnFocusedNodeChanged(null, null);
|
OnFocusedNodeChanged(null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 上传文件
|
/// 上传附件(新)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="filePath"></param>
|
private bool UploadFile(string filePath,out string msg)
|
||||||
/// <returns></returns>
|
|
||||||
private bool UploadFile(string filePath, out string msg)
|
|
||||||
{
|
{
|
||||||
bool isUpload = false;
|
bool isUpload = false;
|
||||||
string File = filePath;
|
string File = filePath;
|
||||||
string returnMsg = "";
|
string returnMsg = "";
|
||||||
string postUrl = "";
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//获取文件信息
|
//获取文件信息
|
||||||
@@ -1392,61 +1391,211 @@ namespace Lskj.PubArtwork
|
|||||||
dataRow["Uploader"] = ERPInfo.Instance.UserId;
|
dataRow["Uploader"] = ERPInfo.Instance.UserId;
|
||||||
dataRow["UploadTime"] = DateTime.Now;
|
dataRow["UploadTime"] = DateTime.Now;
|
||||||
string idValue = this.treeLeft.GetGridViewDataSource().Rows[0]["产品代码"] + "";
|
string idValue = this.treeLeft.GetGridViewDataSource().Rows[0]["产品代码"] + "";
|
||||||
//上传文件到服务器目录
|
string token = "";
|
||||||
postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&idValue={2}&folder={3}&totsize={4}&position={5}&filename={6}&method={7}";
|
string loginUrl = $"{SystemInfo.Instance.OAUrl}/Api/SysUserAjaxApi.ashx";
|
||||||
postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, this.Model.ModuleCode, idValue, "UploadFilesTemp", fileBytes.Length, 0, dataRow["name"], "DoWebUpload");
|
HttpTools.setting("application/x-www-form-urlencoded", null, null, HttpTools.Encode.UTF8);
|
||||||
HttpTools.setting("application/x-www-form-urlencoded", null, null);
|
Dictionary<string, string> loginPmsDic = new Dictionary<string, string>();
|
||||||
string result = "";
|
loginPmsDic.Add("method", "Login");
|
||||||
CookieCollection cookieCollection = null;
|
loginPmsDic.Add("username", ERPInfo.Instance.UserName);
|
||||||
HttpWebResponse webResponse = HttpTools.Post(postUrl, dataRow["fileStream"] + "", null, HttpTools.Method.POST, out cookieCollection, out result);
|
loginPmsDic.Add("password", ERPInfo.Instance.InPassWord);
|
||||||
if (webResponse != null && !string.IsNullOrEmpty(result))
|
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);
|
JObject jObject = JsonConvert.DeserializeObject<JObject>(loginResult);
|
||||||
string isSuccess = jsonObject["success"] + "";
|
if (jObject.ContainsKey("success"))
|
||||||
if (isSuccess.Equals("True", StringComparison.CurrentCultureIgnoreCase))
|
|
||||||
{
|
{
|
||||||
string fileId = jsonObject["other"] + "";
|
if ((jObject["success"] + "").Equals("True"))
|
||||||
string webpath = jsonObject["data"]["WebRelPath"] + "";
|
{
|
||||||
dataRow["fileId"] = fileId;
|
if (jObject.ContainsKey("token"))
|
||||||
dataRow["webpath"] = webpath;
|
{
|
||||||
|
token = jObject["token"] + "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(token))
|
||||||
|
{
|
||||||
|
string fileBase64Str = Convert.ToBase64String(fileBytes) + "";
|
||||||
|
string postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&idValue={2}&folder={3}&totsize={4}&position={5}&filename={6}&method={7}";
|
||||||
|
Dictionary<string, string> headerDic = new Dictionary<string, string>();
|
||||||
|
headerDic.Add("Authorization", $"Bearer {token}");
|
||||||
|
//上传文件到服务器目录
|
||||||
|
postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&idValue={2}&folder={3}&totsize={4}&position={5}&filename={6}&method={7}";
|
||||||
|
postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, this.Model.ModuleCode, idValue, "UploadFilesTemp", fileBytes.Length, 0, dataRow["name"], "DoWebUpload");
|
||||||
|
HttpTools.setting("application/x-www-form-urlencoded", null, null);
|
||||||
|
HttpWebResponse webResponse = HttpTools.Post(postUrl, fileBase64Str, null, headerDic, HttpTools.Method.POST, out CookieCollection cookieCollection, out string result);
|
||||||
|
if (webResponse != null && !string.IsNullOrEmpty(result))
|
||||||
|
{
|
||||||
|
JObject jsonObject = (JObject)JsonConvert.DeserializeObject(result);
|
||||||
|
string isSuccess = jsonObject["success"] + "";
|
||||||
|
if (isSuccess.Equals("True", StringComparison.CurrentCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
string fileId = jsonObject["other"] + "";
|
||||||
|
string webpath = jsonObject["data"]["WebRelPath"] + "";
|
||||||
|
dataRow["fileId"] = fileId;
|
||||||
|
dataRow["webpath"] = webpath;
|
||||||
|
|
||||||
string searchSql = @"update P_fm_FileTab set author='{2}',CreationTime='{3}' ,Uploader='{4}',UploaderId='{5}' ,UploadTime='{6}'
|
string searchSql = @"update P_fm_FileTab set author='{2}',CreationTime='{3}' ,Uploader='{4}',UploaderId='{5}' ,UploadTime='{6}'
|
||||||
where dllcoid = '{0}' and
|
where dllcoid = '{0}' and
|
||||||
parentid = (select dirid from P_fm_DirectoryTab where
|
parentid = (select dirid from P_fm_DirectoryTab where
|
||||||
ParentId = (select dirid from v_systemdlltab where DllCoid = '{0}') and PID = '{1}') and fileId='{7}' ";
|
ParentId = (select dirid from v_systemdlltab where DllCoid = '{0}') and PID = '{1}') and fileId='{7}' ";
|
||||||
searchSql = string.Format(searchSql, this.Model.ModuleCode, this.leftTreeGridIdValue, dataRow["author"], fileInfo.CreationTime, ERPInfo.Instance.UserName, ERPInfo.Instance.UserId, dataRow["UploadTime"], fileId);
|
searchSql = string.Format(searchSql, this.Model.ModuleCode, this.leftTreeGridIdValue, dataRow["author"], fileInfo.CreationTime, ERPInfo.Instance.UserName, ERPInfo.Instance.UserId, dataRow["UploadTime"], fileId);
|
||||||
SqlHelper.ExecuteNonQuery(searchSql);
|
SqlHelper.ExecuteNonQuery(searchSql);
|
||||||
dataTable.Rows.Add(dataRow);
|
dataTable.Rows.Add(dataRow);
|
||||||
isUpload = true;
|
isUpload = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (jsonObject.ContainsKey("msg"))
|
||||||
|
{
|
||||||
|
returnMsg = jsonObject["msg"] + "";
|
||||||
|
}
|
||||||
|
isUpload = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (jsonObject.ContainsKey("msg"))
|
MessageUtil.Show(string.Format("上传失败,原因:{0}", result));
|
||||||
{
|
|
||||||
returnMsg = jsonObject["msg"] + "";
|
|
||||||
}
|
|
||||||
isUpload = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
returnMsg = "上传请求失败";
|
MessageUtil.Show(string.Format("验证失败,原因:{0}", loginResult));
|
||||||
isUpload = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
returnMsg = ex.Message;
|
returnMsg = ex.Message;
|
||||||
isUpload = false;
|
isUpload = false;
|
||||||
|
//MessageUtil.Show(string.Format("上传失败,原因:{0}", ex.Message));
|
||||||
|
//isUpload = false;
|
||||||
}
|
}
|
||||||
//if (!string.IsNullOrEmpty(returnMsg))
|
|
||||||
//{
|
|
||||||
// returnMsg += string.Format("\r\n接口Url:{0}", postUrl);
|
|
||||||
//}
|
|
||||||
msg = returnMsg;
|
msg = returnMsg;
|
||||||
return isUpload;
|
return isUpload;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 上传文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//private bool UploadFile(string filePath, out string msg)
|
||||||
|
//{
|
||||||
|
// bool isUpload = false;
|
||||||
|
// string File = filePath;
|
||||||
|
// string returnMsg = "";
|
||||||
|
// string postUrl = "";
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// //获取文件信息
|
||||||
|
// System.IO.FileInfo fileInfo = new FileInfo(File);
|
||||||
|
// string suffix = Path.GetExtension(File);
|
||||||
|
// //获取Excel等文件信息
|
||||||
|
// string fileAuthor = "";
|
||||||
|
// string fileType = "";
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// var file = ShellFile.FromFilePath(File);
|
||||||
|
// string[] oldAuthors = file.Properties.System.Author.Value;//作者
|
||||||
|
// if (oldAuthors != null && oldAuthors.Length > 0)
|
||||||
|
// {
|
||||||
|
// fileAuthor = string.Join(",", oldAuthors);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// fileAuthor = "";
|
||||||
|
// }
|
||||||
|
// fileType = file.Properties.System.ItemTypeText.Value + "";
|
||||||
|
// }
|
||||||
|
// catch (Exception)
|
||||||
|
// {
|
||||||
|
// fileType = Path.GetExtension(File).TrimStart(',');
|
||||||
|
// }
|
||||||
|
// //新建行并添加拖动内容
|
||||||
|
// DataTable dataTable = gm_Operate.gridControl.DataSource as DataTable;
|
||||||
|
// DataRow dataRow = dataTable.NewRow();
|
||||||
|
// //文件图标
|
||||||
|
// //Icon img = Icon.ExtractAssociatedIcon(File);
|
||||||
|
// //Icon img = picture.IconFromExtension(fi.Extension, picture.SystemIconSize.Small);
|
||||||
|
// byte[] imgBytes;
|
||||||
|
// if (IconBytesList.ContainsKey(suffix))
|
||||||
|
// {
|
||||||
|
// imgBytes = IconBytesList[suffix];
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// imgBytes = picture.GetFileBytes(suffix, false);
|
||||||
|
// IconBytesList.Add(suffix, imgBytes);
|
||||||
|
// }
|
||||||
|
// dataRow["icon"] = imgBytes;
|
||||||
|
// dataRow["name"] = fileInfo.Name;
|
||||||
|
// dataRow["CreationTime"] = fileInfo.CreationTime;
|
||||||
|
// //dataRow["type"] = fi.Extension.Replace(".", "");
|
||||||
|
// dataRow["type"] = fileType;
|
||||||
|
// dataRow["fileSize"] = BytesToReadableValue(fileInfo.Length);
|
||||||
|
// //dataRow["category"] = "";
|
||||||
|
// dataRow["author"] = fileAuthor;
|
||||||
|
// //dataRow["title"] = oldTitle;
|
||||||
|
// //dataRow["copyright"] = "";
|
||||||
|
// byte[] fileBytes = ConvertFileToBytes(File);
|
||||||
|
// dataRow["fileStream"] = Convert.ToBase64String(fileBytes);
|
||||||
|
// dataRow["Uploader"] = ERPInfo.Instance.UserId;
|
||||||
|
// dataRow["UploadTime"] = DateTime.Now;
|
||||||
|
// string idValue = this.treeLeft.GetGridViewDataSource().Rows[0]["产品代码"] + "";
|
||||||
|
// //上传文件到服务器目录
|
||||||
|
// postUrl = "{0}Api/FileUploadApi.ashx?moduleId={1}&idValue={2}&folder={3}&totsize={4}&position={5}&filename={6}&method={7}";
|
||||||
|
// postUrl = string.Format(postUrl, SystemInfo.Instance.OAUrl, this.Model.ModuleCode, idValue, "UploadFilesTemp", fileBytes.Length, 0, dataRow["name"], "DoWebUpload");
|
||||||
|
// HttpTools.setting("application/x-www-form-urlencoded", null, null);
|
||||||
|
// string result = "";
|
||||||
|
// CookieCollection cookieCollection = null;
|
||||||
|
// HttpWebResponse webResponse = HttpTools.Post(postUrl, dataRow["fileStream"] + "", 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))
|
||||||
|
// {
|
||||||
|
// string fileId = jsonObject["other"] + "";
|
||||||
|
// string webpath = jsonObject["data"]["WebRelPath"] + "";
|
||||||
|
// dataRow["fileId"] = fileId;
|
||||||
|
// dataRow["webpath"] = webpath;
|
||||||
|
|
||||||
|
// string searchSql = @"update P_fm_FileTab set author='{2}',CreationTime='{3}' ,Uploader='{4}',UploaderId='{5}' ,UploadTime='{6}'
|
||||||
|
// where dllcoid = '{0}' and
|
||||||
|
// parentid = (select dirid from P_fm_DirectoryTab where
|
||||||
|
// ParentId = (select dirid from v_systemdlltab where DllCoid = '{0}') and PID = '{1}') and fileId='{7}' ";
|
||||||
|
// searchSql = string.Format(searchSql, this.Model.ModuleCode, this.leftTreeGridIdValue, dataRow["author"], fileInfo.CreationTime, ERPInfo.Instance.UserName, ERPInfo.Instance.UserId, dataRow["UploadTime"], fileId);
|
||||||
|
// SqlHelper.ExecuteNonQuery(searchSql);
|
||||||
|
// dataTable.Rows.Add(dataRow);
|
||||||
|
// isUpload = true;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// if (jsonObject.ContainsKey("msg"))
|
||||||
|
// {
|
||||||
|
// returnMsg = jsonObject["msg"] + "";
|
||||||
|
// }
|
||||||
|
// isUpload = false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// returnMsg = "上传请求失败";
|
||||||
|
// isUpload = false;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// returnMsg = ex.Message;
|
||||||
|
// isUpload = false;
|
||||||
|
// }
|
||||||
|
// //if (!string.IsNullOrEmpty(returnMsg))
|
||||||
|
// //{
|
||||||
|
// // returnMsg += string.Format("\r\n接口Url:{0}", postUrl);
|
||||||
|
// //}
|
||||||
|
// msg = returnMsg;
|
||||||
|
// return isUpload;
|
||||||
|
//}
|
||||||
|
/// <summary>
|
||||||
/// 删除文件
|
/// 删除文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="rowIndex"></param>
|
/// <param name="rowIndex"></param>
|
||||||
@@ -2024,33 +2173,4 @@ namespace Lskj.PubArtwork
|
|||||||
case ControlType.LabAutoCompleteTextParam:
|
case ControlType.LabAutoCompleteTextParam:
|
||||||
if (!this.SearchMainObj.isRevTextEdit)
|
if (!this.SearchMainObj.isRevTextEdit)
|
||||||
{
|
{
|
||||||
LabelAutoTextEdit autoTextEdit = control as LabelAutoTextEdit;
|
|
||||||
autoTextEdit.TextEdit.HidePopup();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LabelAutoTextRevEdit autoTextEdit = control as LabelAutoTextRevEdit;
|
|
||||||
autoTextEdit.TextEdit.HidePopup();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TextEdit_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (sender is AutoGridLookUp)
|
|
||||||
{
|
|
||||||
AutoGridLookUp agl = sender as AutoGridLookUp;
|
|
||||||
if (!agl.AutoShowPopup)
|
|
||||||
{
|
|
||||||
agl.AutoShowPopup = true;
|
|
||||||
agl.Focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user