public static string Format(InvestigationResult investigationResult)
 {
     var sb = new StringBuilder();
     foreach (var result in investigationResult.GetAllDistinctRecursive())
     {
         Format(sb, result);
     }
     return sb.ToString();
 }
        private void LogSummaryMessage(InvestigationResult result, Stopwatch sw)
        {
            var grouped = result.GetAllDistinctRecursive()
                .GroupBy(r => r.SupportType)
                .ToDictionary(g => g.Key, g => g.Count());

            int itCount;
            grouped.TryGetValue(SupportType.InvestigationTarget, out itCount);
            Log.Information("Processed {Count} packages files in {Time}ms resulting in {Total} dependencies. Breakdown: {Breakdown}.", itCount, sw.ElapsedMilliseconds, grouped.Sum(g => g.Value), grouped);
        }
Esempio n. 3
0
        private static void WriteToOutputFiles(string outputDirectory, InvestigationResult result)
        {
            Directory.CreateDirectory(outputDirectory);
            File.WriteAllLines(Path.Combine(outputDirectory, "Flat.txt"), new[] { FlatListingOutputFormatter.Format(result) });
            File.WriteAllLines(Path.Combine(outputDirectory, "Tree.txt"), new[] { TreeOutputFormatter.Format(result) });
            File.WriteAllLines(Path.Combine(outputDirectory, "1Level.gv"), new[] { GraphVizOutputFormatter.Format(result, 1) });
            File.WriteAllLines(Path.Combine(outputDirectory, "All.gv"), new[] { GraphVizOutputFormatter.Format(result) });

            foreach (var package in result.PackageConfigResults)
                File.WriteAllLines(Path.Combine(outputDirectory, package.PackageName + ".gv"), new[] { GraphVizOutputFormatter.Format(package) });

            System.Console.ForegroundColor = ConsoleColor.Magenta;
            System.Console.WriteLine($"Output written to {outputDirectory}");
            System.Console.ResetColor();
        }
        public async Task AddStatisticsForResult(InvestigationResult result)
        {
            try
            {
                using (var con = new SqlConnection(_connectionString))
                {
                    await con.OpenAsync();
                    var tasks = result.GetAllDistinctRecursive()
                        .Where(p => AddStatisticsFor.Contains(p.SupportType))
                        .Select(p => AddStatistic(con, p))
                        .ToArray();

                    await Task.WhenAll(tasks);
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Error(ex, "Exception writing statistics");
            }
        }
 public static string Format(InvestigationResult investigationResult, int levels = Int32.MaxValue)
 {
     var allResults = investigationResult.GetAllDistinctRecursive(levels);
     return Format(allResults, "All");
 }
 private static GetResultResponse BuildResponse(InvestigationResult result)
 {
     return new GetResultResponse()
     {
         Result = result.GetAllDistinctRecursive().Select(r => new PackageResult
         {
             PackageName = r.PackageName,
             SupportType = r.SupportType,
             Error = r.Error,
             Dependencies = r.Dependencies?.Select(d => d.PackageName).ToArray(),
             ProjectUrl = r.ProjectUrl,
             MoreInformation = r.MoreInformation.ValueOrNull()
         }).ToArray(),
         GraphViz = GraphVizOutputFormatter.Format(result),
     };
 }
        private void LogErroredAndNotFoundPackages(string repoId, InvestigationResult result)
        {
            foreach(var package in result.GetAllDistinctRecursive().Where(p => p.SupportType == SupportType.Error))
                Log.Error("Error occured with package {package} in GitHub repo {repoId}: {error}", package.PackageName, repoId, package.Error);

            foreach (var package in result.GetAllDistinctRecursive().Where(p => p.SupportType == SupportType.NotFound))
                Log.Warning("Package {package} in GitHub repo {repoId} was not found", package.PackageName, repoId);
        }
 public static string Format(InvestigationResult investigationResult)
 {
     var sb = new StringBuilder();
     Format(sb, investigationResult.PackageConfigResults);
     return sb.ToString();
 }