Пример #1
0
        /// <summary>
        /// 初始化网站全局信息
        /// </summary>
        private void GlobalInitial()
        {
            DbRepository.ConnectionName = "Lampblack_Platform";
            GeneralProcess.LoadBaseInfomations();

            var deviceModels = GeneralProcess.GetDeviceModels();

            foreach (var model in deviceModels)
            {
                var rate = new CleanessRate(model);
                PlatformCaches.Add($"CleanessRate-{model.Id}", rate, false, "deviceModels");
            }

            var configDictionary = new Dictionary <string, object>
            {
                {
                    "deviceTypeGuid",
                    ((IList <DeviceType>)
                     GeneralProcess.GetConfig <DeviceType>(obj => obj.DeviceTypeCode == "WD_Lampblack"))
                    .FirstOrDefault()?.Id
                },
                {
                    "firmwareSetGuid",
                    ((IList <FirmwareSet>)
                     GeneralProcess.GetConfig <FirmwareSet>(obj => obj.FirmwareSetName == "油烟协议第一版"))
                    .FirstOrDefault()?.Id
                }
            };

            var userDiscticts =
                (IList <SysDictionary>)GeneralProcess.GetConfig <SysDictionary>(c => c.ItemName == "userDistrict");

            PlatformCaches.Add("userDistrict", userDiscticts, false, "SystemConfig");

            LampblackConfig.InitConfig(configDictionary);
            WdControllerBase.LoginName = LampblackConfig.LoginName;
            PlatformCaches.Add("Cleaness", ProcessInvoke.Instance <HotelRestaurantProcess>().GetHotelCleanessList());
            var updateCleaness = new WdScheduler(SchedulerType.Interval)
            {
                Interval = 120000
            };

            updateCleaness.OnExecuting += () =>
            {
                PlatformCaches.Add("Cleaness", ProcessInvoke.Instance <HotelRestaurantProcess>().GetHotelCleanessList());
            };
            WdSchedulerManager.Register(updateCleaness);
            PlatformCaches.Add("HotelLocations", ProcessInvoke.Instance <HotelRestaurantProcess>().GetHotelLocations());
            var updateLocations = new WdScheduler(SchedulerType.Interval)
            {
                Interval = 120000
            };

            updateLocations.OnExecuting += () =>
            {
                PlatformCaches.Add("HotelLocations", ProcessInvoke.Instance <HotelRestaurantProcess>().GetHotelLocations());
            };
            WdSchedulerManager.Register(updateLocations);
        }
Пример #2
0
 /// <summary>
 /// 刷新权限信息缓存
 /// </summary>
 public static void RefreashPermissions()
 {
     using (var context = new RepositoryDbContext())
     {
         PlatformCaches.DeleteCachesByName("Permissions");
         var permissions = context.Set <Permission>().ToList();
         PlatformCaches.Add("Permissions", permissions, false, "System");
     }
 }
Пример #3
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");
         }
     }
 }
Пример #4
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");
         }
     }
 }
Пример #5
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");
         }
     }
 }
Пример #6
0
        public Dictionary <string, string> GetBasePageInformation(IWdUser user)
        {
            var cache = PlatformCaches.GetCache($"{user.DomainId}-{SystemCacheNames.DomainCompany}");

            if (cache != null)
            {
                return((Dictionary <string, string>)cache.CacheItem);
            }

            var repo = Repo <SysConfigRepository>();

            var information = repo.GetSysConfigDictionary(config => config.SysConfigType == SystemConfigType.DomainCompanyConfig);

            PlatformCaches.Add($"{user.DomainId}-{SystemCacheNames.DomainCompany}", information);

            return(information);
        }
Пример #7
0
        /// <summary>
        /// 获取系统权限列表
        /// </summary>
        /// <returns></returns>
        public static List <Permission> GetSysPeremissions()
        {
            var cache = PlatformCaches.GetCache("Permissions");

            if (cache == null)
            {
                using (var context = new RepositoryDbContext())
                {
                    var sysPeremissions = context.Set <Permission>().ToList();
                    PlatformCaches.Add("Permissions", sysPeremissions, false, "System");
                    return(sysPeremissions);
                }
            }

            var permissions = cache.CacheItem as List <Permission>;

            return(permissions);
        }