private static void AddCostTableHeaders( ref Table costTable, DocumentInfo documentInfo, string tableName) { // TODO: extract to extension method // TODO: refine cost table columns costTable.AddColumn("4cm"); costTable.AddColumn("4cm"); costTable.AddColumn("6cm"); costTable.AddColumn("2cm").Format.Alignment = ParagraphAlignment.Right; costTable.AddColumn("2cm").Format.Alignment = ParagraphAlignment.Right; var costResourceGroup = costTable.AddRow(); costResourceGroup.Cells[0].AddParagraph("Resource Group Name"); costResourceGroup.Cells[0].Format.Font.Bold = true; costResourceGroup.Cells[1].MergeRight = 3; documentInfo.AddParagraphWordWrap(costResourceGroup.Cells[1], tableName); var costProperties = costTable.AddRow(); costProperties.Format.Font.Bold = true; costProperties.Cells[0].AddParagraph("Name"); costProperties.Cells[1].AddParagraph("Category"); costProperties.Cells[2].AddParagraph("Meter Name"); costProperties.Cells[3].AddParagraph("Quantity").Format.Alignment = ParagraphAlignment.Left; costProperties.Cells[4].AddParagraph("Daily Cost").Format.Alignment = ParagraphAlignment.Left; }
private static Row AddCostTableRow( ref Table costTable, DocumentInfo documentInfo, RegionInfo regionInfo, CostEstimationDetail costEstimationDetail) { // TODO: extract to extension method // TODO: refine cost table columns var allupTableCostItem = costTable.AddRow(); documentInfo.AddParagraphWordWrap(allupTableCostItem.Cells[0], costEstimationDetail.ResourceName); var catergoryName = costEstimationDetail.MeterCategory; if (!string.IsNullOrEmpty(costEstimationDetail.MeterSubCategory)) { catergoryName += " - " + costEstimationDetail.MeterSubCategory; } allupTableCostItem.Cells[1].AddParagraph(catergoryName ?? "N/A"); allupTableCostItem.Cells[2].AddParagraph(costEstimationDetail?.MeterName ?? "N/A"); var quantity = costEstimationDetail.UsagesQuantity?.ToString("0.####", CultureInfo.InvariantCulture); allupTableCostItem.Cells[3].AddParagraph(quantity ?? "N/A"); allupTableCostItem.Cells[4].AddParagraph( ToCurrencyString(costEstimationDetail.EstimatedCost, regionInfo.CurrencySymbol)); return(allupTableCostItem); }
private static Section CreateAppendixServiceParityResultSection( ref DocumentInfo documentInfo, ServiceParityResult serviceParityResult, CostEstimationResult costEstimationResult) { // TODO: extract to extension method // TODO: move hard code string to resource file var appendixServiceParityResultSection = documentInfo.CreateSection(); var appendixServiceParityResultTitle = appendixServiceParityResultSection.AddParagraph("Service Parity", DocumentInfo.TitleStyleName); appendixServiceParityResultTitle.AddBookmark("ServiceParity"); // All parities if (serviceParityResult.Pass) { appendixServiceParityResultSection.AddParagraph( "There is no service failed in the parity rule check regarding this migration & expansion", DocumentInfo.TableDesStyleName); } else { appendixServiceParityResultSection.AddParagraph( "Below are the summary of all services failed in the parity rule check regarding this migration & expansion: ", DocumentInfo.TableDesStyleName); var detailsAll = serviceParityResult.Details.Where(d => d.Value.Pass == false).ToDictionary(i => i.Key, i => i.Value); // Group up parities by resource group foreach (var resourceGroup in costEstimationResult.DetailsByResourceGroup) { // ResourceGroup.Key is the name of the group if (resourceGroup.Value.Where(r => detailsAll.Keys.Contains(r.ResourceId)).Count() != 0) { var resourceGroupName = resourceGroup.Key; var groupNameTxt = appendixServiceParityResultSection.AddParagraph( "Resource Group: " + resourceGroupName, DocumentInfo.TableDesStyleName); } var parityTable = DocumentInfo.CreateTable(ref appendixServiceParityResultSection); parityTable.AddColumn("4cm"); // Rule name parityTable.AddColumn("2cm"); // Pass parityTable.AddColumn("12cm"); // Message // Check each resource in the group foreach (var resource in resourceGroup.Value) { if (detailsAll.Keys.Contains(resource.ResourceId) && detailsAll[resource.ResourceId].Pass == false) { // Resource name var parityResourceName = parityTable.AddRow(); parityResourceName.Cells[0].AddParagraph("Resource Name"); parityResourceName.Cells[0].Format.Font.Bold = true; parityResourceName.Cells[1].MergeRight = 1; parityResourceName.Cells[1].Column.Width = "14.5cm"; documentInfo.AddParagraphWordWrap(parityResourceName.Cells[1], resource.ResourceName); // Resource Id var parityResourceID = parityTable.AddRow(); parityResourceID.Cells[0].AddParagraph("Resource ID"); parityResourceID.Cells[0].Format.Font.Bold = true; parityResourceID.Cells[1].MergeRight = 1; parityResourceID.Cells[1].Column.Width = "14.5cm"; var cutMark = "providers"; var cut = resource.ResourceId.IndexOf(cutMark, StringComparison.OrdinalIgnoreCase) + cutMark.Length; var resourceID = cut == -1 ? resource.ResourceId : resource.ResourceId.Substring(cut, resource.ResourceId.Length - cut); documentInfo.AddParagraphWordWrap(parityResourceID.Cells[1], resourceID); var parityProperties = parityTable.AddRow(); parityResourceID.Cells[1].Column.Width = "2cm"; parityProperties.Format.Font.Bold = true; parityProperties.Cells[0].AddParagraph("RuleName"); parityProperties.Cells[1].AddParagraph("Pass"); parityProperties.Cells[2].AddParagraph("Message"); // Check each parity result for the resource foreach (var ruleCheck in detailsAll[resource.ResourceId].Details.Where(d => d.Pass == false)) { var ruleCheckRow = parityTable.AddRow(); documentInfo.AddParagraphWordWrap(ruleCheckRow.Cells[0], ruleCheck.Brief); documentInfo.AddParagraphWordWrap(ruleCheckRow.Cells[1], "N"); documentInfo.AddParagraphWordWrap(ruleCheckRow.Cells[2], ruleCheck.Message); } } } } } return(appendixServiceParityResultSection); }
private static Section CreateMigrationSummarySection( ref DocumentInfo documentInfo, RegionInfo regionInfo, CostEstimationResult costEstimationResult, ServiceParityResult serviceParityResult) { // TODO: extract to extension method // TODO: move hard code string to resource file var subscriptionName = costEstimationResult.SubscriptionName; var resourceGroupsCount = costEstimationResult.ResourceGroupsCount; var resourcesCount = costEstimationResult.ResourcesCount; var migrationSummarySection = documentInfo.CreateSection(); var summaryTitle = migrationSummarySection.AddParagraph( "Assessment Summary for " + subscriptionName, DocumentInfo.TitleStyleName); summaryTitle.AddBookmark("MigrationSummary" + subscriptionName); migrationSummarySection.AddParagraph( "Based on user selection and configuration, here is summary about subscription " + subscriptionName + ":", DocumentInfo.TableDesStyleName); var shortSummary = DocumentInfo.CreateTable(ref migrationSummarySection); var summaryTitleColumn = shortSummary.AddColumn("8cm"); summaryTitleColumn.Format.Font = DocumentInfo.ContentFontBold.Clone(); shortSummary.AddColumn("8cm"); var shortSummaryRow = shortSummary.AddRow(); shortSummaryRow.Cells[0].AddParagraph("Reference Environment"); shortSummaryRow.Cells[1].AddParagraph("Microsoft Azure"); shortSummaryRow = shortSummary.AddRow(); shortSummaryRow.Cells[0].AddParagraph("Reference Subscription"); documentInfo.AddParagraphWordWrap(shortSummaryRow.Cells[1], subscriptionName); shortSummaryRow = shortSummary.AddRow(); shortSummaryRow.Cells[0].AddParagraph("Target Environment"); shortSummaryRow.Cells[1].AddParagraph(regionInfo.TargetRegionName); shortSummaryRow = shortSummary.AddRow(); shortSummaryRow.Cells[0].AddParagraph("Number of Resource Group"); shortSummaryRow.Cells[1].AddParagraph(resourceGroupsCount.ToString(CultureInfo.InvariantCulture)); shortSummaryRow = shortSummary.AddRow(); shortSummaryRow.Cells[0].AddParagraph("Number of Resources"); shortSummaryRow.Cells[1].AddParagraph(resourcesCount.ToString(CultureInfo.InvariantCulture)); shortSummaryRow = shortSummary.AddRow(); shortSummaryRow.Cells[0].AddParagraph("Number of Resources Failed in Parity Rule Check/Number of All Resources"); var detailPassFailed = serviceParityResult.Details.Where(d => !d.Value.Pass); var resourceNotPassedCount = costEstimationResult.Details.Where(c => detailPassFailed.Any(d => d.Key == c.ResourceId)).GroupBy(g => g.ResourceId).Count(); shortSummaryRow.Cells[1].AddParagraph(FormattableString.Invariant($"{resourceNotPassedCount}/{resourcesCount}")); shortSummaryRow = shortSummary.AddRow(); shortSummaryRow.Cells[0].AddParagraph("Target Region"); shortSummaryRow.Cells[1].AddParagraph(costEstimationResult.TargetRegion); return(migrationSummarySection); }
private static Section CreateAppendixResouceListSection( ref DocumentInfo documentInfo, RegionInfo regionInfo, CostEstimationResult costEstimationResult) { // TODO: extract to extension method // TODO: move hard code string to resource file. var subscriptionName = costEstimationResult.SubscriptionName; var appendixResouceListSection = documentInfo.CreateSection(); var appendixResourceListTitle = appendixResouceListSection.AddParagraph( "Full Resource List For " + subscriptionName, DocumentInfo.TitleStyleName); appendixResourceListTitle.AddBookmark("AppendixResourceList" + subscriptionName); // Resource List by Resource Group appendixResouceListSection.AddParagraph( "Here is the full resource list in reference subscription related to this migration: ", DocumentInfo.TableDesStyleName); var locationMap = costEstimationResult.LocationMap[costEstimationResult.SubscriptionId]; foreach (var kvp in costEstimationResult.DetailsByResourceGroup) { var resourceTable = DocumentInfo.CreateTable(ref appendixResouceListSection); resourceTable.AddColumn("5cm"); resourceTable.AddColumn("7cm"); resourceTable.AddColumn("4.5cm"); var resourceGroupName = resourceTable.AddRow(); resourceGroupName.Cells[0].AddParagraph("Resource Group Name"); resourceGroupName.Cells[0].Format.Font.Bold = true; resourceGroupName.Cells[1].MergeRight = 1; documentInfo.AddParagraphWordWrap(resourceGroupName.Cells[1], kvp.Key); var resourceProperties = resourceTable.AddRow(); resourceProperties.Format.Font.Bold = true; resourceProperties.Cells[0].AddParagraph("Name"); resourceProperties.Cells[1].AddParagraph("Type"); resourceProperties.Cells[2].AddParagraph("Location"); foreach (var detail in kvp.Value) { var resourceRow = resourceTable.AddRow(); documentInfo.AddParagraphWordWrap(resourceRow.Cells[0], detail.ResourceName); documentInfo.AddParagraphWordWrap(resourceRow.Cells[1], detail.ResourceType); if (locationMap.TryGetValue(detail.Location, out var locationDisplayName)) { documentInfo.AddParagraphWordWrap(resourceRow.Cells[2], locationDisplayName); } else { documentInfo.AddParagraphWordWrap(resourceRow.Cells[2], detail.Location); } } appendixResouceListSection.AddParagraph(string.Empty); } return(appendixResouceListSection); }