using System; using System.Data; using DSWeb.Models; using DSWeb.EntityDA; using System.Collections; using System.Collections.Generic; namespace DSWeb.Authority { public class AuthorityManage { private UserEntity _userEntity; private RoleEntity _roleEntity; private CompanyEntity _companyEntity; private CRMClientEntity _crmClientEntity; public AuthorityManage() { } public AuthorityManage(AuthorityType type,object obj) { switch (type) { case AuthorityType.USER: _userEntity = (UserEntity)obj; break; case AuthorityType.ROLE: _roleEntity = (RoleEntity)obj; break; case AuthorityType.DEPARTMENT: _companyEntity = (CompanyEntity)obj; break; case AuthorityType.CRMCLIENT: _crmClientEntity = (CRMClientEntity)obj; break; } } #region 获得用户行为信息 /// /// 获得用户行为信息 /// /// public IList GetUserAction() { IList userActionEntities = new List(); //先判断是否已经获取用户信息 if (_userEntity != null) { //根据用户GID获取用户相关的行为信息 UserActionDA userActionDA = new UserActionDA(); userActionEntities = userActionDA.GetUserActionByUserID(_userEntity.Gid); //查看是否此用户相关的行为信息 if (userActionEntities.Count > 0) { //根据用户相关的行为信息获取行为表信息 ActionDA actionDA = new ActionDA(); ModuleDA moduleDA = new ModuleDA(); foreach (UserActionEntity userActionEntity in userActionEntities) { ActionEntity actionEntity = new ActionEntity(); actionEntity = actionDA.GetActionByGID(userActionEntity.ActionID); //获取模块信息 ModuleEntity moduleEntity = new ModuleEntity(); moduleEntity = moduleDA.GetModuleByID(actionEntity.ModuleID); actionEntity.ModuleEntity = moduleEntity; //将行为表信息赋值到UserActionEntity实体类中 userActionEntity.ActionEntity = actionEntity; } } } return userActionEntities; } #endregion #region 获得往来单位行为信息 /// /// 获得往来单位行为信息 /// /// public IList GetCrmClientAction() { IList userActionEntities = new List(); //先判断是否已经获取用户信息 if (_crmClientEntity != null) { //根据用户GID获取用户相关的行为信息 UserActionDA userActionDA = new UserActionDA(); userActionEntities = userActionDA.GetUserActionByUserID(_crmClientEntity.GID); //查看是否此用户相关的行为信息 if (userActionEntities.Count > 0) { //根据用户相关的行为信息获取行为表信息 ActionDA actionDA = new ActionDA(); ModuleDA moduleDA = new ModuleDA(); foreach (UserActionEntity userActionEntity in userActionEntities) { ActionEntity actionEntity = new ActionEntity(); actionEntity = actionDA.GetActionByGID(userActionEntity.ActionID); //获取模块信息 ModuleEntity moduleEntity = new ModuleEntity(); moduleEntity = moduleDA.GetModuleByID(actionEntity.ModuleID); actionEntity.ModuleEntity = moduleEntity; //将行为表信息赋值到UserActionEntity实体类中 userActionEntity.ActionEntity = actionEntity; } } } return userActionEntities; } #endregion public enum AuthorityType { USER = 1, ROLE = 2, DEPARTMENT = 3, CRMCLIENT = 4 } } }