public HostedSolution(ConnectionStringSettings connectionString, string region)
 {
     tenantService = new DbTenantService(connectionString);
     userService = new DbUserService(connectionString);
     quotaService = new DbQuotaService(connectionString);
     tariffService = new TariffService(connectionString, quotaService, tenantService);
     clientTenantManager = new TenantManager(tenantService, quotaService, tariffService);
     Region = region ?? string.Empty;
     DbId = connectionString.Name;
 }
        private static void ConfigureCoreContextByDefault()
        {
            var cs = DbRegistry.GetConnectionString("core");
            if (cs == null)
            {
                throw new ConfigurationErrorsException("Can not configure CoreContext: connection string with name core not found.");
            }

            var tenantService = new CachedTenantService(new DbTenantService(cs));
            var userService = new CachedUserService(new DbUserService(cs));
            var azService = new CachedAzService(new DbAzService(cs));
            var quotaService = new CachedQuotaService(new DbQuotaService(cs));
            var subService = new CachedSubscriptionService(new DbSubscriptionService(cs));
            var tariffService = new TariffService(cs, quotaService, tenantService);

            Configuration = new CoreConfiguration(tenantService);
            TenantManager = new TenantManager(tenantService, quotaService, tariffService);
            PaymentManager = new PaymentManager(Configuration, quotaService, tariffService);
            UserManager = new UserManager(userService);
            Authentication = new AuthManager(userService);
            AuthorizationManager = new AuthorizationManager(azService);
            SubscriptionManager = new SubscriptionManager(subService);
        }
 public AuthorizationManager(IAzService service, TenantManager tenantManager)
 {
     this.service  = service;
     TenantManager = tenantManager;
 }
 public void SaveSection <T>(string sectionName, T section) where T : class
 {
     SaveSection(TenantManager.GetCurrentTenant().TenantId, sectionName, section);
 }
 public T GetSection <T>(string sectionName) where T : class
 {
     return(GetSection <T>(TenantManager.GetCurrentTenant().TenantId, sectionName));
 }
 public CoreConfiguration(CoreSettings coreSettings, TenantManager tenantManager, IConfiguration configuration)
 {
     CoreSettings  = coreSettings;
     TenantManager = tenantManager;
     Configuration = configuration;
 }
Exemple #7
0
 public SubscriptionManager(ISubscriptionService service, TenantManager tenantManager)
 {
     this.service  = service ?? throw new ArgumentNullException("subscriptionManager");
     TenantManager = tenantManager;
 }
 public Uri GetShoppingUri(int quotaId, bool forCurrentTenant = true, string affiliateId = null, string currency = null, string language = null, string customerId = null, string quantity = null)
 {
     return(tariffService.GetShoppingUri(forCurrentTenant ? TenantManager.GetCurrentTenant().TenantId : (int?)null, quotaId, affiliateId, currency, language, customerId, quantity));
 }
        public void ActivateKey(string key)
        {
            if (string.IsNullOrEmpty(key))
            {
                throw new ArgumentNullException("key");
            }

            var now       = DateTime.UtcNow;
            var actionUrl = "/partnerapi/ActivateKey?code=" + HttpUtility.UrlEncode(key) + "&portal=" + HttpUtility.UrlEncode(TenantManager.GetCurrentTenant().TenantAlias);

            using var webClient = new WebClient();
            webClient.Headers.Add("Authorization", GetPartnerAuthHeader(actionUrl));
            try
            {
                webClient.DownloadData(partnerUrl + actionUrl);
            }
            catch (WebException we)
            {
                var error = GetException(we);
                if (error != null)
                {
                    throw error;
                }
                throw;
            }
            tariffService.ClearCache(TenantManager.GetCurrentTenant().TenantId);

            var timeout = DateTime.UtcNow - now - TimeSpan.FromSeconds(5);

            if (TimeSpan.Zero < timeout)
            {
                // clear tenant cache
                Thread.Sleep(timeout);
            }
            TenantManager.GetTenant(TenantManager.GetCurrentTenant().TenantId);
        }