Ejemplo n.º 1
0
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="tenantAuthorizationHandlers">租户权限处理器集合</param>
        /// <param name="anonymous">匿名用户角色名称</param>
        /// <param name="superAdministrator">超级管理员角色名称</param>
        /// <param name="permissionService">权限管理服务</param>
        public AuthorizationService(IEnumerable<ITenantAuthorizationHandler> tenantAuthorizationHandlers, string anonymous, string superAdministrator, PermissionService permissionService)
        {
            tenantAuthorizationHandlerDictionary = new ConcurrentDictionary<string, ITenantAuthorizationHandler>();
            foreach (var tenantAuthorizationHandler in tenantAuthorizationHandlers)
            {
                tenantAuthorizationHandlerDictionary[tenantAuthorizationHandler.TenantTypeId] = tenantAuthorizationHandler;
            }

            this.AnonymousRoleName = anonymous;
            this.SuperAdministratorRoleName = superAdministrator;
            this.permissionService = permissionService;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 构造函数
        /// </summary>
        public AuthorizationService()
        {
            tenantAuthorizationHandlerDictionary = new ConcurrentDictionary<string, ITenantAuthorizationHandler>();
            foreach (var tenantAuthorizationHandler in DIContainer.Resolve<IEnumerable<ITenantAuthorizationHandler>>())
            {
                tenantAuthorizationHandlerDictionary[tenantAuthorizationHandler.TenantTypeId] = tenantAuthorizationHandler;
            }

            UserSettings userSettings = DIContainer.Resolve<ISettingsManager<UserSettings>>().Get();

            this.AnonymousRoleName = userSettings.AnonymousRoleName;
            this.SuperAdministratorRoleName = userSettings.SuperAdministratorRoleName;
            this.permissionService = new PermissionService();
        }
        void PermissionOperationLogEventMoudle_BatchAfter(IEnumerable<PermissionItemInUserRole> senders, CommonEventArgs eventArgs)
        {
            //只记录批量更新操作
            if (eventArgs.EventOperationType != EventOperationType.Instance().Update())
                return;
            OperationLogService logService = Tunynet.DIContainer.Resolve<OperationLogService>();
            PermissionService permissionService = new PermissionService();

            OperationLogEntry entry = new OperationLogEntry(eventArgs.OperatorInfo);

            entry.ApplicationId = 0;
            entry.Source = string.Empty;
            entry.OperationType = eventArgs.EventOperationType;
            IEnumerable<string> roleNames = senders.Select(n => n.RoleName).Distinct();
            entry.OperationObjectName = string.Join(",", roleNames);
            entry.OperationObjectId = 0;
            entry.Description = string.Format(ResourceAccessor.GetString("OperationLog_Pattern_" + eventArgs.EventOperationType), "权限", entry.OperationObjectName);
            logService.Create(entry);
        }