using Bootstrap.Security; using Longbow.Cache; using Longbow.Data; using System.Collections.Generic; namespace Bootstrap.DataAccess { /// /// /// public static class DictHelper { /// /// /// /// /// 缓存索引,BootstrapAdmin后台清理缓存时使用 /// public const string RetrieveDictsDataKey = "BootstrapDict-RetrieveDicts"; /// /// /// public const string RetrieveCategoryDataKey = "DictHelper-RetrieveDictsCategory"; /// /// /// /// public static IEnumerable RetrieveDicts() => CacheManager.GetOrAdd(RetrieveDictsDataKey, key => DbContextManager.Create().RetrieveDicts()); /// /// 删除字典中的数据 /// /// 需要删除的IDs /// public static bool Delete(IEnumerable value) { var ret = DbContextManager.Create().Delete(value); CacheCleanUtility.ClearCache(dictIds: value); return ret; } /// /// 保存新建/更新的字典信息 /// /// /// public static bool Save(BootstrapDict p) { var ret = DbContextManager.Create().Save(p); if (ret) CacheCleanUtility.ClearCache(dictIds: new List()); return ret; } /// /// 保存网站个性化设置 /// /// /// /// /// public static bool SaveSettings(BootstrapDict dict) { var ret = DbContextManager.Create().SaveSettings(dict); if (ret) CacheCleanUtility.ClearCache(dictIds: new List()); return ret; } /// /// 获取字典分类名称 /// /// public static IEnumerable RetrieveCategories() => CacheManager.GetOrAdd(RetrieveCategoryDataKey, key => DbContextManager.Create().RetrieveCategories()); /// /// /// /// public static string RetrieveWebTitle() => DbContextManager.Create().RetrieveWebTitle(); /// /// /// /// public static string RetrieveWebFooter() => DbContextManager.Create().RetrieveWebFooter(); /// /// 获得系统中配置的可以使用的网站样式 /// /// public static IEnumerable RetrieveThemes() => DbContextManager.Create().RetrieveThemes(); /// /// 获得网站设置中的当前样式 /// /// public static string RetrieveActiveTheme() => DbContextManager.Create().RetrieveActiveTheme(); /// /// 获取头像路径 /// /// public static string RetrieveIconFolderPath() => DbContextManager.Create().RetrieveIconFolderPath(); /// /// 获得默认的前台首页地址,默认为~/Home/Index /// /// 应用程序编码 /// public static string RetrieveHomeUrl(string appCode) => DbContextManager.Create().RetrieveHomeUrl(appCode); /// /// /// /// public static IEnumerable> RetrieveApps() => DbContextManager.Create().RetrieveApps(); /// /// 程序异常时长 默认1月 /// /// public static int RetrieveExceptionsLogPeriod() => DbContextManager.Create().RetrieveExceptionsLogPeriod(); /// /// /// /// public static int RetrieveLogsPeriod() => DbContextManager.Create().RetrieveLogsPeriod(); /// /// /// /// public static int RetrieveLoginLogsPeriod() => DbContextManager.Create().RetrieveLoginLogsPeriod(); /// /// /// /// public static int RetrieveCookieExpiresPeriod() => DbContextManager.Create().RetrieveCookieExpiresPeriod(); /// /// /// /// public static int RetrieveLocaleIP() => DbContextManager.Create().RetrieveLocaleIP(); /// /// 访问日志保留时长 默认一个月 /// /// public static int RetrieveAccessLogPeriod() => DbContextManager.Create().RetrieveAccessLogPeriod(); } }