/// <summary>
        /// 按某个权限域获取模块列表
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userId">用户主键</param>
        /// <param name="permissionItemCode">权限域编号</param>
        /// <returns>数据表</returns>
        public DataTable GetModuleDTByPermissionScope(BaseUserInfo userInfo, string userId, string permissionItemCode)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
                LogOnService.UserIsLogOn(userInfo);
            #endif

            DataTable dataTable = new DataTable(BaseModuleEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseModuleManager moduleManager = new BaseModuleManager(dbHelper, userInfo);
                    dataTable = moduleManager.GetDataTableByPermission(userId, permissionItemCode);
                    dataTable.TableName = BaseModuleEntity.TableName;
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.PermissionService_GetModuleDTByPermission, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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

            return dataTable;
        }
 public new string GetIdByCode(string permissionItemCode)
 {
     string tableName = BaseOrganizeEntity.TableName;
     if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode))
     {
         tableName = BaseSystemInfo.SystemCode + "PermissionItem";
     }
     BaseModuleManager moduleManager = new BaseModuleManager(dbHelper, UserInfo, tableName);
     return moduleManager.GetIdByCode(permissionItemCode);
     //BasePermissionItemManager permissionItemManager = new BasePermissionItemManager(DbHelper);
     //// 这里应该是若不存在就自动加一个操作权限
     //return permissionItemManager.GetIdByAdd(permissionItemCode);
 }
 /// <summary>
 /// 是否有相应的权限
 /// </summary>
 /// <param name="userId">用户主键</param>
 /// <param name="permissionItemCode">权限编号</param>
 /// <returns>是否有权限</returns>
 public bool IsModuleAuthorized(string userId, string moduleCode, string permissionItemCode)
 {
     BaseModuleManager moduleManager = new BaseModuleManager(DbHelper);
     string moduleId = moduleManager.GetIdByCode(moduleCode);
     BasePermissionItemManager permissionItemManager = new BasePermissionItemManager(DbHelper);
     string permissionItemId = permissionItemManager.GetIdByCode(permissionItemCode);
     // 判断员工权限
     if (this.CheckUserModulePermission(userId, moduleId, permissionItemId))
     {
         return true;
     }
     // 判断员工角色权限
     if (this.CheckRoleModulePermission(userId, moduleId, permissionItemId))
     {
         return true;
     }
     return false;
 }
        /// <summary>
        /// 获得用户有访问权限的模块
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userId">用户主键</param>
        /// <returns>数据表</returns>
        public DataTable GetModuleDTByUser(BaseUserInfo userInfo, string userId)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
                LogOnService.UserIsLogOn(userInfo);
            #endif

            DataTable dataTable = new DataTable(BaseModuleEntity.TableName);
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    string tableName = BaseModuleEntity.TableName;
                    if (!string.IsNullOrEmpty(BaseSystemInfo.SystemCode))
                    {
                        tableName = BaseSystemInfo.SystemCode + "Module";
                    }
                    BaseModuleManager moduleManager = new BaseModuleManager(dbHelper, userInfo, tableName);
                    if (userInfo.IsAdministrator)
                    {
                        List<KeyValuePair<string, object>> parameters = new List<KeyValuePair<string, object>>();
                        parameters.Add(new KeyValuePair<string, object>(BaseModuleEntity.FieldEnabled, 1));
                        parameters.Add(new KeyValuePair<string, object>(BaseModuleEntity.FieldDeletionStateCode, 0));
                        // 有效的,未被删除的显示出来
                        dataTable = moduleManager.GetDataTable(parameters, BaseModuleEntity.FieldSortCode);
                    }
                    else
                    {
                        dataTable = moduleManager.GetDataTableByUser(userId);
                    }
                    // 若不是员工,有些菜单可以去掉的功能,加在这里
                    if (string.IsNullOrEmpty(userInfo.StaffId))
                    {
                        BaseBusinessLogic.Delete(dataTable, BaseModuleEntity.FieldCode, "FrmStaffAddressEdit");
                        dataTable.AcceptChanges();
                    }
                    dataTable.TableName = BaseModuleEntity.TableName;
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.PermissionService_GetModuleDTByUser, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

            // 写入调试信息
            #if (DEBUG)
                BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart);
            #endif
            return dataTable;
        }
        /// <summary>
        /// 某个用户是否对某个模块有相应的权限
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userId">用户主键</param>
        /// <param name="moduleCode">模块编号</param>
        /// <returns>是否有权限</returns>
        public bool IsModuleAuthorizedByUser(BaseUserInfo userInfo, string userId, string moduleCode)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
                LogOnService.UserIsLogOn(userInfo);
            #endif

            bool returnValue = false;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    // 是否超级管理员
                    BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo);
                    if (userManager.IsAdministrator(userId))
                    {
                        return true;
                    }
                    else
                    {
                        BaseModuleManager moduleManager = new BaseModuleManager(dbHelper, userInfo);
                        DataTable dataTable = moduleManager.GetDataTableByUser(userId);
                        foreach (DataRow dataRow in dataTable.Rows)
                        {
                            if (dataRow[BaseModuleEntity.FieldCode].ToString().Equals(moduleCode))
                            {
                                returnValue = true;
                                break;
                            }
                        }
                    }
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.PermissionService_IsModuleAuthorizedByUser, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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

            return returnValue;
        }
        /// <summary>
        /// 获取用户有权限访问的模块主键
        /// </summary>
        /// <param name="userInfo">用户</param>
        /// <param name="userId">用户主键</param>
        /// <returns>主键数组</returns>
        public string[] GetModuleIdsByUser(BaseUserInfo userInfo, string userId)
        {
            // 写入调试信息
            #if (DEBUG)
                int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod());
            #endif

            // 加强安全验证防止未授权匿名调用
            #if (!DEBUG)
                LogOnService.UserIsLogOn(userInfo);
            #endif

            string[] returnValue = null;
            using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType))
            {
                try
                {
                    dbHelper.Open(UserCenterDbConnection);
                    BaseModuleManager moduleManager = new BaseModuleManager(dbHelper, userInfo);
                    if (userInfo.IsAdministrator)
                    {
                        // 有效的,未被删除的显示出来
                        returnValue = moduleManager.GetIds(new KeyValuePair<string, object>(BaseModuleEntity.FieldDeletionStateCode, 0), new KeyValuePair<string, object>(BaseModuleEntity.FieldEnabled, 1));
                    }
                    else
                    {
                        returnValue = moduleManager.GetIdsByUser(userId);
                    }
                    BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, AppMessage.PermissionService_GetModuleDTByUser, MethodBase.GetCurrentMethod());
                }
                catch (Exception ex)
                {
                    BaseExceptionManager.LogException(dbHelper, userInfo, ex);
                    throw ex;
                }
                finally
                {
                    dbHelper.Close();
                }
            }

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