예제 #1
0
        private List <ViewModels.Home.CalculateResultDetail> Calculate(StorageRedundancy redundancy, StorageTemperature temperature, ViewModels.Home.CalculateArgs args)
        {
            var results             = new List <ViewModels.Home.CalculateResultDetail>();
            var atRestPrices        = AtRestPrice.GetDefault();
            var otherPrices         = OtherPrice.GetDefault();
            var mainTransactionRate = otherPrices.FirstOrDefault(x => x.StorageRedundancy == redundancy &&
                                                                 x.StorageTemperature == temperature &&
                                                                 x.PriceType == OtherPriceType.BlobBlockPutListCreateContainer);
            var otherTransactionRate = otherPrices.FirstOrDefault(x => x.StorageRedundancy == redundancy &&
                                                                  x.StorageTemperature == temperature &&
                                                                  x.PriceType == OtherPriceType.BlobBlockOther);
            var retreivedRate = otherPrices.FirstOrDefault(x => x.StorageRedundancy == redundancy &&
                                                           x.StorageTemperature == temperature &&
                                                           x.PriceType == OtherPriceType.DataRetrieval);
            var writeRate = otherPrices.FirstOrDefault(x => x.StorageRedundancy == redundancy &&
                                                       x.StorageTemperature == temperature &&
                                                       x.PriceType == OtherPriceType.DataWrite);
            var replicationRate = otherPrices.FirstOrDefault(x => x.StorageRedundancy == redundancy &&
                                                             x.StorageTemperature == temperature &&
                                                             x.PriceType == OtherPriceType.GeoReplication);

            for (int i = 0; i <= args.MonthsToProject; i++)
            {
                results.Add(Calculate(redundancy, temperature, args, i, atRestPrices, mainTransactionRate, otherTransactionRate, retreivedRate, writeRate, replicationRate));
            }

            return(results);
        }
예제 #2
0
        private ViewModels.Home.CalculateResultSummary Calculate(StorageRedundancy redundancy, StorageTemperature temperature, List <ViewModels.Home.CalculateResultDetail> details)
        {
            var tmp = new ViewModels.Home.CalculateResultSummary();

            tmp.StorageRedundancy  = redundancy;
            tmp.StorageTemperature = temperature;
            tmp.TotalGB            = details.Sum(x => x.GbStored);
            tmp.TotalPrice         = details.Sum(x => x.TotalPrice);
            tmp.AveragePricePerGB  = tmp.TotalPrice / tmp.TotalGB;
            tmp.AveragePricePerTB  = tmp.AveragePricePerGB * 1000;
            return(tmp);
        }
예제 #3
0
        private ViewModels.Home.CalculateResultDetail Calculate(StorageRedundancy redundancy, StorageTemperature temperature, ViewModels.Home.CalculateArgs args, int month,
                                                                List <AtRestPrice> atRestPrices, OtherPrice mainTransactionRate, OtherPrice otherTransactionRate, OtherPrice retreivedRate, OtherPrice writeRate, OtherPrice replicationRate)
        {
            var tmp = new ViewModels.Home.CalculateResultDetail();

            tmp.Month    = month;
            tmp.GbStored = (args.StartingStorage * 1000) + (month * args.MonthlyGrowthStorage * 1000);

            if (month == 0)
            {
                tmp.GbWritten = (args.StartingStorage * 1000);
            }
            else
            {
                tmp.GbWritten = (args.MonthlyGrowthStorage * 1000);
            }

            tmp.GbRetreived = tmp.GbStored * args.PctStorageRetrieval;

            var price = atRestPrices.Where(x => x.StorageRedundancy == redundancy &&
                                           x.StorageTemperature == temperature &&
                                           x.SizeCutoff > tmp.GbStored)
                        .OrderByDescending(x => x.Amount)
                        .FirstOrDefault();

            //This allows for sizing storage over 4 PBs
            if (price == null)
            {
                price = atRestPrices.Where(x => x.StorageRedundancy == redundancy &&
                                           x.StorageTemperature == temperature)
                        .OrderBy(x => x.Amount)
                        .FirstOrDefault();
            }

            tmp.PricePerGb       = price.Amount;
            tmp.StoredPrice      = tmp.GbStored * tmp.PricePerGb;
            tmp.MainTransPrice   = args.MainTransactions * mainTransactionRate.Amount;
            tmp.OtherTransPrice  = args.OtherTransactions * otherTransactionRate.Amount;
            tmp.PriceRetreived   = tmp.GbRetreived * retreivedRate.Amount;
            tmp.PriceWrites      = tmp.GbWritten * writeRate.Amount;
            tmp.PriceReplication = tmp.GbWritten * replicationRate.Amount;
            tmp.TotalPrice       = tmp.StoredPrice + tmp.MainTransPrice + tmp.OtherTransPrice + tmp.PriceRetreived + tmp.PriceWrites + tmp.PriceReplication;

            return(tmp);
        }