SVN r650
SVN-Revision: r650
This commit is contained in:
@@ -28,6 +28,7 @@ namespace Lskj.Control.Model
|
||||
private bool _autoRefresh;
|
||||
private bool _rightVisible;
|
||||
private bool _isSearch;
|
||||
private bool _isDownloadRelated;
|
||||
private string _detailName;
|
||||
private string _detailSql;
|
||||
private string _formKey;
|
||||
@@ -203,6 +204,10 @@ namespace Lskj.Control.Model
|
||||
/// </summary>
|
||||
public bool IsMrpDrag { get { return this._isMrpDrag; } }
|
||||
/// <summary>
|
||||
/// 批量关联明细
|
||||
/// </summary>
|
||||
public bool IsDownloadRelated { get { return this._isDownloadRelated; } }
|
||||
/// <summary>
|
||||
/// Mrp拖拽标记
|
||||
/// </summary>
|
||||
public string MrpDragTag { get { return this._mrpDragTag; } }
|
||||
@@ -296,6 +301,7 @@ namespace Lskj.Control.Model
|
||||
this._unionValue = item.Table.Columns.Contains("unionValue") ? (item["unionValue"] + "").Replace("{", "").Replace("}", "") : string.Empty;
|
||||
this._unionParentField = item.Table.Columns.Contains("unionParentField") ? (item["unionParentField"] + "").Replace("{", "").Replace("}", "") : string.Empty;
|
||||
this._columns = gridColumns;
|
||||
this._isDownloadRelated = item.Table.Columns.Contains("IsDownloadRelated") ? "True".Equals(item["IsDownloadRelated"] + "") : false;
|
||||
this._isSearch = isSearch;
|
||||
this._isUnioDetail = item.Table.Columns.Contains("IsUnioDetail") ? "1".Equals(item["IsUnioDetail"] + "") : false;
|
||||
this.AutoMultiHeader = item.Table.Columns.Contains("AutoMultiHeader") && !string.IsNullOrEmpty(item["AutoMultiHeader"] + "") ? Convert.ToInt32(item["AutoMultiHeader"] + "") : 0;
|
||||
|
||||
@@ -588,10 +588,11 @@ namespace Lskj.Control.Model
|
||||
string fileTitle = szName[szName.Length - 1];
|
||||
//设置文件存放路径
|
||||
string DownloadFileDirectory = string.Format("{0}\\{1}", Application.StartupPath, "RightDownloadFile");
|
||||
if (!Directory.Exists(DownloadFileDirectory))
|
||||
if (Directory.Exists(DownloadFileDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(DownloadFileDirectory);
|
||||
Directory.Delete(DownloadFileDirectory, true);
|
||||
}
|
||||
Directory.CreateDirectory(DownloadFileDirectory);
|
||||
DownloadFileDirectory = string.Format("{0}\\{1}", DownloadFileDirectory, fileTitle);
|
||||
|
||||
FrmDownload frm = new FrmDownload(url, fileTitle, DownloadFileDirectory, true, false);
|
||||
@@ -1113,116 +1114,148 @@ namespace Lskj.Control.Model
|
||||
string procName = model.Action;
|
||||
if (string.IsNullOrWhiteSpace(procName))
|
||||
{
|
||||
if (rows.Length > 0 && rows[0].Table.Columns.Contains("webpath"))
|
||||
if (rows.Length > 0 && !string.IsNullOrWhiteSpace(Model.ModuleCode))
|
||||
{
|
||||
StringBuilder urlsBuilder = new StringBuilder();
|
||||
foreach (DataRow row in rows)
|
||||
int filequency = 0;
|
||||
bool isOpenvisble = rows.Count() > 0;
|
||||
string parmaryKey = BaseImpl.GetBasePrimaryKey(this.Model.ModuleCode);//获取主键
|
||||
//string detailparmaryKey = parmaryKey;
|
||||
List <GridDetailModel> details = GetDetails(Model.ModuleCode);//捕获所有明细 // 2. 筛选出 “关联下载” 的明细
|
||||
List<GridDetailModel> downloadRelated = details
|
||||
.Where(d => d.IsDownloadRelated) // 只保留 IsDownloadRelated 为 true 的项
|
||||
.ToList();
|
||||
if (downloadRelated.Count > 0)
|
||||
{
|
||||
string url = row["webpath"] + "";
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
foreach (DataRow dataRow in rows)
|
||||
{
|
||||
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))
|
||||
StringBuilder urlsBuilder = new StringBuilder();
|
||||
string filenameheader = dataRow[parmaryKey] + "";//头部文件数据
|
||||
foreach (GridDetailModel gridDetailModel in downloadRelated)
|
||||
{
|
||||
JObject jObject = JsonConvert.DeserializeObject<JObject>(loginResult);
|
||||
if (jObject.ContainsKey("success"))
|
||||
//detailparmaryKey = BaseImpl.GetBasePrimaryKey(gridDetailModel.UnionModule);//获取主键
|
||||
string searchSql = this.GetSearchSql(gridDetailModel, dataRow, parmaryKey);
|
||||
DataTable dataTable = SqlHelper.ExecuteDataTable(searchSql);
|
||||
if (dataTable.Rows.Count > 0 && dataTable.Columns.Contains("webpath"))
|
||||
{
|
||||
if ((jObject["success"] + "").Equals("True"))
|
||||
foreach (DataRow row in dataTable.Rows)
|
||||
{
|
||||
if (jObject.ContainsKey("token"))
|
||||
|
||||
string url = row["webpath"] + "";
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
token = jObject["token"] + "";
|
||||
urlsBuilder.Append($"{url},");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(token))
|
||||
try
|
||||
{
|
||||
string downUrl = string.Format("{0}Api/FileUploadApi.ashx", SystemInfo.Instance.OAUrl);
|
||||
Dictionary<string, string> parmarsDic = new Dictionary<string, string>();
|
||||
parmarsDic.Add("userid", HttpUtility.UrlEncode(ERPInfo.Instance.UserId));
|
||||
parmarsDic.Add("username", HttpUtility.UrlEncode(ERPInfo.Instance.UserName));
|
||||
parmarsDic.Add("password", HttpUtility.UrlEncode(ERPInfo.Instance.InPassWord));
|
||||
parmarsDic.Add("method", HttpUtility.UrlEncode("DownLoadFiels"));
|
||||
parmarsDic.Add("urls", HttpUtility.UrlEncode(urls));
|
||||
parmarsDic.Add("moduleid", HttpUtility.UrlEncode(model.MenuTabName));
|
||||
parmarsDic.Add("idvalue", HttpUtility.UrlEncode(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))
|
||||
string urls = urlsBuilder.ToString().TrimEnd(',');
|
||||
string idvalue = parmaryKey;
|
||||
//string fileDownTitle = rows[0].Table.Columns.Contains("fileTitle") ? rows[0]["fileTitle"] + "" : "";
|
||||
if (!string.IsNullOrWhiteSpace(urls))
|
||||
{
|
||||
JObject jsonObject = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(result);
|
||||
string isSuccess = jsonObject["success"] + "";
|
||||
if (isSuccess.Equals("True", StringComparison.CurrentCultureIgnoreCase))
|
||||
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))
|
||||
{
|
||||
string zipPathUrl = jsonObject["data"] + "";
|
||||
string downLoadUrl = string.Format("{0}{1}", SystemInfo.Instance.OAUrl, zipPathUrl.TrimStart('/'));
|
||||
FrmSelectDownload frmSelectDownload = new FrmSelectDownload();
|
||||
frmSelectDownload.URL = downLoadUrl;
|
||||
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", HttpUtility.UrlEncode(ERPInfo.Instance.UserId));
|
||||
parmarsDic.Add("username", HttpUtility.UrlEncode(ERPInfo.Instance.UserName));
|
||||
parmarsDic.Add("password", HttpUtility.UrlEncode(ERPInfo.Instance.InPassWord));
|
||||
parmarsDic.Add("method", HttpUtility.UrlEncode("DownLoadFiels"));
|
||||
parmarsDic.Add("urls", HttpUtility.UrlEncode(urls));
|
||||
parmarsDic.Add("moduleid", HttpUtility.UrlEncode(model.MenuTabName));
|
||||
parmarsDic.Add("idvalue", HttpUtility.UrlEncode(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);
|
||||
|
||||
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();
|
||||
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();
|
||||
if (filequency > 0) frmSelectDownload.isMultiple = true;
|
||||
frmSelectDownload.isprompt = filequency + 1 == rows.Count();
|
||||
frmSelectDownload.URL = downLoadUrl;
|
||||
frmSelectDownload.isOpenvisble = isOpenvisble;
|
||||
frmSelectDownload.ModelId = model.MenuTabName;
|
||||
frmSelectDownload.MenuName = model.MenuName;
|
||||
frmSelectDownload.MenuId = model.Id + "";
|
||||
string[] szName = zipPathUrl.Split('/');
|
||||
string fileTitle = !string.IsNullOrWhiteSpace(filenameheader) ? filenameheader + ".zip" : szName[szName.Length - 1];
|
||||
frmSelectDownload.FileName = fileTitle;
|
||||
//frmSelectDownload.TopMost = true;
|
||||
frmSelectDownload.ShowDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageUtil.Show(jsonObject["msg"] + "");
|
||||
}
|
||||
}
|
||||
response.GetResponseStream().Close();
|
||||
response.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageUtil.Show(jsonObject["msg"] + "");
|
||||
MessageUtil.Show($"登录验证失败\r\n{loginResult}");
|
||||
}
|
||||
}
|
||||
response.GetResponseStream().Close();
|
||||
response.Close();
|
||||
else
|
||||
{
|
||||
MessageUtil.Show("操作失败,未查询到数据");
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (SqlException ex)
|
||||
{
|
||||
MessageUtil.Show($"登录验证失败\r\n{loginResult}");
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message, ex.Message);
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageUtil.Show(ex.Message);
|
||||
}
|
||||
filequency++;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageUtil.Show("操作失败,未查询到数据");
|
||||
}
|
||||
|
||||
}
|
||||
catch (SqlException ex)
|
||||
else
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message, ex.Message);
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageUtil.Show(ex.Message);
|
||||
MessageUtil.Show("未配置关联明细数据");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
|
||||
MessageUtil.Show("没有需要下载的数据");
|
||||
}
|
||||
return reaultValue;
|
||||
@@ -1375,6 +1408,59 @@ namespace Lskj.Control.Model
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:获取查询条件</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-11-22 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="model">The model.</param>
|
||||
/// <param name="rowItem">The row item.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
protected string GetSearchSql(GridDetailModel model, DataRow rowItem,string ParmaryKey)
|
||||
{
|
||||
string fieldName = !string.IsNullOrEmpty(model.UnionParentField) && rowItem.Table.Columns.Contains(model.UnionParentField) ? model.UnionParentField : ParmaryKey;
|
||||
string sqlValue = model.IsReadOnly || model.IsChart ? model.DetailSql : model.SystemModel.MenuSql;
|
||||
|
||||
|
||||
sqlValue = ReplaceHelper.ReplaceRowParam(rowItem, sqlValue);
|
||||
|
||||
if (ReplaceHelper.IsSelect(sqlValue) && !string.IsNullOrEmpty(model.UnionValue))
|
||||
{
|
||||
string Conditions = string.Empty;
|
||||
sqlValue = ReplaceHelper.ReplaceWhereCond(sqlValue) + string.Format(" and {0}='{1}'", model.UnionValue, Conditions);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(model.UnionCond))
|
||||
{
|
||||
string UnionCond = ReplaceHelper.ReplaceRowParam(rowItem, model.UnionCond);
|
||||
sqlValue += UnionCond;
|
||||
}
|
||||
return sqlValue;
|
||||
}
|
||||
/// <summary>
|
||||
/// <para>说明:右键捕获明细</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-11-21 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <returns>List<GridDetailModel>.</returns>
|
||||
private List<GridDetailModel> GetDetails(string ModuleCode)
|
||||
{
|
||||
List<GridDetailModel> details = new List<GridDetailModel>();//表格明细对象的集合
|
||||
DataTable table = BaseModuleImpl.GetBaseDetailPages(ModuleCode);// 根据传入的模块编号获得基础档案底部标签的数据
|
||||
foreach (DataRow item in table.Rows)
|
||||
{
|
||||
DataTable gridColumns = ReportImpl.GetReportDetailColumns(ModuleCode, item["id"] + "");//获取报表明细列
|
||||
details.Add(new GridDetailModel(item, gridColumns, GridCustomColumnStruct.BaseDetailGridView));
|
||||
}
|
||||
return details;
|
||||
}
|
||||
/// <summary>
|
||||
/// 调用主程序右键直接添加到page上页面自动关闭后执行刷新
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
|
||||
Reference in New Issue
Block a user