Beispiel #1
0
        public CyclicLinkConflictDetails GetConflictDetails(MigrationConflict conflict)
        {
            if (!conflict.ConflictType.ReferenceName.Equals(this.ReferenceName))
            {
                throw new InvalidOperationException();
            }

            if (string.IsNullOrEmpty(conflict.ConflictDetails))
            {
                throw new ArgumentNullException("conflict.ConflictDetails");
            }

            try
            {
                // V2 conflict details, i.e. using property bag
                return(new CyclicLinkConflictDetails(conflict.ConflictDetailsProperties));
            }
            catch (Exception)
            {
                GenericSerializer <InvalidWorkItemLinkDetails> serializer =
                    new GenericSerializer <InvalidWorkItemLinkDetails>();
                InvalidWorkItemLinkDetails baseDetails = serializer.Deserialize(conflict.ConflictDetails) as InvalidWorkItemLinkDetails;
                return(new CyclicLinkConflictDetails(baseDetails.SourceWorkItemID, baseDetails.TargetWorkItemID,
                                                     baseDetails.LinkTypeReferenceName, null));
            }
        }
        private static void ParseExceptionMessage(Exception linkSubmissionException, LinkChangeAction action, out string scopeHint, out string conflictDetails)
        {
            /*
             * Example Exception:
             * System.Web.Services.Protocols.SoapException
             *
             * Example Message
             * AddLink: The specified link type requires that work items have a single parent.
             * The target work item already has a parent of that type: %SourceID="969";%, %TargetID="967";%, %LinkType="2";%
             * ---> AddLink: The specified link type requires that work items have a single parent. The target work item already
             * has a parent of that type: %SourceID="969";%, %TargetID="967";%, %LinkType="2";%
             */
            Debug.Assert(linkSubmissionException is System.Web.Services.Protocols.SoapException,
                         "linkSubmissionException is not System.Web.Services.Protocols.SoapException");
            Debug.Assert(!string.IsNullOrEmpty(linkSubmissionException.Message), "linkSubmissionException.Message is null or empty");
            Debug.Assert(linkSubmissionException.Message.StartsWith(SingleParentViolationMessage, StringComparison.OrdinalIgnoreCase),
                         string.Format("linkSubmissionException.Message does not start with '{0}'", SingleParentViolationMessage));

            string sourceItem = action.Link.SourceArtifactId;
            string targetItem = TfsWorkItemHandler.IdFromUri(action.Link.TargetArtifact.Uri);
            string linkType   = action.Link.LinkType.ReferenceName;

            scopeHint       = string.Format("/{0}/{1}/{2}", linkType, sourceItem, targetItem);
            conflictDetails = InvalidWorkItemLinkDetails.CreateConflictDetails(sourceItem, targetItem, linkType);
        }
Beispiel #3
0
        private static void ParseExceptionMessage(
            Exception linkSubmissionException,
            LinkChangeAction action,
            out string scopeHint,
            out string conflictDetails)
        {
            /*
             * Example Exception:
             * System.Web.Services.Protocols.SoapException
             *
             * Example Message
             * Failed to modify links. The following linked work items have been locked by an administrator:
             * %LinkFailures="1954;1955;2;2,";% ---> Failed to modify links. The following linked work items
             * have been locked by an administrator: %LinkFailures="1954;1955;2;2,";%
             */
            Debug.Assert(linkSubmissionException is System.Web.Services.Protocols.SoapException,
                         "linkSubmissionException is not System.Web.Services.Protocols.SoapException");
            Debug.Assert(!string.IsNullOrEmpty(linkSubmissionException.Message), "linkSubmissionException.Message is null or empty");
            Debug.Assert(linkSubmissionException.Message.StartsWith(ModifyLockedWorkItemLinkViolationMessage, StringComparison.OrdinalIgnoreCase),
                         string.Format("linkSubmissionException.Message does not start with '{0}'", ModifyLockedWorkItemLinkViolationMessage));

            string sourceItem = action.Link.SourceArtifactId;
            string targetItem = TfsWorkItemHandler.IdFromUri(action.Link.TargetArtifact.Uri);
            string linkType   = action.Link.LinkType.ReferenceName;

            scopeHint       = string.Format("/{0}/{1}/{2}", linkType, sourceItem, targetItem);
            conflictDetails = InvalidWorkItemLinkDetails.CreateConflictDetails(sourceItem, targetItem, linkType);
        }
Beispiel #4
0
        private static void ParseExceptionMessage(
            Exception linkSubmissionException,
            LinkChangeAction action,
            out string scopeHint,
            out string conflictDetails)
        {
            Debug.Assert(linkSubmissionException is System.Web.Services.Protocols.SoapException,
                         "linkSubmissionException is not System.Web.Services.Protocols.SoapException");

            string sourceItem = action.Link.SourceArtifactId;
            string targetItem = TfsWorkItemHandler.IdFromUri(action.Link.TargetArtifact.Uri);
            string linkType   = action.Link.LinkType.ReferenceName;

            scopeHint       = string.Format("/{0}/{1}/{2}", linkType, sourceItem, targetItem);
            conflictDetails = InvalidWorkItemLinkDetails.CreateConflictDetails(sourceItem, targetItem, linkType);
        }
Beispiel #5
0
        internal static string CreateConflictDetails(string sourceItem, string targetItem, string linkType)
        {
            InvalidWorkItemLinkDetails dtls =
                new InvalidWorkItemLinkDetails(sourceItem, targetItem, linkType);

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

            using (MemoryStream memStrm = new MemoryStream())
            {
                serializer.Serialize(memStrm, dtls);
                memStrm.Seek(0, SeekOrigin.Begin);
                using (StreamReader sw = new StreamReader(memStrm))
                {
                    return(sw.ReadToEnd());
                }
            }
        }
Beispiel #6
0
        internal static string TranslateConflictDetailsToReadableDescription(string detailsBlob, string conflictMessage)
        {
            if (string.IsNullOrEmpty(detailsBlob))
            {
                throw new ArgumentNullException("detailsBlob");
            }

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

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

                    return(string.Format(
                               "{0} (Source WorkItem: {1}; Target WorkItem: {2}; LinkType: {3}.)",
                               conflictMessage, details.SourceWorkItemID, details.TargetWorkItemID, details.LinkTypeReferenceName));
                }
        }
        private static void ParseExceptionMessage(
            Exception linkSubmissionException,
            LinkChangeAction action,
            out string scopeHint,
            out string conflictDetails)
        {
            Debug.Assert(linkSubmissionException is System.Web.Services.Protocols.SoapException,
                         "linkSubmissionException is not System.Web.Services.Protocols.SoapException");
            Debug.Assert(!string.IsNullOrEmpty(linkSubmissionException.Message), "linkSubmissionException.Message is null or empty");
            Debug.Assert(
                linkSubmissionException.Message.StartsWith(LinkAccessViolationMessage1, StringComparison.OrdinalIgnoreCase) ||
                linkSubmissionException.Message.StartsWith(LinkAccessViolationMessage2, StringComparison.OrdinalIgnoreCase),
                string.Format("linkSubmissionException.Message does not start with '{0}' or '{1}'",
                              LinkAccessViolationMessage1, LinkAccessViolationMessage2));

            string sourceItem = action.Link.SourceArtifactId;
            string targetItem = TfsWorkItemHandler.IdFromUri(action.Link.TargetArtifact.Uri);
            string linkType   = action.Link.LinkType.ReferenceName;

            scopeHint       = string.Format("/{0}/{1}/{2}", linkType, sourceItem, targetItem);
            conflictDetails = InvalidWorkItemLinkDetails.CreateConflictDetails(sourceItem, targetItem, linkType);
        }
Beispiel #8
0
 public override string TranslateConflictDetailsToReadableDescription(string dtls)
 {
     return(InvalidWorkItemLinkDetails.TranslateConflictDetailsToReadableDescription(dtls, SingleParentViolationMessage));
 }
 public override string TranslateConflictDetailsToReadableDescription(string dtls)
 {
     return(InvalidWorkItemLinkDetails.TranslateConflictDetailsToReadableDescription(dtls, FriendlyName));
 }