Exemple #1
0
        public bool UpdateTfs(TfsUpdateDocument updateDoc, LinkChangeAction linkChangeAction)
        {
            if (null == updateDoc)
            {
                throw new ArgumentNullException("updateDoc");
            }

            if (null == linkChangeAction)
            {
                throw new ArgumentNullException("linkChangeAction");
            }

            if (!linkChangeAction.Link.LinkType.ReferenceName.Equals(REFERENCE_NAME))
            {
                throw new ArgumentException("Link type mismatch.");
            }

            string uri     = linkChangeAction.Link.TargetArtifact.Uri;
            string comment = linkChangeAction.Link.Comment;

            if (linkChangeAction.ChangeActionId.Equals(WellKnownChangeActionId.Add))
            {
                updateDoc.AddExternalLink(LinkingConstants.VcFileLinkType, uri, comment);
            }
            else if (linkChangeAction.ChangeActionId.Equals(WellKnownChangeActionId.Delete))
            {
                Debug.Assert(updateDoc.WorkItem != null, "WorkItem is null in updateDoc");
                int?extId = ExtractFileLinkInfoExtId(updateDoc.WorkItem, uri);

                if (extId.HasValue)
                {
                    updateDoc.DeleteExternalLink(extId.Value);
                }
                else
                {
                    TraceManager.TraceInformation("Deleting link {0}-to-{1} failed - cannot find linked target artifact.",
                                                  linkChangeAction.Link.SourceArtifactId,
                                                  linkChangeAction.Link.TargetArtifact.Uri);
                    return(false);
                }
            }
            else
            {
                throw new MigrationException(TfsWITAdapterResources.ErrorUnsupportedChangeAction);
            }

            return(true);
        }
Exemple #2
0
        public bool UpdateTfs(TfsUpdateDocument updateDoc, LinkChangeAction linkChangeAction)
        {
            if (null == updateDoc)
            {
                throw new ArgumentNullException("updateDoc");
            }

            if (null == linkChangeAction)
            {
                throw new ArgumentNullException("linkChangeAction");
            }

            if (!linkChangeAction.Link.LinkType.ReferenceName.Equals(ReferenceName))
            {
                throw new ArgumentException("Link type mismatch.");
            }

            string targetId   = TfsWorkItemHandler.IdFromUri(linkChangeAction.Link.TargetArtifact.Uri);
            string sourceId   = TfsWorkItemHandler.IdFromUri(linkChangeAction.Link.SourceArtifact.Uri);
            int    linkTypeId = WorkItemLinkTypeId(ReferenceName, true);
            string comment    = linkChangeAction.Link.Comment ?? string.Empty;


            var tfs2010UpdateDoc = updateDoc as Tfs2010UpdateDocument;

            Debug.Assert(null != tfs2010UpdateDoc);

            if (linkChangeAction.ChangeActionId.Equals(WellKnownChangeActionId.Add))
            {
                tfs2010UpdateDoc.AddWorkItemLink(sourceId, targetId, linkTypeId, comment, linkChangeAction.Link.IsLocked);
            }
            else if (linkChangeAction.ChangeActionId.Equals(WellKnownChangeActionId.Edit))
            {
                tfs2010UpdateDoc.UpdateWorkItemLink(sourceId, targetId, linkTypeId, comment, linkChangeAction.Link.IsLocked);
            }
            else if (linkChangeAction.ChangeActionId.Equals(WellKnownChangeActionId.Delete))
            {
                tfs2010UpdateDoc.RemoveWorkItemLink(sourceId, targetId, linkTypeId, comment);
            }
            else
            {
                throw new MigrationException(TfsWITAdapterResources.ErrorUnsupportedChangeAction);
            }

            return(true);
        }
Exemple #3
0
        public bool UpdateTfs(TfsUpdateDocument updateDoc, LinkChangeAction linkChangeAction)
        {
            if (null == updateDoc)
            {
                throw new ArgumentNullException("updateDoc");
            }

            if (null == linkChangeAction)
            {
                throw new ArgumentNullException("linkChangeAction");
            }

            if (!linkChangeAction.Link.LinkType.ReferenceName.Equals(REFERENCE_NAME))
            {
                throw new ArgumentException("Link type mismatch.");
            }

            //if (!linkChangeAction.ChangeActionId.Equals(WellKnownChangeActionId.Add))
            //{
            //    Debug.Assert(false, "Unsupported action!");
            //    TraceManager.TraceError("Non-add action on external links is not supported.");
            //}

            string uri     = linkChangeAction.Link.TargetArtifact.Uri;
            string comment = linkChangeAction.Link.Comment;

            if (linkChangeAction.ChangeActionId.Equals(WellKnownChangeActionId.Add))
            {
                updateDoc.AddWorkItemLink(TfsWorkItemHandler.IdFromUri(uri), comment);
            }
            else if (linkChangeAction.ChangeActionId.Equals(WellKnownChangeActionId.Delete))
            {
                updateDoc.RemoveWorkItemLink(TfsWorkItemHandler.IdFromUri(uri));
            }
            else
            {
                throw new MigrationException(TfsWITAdapterResources.ErrorUnsupportedChangeAction);
            }

            return(true);
        }