Пример #1
0
        private static void GenerateUnreferencedAssembliesPage(Worksheet missingAssembliesPage, ReportingResult analysisResult)
        {
            List <string> missingAssembliesPageHeader = new List <string>()
            {
                LocalizedStrings.AssemblyHeader, LocalizedStrings.UsedBy, LocalizedStrings.MissingAssemblyStatus
            };
            int detailsRows = 0;

            missingAssembliesPage.AddRow(missingAssembliesPageHeader.ToArray());
            detailsRows++;

            var unresolvedAssembliesMap = analysisResult.GetUnresolvedAssemblies();

            foreach (var unresolvedAssemblyPair in unresolvedAssembliesMap.OrderBy(asm => asm.Key))
            {
                if (unresolvedAssemblyPair.Value.Any())
                {
                    foreach (var usedIn in unresolvedAssemblyPair.Value)
                    {
                        missingAssembliesPage.AddRow(unresolvedAssemblyPair.Key, usedIn, LocalizedStrings.UnresolvedUsedAssembly);
                        detailsRows++;
                    }
                }
                else
                {
                    missingAssembliesPage.AddRow(unresolvedAssemblyPair.Key, String.Empty, LocalizedStrings.UnresolvedUsedAssembly);
                }
            }

            // Generate the pretty table
            missingAssembliesPage.AddTable(1, detailsRows, 1, missingAssembliesPageHeader.ToArray());
            missingAssembliesPage.AddColumnWidth(40, 40, 30);
        }
Пример #2
0
 void UndoFillRangeTables()
 {
     if ((_cachedTables != null) && (_cachedTables.Count > 0))
     {
         foreach (SheetTable table in _cachedTables)
         {
             CellRange range       = table.Range;
             int       row         = range.Row;
             int       column      = range.Column;
             int       rowCount    = range.RowCount;
             int       columnCount = range.ColumnCount;
             if (!table.ShowHeader)
             {
                 row--;
                 rowCount++;
             }
             if (table.ShowFooter)
             {
                 rowCount--;
             }
             SheetTable table2 = _workSheet.AddTable(table.Name, row, column, rowCount, columnCount, table.Style);
             table2.BandedColumns        = table.BandedColumns;
             table2.BandedRows           = table.BandedRows;
             table2.HighlightFirstColumn = table.HighlightFirstColumn;
             table2.HighlightLastColumn  = table.HighlightLastColumn;
             table2.ShowFooter           = table.ShowFooter;
             table2.ShowHeader           = table.ShowHeader;
         }
     }
 }
Пример #3
0
        private void GenerateSummaryPage(Worksheet summaryPage, ReportingResult analysisResult)
        {
            var targetNames = _mapper.GetTargetNames(analysisResult.Targets, alwaysIncludeVersion: true);

            // This is the submission id
            summaryPage.AddRow(LocalizedStrings.SubmissionId, AddSubmissionLink(analysisResult.SubmissionId));

            // This is the description of the app
            summaryPage.AddRow(LocalizedStrings.Description, _description);

            // This is the target list that was submitted to the service.
            summaryPage.AddRow(LocalizedStrings.Targets, string.Join(",", targetNames));

            // Add an empty row.
            summaryPage.AddRow();

            if (analysisResult.GetAssemblyUsageInfo().Any())
            {
                var assemblyInfoHeader = new List <string> {
                    LocalizedStrings.AssemblyHeader, "Target Framework"
                };
                assemblyInfoHeader.AddRange(targetNames);
                int tableRowCount = 0;

                summaryPage.AddRow(assemblyInfoHeader.ToArray());
                tableRowCount++;

                foreach (var item in analysisResult.GetAssemblyUsageInfo().OrderBy(a => a.SourceAssembly.AssemblyIdentity))
                {
                    var summaryData = new List <object>()
                    {
                        analysisResult.GetNameForAssemblyInfo(item.SourceAssembly), item.SourceAssembly.TargetFrameworkMoniker ?? string.Empty
                    };

                    // TODO: figure out how to add formatting to cells to show percentages.
                    summaryData.AddRange(item.UsageData.Select(pui => (object)Math.Round(pui.PortabilityIndex * 100.0, 2)));
                    summaryPage.AddRow(summaryData.ToArray());
                    tableRowCount++;
                }

                summaryPage.AddConditionalFormatting(6, analysisResult.GetAssemblyUsageInfo().Count(), 3, analysisResult.Targets.Count);
                summaryPage.AddTable(5, tableRowCount, 1, assemblyInfoHeader.ToArray());

                var columnWidths = new List <double>
                {
                    ColumnWidths.SummaryPage.AssemblyName,
                    ColumnWidths.SummaryPage.TFM
                };

                columnWidths.AddRange(Enumerable.Repeat(ColumnWidths.Targets, analysisResult.Targets.Count)); // Targets

                summaryPage.AddColumnWidth(columnWidths);
            }

            summaryPage.AddRow();
            summaryPage.AddRow(LocalizedStrings.CatalogLastUpdated, _catalogLastUpdated.ToString("D", CultureInfo.CurrentCulture));
            summaryPage.AddRow(LocalizedStrings.HowToReadTheExcelTable);
        }
        private void GenerateBreakingChangesPage(Worksheet worksheet, IEnumerable <BreakingChangeDependency> breakingChanges)
        {
            var row = 1;

            var header = new[]
            {
                "Break ID",
                "API",
                "Assembly",
                "Title",
                "Scope",
                "Quirked",
                "Requires Retargeting",
                "Build Time",
                "VersionBroken",
                "Version Fixed",
                "Details",
                "Suggestion",
                "Analyzer Status",
                "Link",
                "Investigated"
            };

            worksheet.AddRow(header);

            foreach (var breakingChange in breakingChanges)
            {
                var rowContent = new object[]
                {
                    breakingChange.Break.Id,
                    breakingChange.Member.MemberDocId,
                    breakingChange.DependantAssembly.ToString(),
                    breakingChange.Break.Title,
                    breakingChange.Break.ImpactScope.ToString(),
                    breakingChange.Break.IsQuirked.ToString((IFormatProvider)CultureInfo.CurrentUICulture),
                    breakingChange.Break.IsRetargeting.ToString((IFormatProvider)CultureInfo.CurrentUICulture),
                    breakingChange.Break.IsBuildTime.ToString((IFormatProvider)CultureInfo.CurrentUICulture),
                    breakingChange.Break.VersionBroken.ToString(),
                    breakingChange.Break.VersionFixed?.ToString() ?? string.Empty,
                    breakingChange.Break.Details,
                    breakingChange.Break.Suggestion,
                    breakingChange.Break.SourceAnalyzerStatus.ToString(),
                    string.IsNullOrWhiteSpace(breakingChange.Break.Link) ? "No link" : CreateHyperlink("Link", breakingChange.Break.Link),
                    string.Empty
                };

                worksheet.AddRow(rowContent);
                row++;
            }

            worksheet.AddTable(1, row, 1, header);
            worksheet.AddColumnWidth(10, 10, 30, 30, 20, 10, 10, 10, 10, 30, 30, 10, 10, 10);
        }
        private void GenerateNuGetInfoPage(Worksheet page, ReportingResult analysisResult)
        {
            bool showAssemblyName = analysisResult.NuGetPackages.Any(p => !string.IsNullOrEmpty(p.AssemblyInfo));

            var headerList = new List <string>()
            {
                LocalizedStrings.PackageIdHeader
            };

            headerList.AddRange(_mapper.GetTargetNames(analysisResult.Targets));

            if (showAssemblyName)
            {
                headerList.Add(LocalizedStrings.AssemblyHeader);
            }

            var header = headerList.ToArray();

            page.AddRow(header);

            int rowCount = 1;

            foreach (var nugetInfo in analysisResult.NuGetPackages)
            {
                var rowContent = new List <string>()
                {
                    nugetInfo.PackageId
                };

                foreach (var target in analysisResult.Targets)
                {
                    var supported = nugetInfo.SupportedVersions.TryGetValue(target, out var version) ? version : LocalizedStrings.NotSupported;
                    rowContent.Add(supported);
                }

                if (showAssemblyName && nugetInfo.AssemblyInfo != null)
                {
                    rowContent.Add(nugetInfo.AssemblyInfo);
                }

                page.AddRow(rowContent.ToArray());
                rowCount++;
            }

            page.AddTable(1, rowCount, 1, header.ToArray());
            page.AddColumnWidth(70, 40, 30, 30);
        }
Пример #6
0
        /// <summary>
        /// 添加表格
        /// </summary>
        /// <param name="p_range"></param>
        SheetTable AddSheetTable(CellRange p_range)
        {
            Worksheet sheet  = _excel.ActiveSheet;
            int       maxRow = p_range.Row + p_range.RowCount;
            int       maxCol = p_range.Column + p_range.ColumnCount;

            for (int i = p_range.Row; i < maxRow; i++)
            {
                for (int j = p_range.Column; j < maxCol; j++)
                {
                    sheet[i, j].StyleName = "";
                }
            }
            SheetTable table = sheet.AddTable("table" + Kit.NewGuid, p_range.Row, p_range.Column, p_range.RowCount, p_range.ColumnCount, TableStyles.Light21);

            sheet.SetActiveCell(0, 0, true);
            return(table);
        }
        private static void GenerateOrderPage(Worksheet page, AnalyzeResponse response)
        {
            page.AddRow(new[] { LocalizedStrings.RecommendedOrderDetails });
            page.AddRow();

            var header = new[] { LocalizedStrings.AssemblyHeader };

            page.AddRow(header);

            int detailsRows = 1;

            foreach (var assembly in response.RecommendedOrder)
            {
                page.AddRow(assembly);
                detailsRows++;
            }

            // Generate the pretty table
            page.AddTable(3, detailsRows, 1, header.ToArray());
            page.AddColumnWidth(100);
        }
        private static void GenerateUnreferencedAssembliesPage(Worksheet missingAssembliesPage, AnalyzeResponse response)
        {
            var missingAssembliesPageHeader = new[] { LocalizedStrings.AssemblyHeader, LocalizedStrings.UsedBy, LocalizedStrings.UnresolvedAssemblyStatus };
            int detailsRows = 0;

            missingAssembliesPage.AddRow(missingAssembliesPageHeader.ToArray());
            detailsRows++;

            var unresolvedAssembliesMap = response.ReportingResult.GetUnresolvedAssemblies();

            foreach (var unresolvedAssemblyPair in unresolvedAssembliesMap.OrderBy(asm => asm.Key))
            {
                if (unresolvedAssemblyPair.Value.Any())
                {
                    foreach (var usedIn in unresolvedAssemblyPair.Value)
                    {
                        missingAssembliesPage.AddRow(unresolvedAssemblyPair.Key, usedIn, LocalizedStrings.UnresolvedUsedAssembly);
                        detailsRows++;
                    }
                }
                else
                {
                    missingAssembliesPage.AddRow(unresolvedAssemblyPair.Key, string.Empty, LocalizedStrings.UnresolvedUsedAssembly);
                    detailsRows++;
                }
            }

            if (response.Request.NonUserAssemblies != null)
            {
                foreach (var unresolvedAssemblyPair in response.Request.NonUserAssemblies.OrderBy(asm => asm.AssemblyIdentity))
                {
                    missingAssembliesPage.AddRow(unresolvedAssemblyPair.AssemblyIdentity, string.Empty, LocalizedStrings.SkippedAssembly);
                    detailsRows++;
                }
            }

            // Generate the pretty table
            missingAssembliesPage.AddTable(1, detailsRows, 1, missingAssembliesPageHeader);
            missingAssembliesPage.AddColumnWidth(40, 40, 30);
        }
        private void GenerateExceptionsPage(Worksheet worksheet, IList <ExceptionInfo> throwingMembers, IList <FrameworkName> targets)
        {
            var exceptionsPageHeader = new List <string>()
            {
                LocalizedStrings.AssemblyHeader, LocalizedStrings.TargetMemberHeader, LocalizedStrings.ExceptionColumnHeader
            };

            exceptionsPageHeader.AddRange(_mapper.GetTargetNames(targets, alwaysIncludeVersion: true));

            int exceptionRows = 0;

            worksheet.AddRow(exceptionsPageHeader.ToArray());
            exceptionRows++;

            foreach (var member in throwingMembers.OrderBy(info => info.MemberDocId))
            {
                var exceptionsByType = member.ExceptionsThrown.GroupBy(exc => exc.Exception, (exception, exceptionList) => new { Key = exception, exceptions = exceptionList });
                foreach (var grouping in exceptionsByType)
                {
                    var rowContent = new List <object> {
                        member.DefinedInAssemblyIdentity, member.MemberDocId, grouping.Key
                    };
                    var groupsByTarget = grouping.exceptions.GroupBy(exc => new FrameworkName(exc.Platform, Version.Parse(exc.Version)), (framework, exceptionList) => new { Key = framework, exceptionsByPlatform = exceptionList });
                    foreach (var target in targets)
                    {
                        bool hasExceptions = false;
                        foreach (var exceptionsByTarget in groupsByTarget)
                        {
                            if (exceptionsByTarget.Key.Equals(target))
                            {
                                hasExceptions = true;
                                string resourceIDHolder = string.Empty;
                                foreach (var exception in exceptionsByTarget.exceptionsByPlatform.OrderBy(exc => exc.RID))
                                {
                                    resourceIDHolder = string.Concat(resourceIDHolder, exception.RID + ";");
                                }

                                if (resourceIDHolder.Length > 0)
                                {
                                    rowContent.Add(resourceIDHolder);
                                }
                                else
                                {
                                    rowContent.Add(LocalizedStrings.NoExceptionNoted);
                                }
                            }
                        }

                        if (!hasExceptions)
                        {
                            rowContent.Add(LocalizedStrings.NoExceptionNoted);
                        }
                    }

                    worksheet.AddRow(rowContent.ToArray());
                    exceptionRows++;
                }
            }

            worksheet.AddTable(1, exceptionRows, 1, exceptionsPageHeader.ToArray());

            // Generate the columns
            var columnWidths = new List <double>
            {
                ColumnWidths.DetailsPage.AssemblyName, // Assembly name
                ColumnWidths.DetailsPage.TargetMember, // Target member
                ColumnWidths.DetailsPage.TargetMember  // Exception Width
            };

            columnWidths.AddRange(Enumerable.Repeat(ColumnWidths.Targets, targets.Count)); // Targets

            worksheet.AddColumnWidth(columnWidths);
        }
        private void GenerateDetailsPage(Worksheet detailsPage, ReportingResult analysisResult)
        {
            var showAssemblyColumn = analysisResult.GetAssemblyUsageInfo().Any();

            var detailsPageHeader = new List <string>()
            {
                LocalizedStrings.TargetTypeHeader, LocalizedStrings.TargetMemberHeader
            };

            if (showAssemblyColumn)
            {
                detailsPageHeader.Add(LocalizedStrings.AssemblyHeader);
            }

            detailsPageHeader.AddRange(_mapper.GetTargetNames(analysisResult.Targets, alwaysIncludeVersion: true));
            detailsPageHeader.Add(LocalizedStrings.RecommendedChanges);

            int detailsRows = 0;

            detailsPage.AddRow(detailsPageHeader.ToArray());
            detailsRows++;

            // Dump out all the types that were identified as missing from the target
            foreach (var item in analysisResult.GetMissingTypes().OrderByDescending(n => n.IsMissing))
            {
                if (item.IsMissing)
                {
                    if (!showAssemblyColumn)
                    {
                        // for a missing type we are going to dump the type name for both the target type and target member columns
                        var rowContent = new List <object> {
                            AddLink(item.TypeName), AddLink(item.TypeName)
                        };

                        rowContent.AddRange(item.TargetStatus);
                        rowContent.Add(item.RecommendedChanges);
                        detailsPage.AddRow(rowContent.ToArray());
                        detailsRows++;
                    }
                    else
                    {
                        foreach (var assemblies in item.UsedIn)
                        {
                            string assemblyName = analysisResult.GetNameForAssemblyInfo(assemblies);

                            // for a missing type we are going to dump the type name for both the target type and target member columns
                            var rowContent = new List <object> {
                                AddLink(item.TypeName), AddLink(item.TypeName), assemblyName
                            };
                            rowContent.AddRange(item.TargetStatus);
                            rowContent.Add(item.RecommendedChanges);
                            detailsPage.AddRow(rowContent.ToArray());
                            detailsRows++;
                        }
                    }
                }

                foreach (var member in item.MissingMembers.OrderBy(type => type.MemberName))
                {
                    if (showAssemblyColumn)
                    {
                        foreach (var assem in member.UsedIn.OrderBy(asm => asm.AssemblyIdentity))
                        {
                            string assemblyName = analysisResult.GetNameForAssemblyInfo(assem);
                            var    rowContent   = new List <object> {
                                AddLink(item.TypeName), AddLink(member.MemberName), assemblyName
                            };

                            rowContent.AddRange(member.TargetStatus);
                            rowContent.Add(member.RecommendedChanges);
                            detailsPage.AddRow(rowContent.ToArray());
                            detailsRows++;
                        }
                    }
                    else
                    {
                        var rowContent = new List <object> {
                            AddLink(item.TypeName), AddLink(member.MemberName)
                        };

                        rowContent.AddRange(member.TargetStatus);
                        rowContent.Add(member.RecommendedChanges);
                        detailsPage.AddRow(rowContent.ToArray());
                        detailsRows++;
                    }
                }
            }

            // Generate the pretty tables
            detailsPage.AddTable(1, detailsRows, 1, detailsPageHeader.ToArray());

            // Generate the columns
            var columnWidths = new List <double>
            {
                ColumnWidths.DetailsPage.TargetType,   // Target type
                ColumnWidths.DetailsPage.TargetMember, // Target member
                ColumnWidths.DetailsPage.AssemblyName  // Assembly name
            };

            columnWidths.AddRange(Enumerable.Repeat(ColumnWidths.Targets, analysisResult.Targets.Count)); // Targets
            columnWidths.Add(ColumnWidths.DetailsPage.RecommendedChanges);                                // Recommended changes

            detailsPage.AddColumnWidth(columnWidths);
        }
Пример #11
0
 public bool Undo(object parameter)
 {
     if (Worksheet != null)
     {
         bool flag = false;
         if ((_cachedTables != null) && (_cachedTables.Count > 0))
         {
             foreach (SheetTable table in _cachedTables)
             {
                 CellRange range       = table.Range;
                 int       row         = range.Row;
                 int       column      = range.Column;
                 int       rowCount    = range.RowCount;
                 int       columnCount = range.ColumnCount;
                 if (!table.ShowHeader)
                 {
                     row--;
                     rowCount++;
                 }
                 if (table.ShowFooter)
                 {
                     rowCount--;
                 }
                 SheetTable table2 = Worksheet.AddTable(table.Name, row, column, rowCount, columnCount, table.Style);
                 table2.BandedColumns        = table.BandedColumns;
                 table2.BandedRows           = table.BandedRows;
                 table2.HighlightFirstColumn = table.HighlightFirstColumn;
                 table2.HighlightLastColumn  = table.HighlightLastColumn;
                 table2.ShowFooter           = table.ShowFooter;
                 table2.ShowHeader           = table.ShowHeader;
             }
         }
         CellRange range2 = FixRange(Worksheet, ClearRange);
         if (((_cachedValues != null) && (range2.ColumnCount > 0)) && (range2.RowCount > 0))
         {
             try
             {
                 _excel = parameter as Excel;
                 Worksheet.CellChanged += new EventHandler <CellChangedEventArgs>(OnEditedCellChanged);
                 int num5 = range2.RowCount;
                 int num6 = range2.ColumnCount;
                 for (int i = 0; i < num5; i++)
                 {
                     for (int j = 0; j < num6; j++)
                     {
                         int   num9  = range2.Row + i;
                         int   num10 = range2.Column + j;
                         ulong num11 = CopyMoveHelper.ConvertToKey(i, j);
                         if (_cachedValues.ContainsKey(num11))
                         {
                             CellValueEntry entry = _cachedValues[num11];
                             if (entry.IsFormula)
                             {
                                 Worksheet.SetFormula(num9, num10, (string)(entry.Value as string));
                             }
                             else
                             {
                                 Worksheet.SetFormula(num9, num10, null);
                                 Worksheet.SetValue(num9, num10, entry.Value);
                             }
                         }
                         else
                         {
                             Worksheet.SetFormula(num9, num10, null);
                             Worksheet.SetValue(num9, num10, null);
                         }
                     }
                 }
                 foreach (KeyValuePair <CellRange, string> pair in _arrayFormulas)
                 {
                     Worksheet.SetArrayFormula(pair.Key.Row, pair.Key.Column, pair.Key.RowCount, pair.Key.ColumnCount, pair.Value);
                 }
                 flag = true;
             }
             finally
             {
                 Worksheet.CellChanged -= new EventHandler <CellChangedEventArgs>(OnEditedCellChanged);
                 _excel = null;
             }
         }
         if (((_cachedFilteredColumns != null) && (_cachedFilteredColumns.Count > 0)) && (Worksheet.RowFilter != null))
         {
             foreach (int num12 in _cachedFilteredColumns)
             {
                 Worksheet.RowFilter.Filter(num12);
             }
         }
         if (flag)
         {
             RefreshUI(parameter);
             return(true);
         }
     }
     return(false);
 }