Ejemplo n.º 1
0
        public async Task <ActionResult> DoAsync(SignInInfo model)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.InvalidModelState(this.ModelState));
            }

            try
            {
                bool isValid = await this.CheckPasswordAsync(this.Tenant, model.Email, model.Password).ConfigureAwait(false);

                if (!isValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.Forbidden));
                }

                var result = await DAL.SignIn.DoAsync(this.Tenant, model.Email, model.OfficeId, this.RemoteUser.Browser, this.RemoteUser.IpAddress, model.Culture.Or("en-US")).ConfigureAwait(false);

                string key     = "access_tokens_" + this.Tenant;
                var    factory = new DefaultCacheFactory();
                factory.Remove(key);

                return(await this.OnAuthenticatedAsync(result, model).ConfigureAwait(true));
            }
            catch (DbException ex)
            {
                Log.Information(ex.Message);
                return(this.AccessDenied());
            }
        }
Ejemplo n.º 2
0
        public static async Task<LoginView> SetCurrentLoginAsync(string tenant, long loginId)
        {
            if(loginId <= 0)
            {
                return new LoginView();
            }

            string key = tenant + "-" + loginId.ToString(CultureInfo.InvariantCulture);

            var factory = new DefaultCacheFactory();

            var login = factory.Get<LoginView>(key);

            if(login != null)
            {
                return login;
            }

            login = await GetMetaLoginAsync(tenant, loginId).ConfigureAwait(false);

            var dictionary = GetDictionary(tenant, login);


            factory.Add(tenant + "/dictionary/" + loginId, dictionary, DateTimeOffset.UtcNow.AddHours(2));
            factory.Add(key, login, DateTimeOffset.UtcNow.AddHours(2));

            return login;
        }
Ejemplo n.º 3
0
        private static InventorySetup FromCache(string tenant, int officeId)
        {
            var cache = new DefaultCacheFactory();
            var item  = cache.Get <List <InventorySetup> >(tenant + AppDatesKey);

            return(item?.FirstOrDefault(x => x.OfficeId == officeId));
        }
Ejemplo n.º 4
0
        public static async Task <LoginView> SetCurrentLoginAsync(string tenant, long loginId)
        {
            if (loginId <= 0)
            {
                return(new LoginView());
            }

            string key = tenant + "-" + loginId.ToString(CultureInfo.InvariantCulture);

            var factory = new DefaultCacheFactory();

            var login = factory.Get <LoginView>(key);

            if (login != null)
            {
                return(login);
            }

            login = await GetMetaLoginAsync(tenant, loginId).ConfigureAwait(false);

            var dictionary = GetDictionary(tenant, login);


            factory.Add(tenant + "/dictionary/" + loginId, dictionary, DateTimeOffset.UtcNow.AddHours(2));
            factory.Add(key, login, DateTimeOffset.UtcNow.AddHours(2));

            return(login);
        }
Ejemplo n.º 5
0
        public static FrequencyDates GetFrequencyDates(string tenant, int officeId)
        {
            var cache = new DefaultCacheFactory();
            var item  = cache.Get <List <FrequencyDates> >(tenant + AppDatesKey);

            return(item.FirstOrDefault(x => x.OfficeId == officeId));
        }
Ejemplo n.º 6
0
        public async Task<ActionResult> DoAsync(SignInInfo model)
        {
            if (!this.ModelState.IsValid)
            {
                return this.InvalidModelState(this.ModelState);
            }

            try
            {
                bool isValid =
                    await this.CheckPasswordAsync(this.Tenant, model.Email, model.Password).ConfigureAwait(false);

                if (!isValid)
                {
                    return new HttpStatusCodeResult(HttpStatusCode.Forbidden);
                }

                var result = await DAL.SignIn.DoAsync(this.Tenant, model.Email, model.OfficeId, this.RemoteUser.Browser,
                            this.RemoteUser.IpAddress, model.Culture.Or("en-US")).ConfigureAwait(false);

                string key = "access_tokens_" + this.Tenant;
                var factory = new DefaultCacheFactory();
                factory.Remove(key);

                return await this.OnAuthenticatedAsync(result, model).ConfigureAwait(true);
            }
            catch (DbException ex)
            {
                Log.Information(ex.Message);
                return this.AccessDenied();
            }
        }
Ejemplo n.º 7
0
        public static async Task SaveAsync(string tenant, UserMenuPolicyInfo model)
        {
            await Menus.SavePolicyAsync(tenant, model.OfficeId, model.UserId, model.Allowed, model.Disallowed).ConfigureAwait(false);

            //Invalidate existing cache data
            string prefix  = $"menu_policy_{tenant}_{model.OfficeId}_{model.UserId}";
            var    factory = new DefaultCacheFactory();

            factory.RemoveByPrefix(prefix);
        }
Ejemplo n.º 8
0
        protected async Task RefreshTokens()
        {
            string key     = "access_tokens_" + this.Tenant;
            var    factory = new DefaultCacheFactory();

            factory.Remove(key);

            var tokens = await TokenManager.DAL.AccessTokens.FromStoreAsync(this.Tenant).ConfigureAwait(false);

            factory.Add(key, tokens, DateTimeOffset.Now.AddMinutes(60));
        }
Ejemplo n.º 9
0
        public async Task <ActionResult> RevokeAsync()
        {
            if (!string.IsNullOrWhiteSpace(this.AppUser?.ClientToken))
            {
                await AccessTokens.RevokeAsync(this.Tenant, this.AppUser.ClientToken).ConfigureAwait(true);

                string key     = "access_tokens_" + this.Tenant;
                var    factory = new DefaultCacheFactory();
                factory.Remove(key);
            }

            return(this.Ok("OK"));
        }
Ejemplo n.º 10
0
        public async Task<ActionResult> SignOutAsync()
        {
            if (!string.IsNullOrWhiteSpace(this.AppUser?.ClientToken))
            {
                await AccessTokens.RevokeAsync(this.Tenant, this.AppUser.ClientToken).ConfigureAwait(true);
                string key = "access_tokens_" + this.Tenant;
                var factory = new DefaultCacheFactory();
                factory.Remove(key);
            }

            FormsAuthentication.SignOut();
            return this.View(this.GetRazorView<AreaRegistration>("SignOut/Index.cshtml", this.Tenant));
        }
Ejemplo n.º 11
0
        public async Task <ActionResult> SignOutAsync()
        {
            if (!string.IsNullOrWhiteSpace(this.AppUser?.ClientToken))
            {
                await AccessTokens.RevokeAsync(this.Tenant, this.AppUser.ClientToken).ConfigureAwait(true);

                string key     = "access_tokens_" + this.Tenant;
                var    factory = new DefaultCacheFactory();
                factory.Remove(key);
            }

            FormsAuthentication.SignOut();
            return(this.View(this.GetRazorView <AreaRegistration>("SignOut/Index.cshtml", this.Tenant)));
        }
Ejemplo n.º 12
0
        public static async Task SaveAsync(AppUser appUser, GroupMenuPolicyInfo model)
        {
            if (!appUser.IsAdministrator)
            {
                return;
            }

            await Menus.SaveGroupPolicyAsync(appUser.Tenant, model.OfficeId, model.RoleId, model.MenuIds).ConfigureAwait(false);

            //Invalidate existing cache data
            string prefix  = $"menu_policy_{appUser.Tenant}_{appUser.OfficeId}";
            var    factory = new DefaultCacheFactory();

            factory.RemoveByPrefix(prefix);
        }
Ejemplo n.º 13
0
        public static async Task SaveAsync(AppUser appUser, int officeId, int roleId, List <AccessPolicyInfo> model)
        {
            if (!appUser.IsAdministrator)
            {
                return;
            }

            await AccessPolicy.SaveGroupPolicyAsync(appUser.Tenant, officeId, roleId, model).ConfigureAwait(false);

            //Invalidate existing cache data
            string prefix  = $"access_policy_{appUser.Tenant}";
            var    factory = new DefaultCacheFactory();

            factory.RemoveByPrefix(prefix);
        }
Ejemplo n.º 14
0
        public static async Task <EmployeeInfo> GetAsync(string tenant, int employeeId)
        {
            string key     = tenant + ".employeeinfo." + employeeId;
            var    factory = new DefaultCacheFactory();
            var    model   = factory.Get <EmployeeInfo>(key);

            if (model == null)
            {
                model = await FromStoreAsync(tenant, employeeId).ConfigureAwait(false);

                factory.Add(key, model, DateTimeOffset.UtcNow.AddMinutes(2));
            }

            return(model);
        }
Ejemplo n.º 15
0
        private static async Task<IEnumerable<AccessToken>> GetActiveTokensAsync(string tenant)
        {
            string key = "access_tokens_" + tenant;
            var factory = new DefaultCacheFactory();
            var tokens = factory.Get<IEnumerable<AccessToken>>(key);

            if (tokens != null)
            {
                return tokens;
            }

            tokens = await FromStoreAsync(tenant).ConfigureAwait(false);
            factory.Add(key, tokens, DateTimeOffset.Now.AddMinutes(5));

            return tokens;
        }
Ejemplo n.º 16
0
        public static SearchResult GetResult(string query)
        {
            query = Sanitize(query);
            string key     = "/search-contents/" + query;
            var    factory = new DefaultCacheFactory();

            var result = factory.Get <SearchResult>(key);

            if (result == null)
            {
                result = FromStore(query);
                factory.Add(key, result, DateTimeOffset.UtcNow.AddMinutes(15));
            }

            return(result);
        }
Ejemplo n.º 17
0
        public static async Task<SearchResult> GetResultAsync(string tenant, string query)
        {
            query = Sanitize(query);
            string key = "/search-contents/" + query;
            var factory = new DefaultCacheFactory();

            var result = factory.Get<SearchResult>(key);

            if (result == null)
            {
                result = await FromStoreAsync(tenant, query).ConfigureAwait(false);
                factory.Add(key, result, DateTimeOffset.UtcNow.AddMinutes(15));
            }

            return result;
        }
Ejemplo n.º 18
0
        public static async Task <SearchResult> GetResultAsync(string tenant, string query)
        {
            query = Sanitize(query);
            string key     = "/search-contents/" + query;
            var    factory = new DefaultCacheFactory();

            var result = factory.Get <SearchResult>(key);

            if (result == null)
            {
                result = await FromStoreAsync(tenant, query).ConfigureAwait(false);

                factory.Add(key, result, DateTimeOffset.UtcNow.AddMinutes(15));
            }

            return(result);
        }
Ejemplo n.º 19
0
        private IEnumerable <Menu> GetAllMenus(string tenant, int userId, int officeId)
        {
            string key = $"menu_policy_{tenant}_{officeId}_{userId}";

            var factory = new DefaultCacheFactory();
            var policy  = factory.Get <List <Menu> >(key);

            if (policy != null && policy.Any())
            {
                return(policy);
            }

            policy = this.FromStore(tenant, userId, officeId).ToList();
            factory.Add(key, policy, DateTimeOffset.UtcNow.AddSeconds(GetTotalCacheDuration(tenant)));

            return(policy);
        }
Ejemplo n.º 20
0
        public async Task ValidateAsync()
        {
            string key = $"access_policy_{this.Tenant}_{this.ObjectNamespace}_{this.ObjectName}_{this.LoginId}";

            var factory = new DefaultCacheFactory();
            var policy  = factory.Get <dynamic>(key);

            if (policy != null)
            {
                this.HasAccess = policy.HasAccess;
                return;
            }

            this.HasAccess = await FromStore(this).ConfigureAwait(false);

            factory.Add(key, new { this.HasAccess }, DateTimeOffset.UtcNow.AddSeconds(GetTotalCacheDuration(this.Tenant)));
        }
Ejemplo n.º 21
0
        private static async Task <IEnumerable <AccessToken> > GetActiveTokensAsync(string tenant)
        {
            string key     = "access_tokens_" + tenant;
            var    factory = new DefaultCacheFactory();
            var    tokens  = factory.Get <IEnumerable <AccessToken> >(key);

            if (tokens != null)
            {
                return(tokens);
            }

            tokens = await FromStoreAsync(tenant).ConfigureAwait(false);

            factory.Add(key, tokens, DateTimeOffset.Now.AddMinutes(5));

            return(tokens);
        }
Ejemplo n.º 22
0
        public static async Task <LoginView> GetCurrentAsync(string tenant, long loginId)
        {
            if (loginId == 0)
            {
                return(new LoginView());
            }

            string key = tenant + "-" + loginId.ToString(CultureInfo.InvariantCulture);

            var factory = new DefaultCacheFactory();

            var login = factory.Get <LoginView>(key);

            var view = login ?? await SetCurrentLoginAsync(tenant, loginId).ConfigureAwait(false);

            await UpdateActivityAsync(tenant, view.UserId.To <int>(), view.IpAddress, view.Browser).ConfigureAwait(false);

            return(view);
        }
Ejemplo n.º 23
0
        public static async Task <IEnumerable <AccessToken> > GetActiveTokensAsync(string tenant)
        {
            string key     = "access_tokens_" + tenant;
            var    factory = new DefaultCacheFactory();
            var    tokens  = factory.Get <IEnumerable <AccessToken> >(key);

            if (tokens != null)
            {
                return(tokens);
            }

            tokens = await FromStoreAsync(tenant).ConfigureAwait(false);

            // ReSharper disable once PossibleMultipleEnumeration
            //False positive
            factory.Add(key, tokens, DateTimeOffset.Now.AddMinutes(60));

            return(tokens);
        }
Ejemplo n.º 24
0
        public static LoginView GetCurrent(string tenant, long loginId)
        {
            var login = new LoginView();

            if (loginId == 0)
            {
                return(login);
            }

            string key = tenant + "-" + loginId.ToString(CultureInfo.InvariantCulture);

            var factory = new DefaultCacheFactory();

            login = factory.Get <LoginView>(key);

            var view = login ?? SetCurrentLogin(tenant, loginId);

            UpdateActivity(view.UserId.To <int>(), view.IpAddress, view.Browser);
            return(view);
        }
Ejemplo n.º 25
0
        internal static DnsSpamLookupResult IsListedInSpamDatabase(string tenant, string ipAddress)
        {
            bool isLoopBack = IPAddress.IsLoopback(IPAddress.Parse(ipAddress));

            if (isLoopBack)
            {
                return(new DnsSpamLookupResult());
            }

            string key     = ipAddress + ".spam.check";
            var    factory = new DefaultCacheFactory();

            var isListed = factory.Get <DnsSpamLookupResult>(key);

            if (isListed == null)
            {
                isListed = FromStore(tenant, ipAddress);
                factory.Add(key, isListed, DateTimeOffset.UtcNow.AddHours(2));
            }

            return(isListed);
        }
Ejemplo n.º 26
0
        internal static DnsSpamLookupResult IsListedInSpamDatabase(string tenant, string ipAddress)
        {
            bool isLoopBack = IPAddress.IsLoopback(IPAddress.Parse(ipAddress));

            if (isLoopBack)
            {
                return new DnsSpamLookupResult();
            }

            string key = ipAddress + ".spam.check";
            var factory = new DefaultCacheFactory();

            var isListed = factory.Get<DnsSpamLookupResult>(key);

            if (isListed == null)
            {
                isListed = FromStore(tenant, ipAddress);
                factory.Add(key, isListed, DateTimeOffset.UtcNow.AddHours(2));
            }

            return isListed;
        }
Ejemplo n.º 27
0
        private static string GetDictionaryValue(string tenant, string key)
        {
            string globalLoginId = HttpContext.Current.User.Identity.Name;

            if (!string.IsNullOrWhiteSpace(globalLoginId))
            {
                string cacheKey = tenant + "/dictionary/" + globalLoginId;

                var cache = new DefaultCacheFactory();
                var dictionary = cache.Get<Dictionary<string, object>>(cacheKey);

                if (dictionary != null && dictionary.ContainsKey(key))
                {
                    var value = dictionary?[key];

                    if (value != null)
                    {
                        return value.ToString();
                    }
                }
            }

            return string.Empty;
        }
Ejemplo n.º 28
0
        private static string GetDictionaryValue(string tenant, string key)
        {
            string globalLoginId = HttpContext.Current.User.Identity.Name;

            if (!string.IsNullOrWhiteSpace(globalLoginId))
            {
                string cacheKey = tenant + "/dictionary/" + globalLoginId;

                var cache      = new DefaultCacheFactory();
                var dictionary = cache.Get <Dictionary <string, object> >(cacheKey);

                if (dictionary != null && dictionary.ContainsKey(key))
                {
                    var value = dictionary?[key];

                    if (value != null)
                    {
                        return(value.ToString());
                    }
                }
            }

            return(string.Empty);
        }
Ejemplo n.º 29
0
 public Profile(DebugConnectionFactory connectionFactory, DefaultCacheFactory cacheFactory)
     : this()
 {
     this.connectionFactory = connectionFactory;
     this.cacheFactory      = cacheFactory;
 }
Ejemplo n.º 30
0
        private static void SetInventorySetup(string catalog, List <InventorySetup> inventorySetups)
        {
            var cache = new DefaultCacheFactory();

            cache.Add(catalog + AppDatesKey, inventorySetups, DateTimeOffset.UtcNow.AddHours(1));
        }
Ejemplo n.º 31
0
        static void Main(string[] args)
        {
            //使用MemoryCache作为缓存存储  默认使用HttpRuntime.Cache,需要依赖System.Web  必要时可以进行自由切换
            GlobalCacheProviderFactory.Instance.SetDefaultCacheProviderFactory(new MemoryCacheProviderFactory());

            //设置zookeeper连接信息
            string zkConns = ConfigurationManager.AppSettings["zk_cache_quorums"];

            GlobalZKCacheDependencyOption.Instance.SetDefaultZKCacheDependencyOption(zkConns);

            string node = "/CacheConsole/Test";

            //更新数据
            UpdateData();

            //打印帮助信息
            PrintHelpInfo();

            while (true)
            {
                var input = Console.ReadKey().KeyChar;
                if (input == 'c')
                {
                    DefaultCacheFactory.DefaultCache.ClearOne(node);
                    Console.WriteLine("缓存清理请求已提交,node-->" + node);
                }
                else if (input == 'g')
                {
                    string value = DefaultCacheFactory.DefaultCache.Get <string>(node);
                    if (string.IsNullOrWhiteSpace(value))
                    {
                        value = ReadData();
                        DefaultCacheFactory.DefaultCache.Add(node, value);
                        value = DefaultCacheFactory.DefaultCache.Get <string>(node);
                    }
                    Console.WriteLine("查询到节点{0}的缓存数据值为{1}", node, value);
                }
                else if (input == 'a')
                {
                    string newValue = ReadData();
                    DefaultCacheFactory.DefaultCache.Add(node, newValue);
                    Console.WriteLine("节点{0}的缓存数据已更新,写入值为:{1}", node, newValue);
                }
                else if (input == 'u')
                {
                    string newValue = UpdateData();
                    Console.WriteLine("文件data.zk已更新,新值为:{0}", newValue);
                }
                else if (input == 'r')
                {
                    string newValue = UpdateData();
                    Console.WriteLine("文件data.zk已更新,新值为:{0}", newValue);
                    DefaultCacheFactory.DefaultCache.ClearOne(node);
                    Console.WriteLine("缓存清理请求已提交,node-->" + node);
                }
                else if (input == 'm')
                {
                    GlobalCacheProviderFactory.Instance.SetDefaultCacheProviderFactory(new MemoryCacheProviderFactory());
                    DefaultCacheFactory.Reset();
                    cacheProviderName = "MemoryCache";
                    Console.WriteLine("已切换为MemoryCache作为缓存存储!");
                }
                else if (input == 'd')
                {
                    GlobalCacheProviderFactory.Instance.SetDefaultCacheProviderFactory(new HttpRuntimeCacheProviderFactory());
                    DefaultCacheFactory.Reset();
                    cacheProviderName = "HttpRuntime.Cache";
                    Console.WriteLine("已切换为HttpRuntime.Cache作为缓存存储!");
                }
                else if (input == 'q')
                {
                    Console.WriteLine("再次按任意键退出!");
                    Console.ReadKey();
                    return;
                }
                else if (input == 'h')
                {
                    PrintHelpInfo();
                }
                else
                {
                    PrintHelpInfo();
                }
            }
        }
Ejemplo n.º 32
0
        public static async Task<LoginView> GetCurrentAsync(string tenant, long loginId)
        {
            if(loginId == 0)
            {
                return new LoginView();
            }

            string key = tenant + "-" + loginId.ToString(CultureInfo.InvariantCulture);

            var factory = new DefaultCacheFactory();

            var login = factory.Get<LoginView>(key);

            var view =  login ?? await SetCurrentLoginAsync(tenant, loginId).ConfigureAwait(false);

            await UpdateActivityAsync(tenant, view.UserId.To<int>(), view.IpAddress, view.Browser).ConfigureAwait(false);

            return view;
        }
Ejemplo n.º 33
0
 public DebugTests()
 {
     this.connectionFactory = new DebugConnectionFactory();
     this.cacheFactory      = new DefaultCacheFactory();
     this.profile           = new Profile(this.connectionFactory, this.cacheFactory);
 }
Ejemplo n.º 34
0
        public static List <FrequencyDates> GetFrequencyDates(string tenant)
        {
            var cache = new DefaultCacheFactory();

            return(cache.Get <List <FrequencyDates> >(tenant + AppDatesKey));
        }
Ejemplo n.º 35
0
        private static void initPubDI(ContainerBuilder builder, bool defaultUserAuth = true)
        {
            builder.Register(c => new Log4NetLogAdapter(AppDomain.CurrentDomain.BaseDirectory + "Config/log4net.config")).As <ILogAdapter>().SingleInstance();

            //注册缓存CacheFactory
            int redisCacheServerPort;
            var redisCacheServer    = ConfigurationManager.AppSettings["RedisCacheServer"];
            var redisCacheServerPwd = ConfigurationManager.AppSettings["RedisCacheServerPwd"];

            int.TryParse(ConfigurationManager.AppSettings["RedisCacheServerPort"], out redisCacheServerPort);
            var cache = CacheFactory.Build("RuntimeCache", settings =>
            {
                settings.WithSystemRuntimeCacheHandle("RuntimeCache")
                .WithExpiration(ExpirationMode.Sliding, TimeSpan.FromMinutes(10))
                .And
                .WithRedisConfiguration("RedisUserCache", config =>
                {
                    config.WithAllowAdmin()
                    .WithDatabase(15)
                    .WithPassword(redisCacheServerPwd)
                    .WithEndpoint(redisCacheServer, redisCacheServerPort);
                })
                .WithMaxRetries(100)
                .WithRetryTimeout(50)
                .WithRedisBackPlate("RedisUserCache")
                .WithRedisCacheHandle("RedisUserCache", true)
                .WithExpiration(ExpirationMode.Sliding, TimeSpan.FromMinutes(30));
            });

            var presistentCache = CacheFactory.Build("RuntimeCache2", settings =>
            {
                settings.WithSystemRuntimeCacheHandle("RuntimeCache2")
                .WithExpiration(ExpirationMode.Sliding, TimeSpan.FromMinutes(60))
                .And
                .WithRedisConfiguration("RedisPresistentCache", config =>
                {
                    config.WithAllowAdmin()
                    .WithDatabase(15)
                    .WithPassword(redisCacheServerPwd)
                    .WithEndpoint(redisCacheServer, redisCacheServerPort);
                })
                .WithMaxRetries(100)
                .WithRetryTimeout(50)
                .WithRedisBackPlate("RedisPresistentCache")
                .WithRedisCacheHandle("RedisPresistentCache", true)
                .WithExpiration(ExpirationMode.Sliding, TimeSpan.FromDays(30));
            });

            var tokenCache = CacheFactory.Build("RuntimeTokenCache", settings =>
            {
                settings.WithSystemRuntimeCacheHandle("RuntimeTokenCache")
                .WithExpiration(ExpirationMode.Sliding, TimeSpan.FromMinutes(60))
                .And
                .WithRedisConfiguration("RedisTokenCache", config =>
                {
                    config.WithAllowAdmin()
                    .WithDatabase(15)
                    .WithPassword(redisCacheServerPwd)
                    .WithEndpoint(redisCacheServer, redisCacheServerPort);
                })
                .WithMaxRetries(100)
                .WithRetryTimeout(50)
                .WithRedisBackPlate("RedisTokenCache")
                .WithRedisCacheHandle("RedisTokenCache", true)
                .WithExpiration(ExpirationMode.Sliding, TimeSpan.FromDays(30));
            });

            DefaultCacheFactory.InitCacheInstance(cache, presistentCache, tokenCache, 1);

            //注册ID生成器
            byte serverID = 0;

            byte.TryParse(ConfigurationManager.AppSettings["IDGenServerID"], out serverID);
            builder.Register(c => new DefaultIdBuilder(serverID, "RedisQueueConfig")).As <IdBuilder>().SingleInstance();  //NextIntID与Queue保存在同台Redis中持久化


            //是否使用默认用户验证等信息
            if (defaultUserAuth)
            {
                //服务
                //用户业务逻辑
                builder.Register(c => new UserBL()).As <IUserBL>().SingleInstance();
                //containerBuilder.Register(c => new AdminUserBL()).As<AdminUserBL>().SingleInstance();

                //用户身份认证
                builder.Register(c => new AuthenticationBL()).As <IAuthenticationBL>().InstancePerRequest();
                //containerBuilder.Register(c => new FormsAuthenticationBL()).As<IAuthenticationBL>().InstancePerApiRequest();

                //用户权限处理
                builder.Register(c => new PermissionBL()).As <IPermissionBL>().SingleInstance();

                //用户操作日志处理
                builder.Register(c => new OprtLogBL()).As <IOprtLogBL>().SingleInstance();
            }
        }
Ejemplo n.º 36
0
        public static void SetApplicationDates(string catalog, List <FrequencyDates> applicationDates)
        {
            var cache = new DefaultCacheFactory();

            cache.Add(catalog + AppDatesKey, applicationDates, DateTimeOffset.UtcNow.AddHours(1));
        }