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

            InvalidFieldConflictType conflictType = conflict.ConflictType as InvalidFieldConflictType;

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

            string invalidFieldName = rule.DataFieldDictionary[InvalidFieldConflictDropFieldAction.DATAKEY_INVALID_FIELD];

            return(DropField(conflict, invalidFieldName));
        }
        private ConflictResolutionResult ResolveBySubmitMissingChanges(
            IServiceContainer serviceContainer,
            MigrationConflict conflict,
            ConflictResolutionRule rule,
            out List <MigrationAction> actions)
        {
            actions = null;
            var retVal = new ConflictResolutionResult(false, ConflictResolutionType.Other);

            WITTranslationService translationService = serviceContainer.GetService(typeof(ITranslationService)) as WITTranslationService;

            Debug.Assert(null != translationService, "translationService is not initialized or not a wit translation service");

            using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance())
            {
                RTSessionGroup rtSessionGroup = FindSessionGroupForConflictedAction(conflict, context);
                if (null == rtSessionGroup)
                {
                    return(retVal);
                }

                BM.BusinessModelManager bmm = new BM.BusinessModelManager();
                BM.Configuration        sessionGroupConfig = bmm.LoadConfiguration(rtSessionGroup.GroupUniqueId);

                // find target-side migration source config
                var  parentChangeGroup       = FindChangeGroupForConflictedAction(conflict, context);
                Guid targetMigrationSourceId = parentChangeGroup.SourceUniqueId;
                BM.MigrationSource targetMigrationSourceConfig = sessionGroupConfig.SessionGroup.MigrationSources[targetMigrationSourceId];
                if (null == targetMigrationSourceConfig)
                {
                    return(retVal);
                }

                // find source-side migration source config
                RTSession  rtSession     = FindSessionForConflictedAction(conflict, context);
                BM.Session parentSession = null;
                foreach (BM.Session s in sessionGroupConfig.SessionGroup.Sessions.Session)
                {
                    if (new Guid(s.SessionUniqueId).Equals(rtSession.SessionUniqueId))
                    {
                        parentSession = s;
                        break;
                    }
                }
                if (parentSession == null)
                {
                    return(retVal);
                }
                Guid sourceMigrationSourceId = ((new Guid(parentSession.LeftMigrationSourceUniqueId)).Equals(targetMigrationSourceId))
                    ? new Guid(parentSession.RightMigrationSourceUniqueId) : new Guid(parentSession.LeftMigrationSourceUniqueId);
                BM.MigrationSource sourceMigrationSourceConfig = sessionGroupConfig.SessionGroup.MigrationSources[sourceMigrationSourceId];
                if (null == sourceMigrationSourceConfig)
                {
                    return(retVal);
                }

                string sourceServerUrl   = sourceMigrationSourceConfig.ServerUrl;
                string sourceTeamProject = sourceMigrationSourceConfig.SourceIdentifier;
                string targetServerUrl   = targetMigrationSourceConfig.ServerUrl;
                string targetTeamProject = targetMigrationSourceConfig.SourceIdentifier;

                string srcWorkItemIdStr = TfsMigrationWorkItemStore.GetSourceWorkItemId(conflict.ConflictedChangeAction);
                Debug.Assert(!string.IsNullOrEmpty(srcWorkItemIdStr), "srcWorkItemId is null or empty");
                int srcWorkItemId;
                if (!int.TryParse(srcWorkItemIdStr, out srcWorkItemId))
                {
                    return(retVal);
                }

                string srcRevRanges    = rule.DataFieldDictionary[HistoryNotFoundSubmitMissingChangesAction.DATAKEY_REVISION_RANGE];
                int[]  sourceRevToSync = new int[0];
                if (string.IsNullOrEmpty(srcRevRanges))
                {
                    sourceRevToSync = ExtractMissingRevs(conflict.ConflictedChangeAction);
                }
                else
                {
                    if (!IntegerRange.TryParseRangeString(srcRevRanges, out sourceRevToSync))
                    {
                        return(retVal);
                    }
                }
                if (sourceRevToSync.Length == 0)
                {
                    return(retVal);
                }

                try
                {
                    // compute delta from source side
                    TfsWITAnalysisProvider analysisProvider = new TfsWITAnalysisProvider(sourceServerUrl, sourceTeamProject);
                    WorkItem sourceWorkItem = analysisProvider.GetWorkItem(srcWorkItemId);

                    Hist.MigrationAction[] sourceRevDetails = new Hist.MigrationAction[sourceRevToSync.Length];
                    for (int revIndex = 0; revIndex < sourceRevToSync.Length; ++revIndex)
                    {
                        var details = new TfsWITRecordDetails(sourceWorkItem, sourceRevToSync[revIndex]);
                        SanitizeDetails(details);
                        translationService.MapWorkItemTypeFieldValues(
                            sourceWorkItem.Id.ToString(), details.DetailsDocument, sourceMigrationSourceId);

                        TfsConstants.ChangeActionId actionId = (sourceRevToSync[revIndex] == 1 ? TfsConstants.ChangeActionId.Add : TfsConstants.ChangeActionId.Edit);
                        sourceRevDetails[revIndex] = new Hist.MigrationAction(sourceWorkItem.Id.ToString(), details, actionId);
                    }

                    // migrate to target side
                    TfsWITMigrationProvider migrationProvider = new TfsWITMigrationProvider(targetServerUrl, targetTeamProject, string.Empty);
                    Hist.ConversionResult   conversionResult  = migrationProvider.ProcessChangeGroup(sourceRevDetails);

                    // update conversion history
                    ConversionResult convRslt = new ConversionResult(sourceMigrationSourceId, targetMigrationSourceId);
                    convRslt.ChangeId           = HistoryNotFoundResolutionChangeId;
                    convRslt.ContinueProcessing = true;

                    foreach (var itemConvHist in conversionResult.ItemConversionHistory)
                    {
                        convRslt.ItemConversionHistory.Add(new ItemConversionHistory(
                                                               itemConvHist.SourceItemId, itemConvHist.SourceItemVersion, itemConvHist.TargetItemId, itemConvHist.TargetItemVersion));
                    }

                    parentChangeGroup.SessionRunReference.Load();
                    int sessionRunId = parentChangeGroup.SessionRun.Id;
                    convRslt.Save(sessionRunId, sourceMigrationSourceId);
                }
                catch (Exception ex)
                {
                    TraceManager.TraceException(ex);
                    retVal.Comment = ex.ToString();
                    return(retVal);
                }
            }

            retVal.Resolved = true;
            return(retVal);
        }
示例#3
0
        private ConflictResolutionResult ResolveByFieldMap(MigrationConflict conflict, ConflictResolutionRule rule, out List <MigrationAction> actions)
        {
            actions = null;

            InvalidFieldConflictType conflictType = conflict.ConflictType as InvalidFieldConflictType;

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

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

            if (string.IsNullOrEmpty(mapToValue))
            {
                return(DropField(conflict, mapFromValue));
            }

            InvalidFieldConflictTypeDetails 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}""]", conflictDetails.SourceFieldRefName));

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

            //note: changes to "MigrationConflict conflict" is saved by the conflict manager automatically
            return(new ConflictResolutionResult(true, ConflictResolutionType.UpdatedConflictedChangeAction));
        }
示例#4
0
 /// <summary>
 /// Determines if a conflict can be resolved by a resolution rule.
 /// </summary>
 /// <param name="conflict"></param>
 /// <param name="rule"></param>
 /// <returns></returns>
 public bool CanResolve(MigrationConflict conflict, ConflictResolutionRule rule)
 {
     return(ConflictTypeHandled.ScopeInterpreter.IsInScope(conflict.ScopeHint, rule.ApplicabilityScope));
 }
        private ConflictResolutionResult ResolveByUsingWITMapping(MigrationConflict conflict, ConflictResolutionRule rule)
        {
            string mapToWIT;

            if (rule.DataFieldDictionary.TryGetValue(WITUnmappedWITConflictUpdateWITMappingAction.DATAKEY_MAP_TO, out mapToWIT))
            {
                try
                {
                    Debug.Assert(conflict.ConflictedChangeAction != null, "conflict.ConflictedChangeAction is NULL");
                    XmlDocument updateDoc = conflict.ConflictedChangeAction.MigrationActionDescription;
                    updateDoc.DocumentElement.Attributes["WorkItemType"].Value = mapToWIT;

                    return(new ConflictResolutionResult(true, ConflictResolutionType.UpdatedConflictedChangeAction));
                }
                catch (Exception e)
                {
                    TraceManager.TraceException(e);
                }
            }

            return(new ConflictResolutionResult(false, ConflictResolutionType.Other));
        }
示例#6
0
        private ConflictResolutionResult ResolveByDroppingField(MigrationConflict conflict, ConflictResolutionRule rule, out List <MigrationAction> actions)
        {
            actions = null;

            ClearQuestInvalidFieldValueConflictType conflictType = conflict.ConflictType as ClearQuestInvalidFieldValueConflictType;

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

            string invalidFieldName = rule.DataFieldDictionary[DropFieldConflictResolutionAction.ActionDataKey_FieldName];

            if (string.IsNullOrEmpty(invalidFieldName))
            {
                var result = new ConflictResolutionResult(false, ConflictResolutionType.Other);
                result.Comment = string.Format(ClearQuestResource.ClearQuest_Conflict_MissingResolutionData,
                                               DropFieldConflictResolutionAction.ActionDataKey_FieldName);
                return(result);
            }
            //
            // 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 || 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));
        }
示例#7
0
        public ConflictResolutionResult Resolve(IServiceContainer serviceContainer, MigrationConflict conflict, ConflictResolutionRule rule, out List <MigrationAction> actions)
        {
            actions = null;
            if (rule.ActionRefNameGuid.Equals(new InvalidFieldValueConflictUseValueMapAction().ReferenceName))
            {
                return(ResolveByValueMap(conflict, rule, out actions));
            }
            else if (rule.ActionRefNameGuid.Equals(new InvalidFieldConflictDropFieldAction().ReferenceName))
            {
                return(ResolveByDroppingField(conflict, rule, out actions));
            }
            else if (rule.ActionRefNameGuid.Equals(new ManualConflictResolutionAction().ReferenceName))
            {
                return(new ConflictResolutionResult(true, ConflictResolutionType.Other));
            }
            else if (rule.ActionRefNameGuid.Equals(new UpdatedConfigurationResolutionAction().ReferenceName))
            {
                return(Toolkit.Utility.ResolveConflictByUpdateConfig(rule));
            }

            return(new ConflictResolutionResult(false, ConflictResolutionType.Other));
        }
 public ConflictResolutionResult Resolve(System.ComponentModel.Design.IServiceContainer serviceContainer, MigrationConflict conflict, ConflictResolutionRule rule, out List <MigrationAction> actions)
 {
     actions = null;
     return(new ConflictResolutionResult(false, ConflictResolutionType.Other));
 }
 public ConflictResolutionResult Resolve(IServiceContainer serviceContainer, MigrationConflict conflict, ConflictResolutionRule rule, out List <MigrationAction> actions)
 {
     actions = null;
     if (rule.ActionRefNameGuid.Equals(new TfsCheckinSkipAction().ReferenceName))
     {
         return(new ConflictResolutionResult(true, ConflictResolutionType.SkipConflictedChangeAction));
     }
     else if (rule.ActionRefNameGuid.Equals(new TfsCheckinAutoResolveAction().ReferenceName))
     {
         return(new ConflictResolutionResult(true, ConflictResolutionType.AutoResolve));
     }
     else
     {
         return(new ConflictResolutionResult(false, ConflictResolutionType.UnknownResolutionAction));
     }
 }
示例#10
0
 private ConflictResolutionResult ResolveByIncreasingMaxAttchSetting(MigrationConflict conflict, ConflictResolutionRule rule)
 {
     throw new NotImplementedException();
 }
示例#11
0
 public ConflictResolutionResult Resolve(IServiceContainer serviceContainer, MigrationConflict conflict, ConflictResolutionRule rule, out List <MigrationAction> actions)
 {
     actions = null;
     if (rule.ActionRefNameGuid.Equals(new TfsCheckinFailureRetryAction().ReferenceName))
     {
         ConflictManager conflictManager = (ConflictManager)serviceContainer.GetService(typeof(ConflictManager));
         RemoveInProgressChangeGroupsInSession(conflictManager.ScopeId);
         return(new ConflictResolutionResult(true, ConflictResolutionType.Retry));
     }
     else if (rule.ActionRefNameGuid.Equals(new TfsCheckinFailureManualResolveAction().ReferenceName))
     {
         if (updateConversionHistory(conflict, rule, serviceContainer))
         {
             return(new ConflictResolutionResult(true, ConflictResolutionType.SuppressedConflictedChangeGroup));
         }
         else
         {
             return(new ConflictResolutionResult(false, ConflictResolutionType.Other));
         }
     }
     else
     {
         return(new ConflictResolutionResult(false, ConflictResolutionType.UnknownResolutionAction));
     }
 }
        public ConflictResolutionResult Resolve(IServiceContainer serviceContainer, MigrationConflict conflict, ConflictResolutionRule rule, out List <MigrationAction> actions)
        {
            actions = null;

            if (rule.ActionRefNameGuid.Equals(new ManualConflictResolutionAction().ReferenceName))
            {
                return(ManualResolve(conflict, rule, out actions));
            }

            else if (rule.ActionRefNameGuid.Equals(new FileAttachmentOversizedConflictDropAttachmentAction().ReferenceName))
            {
                return(ResolveByDroppingAttachment(conflict, rule, out actions));
            }

            return(new ConflictResolutionResult(false, ConflictResolutionType.Other));
        }
示例#13
0
        public IEnumerable <ConflictResolutionResult> Save()
        {
            if (CustomControl != null && !ShowAdvancedOptions)
            {
                CustomControl.Save();
            }

            if (CanSave)
            {
                m_newRule = SelectedResolutionAction.NewRule(Scope, Description, DataFields.ToDictionary(x => x.FieldName, x => x.FieldValue));

                List <ConflictResolutionResult> results = new List <ConflictResolutionResult>();
                ConflictResolutionResult        firstConflictResolutionResult = m_conflictManager.ResolveExistingConflictWithNewRule(m_conflict.Id, m_newRule);
                firstConflictResolutionResult.ConflictInternalId = ConflictInternalId;
                results.Add(firstConflictResolutionResult);

                if (firstConflictResolutionResult.Resolved)
                {
                    try
                    {
                        IEnumerable <ConflictResolutionResult> otherConflictsResolutionResult = m_conflictManager.ResolveExistingConflictWithExistingRule(m_newRule);
                        results.AddRange(otherConflictsResolutionResult);
                    }
                    catch (MigrationException)
                    { }
                    catch (EntityException)
                    { }
                }

                foreach (ConflictResolutionResult result in results)
                {
                    if (this.ConflictInternalId == result.ConflictInternalId)
                    {
                        if (result.Resolved)
                        {
                            IsResolved       = ResolvedStatus.Resolved;
                            ResolvedByRuleId = m_newRule.InternalId;
                        }
                        else
                        {
                            IsResolved = ResolvedStatus.Failed;
                        }
                    }
                }

                m_appViewModel.SetResolvedConflicts(results, m_newRule.InternalId);

                // add new rule to rules list
                RuntimeEntityModel context = RuntimeEntityModel.CreateInstance();
                var v = from r in context.RTResolutionRuleSet
                        where r.Id == ResolvedByRuleId
                        select r;
                if (v.Count() > 0)
                {
                    m_appViewModel.Rules.Insert(0, new ExistingRuleViewModel(v.First(), m_appViewModel));
                }

                return(results);
            }
            else
            {
                throw new Exception("Invalid scope");
            }
        }
示例#14
0
 public ConflictResolutionResult Resolve(IServiceContainer serviceContainer, MigrationConflict conflict, ConflictResolutionRule rule, out List <MigrationAction> actions)
 {
     actions = null;
     if (rule.ActionRefNameGuid.Equals(new TfsItemNotFoundSkipAction().ReferenceName))
     {
         return(new ConflictResolutionResult(true, ConflictResolutionType.SkipConflictedChangeAction));
     }
     //else if (rule.ActionRefNameGuid.Equals(new TfsItemNotFoundRetryAction().ReferenceName))
     //{
     //    return new ConflictResolutionResult(true, ConflictResolutionType.Retry);
     //}
     else
     {
         return(new ConflictResolutionResult(false, ConflictResolutionType.UnknownResolutionAction));
     }
 }
        public ConflictResolutionResult Resolve(IServiceContainer serviceContainer, MigrationConflict conflict, ConflictResolutionRule rule, out List <MigrationAction> actions)
        {
            ClearQuestSetFieldValueConflictType conflictType = conflict.ConflictType as ClearQuestSetFieldValueConflictType;

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

            actions = null;

            if (rule.ActionRefNameGuid.Equals(new ManualConflictResolutionAction().ReferenceName))
            {
                return(ManualResolve(conflict, rule, out actions));
            }
            else if (rule.ActionRefNameGuid.Equals(new ClearQuestConflictResolutionUseValueMap()))
            {
                return(UseValueMap(conflict, rule, out actions));
            }
            else if (rule.ActionRefNameGuid.Equals(new ClearQuestConflictResolutionDropValueSetting()))
            {
                return(DropValueSetting(conflict, rule, out actions));
            }
            else if (rule.ActionRefNameGuid.Equals(new ClearQuestConflictResolutionUseRegexValueReplacement()))
            {
                return(UseRegexValueReplacement(conflict, rule, out actions));
            }
            else
            {
                return(new ConflictResolutionResult(false, ConflictResolutionType.Other));
            }
        }
示例#16
0
 public ConflictResolutionResult Resolve(IServiceContainer serviceContainer, MigrationConflict conflict, ConflictResolutionRule rule, out List <MigrationAction> actions)
 {
     actions = null;
     if (rule.ActionRefNameGuid.Equals(new TFSDosShortNameRetryAction().ReferenceName))
     {
         return(new ConflictResolutionResult(true, ConflictResolutionType.Retry));
     }
     else
     {
         return(new ConflictResolutionResult(false, ConflictResolutionType.UnknownResolutionAction));
     }
 }
        private bool CanResolveByUseRegexValueReplacement(MigrationConflict conflict, ConflictResolutionRule rule)
        {
            // deserialize conflict details
            var conflictDetails = ((ClearQuestSetFieldValueConflictType)conflict.ConflictType).GetConflictDetails(conflict);

            // extract the field name and regex specified in the rule
            string regexPattern = rule.DataFieldDictionary[ClearQuestConflictResolutionUseRegexValueReplacement.DATAKEY_REGEX_PATTERN];
            string fieldName    = rule.DataFieldDictionary[ClearQuestConflictResolutionUseRegexValueReplacement.DATAKEY_FIELD_NAME];

            if (!CQStringComparer.FieldName.Equals(conflictDetails.FieldName, fieldName))
            {
                // field name of the rule does not match that in the conflict
                return(false);
            }

            // look up the field in the update document
            XmlNode column = UtilityMethods.ExtractSingleFieldNodeFromMigrationDescription(
                conflict.ConflictedChangeAction.MigrationActionDescription, conflictDetails.FieldName);

            if (null == column)
            {
                // field no longer exists in the update document
                return(false);
            }

            string currFieldValue = column.FirstChild.InnerText ?? ClearQuestSetFieldValueConflictTypeDetails.NullValueString;

            return(Regex.IsMatch(currFieldValue, regexPattern, RegexOptions.Multiline));
        }
 public ConflictResolutionResult Resolve(IServiceContainer serviceContainer, MigrationConflict conflict, ConflictResolutionRule rule, out List <MigrationAction> actions)
 {
     actions = null;
     if (rule.ActionRefNameGuid.Equals(new UnhandledChangeTypeMapAction().ReferenceName))
     {
         string mapFrom = rule.ApplicabilityScope;
         string mapTo   = rule.DataField[0].FieldValue;
         ConflictResolutionResult result;
         if (ValidateRuleData(mapTo, mapFrom))
         {
             result         = new ConflictResolutionResult(true, ConflictResolutionType.Other);
             result.Comment = mapTo;
         }
         else
         {
             result         = new ConflictResolutionResult(false, ConflictResolutionType.Other);
             result.Comment = "MapTo field is invalid.";
         }
         return(result);
     }
     else if (rule.ActionRefNameGuid.Equals(new UnhandledChangeTypeSkipAction().ReferenceName))
     {
         return(new ConflictResolutionResult(true, ConflictResolutionType.Other)); // do not set comment as MapTo
     }
     else
     {
         return(new ConflictResolutionResult(false, ConflictResolutionType.UnknownResolutionAction));
     }
 }
示例#19
0
        private ConflictResolutionResult ResolveByValueMap(MigrationConflict conflict, ConflictResolutionRule rule, out List <MigrationAction> actions)
        {
            actions = null;

            ClearQuestInvalidFieldValueConflictType conflictType = conflict.ConflictType as ClearQuestInvalidFieldValueConflictType;

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

            string mapFromValue    = rule.DataFieldDictionary[UseValueMapConflictResolutionAction.ActionDataKey_MapFromValue];
            string mapToValue      = rule.DataFieldDictionary[UseValueMapConflictResolutionAction.ActionDataKey_MapToValue];
            string targetFieldName = rule.DataFieldDictionary[UseValueMapConflictResolutionAction.ActionDataKey_TargetFieldName];

            //
            // 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}""]", targetFieldName));

            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));
        }
        /// <summary>
        /// Resolves the subject conflict with the passed-in rule.
        /// </summary>
        /// <param name="conflict">The conflict to be resolved</param>
        /// <param name="rule">The candidate rule</param>
        /// <param name="actions">The migration actions that are generated as part of the resolution plan.</param>
        /// <returns>The conflict resolution result</returns>
        public ConflictResolutionResult Resolve(IServiceContainer serviceContainer, MigrationConflict conflict, ConflictResolutionRule rule, out List <MigrationAction> actions)
        {
            actions = null;
            if (rule.ActionRefNameGuid.Equals(new HistoryNotFoundSubmitMissingChangesAction().ReferenceName))
            {
                return(ResolveBySubmitMissingChanges(serviceContainer, conflict, rule, out actions));
            }
            else if (rule.ActionRefNameGuid.Equals(new HistoryNotFoundUpdateConversionHistoryAction().ReferenceName))
            {
                return(ResolveByUpdateConversionHisotry(conflict, rule, out actions));
            }

            return(new ConflictResolutionResult(false, ConflictResolutionType.Other));
        }
示例#21
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));
        }
        private ConflictResolutionResult ResolveByUpdateConversionHisotry(MigrationConflict conflict, ConflictResolutionRule rule, out List <MigrationAction> actions)
        {
            actions = null;
            var unresolvedRslt = new ConflictResolutionResult(false, ConflictResolutionType.Other);

            string tgtItemId    = rule.DataFieldDictionary[HistoryNotFoundUpdateConversionHistoryAction.DATAKEY_TARGET_ITEM_ID];
            string srcRevRanges = rule.DataFieldDictionary[HistoryNotFoundUpdateConversionHistoryAction.DATAKEY_SOURCE_REVISION_RANGES];
            string tgtRevRanges = rule.DataFieldDictionary[HistoryNotFoundUpdateConversionHistoryAction.DATAKEY_TARGET_REVISION_RANGES];

            int[] srcRevs;
            int[] tgtRevs;
            if (string.IsNullOrEmpty(tgtItemId) ||
                !IntegerRange.TryParseRangeString(srcRevRanges, out srcRevs) ||
                !IntegerRange.TryParseRangeString(srcRevRanges, out tgtRevs) ||
                srcRevs == null || srcRevs.Length == 0 || tgtRevs == null || tgtRevs.Length == 0 || srcRevs.Length != tgtRevs.Length)
            {
                return(unresolvedRslt);
            }

            WorkItemHistoryNotFoundConflictType conflictType = conflict.ConflictType as WorkItemHistoryNotFoundConflictType;

            Debug.Assert(null != conflictType, "conflictType is null");

            WorkItemHistoryNotFoundConflictTypeDetails dtls = conflictType.GetConflictDetails(conflict);

            ConversionResult convRslt = new ConversionResult(dtls.SourceMigrationSourceId, dtls.TargetMigrationSourceId);

            convRslt.ChangeId           = HistoryNotFoundResolutionChangeId;
            convRslt.ContinueProcessing = true;

            for (int i = 0; i < srcRevs.Length; ++i)
            {
                convRslt.ItemConversionHistory.Add(new ItemConversionHistory(dtls.SourceWorkItemID, srcRevs[i].ToString(), tgtItemId, tgtRevs[i].ToString()));
            }

            int  sessionRunId            = 0;
            Guid sourceMigrationSourceId = Guid.Empty;

            using (RuntimeEntityModel context = RuntimeEntityModel.CreateInstance())
            {
                long actionInternalId = conflict.ConflictedChangeAction.ActionId;
                var  actionQuery      = context.RTChangeActionSet.Where(a => a.ChangeActionId == actionInternalId);
                if (actionQuery.Count() == 0)
                {
                    return(unresolvedRslt);
                }

                RTChangeAction action = actionQuery.First();
                action.ChangeGroupReference.Load();
                action.ChangeGroup.SessionRunReference.Load();
                sessionRunId = action.ChangeGroup.SessionRun.Id;

                sourceMigrationSourceId = action.ChangeGroup.SourceUniqueId;
            }

            convRslt.Save(sessionRunId, sourceMigrationSourceId);

            return(new ConflictResolutionResult(true, ConflictResolutionType.Other));
        }
示例#23
0
        /// <summary>
        /// Resolve a conflict.
        /// </summary>
        /// <param name="conflict"></param>
        /// <param name="rule"></param>
        /// <param name="actions"></param>
        /// <returns></returns>
        public ConflictResolutionResult Resolve(IServiceContainer serviceContainer, MigrationConflict conflict, ConflictResolutionRule rule, out List <MigrationAction> actions)
        {
            actions = null;

            if (rule.ActionRefNameGuid.Equals(new ManualConflictResolutionAction().ReferenceName))
            {
                return(ManualResolve(conflict, rule, out actions));
            }
            else if (rule.ActionRefNameGuid.Equals(new SkipConflictedActionResolutionAction().ReferenceName))
            {
                return(SkipConflictedActionResolutionAction.SkipConflict(conflict, true));
            }

            return(new ConflictResolutionResult(false, ConflictResolutionType.Other));
        }
        public ConflictResolutionResult Resolve(IServiceContainer serviceContainer, MigrationConflict conflict, ConflictResolutionRule rule, out List <MigrationAction> actions)
        {
            actions = null;

            if (rule.ActionRefNameGuid.Equals(new ManualConflictResolutionAction().ReferenceName))
            {
                return(new ConflictResolutionResult(true, ConflictResolutionType.Other));
            }
            else if (rule.ActionRefNameGuid.Equals(new WITUnmappedWITConflictUpdateWITMappingAction().ReferenceName))
            {
                return(ResolveByUsingWITMapping(conflict, rule));
            }
            else if (rule.ActionRefNameGuid.Equals(new WITUnmappedWITConflictExcludeWITInSessionFilter().ReferenceName) ||
                     rule.ActionRefNameGuid.Equals(new SkipConflictedActionResolutionAction().ReferenceName))
            {
                conflict.ConflictedChangeAction.ChangeGroup.Status = ChangeStatus.Skipped;
                conflict.ConflictedChangeAction.State = ActionState.Skipped;
                return(new ConflictResolutionResult(true, ConflictResolutionType.SkipConflictedChangeAction));
            }
            else
            {
                return(new ConflictResolutionResult(false, ConflictResolutionType.Other));
            }
        }