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.
218 lines
7.7 KiB
218 lines
7.7 KiB
4 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Data;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using QMAPP.Entity;
|
||
|
using QMFrameWork.Data;
|
||
|
using QMFrameWork.Log;
|
||
|
|
||
|
namespace QMAPP.DAL.FuntionDescriptionDAL
|
||
|
{
|
||
|
public class FuntionDescriptionDAL : BaseDAL
|
||
|
{
|
||
|
#region 获取功能模块下拉框
|
||
|
/// <summary>
|
||
|
/// 获取信息
|
||
|
/// </summary>
|
||
|
/// <param name="">条件</param>
|
||
|
/// <returns>信息</returns>
|
||
|
public List<FuntionDescription> GetModelNameCombox()
|
||
|
{
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
try
|
||
|
{
|
||
|
string sql = "SELECT MODELNAME FROM T_QM_FUNTIONDESCRIPTION group by MODELNAME";
|
||
|
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
return session.GetList<FuntionDescription>(sql, parameters.ToArray()).ToList();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogManager.LogHelper.Error(new LogInfo()
|
||
|
{
|
||
|
ErrorInfo = ex,
|
||
|
Tag = ex.StackTrace,
|
||
|
Info = "热点查询-获取功能模块下拉框"
|
||
|
});
|
||
|
throw;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 获取菜单项下拉框
|
||
|
/// <summary>
|
||
|
/// 获取信息
|
||
|
/// </summary>
|
||
|
/// <param name="">条件</param>
|
||
|
/// <returns>信息</returns>
|
||
|
public List<FuntionDescription> GetMenuNameCombox(string ModelName)
|
||
|
{
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
try
|
||
|
{
|
||
|
string sql = "SELECT MENUNAME FROM T_QM_FUNTIONDESCRIPTION where MODELNAME='" + ModelName + "' group by MENUNAME";
|
||
|
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
return session.GetList<FuntionDescription>(sql, parameters.ToArray()).ToList();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogManager.LogHelper.Error(new LogInfo()
|
||
|
{
|
||
|
ErrorInfo = ex,
|
||
|
Tag = ex.StackTrace,
|
||
|
Info = "热点查询-获取菜单项下拉框"
|
||
|
});
|
||
|
throw;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 获取列表
|
||
|
/// <summary>
|
||
|
/// 获取列表
|
||
|
/// </summary>
|
||
|
/// <param name="condition">条件</param>
|
||
|
/// <param name="page">数据页</param>
|
||
|
/// <returns>数据页</returns>
|
||
|
public DataPage GetCountList(FuntionDescription condition, DataPage page)
|
||
|
{
|
||
|
string sql = null;
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
try
|
||
|
{
|
||
|
sql = this.GetQuerySql(condition, ref parameters);
|
||
|
//分页关键字段及排序
|
||
|
page.KeyName = "MODELNAME";
|
||
|
page.SortExpression = "MODELNAME";
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
page = session.GetDataPage<FuntionDescription>(sql, parameters.ToArray(), page);
|
||
|
}
|
||
|
return page;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogManager.LogHelper.Error(new LogInfo()
|
||
|
{
|
||
|
ErrorInfo = ex,
|
||
|
Tag = ex.StackTrace,
|
||
|
Info = "热点查询-获取列表"
|
||
|
});
|
||
|
throw;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 获取查询语句
|
||
|
/// <summary>
|
||
|
/// 获取查询语句
|
||
|
/// </summary>
|
||
|
/// <param name="user">查询条件</param>
|
||
|
/// <param name="parameters">参数</param>
|
||
|
/// <returns>查询语句</returns>
|
||
|
private string GetQuerySql(FuntionDescription condition, ref List<DataParameter> parameters)
|
||
|
{
|
||
|
StringBuilder sqlBuilder = new StringBuilder();
|
||
|
StringBuilder whereBuilder = new StringBuilder();
|
||
|
try
|
||
|
{
|
||
|
//构成查询语句
|
||
|
sqlBuilder.AppendLine(" SELECT CREATEUSER,MODELNAME,MENUNAME,FUNCTIONNAME,count(1) as useCount FROM T_QM_FUNCTIONRECORDER t1,T_QM_FUNTIONDESCRIPTION t2 ");
|
||
|
|
||
|
whereBuilder.Append(" where t1.CONTROLLER=t2.CONTROLLER and t1.action=t2.action");
|
||
|
//查询条件
|
||
|
if (string.IsNullOrEmpty(condition.CREATEUSER) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND CREATEUSER =@CREATEUSER");
|
||
|
parameters.Add(new DataParameter { ParameterName = "CREATEUSER", DataType = DbType.String, Value = condition.CREATEUSER });
|
||
|
}
|
||
|
|
||
|
if (string.IsNullOrEmpty(condition.MODELNAME) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND MODELNAME =@MODELNAME");
|
||
|
parameters.Add(new DataParameter { ParameterName = "MODELNAME", DataType = DbType.String, Value = condition.MODELNAME });
|
||
|
}
|
||
|
|
||
|
if (string.IsNullOrEmpty(condition.MENUNAME.Trim()) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND MENUNAME =@MENUNAME");
|
||
|
parameters.Add(new DataParameter { ParameterName = "MENUNAME", DataType = DbType.String, Value = condition.MENUNAME });
|
||
|
}
|
||
|
if (string.IsNullOrEmpty(condition.STARTCREATEDATE) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND CREATEDATE >= @STARTCREATEDATE");
|
||
|
parameters.Add(new DataParameter { ParameterName = "STARTCREATEDATE", DataType = DbType.String, Value = condition.STARTCREATEDATE });
|
||
|
}
|
||
|
if (string.IsNullOrEmpty(condition.ENDCREATEDATE) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND CREATEDATE <= @ENDCREATEDATE");
|
||
|
parameters.Add(new DataParameter { ParameterName = "ENDCREATEDATE", DataType = DbType.String, Value = condition.ENDCREATEDATE });
|
||
|
}
|
||
|
|
||
|
|
||
|
if (whereBuilder.Length > 0)
|
||
|
{
|
||
|
//sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
|
||
|
sqlBuilder.Append(whereBuilder);
|
||
|
}
|
||
|
|
||
|
sqlBuilder.AppendLine(" group by CREATEUSER,MODELNAME,MENUNAME,FUNCTIONNAME ");
|
||
|
|
||
|
return sqlBuilder.ToString();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 获取导出的数据
|
||
|
/// <summary>
|
||
|
/// 获取导出的数据
|
||
|
/// </summary>
|
||
|
/// <param name="user">查询条件</param>
|
||
|
/// <returns>数据</returns>
|
||
|
public DataTable GetExportData(FuntionDescription model)
|
||
|
{
|
||
|
DataTable dt = null;
|
||
|
string sql = null;
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
try
|
||
|
{
|
||
|
//构成查询语句
|
||
|
sql = this.GetQuerySql(model, ref parameters);
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
dt = session.GetTable(sql, parameters.ToArray());
|
||
|
dt.TableName = "FuntionDescriptionExp";
|
||
|
}
|
||
|
return dt;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogManager.LogHelper.Error(new LogInfo()
|
||
|
{
|
||
|
ErrorInfo = ex,
|
||
|
Tag = ex.StackTrace,
|
||
|
Info = "导出获取数据错误!"
|
||
|
});
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|