コード例 #1
0
 /// <summary>
 /// 刷新角色权限缓存
 /// </summary>
 public static void RefreashRolePermissionsCache()
 {
     using (var context = new RepositoryDbContext())
     {
         PlatformCaches.DeleteCachesByType("RolePermissions");
         var roles = context.Set <WdRole>().Include("Permissions").Where(obj => obj.IsEnabled).ToList();
         foreach (var wdRole in roles)
         {
             PlatformCaches.Add($"Role[{wdRole.Id}]-Permissions", wdRole.Permissions.ToList(), false, "RolePermissions");
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// 刷新系功能单缓存
 /// </summary>
 public static void RefreashModules()
 {
     using (var context = new RepositoryDbContext())
     {
         PlatformCaches.DeleteCachesByType("Modules");
         var modules = context.Set <Module>().Where(obj => obj.IsEnabled).ToList();
         foreach (var module in modules)
         {
             PlatformCaches.Add($"Module[{module.Id}]", module, false, "Modules");
         }
     }
 }
コード例 #3
0
 /// <summary>
 /// 刷新用户权限缓存
 /// </summary>
 public static void RefreashUserPermissionsCache()
 {
     using (var context = new RepositoryDbContext())
     {
         PlatformCaches.DeleteCachesByType("UserPermissions");
         var users = context.Set <WdUser>().Include("Permissions").Where(obj => obj.IsEnabled).ToList();
         foreach (var wdUser in users)
         {
             PlatformCaches.Add($"User[{wdUser.Id}]-Permissions", wdUser.Permissions.ToList(), false, "UserPermissions");
         }
     }
 }