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));
        }
Beispiel #2
0
        /// <summary>
        /// Translates the conflict details to a readable description.
        /// </summary>
        /// <param name="dtls"></param>
        /// <returns></returns>
        public override string TranslateConflictDetailsToReadableDescription(string dtls)
        {
            if (string.IsNullOrEmpty(dtls))
            {
                throw new ArgumentNullException("dtls");
            }

            XmlSerializer serializer = new XmlSerializer(typeof(WorkItemHistoryNotFoundConflictTypeDetails));

            using (StringReader strReader = new StringReader(dtls))
                using (XmlReader xmlReader = XmlReader.Create(strReader))
                {
                    WorkItemHistoryNotFoundConflictTypeDetails details =
                        (WorkItemHistoryNotFoundConflictTypeDetails)serializer.Deserialize(xmlReader);

                    return(string.Format(
                               "Work Item conversion history for Source Item '{0}' (revision: '{1}', Migration Source: '{2}') is not found.",
                               details.SourceWorkItemID, details.SourceWorkItemRevision, details.SourceMigrationSourceId.ToString()));
                }
        }
Beispiel #3
0
        private static string CreateConflictDetails(
            string sourceItemId,
            string sourceItemRevision,
            Guid sourceMigrationSourceId,
            Guid targetMigrationSourceId)
        {
            WorkItemHistoryNotFoundConflictTypeDetails dtls =
                new WorkItemHistoryNotFoundConflictTypeDetails(sourceItemId, sourceItemRevision, sourceMigrationSourceId, targetMigrationSourceId);

            XmlSerializer serializer = new XmlSerializer(typeof(WorkItemHistoryNotFoundConflictTypeDetails));

            using (MemoryStream memStrm = new MemoryStream())
            {
                serializer.Serialize(memStrm, dtls);
                memStrm.Seek(0, SeekOrigin.Begin);
                using (StreamReader sw = new StreamReader(memStrm))
                {
                    return(sw.ReadToEnd());
                }
            }
        }