您的位置:首页 > 大数据

C#.NET 大型通用信息化系统集成快速开发平台 4.1 版本 - 大数据分页功能改进、数据权限改进

2014-05-09 09:17 1266 查看
代码生成器大数据分页



下面参考代码是简易的数据权限的实现,大多情况下下面的数据权限的功能可以满足很多企业的需要了

#region public DataTable GetDataTableByPage(BaseUserInfo userInfo, out int recordCount, int pageIndex = 0, int pageSize = 20, string sortExpression = null, string sortDire = null) 分页查询
/// <summary>
/// 分页查询
/// </summary>
/// <param name="userInfo">用户</param>
/// <param name="recordCount">记录数</param>
/// <param name="pageIndex">当前页</param>
/// <param name="pageSize">每页显示记录条数</param>
/// <param name="sortExpression">排序字段</param>
/// <param name="sortDire">排序方向</param>
/// <returns>数据表</returns>
public DataTable GetDataTableByPage(BaseUserInfo userInfo, out int recordCount, int pageIndex = 0, int pageSize = 20, string sortExpression = null, string sortDire = null)
{
// 写入调试信息
#if (DEBUG)
int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
#endif

// 加強安全验证防止未登录用户调用
#if (!DEBUG)
LogOnService.UserIsLogOn(userInfo);
#endif

var dt = new DataTable(LanNiaoKeJiEntity.TableName);

using (IDbHelper ucDbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
{
try
{
ucDbHelper.Open(UserCenterDbConnection);
BaseLogManager.Instance.Add(userInfo, this.serviceName, "取得列表", MethodBase.GetCurrentMethod());

using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.BusinessDbType))
{
try
{
dbHelper.Open(BusinessDbConnection);
// 取得列表
LanNiaoKeJiManager manager = new LanNiaoKeJiManager(dbHelper, userInfo);
string order = sortExpression + " " + sortDire;
string whereConditional = string.Empty;
List<IDbDataParameter> dbParameters = new List<IDbDataParameter>();
BaseUserManager userManager = new BaseUserManager();
if (userManager.IsInRoleByCode(userInfo, "User"))
{
// 普通用户,只能看自己的
whereConditional = BaseBusinessLogic.FieldUserId + "=" + dbHelper.GetParameter(BaseBusinessLogic.FieldUserId);
dbParameters.Add(dbHelper.MakeParameter(BaseBusinessLogic.FieldUserId, userInfo.Id));
}
else if (userManager.IsInRoleByCode(userInfo, "DepartmentManager"))
{
// 部门主管,只能看自己部门的
whereConditional = BaseBusinessLogic.FieldDepartmentId + "=" + dbHelper.GetParameter(BaseBusinessLogic.FieldDepartmentId);
dbParameters.Add(dbHelper.MakeParameter(BaseBusinessLogic.FieldDepartmentId, userInfo.DepartmentId));
}
else if (userManager.IsInRoleByCode(userInfo, "CompanyManager"))
{
// 公司主管,只能看自己公司的
whereConditional = BaseBusinessLogic.FieldCompanyId + "=" + dbHelper.GetParameter(BaseBusinessLogic.FieldCompanyId);
dbParameters.Add(dbHelper.MakeParameter(BaseBusinessLogic.FieldCompanyId, userInfo.CompanyId));
}
else if (userManager.IsInRoleByCode(userInfo, "Manager"))
{
// 管理者,可以看所有的,不限制条件
}
dt.TableName = LanNiaoKeJiEntity.TableName;
}
catch (Exception ex)
{
BaseExceptionManager.LogException(ucDbHelper, userInfo, ex);
throw;
}
finally
{
dbHelper.Close();
}
}
}
catch (Exception ex)
{
BaseExceptionManager.LogException(ucDbHelper, userInfo, ex);
throw;
}
finally
{
ucDbHelper.Close();
}
}

// 写入调试信息
#if (DEBUG)
BaseBusinessLogic.EndDebug(userInfo, MethodBase.GetCurrentMethod(), milliStart);
#endif

return dt;
}
#endregion
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐