SVN r440
SVN-Revision: r440
This commit is contained in:
@@ -526,7 +526,7 @@ namespace Lskj.Control.Model
|
|||||||
resultValue = ExecDynamicLinkLibary(model, paramList, dllName, true);
|
resultValue = ExecDynamicLinkLibary(model, paramList, dllName, true);
|
||||||
break;
|
break;
|
||||||
case 5://执行存储过程获取下载url集合执行批量下载
|
case 5://执行存储过程获取下载url集合执行批量下载
|
||||||
resultValue = ExecDownloadFiles(model, paramList, rowData);
|
resultValue = ExecDownloadFiles(model, paramList, rows);
|
||||||
break;
|
break;
|
||||||
case 6://下载后打开文件
|
case 6://下载后打开文件
|
||||||
resultValue = OpenAfterDownloading(model, paramList);
|
resultValue = OpenAfterDownloading(model, paramList);
|
||||||
@@ -1076,17 +1076,128 @@ namespace Lskj.Control.Model
|
|||||||
/// <para>版本:1.0</para>
|
/// <para>版本:1.0</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||||
private bool ExecDownloadFiles(GridRightMenuModel model, List<string> paramList, DataRow rowData, string comfirmFlag = "0")
|
private bool ExecDownloadFiles(GridRightMenuModel model, List<string> paramList, DataRow[] rows, string comfirmFlag = "0")
|
||||||
{
|
{
|
||||||
|
bool reaultValue = true;
|
||||||
string procName = model.Action;
|
string procName = model.Action;
|
||||||
if (string.IsNullOrWhiteSpace(procName))
|
if (string.IsNullOrWhiteSpace(procName))
|
||||||
{
|
{
|
||||||
MessageUtil.Show(ResourceKeys.NotFoundProcName);
|
if (rows.Length > 0 && rows[0].Table.Columns.Contains("webpath"))
|
||||||
|
{
|
||||||
|
StringBuilder urlsBuilder = new StringBuilder();
|
||||||
|
foreach (DataRow row in rows)
|
||||||
|
{
|
||||||
|
string url = row["webpath"] + "";
|
||||||
|
if (!string.IsNullOrEmpty(url))
|
||||||
|
{
|
||||||
|
urlsBuilder.Append($"{url},");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string urls = urlsBuilder.ToString().TrimEnd(',');
|
||||||
|
string idvalue = rows[0].Table.Columns.Contains("keyvalue") ? rows[0]["keyvalue"] + "" : "";
|
||||||
|
string fileDownTitle = rows[0].Table.Columns.Contains("fileTitle") ? rows[0]["fileTitle"] + "" : "";
|
||||||
|
if (!string.IsNullOrWhiteSpace(urls))
|
||||||
|
{
|
||||||
|
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 jObject = JsonConvert.DeserializeObject<JObject>(loginResult);
|
||||||
|
if (jObject.ContainsKey("success"))
|
||||||
|
{
|
||||||
|
if ((jObject["success"] + "").Equals("True"))
|
||||||
|
{
|
||||||
|
if (jObject.ContainsKey("token"))
|
||||||
|
{
|
||||||
|
token = jObject["token"] + "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(token))
|
||||||
|
{
|
||||||
|
string downUrl = string.Format("{0}Api/FileUploadApi.ashx", SystemInfo.Instance.OAUrl);
|
||||||
|
Dictionary<string, string> parmarsDic = new Dictionary<string, string>();
|
||||||
|
parmarsDic.Add("userid", ERPInfo.Instance.UserId);
|
||||||
|
parmarsDic.Add("username", ERPInfo.Instance.UserName);
|
||||||
|
parmarsDic.Add("password", ERPInfo.Instance.InPassWord);
|
||||||
|
parmarsDic.Add("method", "DownLoadFiels");
|
||||||
|
parmarsDic.Add("urls", urls);
|
||||||
|
parmarsDic.Add("moduleid", model.MenuTabName);
|
||||||
|
parmarsDic.Add("idvalue", idvalue);
|
||||||
|
Dictionary<string, string> headerDic = new Dictionary<string, string>();
|
||||||
|
headerDic.Add("Authorization", $"Bearer {token}");
|
||||||
|
HttpTools.setting("application/x-www-form-urlencoded", null, null);
|
||||||
|
//HttpWebResponse response = HttpTools.Post(downUrl, "", parmarsDic, HttpTools.Method.POST);
|
||||||
|
HttpWebResponse response = HttpTools.Post(downUrl, "", parmarsDic, headerDic, HttpTools.Method.POST);
|
||||||
|
|
||||||
|
string result = new StreamReader(response.GetResponseStream(), Encoding.UTF8).ReadToEnd();
|
||||||
|
if (response != null && !string.IsNullOrEmpty(result))
|
||||||
|
{
|
||||||
|
JObject jsonObject = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(result);
|
||||||
|
string isSuccess = jsonObject["success"] + "";
|
||||||
|
if (isSuccess.Equals("True", StringComparison.CurrentCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
string zipPathUrl = jsonObject["data"] + "";
|
||||||
|
string downLoadUrl = string.Format("{0}{1}", SystemInfo.Instance.OAUrl, zipPathUrl.TrimStart('/'));
|
||||||
|
FrmSelectDownload frmSelectDownload = new FrmSelectDownload();
|
||||||
|
frmSelectDownload.URL = downLoadUrl;
|
||||||
|
|
||||||
|
frmSelectDownload.ModelId = model.MenuTabName;
|
||||||
|
frmSelectDownload.MenuName = model.MenuName;
|
||||||
|
frmSelectDownload.MenuId = model.Id + "";
|
||||||
|
|
||||||
|
string[] szName = zipPathUrl.Split('/');
|
||||||
|
string fileTitle = !string.IsNullOrWhiteSpace(fileDownTitle) ? fileDownTitle : szName[szName.Length - 1];
|
||||||
|
frmSelectDownload.FileName = fileTitle;
|
||||||
|
//frmSelectDownload.TopMost = true;
|
||||||
|
frmSelectDownload.Show();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageUtil.Show(jsonObject["msg"] + "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
response.GetResponseStream().Close();
|
||||||
|
response.Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageUtil.Show($"登录验证失败\r\n{loginResult}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageUtil.Show("操作失败,未查询到数据");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SqlException ex)
|
||||||
|
{
|
||||||
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||||
|
MessageUtil.Show(Message, ex.Message);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageUtil.Show(ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageUtil.Show("没有需要下载的数据");
|
||||||
|
}
|
||||||
|
return reaultValue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool reaultValue = true;
|
|
||||||
List<string> procParams = ReplaceHelper.GetParamFields(procName);
|
List<string> procParams = ReplaceHelper.GetParamFields(procName);
|
||||||
if (procParams.Count == 0)
|
if (procParams.Count == 0)
|
||||||
{
|
{
|
||||||
@@ -1335,6 +1446,8 @@ namespace Lskj.Control.Model
|
|||||||
else if (model.ActionType == 5)//批量下载
|
else if (model.ActionType == 5)//批量下载
|
||||||
{
|
{
|
||||||
string modelAction = model.Action;
|
string modelAction = model.Action;
|
||||||
|
if (!string.IsNullOrEmpty(modelAction))
|
||||||
|
{
|
||||||
List<string> procParams = ReplaceHelper.GetParamFields(modelAction);
|
List<string> procParams = ReplaceHelper.GetParamFields(modelAction);
|
||||||
string[] paramStr = procParams[0].Replace("{", "").Replace("}", "").Split(',');
|
string[] paramStr = procParams[0].Replace("{", "").Replace("}", "").Split(',');
|
||||||
if (paramStr.Contains("@keyvalue"))
|
if (paramStr.Contains("@keyvalue"))
|
||||||
@@ -1348,6 +1461,7 @@ namespace Lskj.Control.Model
|
|||||||
paramList[index] = ReplaceHelper.ReplaceRowParamSplit(rows, fieldValue, "", "", ';');
|
paramList[index] = ReplaceHelper.ReplaceRowParamSplit(rows, fieldValue, "", "", ';');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
isOnlyOne = true;
|
isOnlyOne = true;
|
||||||
}
|
}
|
||||||
return isOnlyOne;
|
return isOnlyOne;
|
||||||
|
|||||||
Reference in New Issue
Block a user