Пример #1
0
        public async Task <string> GetStorageKey()
        {
            string           signedInUserUniqueId = ClaimsPrincipal.Current.SignedInUserName();
            CacheUserDetails cud = MemoryCacher.GetValue(signedInUserUniqueId) as CacheUserDetails;

            if (cud == null)
            {
                cud = await GetCurrentUserData();

                MemoryCacher.Add(signedInUserUniqueId, cud, DateTime.Now.AddMinutes(20));
            }
            return(cud.StorageKey);
        }
Пример #2
0
        private static void CacheDetails(string subscriptionId, string storageKey, string storageName, string organizationId)
        {
            string signedInUserUniqueId = ClaimsPrincipal.Current.SignedInUserName();

            if (!string.IsNullOrEmpty(storageName) && !string.IsNullOrEmpty(storageKey))
            {
                CacheUserDetails cud = new CacheUserDetails();
                cud.SubscriptionId = subscriptionId;
                cud.StorageName    = storageName;
                cud.OrganizationId = organizationId;
                cud.StorageKey     = storageKey;
                MemoryCacher.Delete(signedInUserUniqueId);
                MemoryCacher.Add(signedInUserUniqueId, cud, DateTime.Now.AddMinutes(15));
            }
        }
Пример #3
0
        private async Task <CacheUserDetails> GetCurrentUserData()
        {
            var cacheUserDetails = new CacheUserDetails();
            var organizationId   = ClaimsPrincipal.Current.TenantId();
            var subscriptions    = this.coreRepository.GetSubscriptionListByOrgId(organizationId);
            var subscription     = subscriptions.Where(x => x.IsConnected == true).FirstOrDefault();

            if (subscription != null)
            {
                cacheUserDetails.SubscriptionId = subscription.Id;
                cacheUserDetails.OrganizationId = subscription.OrganizationId;
                cacheUserDetails.StorageName    = subscription.StorageName;
                //cacheUserDetails.StorageKey = AzureResourceManagerUtil.GetStorageAccountKeysUsingResource(subscription.Id, subscription.OrganizationId, subscription.StorageName);
                cacheUserDetails.StorageKey = await AzureResourceManagerUtil.GetStorageAccountKeysArm(subscription.Id, subscription.StorageName);
            }

            return(cacheUserDetails);
        }