Ejemplo n.º 1
0
        private static string GetCapacityUsed(string authToken, string accountName)
        {
            string capacityUsed = string.Empty;
            CloudStorageAccount storageAccount = GetUserAccount(authToken, accountName);

            if (storageAccount != null)
            {
                CloudAnalyticsClient        storageAnalytics = storageAccount.CreateCloudAnalyticsClient();
                TableQuery <CapacityEntity> capacityQuery    = storageAnalytics.CreateCapacityQuery();
                IQueryable <CapacityEntity> capacityData     = capacityQuery.Where(x => x.RowKey == Constant.Storage.Table.Key.CapacityData);
                try
                {
                    List <CapacityEntity> capacities = capacityData.ToList();
                    if (capacities.Count == 0)
                    {
                        capacityUsed = Storage.MapByteCount(0);
                    }
                    else
                    {
                        capacities.Sort(OrderByLatest);
                        long latestCapacity = capacities.First().Capacity;
                        capacityUsed = Storage.MapByteCount(latestCapacity);
                    }
                }
                catch
                {
                    capacityUsed = Constant.Storage.NotAvailable;
                }
            }
            return(capacityUsed);
        }
Ejemplo n.º 2
0
        protected internal virtual CloudAnalyticsClient CreateAnalyticsClient(IKernel kernel)
        {
            if (kernel == null)
            {
                throw new ArgumentNullException(nameof(kernel));
            }

            CloudStorageAccount  account = GetAccount(kernel);
            CloudAnalyticsClient client  = account.CreateCloudAnalyticsClient();

            return(client);
        }