Esempio n. 1
0
        public static IDataStore GetStorage(string configpath, string tenant, string module, IQuotaController controller)
        {
            var tenantId = -2;

            if (string.IsNullOrEmpty(tenant))
            {
                tenant = DefaultTenantName;
            }
            else
            {
                tenantId = Convert.ToInt32(tenant);
            }

            //Make tenant path
            tenant = TenantPath.CreatePath(tenant);

            var store = DataStoreCache.Get(tenant, module);

            if (store == null)
            {
                var section = GetSection(configpath);
                if (section == null)
                {
                    throw new InvalidOperationException("config section not found");
                }

                var settings = StorageSettings.LoadForTenant(tenantId);

                store = GetStoreAndCache(tenant, module, section, settings.DataStoreConsumer, controller);
            }
            return(store);
        }
Esempio n. 2
0
        public IDataStore GetStorage(string configpath, string tenant, string module, IQuotaController controller)
        {
            var tenantId = -2;

            if (string.IsNullOrEmpty(tenant))
            {
                tenant = DefaultTenantName;
            }
            else
            {
                tenantId = Convert.ToInt32(tenant);
            }

            //Make tennant path
            tenant = TenantPath.CreatePath(tenant);

            var section = StorageFactoryConfig.Section;

            if (section == null)
            {
                throw new InvalidOperationException("config section not found");
            }

            var settings = SettingsManager.LoadForTenant <StorageSettings>(tenantId);

            //TODO:GetStoreAndCache
            return(GetDataStore(tenant, module, StorageSettingsHelper.DataStoreConsumer(settings), controller));
        }
Esempio n. 3
0
        internal static void ClearCache()
        {
            var tenantId = CoreContext.TenantManager.GetCurrentTenant().TenantId.ToString();
            var path     = TenantPath.CreatePath(tenantId);

            foreach (var module in GetModuleList("", true))
            {
                Cache.Publish(DataStoreCacheItem.Create(path, module), CacheNotifyAction.Remove);
            }
        }
Esempio n. 4
0
        public IDataStore GetStorageFromConsumer(string configpath, string tenant, string module, DataStoreConsumer consumer)
        {
            if (tenant == null)
            {
                tenant = DefaultTenantName;
            }

            //Make tennant path
            tenant = TenantPath.CreatePath(tenant);

            var section = StorageFactoryConfig.Section;

            if (section == null)
            {
                throw new InvalidOperationException("config section not found");
            }

            int.TryParse(tenant, out var tenantId);
            return(GetDataStore(tenant, module, consumer, new TenantQuotaController(tenantId, TenantManager)));
        }
Esempio n. 5
0
        public static IDataStore GetStorage(string configpath, string tenant, string module, IQuotaController controller)
        {
            var tenantId = -2;

            if (string.IsNullOrEmpty(tenant))
            {
                tenant = DefaultTenantName;
            }
            else
            {
                tenantId = Convert.ToInt32(tenant);
            }

            //Make tenant path
            tenant = TenantPath.CreatePath(tenant);

            var store = DataStoreCache.Get(tenant, module);

            if (store == null)
            {
                var sectionKey = "StorageConfigurationSection" + (configpath ?? "").Replace("\\", "").Replace("/", "");
                var section    = AscCache.Memory.Get <StorageConfigurationSection>(sectionKey);

                if (section == null)
                {
                    section = GetSection(configpath);
                    AscCache.Memory.Insert(sectionKey, section, DateTime.MaxValue);
                }

                if (section == null)
                {
                    throw new InvalidOperationException("config section not found");
                }

                var settings = StorageSettings.LoadForTenant(tenantId);

                store = GetStoreAndCache(tenant, module, section, settings.DataStoreConsumer, controller);
            }
            return(store);
        }