Esempio n. 1
0
        private void WriteValue([NotNull] ManagedExceptionVersion managedExceptionVersion,
                                IssueAttribute attribute,
                                [NotNull] IRowBuffer buffer)
        {
            int fieldIndex = GetFieldIndex(attribute);

            object rawValue = managedExceptionVersion.GetValue(attribute);

            buffer.Value[fieldIndex] = FormatValue(rawValue);
        }
Esempio n. 2
0
        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);
        }