天津投入产出系统后端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

303 lines
9.5 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMFrameWork.Data;
using QMAPP.Entity.QueryTL;
using QMAPP.DAL.QueryTL;
namespace QMAPP.BLL.QueryTL
{
/// <summary>
/// 查询模板管理
/// 创建者:李炳海
/// 创建日期:2014.8.13
/// </summary>
public class QueryTemplateBLL:BaseBLL
{
#region 获取查询条件设置
private List<TemplateWhere> GetWhereSets(List<TemplateWhere> wheres, string whereDisplays)
{
List<string> selectWheres = new List<string>();
if (string.IsNullOrEmpty(whereDisplays) == false)
{
selectWheres = whereDisplays.Split(",".ToCharArray()).ToList();
}
foreach (TemplateWhere where in wheres)
{
if (selectWheres.IndexOf(where.QUERYCOLUMN) >= 0)
{
where.ISDISPLAY = "1";
}
else
{
where.ISDISPLAY = "0";
}
}
return wheres;
}
#endregion
#region 获取列显示设置
private List<TemplateColumn> GetColumnSets(List<TemplateColumn> columns, Dictionary<string, string> setInfos)
{
List<TemplateColumn> list = new List<TemplateColumn>();
List<string> seqs = setInfos["columns"].ToString().Split(",".ToCharArray()).ToList();
List<string> displays = setInfos["columnDisplays"].ToString().Split(",".ToCharArray()).ToList();
List<string> aligns = setInfos["columnAligns"].ToString().Split(",".ToCharArray()).ToList();
List<string> widths = setInfos["columnWidths"].ToString().Split(",".ToCharArray()).ToList();
List<string> frozens = setInfos["columnFrozens"].ToString().Split(",".ToCharArray()).ToList();
for (int i = 0; i < seqs.Count; i++)
{
TemplateColumn col = new TemplateColumn();
col.COLUMNNAME = seqs[i];
col.SEQ = i + 1;
if (displays.IndexOf(col.COLUMNNAME) < 0)
col.ISHIDDEN = "1";
else
col.ISHIDDEN = "0";
col.WIDTH = int.Parse(widths[i]);
col.DATAALIGN = aligns[i];
if (frozens.IndexOf(col.COLUMNNAME) >= 0)
col.ISFROZEN = "1";
else
col.ISFROZEN = "0";
list.Add(col);
}
return list;
}
#endregion
#region 获取排序设置
private List<TemplateSort> GetSortSets(string selectedSorts)
{
List<TemplateSort> list = QMFrameWork.Common.Serialization.JsonConvertHelper.GetDeserialize<List<TemplateSort>>(selectedSorts);
foreach (TemplateSort sort in list)
{
sort.IFASC = sort.SORTMODE == "ASC" ? "1" : "0";
}
return list;
}
#endregion
#region 新增模板信息
/// <summary>
/// 新增模板信息
/// </summary>
/// <param name="templateInfo">模板信息</param>
public void Insert(QueryTemplate templateInfo,Dictionary<string, string> setInfos)
{
templateInfo.TEMPLATEID = Guid.NewGuid().ToString();
//获取查询条件设置
templateInfo.Wheres = this.GetWhereSets(templateInfo.Wheres, setInfos["whereDisplays"]);
//获取列设置
templateInfo.Columns = this.GetColumnSets(templateInfo.Columns, setInfos);
//获取排序设置
templateInfo.Sorts = this.GetSortSets(setInfos["sortColumns"]);
if (templateInfo.Wheres != null)
{
foreach (TemplateWhere where in templateInfo.Wheres)
{
where.ID = Guid.NewGuid().ToString();
where.TEMPLATEID = templateInfo.TEMPLATEID;
}
}
if (templateInfo.Columns != null)
{
foreach (TemplateColumn column in templateInfo.Columns)
{
column.ID = Guid.NewGuid().ToString();
column.TEMPLATEID = templateInfo.TEMPLATEID;
}
}
if (templateInfo.Sorts != null)
{
foreach (TemplateSort sort in templateInfo.Sorts)
{
sort.ID = Guid.NewGuid().ToString();
sort.TEMPLATEID = templateInfo.TEMPLATEID;
}
}
new QueryTemplateDAL().Insert(templateInfo);
}
#endregion
#region 更新模板信息
/// <summary>
/// 更新模板信息
/// </summary>
/// <param name="templateInfo">模板信息</param>
public void Update(QueryTemplate templateInfo, Dictionary<string, string> setInfos)
{
templateInfo.UPDATEUSER = this.LoginUser.UserID;
//获取查询条件设置
templateInfo.Wheres = this.GetWhereSets(templateInfo.Wheres, setInfos["whereDisplays"]);
//获取列设置
templateInfo.Columns = this.GetColumnSets(templateInfo.Columns, setInfos);
//获取排序设置
templateInfo.Sorts = this.GetSortSets(setInfos["sortColumns"]);
if (templateInfo.Wheres != null)
{
foreach (TemplateWhere where in templateInfo.Wheres)
{
where.ID = Guid.NewGuid().ToString();
where.TEMPLATEID = templateInfo.TEMPLATEID;
}
}
if (templateInfo.Columns != null)
{
foreach (TemplateColumn column in templateInfo.Columns)
{
column.ID = Guid.NewGuid().ToString();
column.TEMPLATEID = templateInfo.TEMPLATEID;
}
}
if (templateInfo.Sorts != null)
{
foreach (TemplateSort sort in templateInfo.Sorts)
{
sort.ID = Guid.NewGuid().ToString();
sort.TEMPLATEID = templateInfo.TEMPLATEID;
}
}
new QueryTemplateDAL().Update(templateInfo);
}
#endregion
#region 删除模板信息
/// <summary>
/// 删除模板信息
/// </summary>
/// <param name="templateInfo">模板信息</param>
public void Delete(List<string> list)
{
new QueryTemplateDAL().Delete(list);
}
#endregion
#region 获取模板信息
/// <summary>
/// 获取模板信息
/// </summary>
/// <param name="templateInfo">获取条件</param>
/// <returns>模板信息</returns>
public QueryTemplate Get(QueryTemplate templateInfo)
{
return new QueryTemplateDAL().Get(templateInfo);
}
#endregion
#region 获取模板列表
/// <summary>
/// 获取模板列表
/// </summary>
/// <param name="condition">查询条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataPage GetList(QueryTemplate condition, DataPage page)
{
page = new QueryTemplateDAL().GetList(condition, page);
foreach (QueryTemplate template in (List<QueryTemplate>)page.Result)
{
template.ISPUBLISH = template.ISPUBLISH == "1" ? "是" : "否";
}
return page;
}
#endregion
#region 设置查询模板默认模板
/// <summary>
/// 设置查询模板默认模板
/// </summary>
/// <param name="userID">用户主键</param>
/// <param name="queryProgram">查询模块</param>
/// <param name="templateID">模板主键</param>
public void SetProgramTemplate(ProgramTemplate pt)
{
pt.ID = Guid.NewGuid().ToString();
pt.CREATEUSER = this.LoginUser.UserID;
new QueryTemplateDAL().SetProgramTemplate(pt);
}
#endregion
#region 取消应用查询模板
/// <summary>
/// 取消应用查询模板
/// </summary>
/// <param name="pt">需要取消的模板信息</param>
public void RemoveQueryTemplate(ProgramTemplate pt)
{
pt.CREATEUSER = this.LoginUser.UserID;
new QueryTemplateDAL().RemoveQueryTemplate(pt);
}
#endregion
#region 获取查询模板默认模板
/// <summary>
/// 获取查询模板默认模板基本信息
/// </summary>
/// <param name="queryProgram">查询模板</param>
/// <returns>模板基本信息</returns>
public QueryTemplate GetProgramTemplateBase(string queryProgram)
{
return new QueryTemplateDAL().GetProgramTemplateBase(this.LoginUser.UserID, queryProgram);
}
/// <summary>
/// 获取查询模板默认模板
/// </summary>
/// <param name="queryProgram">查询模块</param>
/// <returns>默认模板</returns>
public string GetProgramTemplate(string queryProgram)
{
if (this.LoginUser == null)
return "";
return new QueryTemplateDAL().GetProgramTemplate(this.LoginUser.UserID, queryProgram);
}
#endregion
}
}