public static List <string> WriteHtmlReports( [NotNull] QualitySpecification qualitySpecification, [NotNull] string directory, [NotNull] IssueStatistics issueStatistics, [NotNull] XmlVerificationReport verificationReport, [NotNull] string verificationReportFileName, [CanBeNull] string defaultReportTemplatePath = null, [CanBeNull] XmlVerificationOptions options = null, [CanBeNull] string issueGdbPath = null, [CanBeNull] IList <string> issueMapFilePaths = null, [CanBeNull] IList <string> qualitySpecificationReportFilePaths = null) { string defaultTemplateDirectory = VerificationOptionUtils.GetDefaultTemplateDirectory(options); var reportDefinitions = new List <HtmlReportDefinition>(); foreach (XmlHtmlReportOptions reportOptions in VerificationOptionUtils.GetHtmlReportOptions( options, defaultReportTemplatePath)) { HtmlReportDefinition reportDefinition = VerificationOptionUtils.GetReportDefinition(reportOptions, defaultReportTemplatePath, defaultTemplateDirectory); if (!File.Exists(reportDefinition.TemplatePath)) { _msg.WarnFormat("Template file does not exist: {0}", reportOptions.TemplatePath); continue; } reportDefinitions.Add(reportDefinition); } List <string> filePaths = reportDefinitions.Select(d => Path.Combine(directory, d.FileName)) .ToList(); foreach (HtmlReportDefinition reportDefinition in reportDefinitions) { WriteHtmlReport(qualitySpecification, directory, reportDefinition, issueStatistics, verificationReport, verificationReportFileName, issueGdbPath, issueMapFilePaths, filePaths, qualitySpecificationReportFilePaths); } return(filePaths); }
private static List <HtmlReportDataQualityCategory> GroupByCategories( [NotNull] IEnumerable <IssueGroup> issueGroups, [CanBeNull] IHtmlDataQualityCategoryOptionsProvider optionsProvider, [NotNull] out List <HtmlReportIssueGroup> reportIssueGroups) { var statistics = new IssueStatistics(issueGroups); return(HtmlReportUtils.GroupByCategories( statistics, new HtmlReportDataQualityCategoryComparer(), new HtmlReportQualityConditionComparer(), new HtmlReportIssueGroupComparer(), ig => "testidentifier", optionsProvider, out reportIssueGroups)); }
private static void WriteHtmlReport( [NotNull] QualitySpecification qualitySpecification, [NotNull] string directory, [NotNull] HtmlReportDefinition reportDefinition, [NotNull] IssueStatistics issueStatistics, [NotNull] XmlVerificationReport verificationReport, [NotNull] string verificationReportFileName, [CanBeNull] string issueGdbPath, [CanBeNull] IEnumerable <string> issueMapFilePaths, [NotNull] IEnumerable <string> htmlReportFileNames, [CanBeNull] IEnumerable <string> qualitySpecificationReportFilePaths) { Assert.ArgumentNotNull(reportDefinition, nameof(reportDefinition)); Assert.ArgumentCondition(File.Exists(reportDefinition.TemplatePath), "Template file does not exist: {0}", reportDefinition.TemplatePath); string reportFilePath = Path.Combine(directory, reportDefinition.FileName); _msg.DebugFormat("Preparing html report model"); var reportModel = new HtmlReportModel(qualitySpecification, issueStatistics, verificationReport, directory, verificationReportFileName, issueGdbPath, issueMapFilePaths, htmlReportFileNames, qualitySpecificationReportFilePaths, reportDefinition); _msg.DebugFormat("Rendering html report based on template {0}", reportDefinition.TemplatePath); LiquidUtils.RegisterSafeType <HtmlReportModel>(); LiquidUtils.RegisterSafeType <HtmlTexts>(); string output = LiquidUtils.Render( reportDefinition.TemplatePath, new KeyValuePair <string, object>("report", reportModel), new KeyValuePair <string, object>("text", new HtmlTexts())); _msg.DebugFormat("Writing html report to {0}", reportFilePath); FileSystemUtils.WriteTextFile(output, reportFilePath); _msg.InfoFormat("Html report written to {0}", reportFilePath); }
public IIssueStatisticsTable WriteStatistics( [NotNull] IssueStatistics issueStatistics) { Assert.ArgumentNotNull(issueStatistics, nameof(issueStatistics)); // create table ITable table = CreateTable("IssueStatistics", _featureWorkspace, _fieldNames); DatasetUtils.TrySetAliasName(table, LocalizableStrings.IssueStatisticsTableName); // write rows WriteRows(table, issueStatistics, _fieldNames); // create indexes (?) return(new IssueStatisticsTable(table, _fieldNames)); }
void application_CustomProcessShortcut(object sender, CustomProcessShortcutEventArgs e) { if (e.Shortcut.ViewId == "IssueStatistics_ListView") { IObjectSpace nonPersistentObjectSpace = Application.CreateObjectSpace(typeof(IssueStatistics)); IssueStatistics issueStatistics = new IssueStatistics(); using (IObjectSpace objectSpace = Application.CreateObjectSpace(typeof(Issue))) { issueStatistics.ActiveIssuesCount = objectSpace.GetObjectsCount(typeof(Issue), CriteriaOperator.Parse("[Status] == 'Active'")); issueStatistics.ClosedIssuesCount = objectSpace.GetObjectsCount(typeof(Issue), CriteriaOperator.Parse("[Status] == 'Closed'")); issueStatistics.TotalIssuesCount = issueStatistics.ActiveIssuesCount + issueStatistics.ClosedIssuesCount; } e.View = Application.CreateDetailView(nonPersistentObjectSpace, issueStatistics, true); e.View.AllowEdit["CanEditIssueStatistics"] = false; e.Handled = true; } }
private static void WriteRows([NotNull] ITable table, [NotNull] IssueStatistics issueStatistics, [NotNull] IIssueStatisticsTableFieldNames fieldNames) { const bool useBuffering = true; ICursor insertCursor = table.Insert(useBuffering); IRowBuffer rowBuffer = table.CreateRowBuffer(); var attributeWriter = new AttributeWriter(table, fieldNames); foreach (IssueGroup issueGroup in issueStatistics.GetIssueGroups()) { attributeWriter.Write(issueGroup, rowBuffer); insertCursor.InsertRow(rowBuffer); } insertCursor.Flush(); }
private bool Verify([NotNull] QualitySpecification qualitySpecification, double tileSize, [NotNull] string directory, IssueRepositoryType issueRepositoryType, [NotNull] IEnumerable <KeyValuePair <string, string> > properties, [CanBeNull] XmlVerificationOptions verificationOptions, [CanBeNull] AreaOfInterest areaOfInterest, [CanBeNull] ITrackCancel trackCancel, out int errorCount, out int warningCount, out int exceptionCount, out int unusedExceptionObjectCount, out int rowCountWithStopConditions) { Model primaryModel = StandaloneVerificationUtils.GetPrimaryModel(qualitySpecification); Assert.NotNull(primaryModel, "no primary model found for quality specification"); // TODO disable quality conditions based on primaryModel and DatasetTestParameterValue.UsedAsReferenceData? // TODO this would probably require an explicit identification of the primary data source XmlVerificationReportBuilder xmlReportBuilder = GetReportBuilder(); var statisticsBuilder = new IssueStatisticsBuilder(); var datasetsCollector = new InvolvedDatasetsCollector(); var service = new StandaloneQualityVerificationService( new MultiReportBuilder(xmlReportBuilder, statisticsBuilder, datasetsCollector), (context) => new SimpleDatasetOpener(context)); // This context excludes geometric networks, terrains, topology, etc.: var datasetContext = new MasterDatabaseDatasetContext(); var datasetResolver = new QualityConditionObjectDatasetResolver( new MasterDatabaseWorkspaceContextLookup()); string issueWorkspaceName = VerificationOptionUtils.GetIssueWorkspaceName(verificationOptions); string verificationReportFileName = VerificationOptionUtils.GetXmlReportFileName(verificationOptions); ISpatialReference spatialReference = primaryModel.SpatialReferenceDescriptor?.SpatialReference; var issueGdbWritten = false; bool fulfilled; List <string> htmlReportFilePaths; List <string> specificationReportFilePaths; string gdbPath = null; Func <IObjectDataset, string> getKeyField = StandaloneVerificationUtils.GetKeyFieldLookupFunction(verificationOptions); ExceptionObjectRepository exceptionObjectRepository = StandaloneVerificationUtils.PrepareExceptionRepository( qualitySpecification, datasetContext, datasetResolver, areaOfInterest, verificationOptions); using (IIssueRepository issueRepository = ExternalIssueRepositoryUtils.GetIssueRepository( directory, issueWorkspaceName, spatialReference, issueRepositoryType, addExceptionFields: true)) { fulfilled = service.Verify(qualitySpecification, datasetContext, datasetResolver, issueRepository, exceptionObjectRepository, tileSize, getKeyField, areaOfInterest, trackCancel, out errorCount, out warningCount, out rowCountWithStopConditions); if (issueRepository != null) { issueGdbWritten = true; gdbPath = ((IWorkspace)issueRepository.FeatureWorkspace).PathName; _msg.InfoFormat("Issues written to {0}", gdbPath); issueRepository.CreateIndexes(GetForSubProcess(trackCancel), ignoreErrors: true); } using (_msg.IncrementIndentation("Documenting verification results...")) { XmlVerificationReport verificationReport = GetVerificationReport( xmlReportBuilder, qualitySpecification, properties); string verificationReportPath = Path.Combine(directory, verificationReportFileName); XmlUtils.Serialize(verificationReport, verificationReportPath); _msg.InfoFormat("Verification report written to {0}", verificationReportPath); IssueStatistics issueStatistics = statisticsBuilder.IssueStatistics; if (issueRepository != null) { var issueStatisticsWriter = new IssueStatisticsWriter(issueRepository.FeatureWorkspace); issueStatisticsWriter.WriteStatistics(issueStatistics); if (spatialReference != null && areaOfInterest != null && !areaOfInterest.IsEmpty) { var aoiWriter = new AreaOfInterestWriter(issueRepository.FeatureWorkspace); aoiWriter.WriteAreaOfInterest(areaOfInterest, spatialReference); } } specificationReportFilePaths = StandaloneVerificationUtils.WriteQualitySpecificationReport( qualitySpecification, directory, _qualitySpecificationTemplatePath, verificationOptions); htmlReportFilePaths = StandaloneVerificationUtils.WriteHtmlReports( qualitySpecification, directory, issueStatistics, verificationReport, verificationReportFileName, _htmlReportTemplatePath, verificationOptions, issueGdbWritten ? gdbPath : null, null, specificationReportFilePaths); } } GC.Collect(); GC.WaitForPendingFinalizers(); if (htmlReportFilePaths.Count > 0) { using (_msg.IncrementIndentation(htmlReportFilePaths.Count == 1 ? "Html report:" : "Html reports:")) { foreach (string path in htmlReportFilePaths) { _msg.Info(path); } } } if (specificationReportFilePaths.Count > 0) { using (_msg.IncrementIndentation(specificationReportFilePaths.Count == 1 ? "Quality specification report:" : "Quality specification reports:")) { foreach (string path in specificationReportFilePaths) { _msg.Info(path); } } } if (exceptionObjectRepository != null) { IExceptionStatistics stats = exceptionObjectRepository.ExceptionStatistics; exceptionCount = stats.ExceptionCount; unusedExceptionObjectCount = stats.UnusedExceptionObjectCount; } else { exceptionCount = 0; unusedExceptionObjectCount = 0; } return(fulfilled); }