Пример #1
0
        private static void MakeCostEstimationResourceGroupTable(HtmlTextWriter w,
                                                                 RegionInfo regionInfo,
                                                                 CostEstimationResult costEstimationResult)
        {
            foreach (var kvp in costEstimationResult.DetailsByResourceGroup)
            {
                if (!kvp.Value.Any(d => d.EstimatedCost.HasValue))
                {
                    continue;
                }

                #region Table
                w.AddAttribute(HtmlTextWriterAttribute.Class, "table table-bordered");
                w.RenderBeginTag(HtmlTextWriterTag.Table);

                #region Tbody
                w.RenderBeginTag(HtmlTextWriterTag.Tbody);

                #region Resource Group Name
                w.RenderBeginTag(HtmlTextWriterTag.Tr);
                w.AddAttribute(HtmlTextWriterAttribute.Scope, "row");
                w.RenderBeginTag(HtmlTextWriterTag.Th);
                w.Write("Resource Group Name");
                w.RenderEndTag();
                w.AddAttribute(HtmlTextWriterAttribute.Colspan, "4");
                w.RenderBeginTag(HtmlTextWriterTag.Td);
                w.Write(kvp.Key);
                w.RenderEndTag();
                w.RenderEndTag();
                #endregion Resource Group Name

                #region Head for Name Category MeterName Quantity DailyCost
                w.RenderBeginTag(HtmlTextWriterTag.Tr);
                w.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                w.AddAttribute(HtmlTextWriterAttribute.Style, "width:20%");
                w.RenderBeginTag(HtmlTextWriterTag.Th);
                w.Write("Name");
                w.RenderEndTag();

                w.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                w.AddAttribute(HtmlTextWriterAttribute.Style, "width:20%");
                w.RenderBeginTag(HtmlTextWriterTag.Th);
                w.Write("Category");
                w.RenderEndTag();

                w.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                w.AddAttribute(HtmlTextWriterAttribute.Style, "width:20%");
                w.RenderBeginTag(HtmlTextWriterTag.Th);
                w.Write("Meter Name");
                w.RenderEndTag();

                w.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                w.AddAttribute(HtmlTextWriterAttribute.Style, "width:20%");
                w.RenderBeginTag(HtmlTextWriterTag.Th);
                w.Write("Quantity");
                w.RenderEndTag();

                w.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                w.AddAttribute(HtmlTextWriterAttribute.Style, "width:20%");
                w.RenderBeginTag(HtmlTextWriterTag.Th);
                w.Write("Daily Cost");
                w.RenderEndTag();

                w.RenderEndTag();
                #endregion Head for Name Category MeterName Quantity DailyCost

                #region Data for Name Category MeterName Quantity DailyCost
                foreach (var detail in kvp.Value.Where(d => d.EstimatedCost.HasValue))
                {
                    w.RenderBeginTag(HtmlTextWriterTag.Tr);

                    MakeCostEstimationResouceGroupTableRow(w, detail, regionInfo);

                    w.RenderEndTag();
                }

                foreach (var detail in kvp.Value.Where(d => !d.EstimatedCost.HasValue))
                {
                    w.RenderBeginTag(HtmlTextWriterTag.Tr);

                    MakeCostEstimationResouceGroupTableRow(w, detail, regionInfo, true);

                    w.RenderEndTag();
                }

                #endregion Data for Name Category MeterName Quantity DailyCost

                w.RenderEndTag();
                #endregion Tbody

                w.RenderEndTag();
                #endregion Table
            }
        }
Пример #2
0
        private static void MakeFullResourceList(HtmlTextWriter w,
                                                 RegionInfo regionInfo,
                                                 CostEstimationResult costEstimationResult)
        {
            MakeHeader(w, "Full Resource List for " + costEstimationResult.SubscriptionName, "FullResourceList");
            MakeParagraph(w, @"Here is the full resource list in reference subscription related to this migration:");

            var locationMap = costEstimationResult.LocationMap[costEstimationResult.SubscriptionId];

            foreach (var kvp in costEstimationResult.DetailsByResourceGroup)
            {
                #region Table
                w.AddAttribute(HtmlTextWriterAttribute.Class, "table table-bordered");
                w.RenderBeginTag(HtmlTextWriterTag.Table);

                #region Tbody
                w.RenderBeginTag(HtmlTextWriterTag.Tbody);

                #region Resource Group Name
                w.RenderBeginTag(HtmlTextWriterTag.Tr);
                w.AddAttribute(HtmlTextWriterAttribute.Scope, "row");
                w.RenderBeginTag(HtmlTextWriterTag.Th);
                w.Write("Resource Group Name");
                w.RenderEndTag();
                w.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
                w.RenderBeginTag(HtmlTextWriterTag.Td);
                w.Write(kvp.Key);
                w.RenderEndTag();
                w.RenderEndTag();
                #endregion Resource Group Name

                #region Head for Name Type Location
                w.RenderBeginTag(HtmlTextWriterTag.Tr);
                w.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                w.AddAttribute(HtmlTextWriterAttribute.Style, "width:30%");
                w.RenderBeginTag(HtmlTextWriterTag.Th);
                w.Write("Name");
                w.RenderEndTag();

                w.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                w.AddAttribute(HtmlTextWriterAttribute.Style, "width:55%");
                w.RenderBeginTag(HtmlTextWriterTag.Th);
                w.Write("Type");
                w.RenderEndTag();

                w.AddAttribute(HtmlTextWriterAttribute.Scope, "col");
                w.AddAttribute(HtmlTextWriterAttribute.Style, "width:15%");
                w.RenderBeginTag(HtmlTextWriterTag.Th);
                w.Write("Location");
                w.RenderEndTag();

                w.RenderEndTag();
                #endregion Head for Name Type Location

                #region Data for Name Type Location
                foreach (var detail in kvp.Value)
                {
                    #region Row
                    w.RenderBeginTag(HtmlTextWriterTag.Tr);

                    #region Name
                    w.RenderBeginTag(HtmlTextWriterTag.Td);
                    w.Write(detail.ResourceName);
                    w.RenderEndTag();
                    #endregion Name

                    #region Type
                    w.RenderBeginTag(HtmlTextWriterTag.Td);
                    w.Write(detail.ResourceType);
                    w.RenderEndTag();
                    #endregion Type

                    #region Location
                    w.RenderBeginTag(HtmlTextWriterTag.Td);
                    if (locationMap.TryGetValue(detail.Location, out var locationDisplayName))
                    {
                        w.Write(locationDisplayName);
                    }
                    else
                    {
                        w.Write(detail.Location);
                    }
                    w.RenderEndTag();
                    #endregion Location

                    w.RenderEndTag();
                    #endregion Row
                }
                #endregion Data for Name Type Location

                w.RenderEndTag();
                #endregion Tbody

                w.RenderEndTag();
                #endregion Table
            }
        }
Пример #3
0
        private static void MakeCostEstimationSummaryTable(HtmlTextWriter w,
                                                           RegionInfo regionInfo,
                                                           CostEstimationResult costEstimationResult)
        {
            #region Table
            w.AddAttribute(HtmlTextWriterAttribute.Class, "table table-bordered");
            w.RenderBeginTag(HtmlTextWriterTag.Table);

            #region Tbody
            w.RenderBeginTag(HtmlTextWriterTag.Tbody);

            #region Reference Environment
            MakeKeyValueRow(w, "Reference Environment", "Microsoft Azure");
            #endregion Reference Environment

            #region Reference Subscription
            MakeKeyValueRow(w, "Reference Subscription", costEstimationResult.SubscriptionName);
            #endregion Reference Subscription

            #region Target Environment
            MakeKeyValueRow(w, "Target Environment", regionInfo.TargetRegionName);
            #endregion Target Environment

            #region Usage Collection Period
            MakeKeyValueRow(w, "Usage Collection Period", FormattableString.Invariant($"{costEstimationResult.StartTime:r} - {costEstimationResult.EndTime:r}"));
            #endregion Usage Collection Period

            #region Target Price Base
            MakeKeyValueRow(w, "Target Price Base", "List Price");
            #endregion Target Price Base

            #region Currency
            MakeKeyValueRow(w, "Currency", regionInfo.CurrencyUnit);
            #endregion Currency

            #region Currency Format
            MakeKeyValueRow(w, "Currency Format", regionInfo.CurrencyCulture.EnglishName);
            #endregion Currency Format

            #region Total Cost in Period for Available Resources
            if (!costEstimationResult.Details.Any())
            {
                MakeKeyValueRow(w, "Total Cost in Period for Available Resources", "N/A");
            }
            else
            {
                decimal totalCost = 0;
                foreach (var kvp in costEstimationResult.DetailsByResourceGroup)
                {
                    if (!kvp.Value.Any(d => d.EstimatedCost.HasValue))
                    {
                        continue;
                    }
                    foreach (var detail in kvp.Value.Where(d => d.EstimatedCost.HasValue))
                    {
                        totalCost += detail.EstimatedCost.Value;
                    }
                }
                MakeKeyValueRow(w, "Total Cost in Period for Available Resources", ToCurrencyString(totalCost, regionInfo.CurrencySymbol));
            }
            #endregion Total Cost in Period for Available Resources

            w.RenderEndTag();
            #endregion Tbody

            w.RenderEndTag();
            #endregion Table
        }