示例#1
0
        public decimal?calculatePriceMonth(UltraSSD ussd, int?iops, int?throoughput, int?vCPU = 0)
        {
            const int HoursMonth  = 730;
            decimal?  outputPrice = (ussd.priceSize * HoursMonth * ussd.size) + (ussd.priceIops * iops * HoursMonth) + (ussd.priceThroughput * throoughput * HoursMonth) + (ussd.priceVCpu * vCPU * HoursMonth);

            return(outputPrice);

            ;
        }
示例#2
0
        public async Task <List <UltraSSD> > GetUltraSSDs(string region = "us-east", string currency = "usd", DateTime?date = null)
        {
            List <UltraSSD>   usds = new List <UltraSSD>();
            excelAzureHelpers xhlp = new excelAzureHelpers(configuration);
            var response           = await client.GetAsync(xhlp.GetMdiskURL(currency, date));

            if (response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync();

                var     result             = JsonConvert.DeserializeObject <JObject>(content);
                JObject maxIopsPerGb       = (JObject)result["maxIopsPerGb"];
                JObject maxThroughputPerGb = (JObject)result["maxThroughputPerGb"];
                int     minIopsPerGb       = result["minIops"].Value <int>();
                int     minThroughput      = result["minThroughput"].Value <int>();

                try
                {
                    foreach (JObject item in result["ultraSizes"])
                    {
                        UltraSSD disk = new UltraSSD();
                        disk.name          = "ultrassd-u" + item["slug"].Value <string>();
                        disk.currency      = currency;
                        disk.size          = item["slug"].Value <int>();
                        disk.displayName   = "Ultra SSD " + item["displayName"].Value <string>();
                        disk.minIops       = minIopsPerGb;
                        disk.minThroughput = minThroughput;

                        disk.maxIops       = maxIopsPerGb.SelectToken(disk.size.ToString()).Value <int>();
                        disk.maxThroughput = maxThroughputPerGb.SelectToken(disk.size.ToString()).Value <int>();
                        disk.priceIops     = result["offers"]["ultrassd-iops"]["prices"][region]["value"].Value <decimal>();

                        disk.priceThroughput = result["offers"]["ultrassd-throughput"]["prices"][region]["value"].Value <decimal>();
                        disk.priceVCpu       = result["offers"]["ultrassd-vcpu"]["prices"][region]["value"].Value <decimal>();
                        disk.priceSize       = result["offers"]["ultrassd-stored"]["prices"][region]["value"].Value <decimal>();

                        usds.Add(disk);
                    }
                }
                catch (Exception)
                {
                    // Ignore Exceptions
                    //throw;
                }
            }
            return(usds);
        }