SVN r308
SVN-Revision: r308
This commit is contained in:
@@ -31,6 +31,7 @@ using Microsoft.Win32;
|
||||
using DevExpress.XtraEditors;
|
||||
using DevExpress.XtraTreeList.Nodes;
|
||||
using DevExpress.XtraTreeList;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Lskj.PubArtwork
|
||||
{
|
||||
@@ -1324,17 +1325,15 @@ namespace Lskj.PubArtwork
|
||||
OnFocusedNodeChanged(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上传文件
|
||||
/// 上传附件(新)
|
||||
/// </summary>
|
||||
/// <param name="filePath"></param>
|
||||
/// <returns></returns>
|
||||
private bool UploadFile(string filePath, out string msg)
|
||||
private bool UploadFile(string filePath,out string msg)
|
||||
{
|
||||
bool isUpload = false;
|
||||
string File = filePath;
|
||||
string returnMsg = "";
|
||||
string postUrl = "";
|
||||
try
|
||||
{
|
||||
//获取文件信息
|
||||
@@ -1392,61 +1391,211 @@ namespace Lskj.PubArtwork
|
||||
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))
|
||||
string token = "";
|
||||
string loginUrl = $"{SystemInfo.Instance.OAUrl}/Api/SysUserAjaxApi.ashx";
|
||||
HttpTools.setting("application/x-www-form-urlencoded", null, null, HttpTools.Encode.UTF8);
|
||||
Dictionary<string, string> loginPmsDic = new Dictionary<string, string>();
|
||||
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<JObject>(loginResult);
|
||||
if (jObject.ContainsKey("success"))
|
||||
{
|
||||
string fileId = jsonObject["other"] + "";
|
||||
string webpath = jsonObject["data"]["WebRelPath"] + "";
|
||||
dataRow["fileId"] = fileId;
|
||||
dataRow["webpath"] = webpath;
|
||||
if ((jObject["success"] + "").Equals("True"))
|
||||
{
|
||||
if (jObject.ContainsKey("token"))
|
||||
{
|
||||
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
|
||||
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;
|
||||
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
|
||||
{
|
||||
if (jsonObject.ContainsKey("msg"))
|
||||
{
|
||||
returnMsg = jsonObject["msg"] + "";
|
||||
}
|
||||
isUpload = false;
|
||||
MessageUtil.Show(string.Format("上传失败,原因:{0}", result));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
returnMsg = "上传请求失败";
|
||||
isUpload = false;
|
||||
MessageUtil.Show(string.Format("验证失败,原因:{0}", loginResult));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
returnMsg = ex.Message;
|
||||
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;
|
||||
return isUpload;
|
||||
}
|
||||
/// <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>
|
||||
/// <param name="rowIndex"></param>
|
||||
@@ -2024,33 +2173,4 @@ namespace Lskj.PubArtwork
|
||||
case ControlType.LabAutoCompleteTextParam:
|
||||
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