public ManagedExceptionVersion CreateExceptionVersion([NotNull] IRow row) { var result = new ManagedExceptionVersion( row.OID, Assert.NotNull(GetGuid(row, _managedLineageUuidIndex)).Value, Assert.NotNull(GetGuid(row, _managedVersionUuidIndex)).Value, GetString(row, _managedVersionOriginIndex), GetString(row, _managedOriginIndex), GetDateTime(row, _managedVersionBeginDateIndex), GetDateTime(row, _managedVersionEndDateIndex)); foreach (IssueAttribute attribute in _editableAttributes) { result.SetValue(attribute, GetValue(row, _fieldIndexes[attribute])); } return(result); }
private bool HasChange([NotNull] ManagedExceptionVersion update, [NotNull] ManagedExceptionVersion current, [NotNull] ManagedExceptionVersion original, [NotNull] out ManagedExceptionVersion merged, [NotNull] out IList <ExceptionAttributeConflict> conflicts) { merged = update.Clone(); var changedAttributes = new List <IssueAttribute>(); conflicts = new List <ExceptionAttributeConflict>(); if (update.Status == ExceptionObjectStatus.Active && current.Status == ExceptionObjectStatus.Active) { // 1: update: active; current: active --> update of active exception // --> update attributes regularly } else if (update.Status == ExceptionObjectStatus.Inactive && current.Status == ExceptionObjectStatus.Active) { // 2: update: inactive; current: active --> "deletion" of active exception // --> update attributes regularly } else if (update.Status == ExceptionObjectStatus.Active && current.Status == ExceptionObjectStatus.Inactive) { // 3: update: active; current: inactive if (original.Status == ExceptionObjectStatus.Active) { // set to inactive by previous import // --> ignore _msg.DebugFormat( "Exception ({0}) was set to inactive by previous update, ignore update (OID: {1})", ExceptionObjectUtils.FormatGuid(current.LineageUuid), update.ObjectID); return(false); } // resurrection return(true); // --> ignore, no change } else if (update.Status == ExceptionObjectStatus.Inactive && current.Status == ExceptionObjectStatus.Inactive) { // 4: update: inactive; current: inactive // --> update attributes regularly _msg.DebugFormat( "Exception ({0}) was set to inactive by previous update, ignore update (OID: {1})", ExceptionObjectUtils.FormatGuid(current.LineageUuid), update.ObjectID); } foreach (IssueAttribute attribute in _editableAttributes) { object newValue = update.GetValue(attribute); object currentValue = current.GetValue(attribute); object originalValue = original.GetValue(attribute); if (Equals(newValue, originalValue) || Equals(newValue, currentValue)) { // the value was not changed in the update, or it is equal to the current value merged.SetValue(attribute, currentValue); } else { // different from current, changed in update changedAttributes.Add(attribute); merged.SetValue(attribute, newValue); if (!Equals(currentValue, originalValue)) { // also changed in current --> conflict conflicts.Add(CreateConflict(attribute, newValue, currentValue, originalValue, update.LineageUuid, original.VersionUuid)); } } } return(changedAttributes.Count > 0); }