CreateQualityConditionExceptionStatistics( [NotNull] IQualityConditionExceptionStatistics statistics) { var result = new XmlQualityConditionExceptions { QualityConditionName = Escape(statistics.QualityCondition.Name), ExceptionCount = statistics.ExceptionCount, ExceptionObjectCount = statistics.ExceptionObjectCount, UnusedExceptionObjectCount = statistics.UnusedExceptionObjectCount, ExceptionObjectsUsedMultipleTimesCount = statistics.ExceptionObjectUsedMultipleTimesCount }; foreach (ExceptionObject exceptionObject in statistics.UnusedExceptionObjects) { result.AddUnusedExceptionObject( CreateException(exceptionObject, usageCount: 0)); } foreach (ExceptionUsage usage in statistics.ExceptionObjectsUsedMultipleTimes) { result.AddExceptionObjectUsedMultipleTimes( CreateException(usage.ExceptionObject, usage.UsageCount)); } foreach (string tableName in statistics.UnknownTableNames) { ICollection <ExceptionObject> ignored = statistics .GetExceptionObjectsInvolvingUnknownTableName( tableName); result.ExceptionObjectsIgnoredDueToUnknownTableNameCount = ignored.Count; result.AddUnknownTableName( CreateUnknownTableName(tableName, ignored)); } return(result); }
private static XmlExceptionStatistics CreateExceptionStatistics( [NotNull] IExceptionStatistics statistics, [NotNull] IEnumerable <QualitySpecificationElement> verifiedQualityConditions) { var result = new XmlExceptionStatistics { DataSource = WorkspaceUtils.GetWorkspaceDisplayText( statistics.Workspace), ExceptionCount = statistics.ExceptionCount, ExceptionObjectCount = statistics.ExceptionObjectCount, InactiveExceptionObjectCount = statistics.InactiveExceptionObjectCount, UnusedExceptionObjectCount = statistics.UnusedExceptionObjectCount, ExceptionObjectsUsedMultipleTimesCount = statistics.ExceptionObjectsUsedMultipleTimesCount }; foreach (QualitySpecificationElement element in verifiedQualityConditions) { IQualityConditionExceptionStatistics conditionStatistics = statistics.GetQualityConditionStatistics( element.QualityCondition); if (conditionStatistics != null) { result.AddQualityConditionExceptions( CreateQualityConditionExceptionStatistics(conditionStatistics)); } } foreach (ITable table in statistics.TablesWithNonUniqueKeys) { result.AddTableWithNonUniqueKeys( CreateTableWithNonUniqueKeys(table, statistics.GetNonUniqueKeys(table))); } return(result); }
private static void LogElements( [NotNull] IEnumerable <QualitySpecificationElement> qualitySpecificationElements, [NotNull] IssueProcessor issueProcessor, [CanBeNull] IExceptionStatistics exceptionStatistics) { foreach (QualitySpecificationElement element in qualitySpecificationElements) { QualityCondition qualityCondition = element.QualityCondition; int exceptionCount; int issueCount = issueProcessor.GetIssueCount(qualityCondition, out exceptionCount); var sb = new StringBuilder(qualityCondition.Name); if (issueCount > 0) { sb.AppendFormat(element.AllowErrors ? " - warnings: {0}" : " - errors: {0}", issueCount); } if (exceptionCount > 0) { sb.AppendFormat(" - exceptions: {0}", exceptionCount); } if (issueCount > 0) { _msg.Warn(sb.ToString()); } else { _msg.Info(sb.ToString()); } if (exceptionStatistics != null) { IQualityConditionExceptionStatistics conditionStatistics = exceptionStatistics.GetQualityConditionStatistics(qualityCondition); if (conditionStatistics != null) { if (conditionStatistics.UnknownTableNames.Count > 0) { using (_msg.IncrementIndentation()) { _msg.Warn( "Exception objects were ignored for this condition due to unknown table names:"); foreach (string tableName in conditionStatistics.UnknownTableNames) { _msg.WarnFormat( "- {0}: used in {1} exception object(s)", tableName, conditionStatistics .GetExceptionObjectsInvolvingUnknownTableName( tableName).Count); } } } } } } }
private static XmlVerifiedQualityCondition CreateVerifiedQualityCondition( [NotNull] QualitySpecificationElement element, [NotNull] ICollection <XmlIssue> issues, [CanBeNull] IQualityConditionExceptionStatistics exceptionStatistics, bool reportIssues, bool reportParameters, bool reportDescription) { QualityCondition qualityCondition = element.QualityCondition; var result = new XmlVerifiedQualityCondition { Name = Escape(qualityCondition.Name), Guid = qualityCondition.Uuid, VersionGuid = qualityCondition.VersionUuid, Type = element.AllowErrors ? XmlQualityConditionType.Soft : XmlQualityConditionType.Hard, StopCondition = element.StopOnError, Category = qualityCondition.Category }; if (issues.Count > 0) { if (reportIssues) { result.AddIssues(issues, element.ReportIndividualErrors); } else { result.IssueCount = issues.Count; } } if (reportParameters) { result.TestDescriptor = GetTestDescriptor(qualityCondition.TestDescriptor); result.AddParameters(GetParameters(qualityCondition)); } if (reportDescription) { if (StringUtils.IsNotEmpty(qualityCondition.Description)) { result.Description = Escape(qualityCondition.Description); } if (StringUtils.IsNotEmpty(qualityCondition.Url)) { result.Url = Escape(qualityCondition.Url); } } if (exceptionStatistics != null) { result.ExceptionCount = exceptionStatistics.ExceptionCount; } return(result); }