Beispiel #1
0
        private ConflictResolutionResult ResolveByDroppingField(MigrationConflict conflict, ConflictResolutionRule rule, out List <MigrationAction> actions)
        {
            actions = null;

            InvalidFieldValueConflictType conflictType = conflict.ConflictType as InvalidFieldValueConflictType;

            if (null == conflictType)
            {
                throw new InvalidOperationException();
            }

            string invalidFieldName = rule.DataFieldDictionary[InvalidFieldConflictDropFieldAction.DATAKEY_INVALID_FIELD];
            InvalidFieldValueConflictTypeDetails conflictDetails = conflictType.GetConflictDetails(conflict);

            //
            // apply field map to the Action's Description document
            //
            XmlDocument desc   = conflict.ConflictedChangeAction.MigrationActionDescription;
            XmlNode     column = desc.SelectSingleNode(string.Format(
                                                           @"/WorkItemChanges/Columns/Column[@ReferenceName=""{0}""]", invalidFieldName));

            if (column == null ||
                !TFStringComparer.WorkItemFieldReferenceName.Equals(invalidFieldName, column.Attributes["ReferenceName"].Value))
            {
                return(new ConflictResolutionResult(false, ConflictResolutionType.Other));
            }
            XmlNode columnsNode = column.ParentNode;

            columnsNode.RemoveChild(column);

            //note: changes to "MigrationConflict conflict" is saved by the conflict manager automatically
            return(new ConflictResolutionResult(true, ConflictResolutionType.UpdatedConflictedChangeAction));
        }
        public static string CreateConflictDetails(
            string sourceItemId,
            string sourceItemRevision,
            Field invalidValuedTargetItemField)
        {
            InvalidFieldValueConflictTypeDetails dtls =
                new InvalidFieldValueConflictTypeDetails(sourceItemId, sourceItemRevision, invalidValuedTargetItemField);

            return(dtls.Properties.ToString());
        }
        public static string CreateConflictDetails(
            string sourceItemId,
            string sourceItemRevision,
            string targetFieldRefName,
            string targetFieldDispName,
            string targetFieldOriginalValue,
            string targetFieldCurrentValue,
            string targetTeamProjectName,
            string targetWorkItemType,
            string targetTFSUrl)
        {
            InvalidFieldValueConflictTypeDetails dtls = new InvalidFieldValueConflictTypeDetails(
                sourceItemId, sourceItemRevision, targetFieldRefName, targetFieldDispName,
                targetFieldOriginalValue, targetFieldCurrentValue,
                targetTeamProjectName, targetWorkItemType, targetTFSUrl);

            return(dtls.Properties.ToString());
        }
Beispiel #4
0
        private bool CanResolveByValueMap(MigrationConflict conflict, ConflictResolutionRule rule)
        {
            if (conflict.ConflictedChangeAction == null)
            {
                throw new InvalidOperationException();
            }

            if (conflict.ConflictedChangeAction.MigrationActionDescription == null)
            {
                throw new InvalidOperationException();
            }

            var actionDataKeys = new InvalidFieldValueConflictUseValueMapAction().ActionDataKeys;

            if (actionDataKeys.Count != rule.DataField.Length)
            {
                TraceManager.TraceInformation(TfsWITAdapterResources.ErrorResolutionRuleContainsInvalidData,
                                              rule.RuleReferenceName);
                return(false);
            }
            foreach (DataField df in rule.DataField)
            {
                if (!actionDataKeys.Contains(df.FieldName))
                {
                    TraceManager.TraceInformation(TfsWITAdapterResources.ErrorResolutionRuleContainsInvalidDataField,
                                                  rule.RuleReferenceName, df.FieldName);
                    return(false);
                }
            }

            string mapFromValue = rule.DataFieldDictionary[InvalidFieldValueConflictUseValueMapAction.DATAKEY_MAP_FROM];

            InvalidFieldValueConflictType conflictType = conflict.ConflictType as InvalidFieldValueConflictType;

            if (null == conflictType)
            {
                throw new InvalidOperationException();
            }
            InvalidFieldValueConflictTypeDetails conflictDetails = conflictType.GetConflictDetails(conflict);

            return(mapFromValue.Equals(conflictDetails.TargetFieldCurrentValue));
        }
        public override string TranslateConflictDetailsToReadableDescription(string dtls)
        {
            if (string.IsNullOrEmpty(dtls))
            {
                throw new ArgumentNullException("dtls");
            }

            InvalidFieldValueConflictTypeDetails details = null;

            try
            {
                ConflictDetailsProperties properties = ConflictDetailsProperties.Deserialize(dtls);
                details = new InvalidFieldValueConflictTypeDetails(properties);
            }
            catch (Exception)
            {
                try
                {
                    GenericSerializer <InvalidFieldValueConflictTypeDetails> serializer =
                        new GenericSerializer <InvalidFieldValueConflictTypeDetails>();
                    details = serializer.Deserialize(dtls);
                }
                catch (Exception)
                {
                    // do nothing, fall back to raw string later
                }
            }

            if (null != details)
            {
                return(string.Format(
                           "Source work item {0} (revision {1}) contains invalid field change on {2} from '{3}' to '{4}' in target project '{5}'.",
                           details.SourceWorkItemID, details.SourceWorkItemRevision,
                           details.TargetFieldRefName, details.TargetFieldOriginalValue,
                           details.TargetFieldCurrentValue, details.TargetTeamProject));
            }
            else
            {
                return(dtls);
            }
        }
Beispiel #6
0
        private bool CanResolveByDroppingField(MigrationConflict conflict, ConflictResolutionRule rule)
        {
            if (conflict.ConflictedChangeAction == null)
            {
                throw new InvalidOperationException();
            }

            if (conflict.ConflictedChangeAction.MigrationActionDescription == null)
            {
                throw new InvalidOperationException();
            }

            var actionDataKeys = new InvalidFieldConflictDropFieldAction().ActionDataKeys;

            if (actionDataKeys.Count != rule.DataField.Length)
            {
                TraceManager.TraceInformation(TfsWITAdapterResources.ErrorResolutionRuleContainsInvalidData,
                                              rule.RuleReferenceName);
                return(false);
            }
            foreach (DataField df in rule.DataField)
            {
                if (!actionDataKeys.Contains(df.FieldName))
                {
                    TraceManager.TraceInformation(TfsWITAdapterResources.ErrorResolutionRuleContainsInvalidDataField,
                                                  rule.RuleReferenceName, df.FieldName);
                    return(false);
                }
            }

            string invalidFieldName = rule.DataFieldDictionary[InvalidFieldConflictDropFieldAction.DATAKEY_INVALID_FIELD];
            InvalidFieldValueConflictType conflictType = conflict.ConflictType as InvalidFieldValueConflictType;

            if (null == conflictType)
            {
                throw new InvalidOperationException();
            }
            InvalidFieldValueConflictTypeDetails conflictDetails = conflictType.GetConflictDetails(conflict);

            return(TFStringComparer.WorkItemFieldReferenceName.Equals(invalidFieldName, conflictDetails.TargetFieldRefName));
        }
Beispiel #7
0
        private ConflictResolutionResult ResolveByValueMap(
            MigrationConflict conflict,
            ConflictResolutionRule rule,
            out List <MigrationAction> actions)
        {
            actions = null;

            InvalidFieldValueConflictType conflictType = conflict.ConflictType as InvalidFieldValueConflictType;

            if (null == conflictType)
            {
                throw new InvalidOperationException();
            }

            string mapFromValue = rule.DataFieldDictionary[InvalidFieldValueConflictUseValueMapAction.DATAKEY_MAP_FROM];
            string mapToValue   = rule.DataFieldDictionary[InvalidFieldValueConflictUseValueMapAction.DATAKEY_MAP_TO];

            InvalidFieldValueConflictTypeDetails conflictDetails = conflictType.GetConflictDetails(conflict);

            //
            // apply value map to the Action's Description document
            //
            XmlDocument desc   = conflict.ConflictedChangeAction.MigrationActionDescription;
            XmlNode     column = desc.SelectSingleNode(string.Format(
                                                           @"/WorkItemChanges/Columns/Column[@ReferenceName=""{0}""]", conflictDetails.TargetFieldRefName));

            if (column == null)
            {
                // defer to migration time to resolve the conflict, mark it as resolved for now
                return(new ConflictResolutionResult(true, ConflictResolutionType.Other));
            }
            else if (!mapFromValue.Equals(column.FirstChild.InnerText, StringComparison.InvariantCulture))
            {
                return(new ConflictResolutionResult(false, ConflictResolutionType.Other));
            }
            column.FirstChild.InnerText = mapToValue;

            //note: changes to "MigrationConflict conflict" is saved by the conflict manager automatically
            return(new ConflictResolutionResult(true, ConflictResolutionType.UpdatedConflictedChangeAction));
        }