SVN r650
SVN-Revision: r650
This commit is contained in:
@@ -28,6 +28,7 @@ namespace Lskj.Control.Model
|
|||||||
private bool _autoRefresh;
|
private bool _autoRefresh;
|
||||||
private bool _rightVisible;
|
private bool _rightVisible;
|
||||||
private bool _isSearch;
|
private bool _isSearch;
|
||||||
|
private bool _isDownloadRelated;
|
||||||
private string _detailName;
|
private string _detailName;
|
||||||
private string _detailSql;
|
private string _detailSql;
|
||||||
private string _formKey;
|
private string _formKey;
|
||||||
@@ -203,6 +204,10 @@ namespace Lskj.Control.Model
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsMrpDrag { get { return this._isMrpDrag; } }
|
public bool IsMrpDrag { get { return this._isMrpDrag; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// 批量关联明细
|
||||||
|
/// </summary>
|
||||||
|
public bool IsDownloadRelated { get { return this._isDownloadRelated; } }
|
||||||
|
/// <summary>
|
||||||
/// Mrp拖拽标记
|
/// Mrp拖拽标记
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string MrpDragTag { get { return this._mrpDragTag; } }
|
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._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._unionParentField = item.Table.Columns.Contains("unionParentField") ? (item["unionParentField"] + "").Replace("{", "").Replace("}", "") : string.Empty;
|
||||||
this._columns = gridColumns;
|
this._columns = gridColumns;
|
||||||
|
this._isDownloadRelated = item.Table.Columns.Contains("IsDownloadRelated") ? "True".Equals(item["IsDownloadRelated"] + "") : false;
|
||||||
this._isSearch = isSearch;
|
this._isSearch = isSearch;
|
||||||
this._isUnioDetail = item.Table.Columns.Contains("IsUnioDetail") ? "1".Equals(item["IsUnioDetail"] + "") : false;
|
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;
|
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 fileTitle = szName[szName.Length - 1];
|
||||||
//设置文件存放路径
|
//设置文件存放路径
|
||||||
string DownloadFileDirectory = string.Format("{0}\\{1}", Application.StartupPath, "RightDownloadFile");
|
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);
|
DownloadFileDirectory = string.Format("{0}\\{1}", DownloadFileDirectory, fileTitle);
|
||||||
|
|
||||||
FrmDownload frm = new FrmDownload(url, fileTitle, DownloadFileDirectory, true, false);
|
FrmDownload frm = new FrmDownload(url, fileTitle, DownloadFileDirectory, true, false);
|
||||||
@@ -1113,116 +1114,148 @@ namespace Lskj.Control.Model
|
|||||||
string procName = model.Action;
|
string procName = model.Action;
|
||||||
if (string.IsNullOrWhiteSpace(procName))
|
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();
|
int filequency = 0;
|
||||||
foreach (DataRow row in rows)
|
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"] + "";
|
foreach (DataRow dataRow in rows)
|
||||||
if (!string.IsNullOrEmpty(url))
|
|
||||||
{
|
{
|
||||||
urlsBuilder.Append($"{url},");
|
StringBuilder urlsBuilder = new StringBuilder();
|
||||||
}
|
string filenameheader = dataRow[parmaryKey] + "";//头部文件数据
|
||||||
}
|
foreach (GridDetailModel gridDetailModel in downloadRelated)
|
||||||
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);
|
//detailparmaryKey = BaseImpl.GetBasePrimaryKey(gridDetailModel.UnionModule);//获取主键
|
||||||
if (jObject.ContainsKey("success"))
|
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);
|
string urls = urlsBuilder.ToString().TrimEnd(',');
|
||||||
Dictionary<string, string> parmarsDic = new Dictionary<string, string>();
|
string idvalue = parmaryKey;
|
||||||
parmarsDic.Add("userid", HttpUtility.UrlEncode(ERPInfo.Instance.UserId));
|
//string fileDownTitle = rows[0].Table.Columns.Contains("fileTitle") ? rows[0]["fileTitle"] + "" : "";
|
||||||
parmarsDic.Add("username", HttpUtility.UrlEncode(ERPInfo.Instance.UserName));
|
if (!string.IsNullOrWhiteSpace(urls))
|
||||||
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))
|
|
||||||
{
|
{
|
||||||
JObject jsonObject = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(result);
|
string token = "";
|
||||||
string isSuccess = jsonObject["success"] + "";
|
string loginUrl = $"{SystemInfo.Instance.OAUrl}/Api/SysUserAjaxApi.ashx";
|
||||||
if (isSuccess.Equals("True", StringComparison.CurrentCultureIgnoreCase))
|
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"] + "";
|
JObject jObject = JsonConvert.DeserializeObject<JObject>(loginResult);
|
||||||
string downLoadUrl = string.Format("{0}{1}", SystemInfo.Instance.OAUrl, zipPathUrl.TrimStart('/'));
|
if (jObject.ContainsKey("success"))
|
||||||
FrmSelectDownload frmSelectDownload = new FrmSelectDownload();
|
{
|
||||||
frmSelectDownload.URL = downLoadUrl;
|
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;
|
string result = new StreamReader(response.GetResponseStream(), Encoding.UTF8).ReadToEnd();
|
||||||
frmSelectDownload.MenuName = model.MenuName;
|
if (response != null && !string.IsNullOrEmpty(result))
|
||||||
frmSelectDownload.MenuId = model.Id + "";
|
{
|
||||||
|
JObject jsonObject = (JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(result);
|
||||||
string[] szName = zipPathUrl.Split('/');
|
string isSuccess = jsonObject["success"] + "";
|
||||||
string fileTitle = !string.IsNullOrWhiteSpace(fileDownTitle) ? fileDownTitle : szName[szName.Length - 1];
|
if (isSuccess.Equals("True", StringComparison.CurrentCultureIgnoreCase))
|
||||||
frmSelectDownload.FileName = fileTitle;
|
{
|
||||||
//frmSelectDownload.TopMost = true;
|
string zipPathUrl = jsonObject["data"] + "";
|
||||||
frmSelectDownload.Show();
|
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
|
else
|
||||||
{
|
{
|
||||||
MessageUtil.Show(jsonObject["msg"] + "");
|
MessageUtil.Show($"登录验证失败\r\n{loginResult}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
response.GetResponseStream().Close();
|
else
|
||||||
response.Close();
|
{
|
||||||
|
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("未配置关联明细数据");
|
||||||
MessageUtil.Show(Message, ex.Message);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageUtil.Show(ex.Message);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
MessageUtil.Show("没有需要下载的数据");
|
MessageUtil.Show("没有需要下载的数据");
|
||||||
}
|
}
|
||||||
return reaultValue;
|
return reaultValue;
|
||||||
@@ -1375,6 +1408,59 @@ namespace Lskj.Control.Model
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <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上页面自动关闭后执行刷新
|
/// 调用主程序右键直接添加到page上页面自动关闭后执行刷新
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
|
|||||||
Reference in New Issue
Block a user