Esempio n. 1
0
        public static void AddStores(this IServiceCollection services, DataBaseFactory dataBaseFactory)
        {
            // Add Singleton Stores
            var userGroupStore = new RolesCache(dataBaseFactory);

            services.AddSingleton <IRolesCache>(userGroupStore);

            services.AddSingleton <ICategoriesCache, CategoriesCache>();

            services.AddSingleton <IContentCache, CategoryContentCache>();

            services.AddSingleton <CacheKeyGenerator>();

            services.AddSingleton <SpamProtectionCache>();
        }
Esempio n. 2
0
        public override void CreateRole(string roleName)
        {
            if (RolesCache.Exists(r => r.RoleName.EqualsEx(roleName)))
            {
                return;
            }

            OracleConnection con = new OracleConnection(_connectionString);
            OracleCommand    com = con.CreateCommand(SchemaOwner + PackageName + "create_role", CommandType.StoredProcedure);

            com.Parameters.Add("i_app_name", OracleDbType.Varchar2, ApplicationName, ParameterDirection.Input);
            com.Parameters.Add("i_role_name", OracleDbType.Varchar2, roleName.Trim().ToUpper(), ParameterDirection.Input);
            com.Parameters.Add("i_audit_user", OracleDbType.Varchar2, HttpContext.Current.User.Identity.Name, ParameterDirection.Input);

            try
            {
                con.Open();

                com.ExecuteNonQuery();

                con.Close();

                // reset cache
                _refreshRolesCache = true;
            }
            catch (OracleException oex)
            {
                // check if its a custom oracle exception
                if (oex.Number >= 20000 && oex.Number <= 20999)
                {
                    // throw a custom exception
                    throw new DalException(Dal.ExtractOracleMessage(oex.Message), oex);
                }
                else
                {
                    throw;
                }
            }
            finally
            {
                // cleanup
                Dal.Cleanup(con, com);

                con = null;
                com = null;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Add Singleton cache services
        /// </summary>
        public static void AddCaches(this IServiceCollection services, IDataBaseFactory dataBaseFactory)
        {
            var rolesCache = new RolesCache(dataBaseFactory);

            services.AddSingleton <IRolesCache>(rolesCache);
            services.AddSingleton <ICheckRoles>(rolesCache);

            services.AddSingleton <ICategoriesCache, CategoriesCache>();

            services.AddSingleton <IMenuCache, MenuCache>();

            services.AddSingleton <ISectionsCache, SectionsCache>();

            services.AddSingleton <IContentCache, CategoryContentCache>();

            services.AddSingleton <CacheKeyGenerator>();

            services.AddSingleton <SpamProtectionCache>();

            services.AddSingleton <IMailTemplatesCache, MailTemplatesCache>();

            services.AddSingleton <CaptchaCacheService>();
        }
Esempio n. 4
0
 public override bool RoleExists(string roleName)
 {
     return(RolesCache.Exists(r => r.RoleName.EqualsEx(roleName.Trim())));
 }
Esempio n. 5
0
 public override string[] GetAllRoles()
 {
     return(RolesCache.Select(r => r.RoleName).ToArray());
 }