public PingCastleReportCollection <T> ToLatestReportCollection() { var output = new PingCastleReportCollection <T>(); foreach (var sid in data.Keys) { DateTime maxDate = DateTime.MinValue; foreach (var date in data[sid].Keys) { if (maxDate < date) { maxDate = date; } } output.Add(data[sid][maxDate]); } output.EnrichInformation(); return(output); }
public PingCastleReportCollection <T> GetDataReportAtDate(DateTime dateToIssueReport) { var output = new PingCastleReportCollection <T>(); foreach (var sid in data.Keys) { DateTime min = DateTime.MinValue; foreach (var date in data[sid].Keys) { if (date > min && date <= dateToIssueReport) { min = date; } } if (min != DateTime.MinValue) { output.Add(data[sid][min]); } } output.EnrichInformation(); return(output); }
public bool CartoTask(bool PerformHealthCheckGenerateDemoReports) { List <HealthcheckAnalyzer.ReachableDomainInfo> domains = null; StartTask("Exploration", () => { HealthcheckAnalyzer hcroot = new HealthcheckAnalyzer(); domains = hcroot.GetAllReachableDomains(Port, Credential); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("List of domains that will be queried"); Console.ResetColor(); foreach (var domain in domains) { Console.WriteLine(domain.domain); } }); var consolidation = new PingCastleReportCollection <HealthcheckData>(); StartTask("Examining all domains in parallele (this can take a few minutes)", () => { BlockingQueue <string> queue = new BlockingQueue <string>(30); int numberOfThread = 100; Thread[] threads = new Thread[numberOfThread]; try { ThreadStart threadFunction = () => { for (; ;) { string domain = null; if (!queue.Dequeue(out domain)) { break; } try { Console.WriteLine("[" + DateTime.Now.ToLongTimeString() + "] " + "Starting the analysis of " + domain); HealthcheckAnalyzer hc = new HealthcheckAnalyzer(); var data = hc.GenerateCartoReport(domain, Port, Credential, AnalyzeReachableDomains); consolidation.Add(data); Console.WriteLine("[" + DateTime.Now.ToLongTimeString() + "] " + "Analysis of " + domain + " completed with success"); } catch (Exception ex) { Console.WriteLine("[" + DateTime.Now.ToLongTimeString() + "] " + "Analysis of " + domain + " failed"); Trace.WriteLine("Exception while analysing domain " + domain + " : " + ex.Message); Trace.WriteLine(ex.StackTrace); } } }; // Consumers for (int i = 0; i < numberOfThread; i++) { threads[i] = new Thread(threadFunction); threads[i].Start(); } foreach (var domain in domains) { queue.Enqueue(domain.domain); } queue.Quit(); Trace.WriteLine("examining domains file completed. Waiting for worker thread to complete"); for (int i = 0; i < numberOfThread; i++) { threads[i].Join(); } Trace.WriteLine("Done examining domains"); } catch (Exception ex) { Trace.WriteLine("Exception while analysing domain in carto: " + ex.Message); Trace.WriteLine(ex.StackTrace); } finally { queue.Quit(); for (int i = 0; i < numberOfThread; i++) { if (threads[i] != null) { if (threads[i].ThreadState == System.Threading.ThreadState.Running) { threads[i].Abort(); } } } } }); if (PerformHealthCheckGenerateDemoReports) { Console.WriteLine("Performing demo report transformation"); Trace.WriteLine("Performing demo report transformation"); consolidation = PingCastleReportHelper <HealthcheckData> .TransformReportsToDemo(consolidation); } if (!StartTask("Healthcheck consolidation", () => { consolidation.EnrichInformation(); ReportHealthCheckMapBuilder nodeAnalyzer = new ReportHealthCheckMapBuilder(consolidation, License); nodeAnalyzer.Log = Console.WriteLine; nodeAnalyzer.CenterDomainForSimpliedGraph = CenterDomainForSimpliedGraph; nodeAnalyzer.GenerateReportFile("ad_carto_full_node_map.html"); nodeAnalyzer.FullNodeMap = false; nodeAnalyzer.CenterDomainForSimpliedGraph = CenterDomainForSimpliedGraph; nodeAnalyzer.GenerateReportFile("ad_carto_simple_node_map.html"); } )) { return(false); } return(true); }