private static IDictionary <Guid, QualityConditionExceptions> ReadTargetExceptions( [NotNull] IList <IObjectClass> targetExceptionClasses, [NotNull] IIssueTableFields fields) { Assert.ArgumentNotNull(targetExceptionClasses, nameof(targetExceptionClasses)); Assert.ArgumentCondition(targetExceptionClasses.Count > 0, "no exception classes"); var result = new Dictionary <Guid, QualityConditionExceptions>(); foreach (ITable targetTable in targetExceptionClasses.Cast <ITable>()) { var factory = new ExceptionObjectFactory( targetTable, fields, defaultStatus: ExceptionObjectStatus.Inactive, includeManagedExceptionAttributes: true); foreach (IRow row in GdbQueryUtils.GetRows(targetTable, recycle: true)) { ExceptionObject exceptionObject = factory.CreateExceptionObject(row); Guid qconVersionUuid = exceptionObject.QualityConditionVersionUuid; QualityConditionExceptions exceptions; if (!result.TryGetValue(qconVersionUuid, out exceptions)) { exceptions = new QualityConditionExceptions(qconVersionUuid, null); result.Add(qconVersionUuid, exceptions); } exceptions.Add(exceptionObject); } } return(result); }
private static bool ImportException( [NotNull] IRow row, [NotNull] string importOriginValue, DateTime importDate, [NotNull] ExceptionObjectFactory factory, [NotNull] IDictionary <Guid, QualityConditionExceptions> targetExceptionsByConditionVersion, [NotNull] IDictionary <esriGeometryType, HashSet <int> > replacedExceptionObjects, [NotNull] ExceptionWriter writer, out int matchCount) { ExceptionObject exceptionObject = factory.CreateExceptionObject(row); matchCount = 0; // import only active exceptions if (exceptionObject.Status != ExceptionObjectStatus.Active) { return(false); } var matchingLineageUuids = new DistinctValues <Guid>(); var origins = new HashSet <string>(StringComparer.OrdinalIgnoreCase) { importOriginValue }; foreach (ExceptionObject matchingExceptionObject in GetMatchingExceptionObjects( targetExceptionsByConditionVersion, exceptionObject)) { // add to Uuids of matching exceptions (usually, should be unique) if (matchingExceptionObject.ManagedLineageUuid != null) { // also if matching exception is inactive // --> lineage of inactive exceptions may be continued (resurrection of inactive exceptions) matchingLineageUuids.Add(matchingExceptionObject.ManagedLineageUuid.Value); // NOTE: consider *preferring* active exceptions, only if none: resurrect inactive exception lineage } // include the origin values of active replaced exceptions // Note: not for resurrected exceptions (inactive/with end date -> active) if (matchingExceptionObject.ManagedVersionEndDate == null) { foreach (string replacedOrigin in ExceptionObjectUtils.ParseOrigins(matchingExceptionObject.ManagedOrigin)) { origins.Add(replacedOrigin); } } matchCount++; AddToReplacedExceptionObjects(matchingExceptionObject, replacedExceptionObjects); } writer.Write(row, importDate, ExceptionObjectUtils.FormatOrigins(origins), GetLineageUuid(matchingLineageUuids), versionOriginValue: importOriginValue, statusValue: "Active"); return(true); }