Beispiel #1
0
        private void CreateExternalLink(ExternalLink sourceLink, WorkItemData target)
        {
            var exist = (from Link l in target.ToWorkItem().Links
                         where l is ExternalLink && ((ExternalLink)l).LinkedArtifactUri == ((ExternalLink)sourceLink).LinkedArtifactUri
                         select(ExternalLink) l).SingleOrDefault();

            if (exist == null)
            {
                Log.LogInformation("Creating new {SourceLinkType} on {TargetId}", sourceLink.GetType().Name, target.Id);
                ExternalLink el = new ExternalLink(sourceLink.ArtifactLinkType, sourceLink.LinkedArtifactUri)
                {
                    Comment = sourceLink.Comment
                };
                target.ToWorkItem().Links.Add(el);
                if (_save)
                {
                    target.SaveToAzureDevOps();
                }
            }
            else
            {
                Log.LogInformation("Link {SourceLinkType} on {TargetId} already exists",
                                   sourceLink.GetType().Name, target.Id);
            }
        }
Beispiel #2
0
        private void CreateExternalLink(ExternalLink sourceLink, WorkItem target, bool save)
        {
            var exist = (from Link l in target.Links
                         where l is ExternalLink && ((ExternalLink)l).LinkedArtifactUri == ((ExternalLink)sourceLink).LinkedArtifactUri
                         select(ExternalLink) l).SingleOrDefault();

            if (exist == null)
            {
                Trace.WriteLine(string.Format("Creating new {0} on {1}",
                                              sourceLink.GetType().Name, target.Id), "LinkMigrationContext");
                ExternalLink el = new ExternalLink(sourceLink.ArtifactLinkType, sourceLink.LinkedArtifactUri);
                el.Comment = sourceLink.Comment;
                target.Links.Add(el);
                if (save)
                {
                    target.Fields["System.ChangedBy"].Value = "Migration";
                    target.Save();
                }
            }
            else
            {
                Trace.WriteLine(string.Format("Link {0} on {1} already exists",
                                              sourceLink.GetType().Name, target.Id), "LinkMigrationContext");
            }
        }
Beispiel #3
0
        private void CreateExternalLink(ExternalLink sourceLink, WorkItemData target)
        {
            var exist = (from Link l in target.ToWorkItem().Links
                         where l is ExternalLink && ((ExternalLink)l).LinkedArtifactUri == ((ExternalLink)sourceLink).LinkedArtifactUri
                         select(ExternalLink) l).SingleOrDefault();

            if (exist == null)
            {
                Log.LogInformation("Creating new {SourceLinkType} on {TargetId}", sourceLink.GetType().Name, target.Id);
                ExternalLink el = new ExternalLink(sourceLink.ArtifactLinkType, sourceLink.LinkedArtifactUri)
                {
                    Comment = sourceLink.Comment
                };
                target.ToWorkItem().Links.Add(el);
                if (_save)
                {
                    try
                    {
                        target.SaveToAzureDevOps();
                    }
                    catch (Exception ex)
                    {
                        // Ignore this link because the TFS server didn't recognize its type (There's no point in crashing the rest of the migration due to a link)
                        if (ex.Message.Contains("Unrecognized Resource link"))
                        {
                            Log.LogError(ex, "[{ExceptionType}] Failed to save link {SourceLinkType} on {TargetId}", ex.GetType().Name, sourceLink.GetType().Name, target.Id);
                            // Remove the link from the target so it doesn't cause problems downstream
                            target.ToWorkItem().Links.Remove(el);
                        }
                        else
                        {
                            //pass along the exception since we don't know what went wrong
                            throw;
                        }
                    }
                }
            }
            else
            {
                Log.LogInformation("Link {SourceLinkType} on {TargetId} already exists",
                                   sourceLink.GetType().Name, target.Id);
            }
        }
Beispiel #4
0
        private void CreateExternalLink(ExternalLink sourceLink, WorkItemData target, bool save)
        {
            var exist = (from Link l in target.ToWorkItem().Links
                         where l is ExternalLink && ((ExternalLink)l).LinkedArtifactUri == ((ExternalLink)sourceLink).LinkedArtifactUri
                         select(ExternalLink) l).SingleOrDefault();

            if (exist == null)
            {
                Log.Information("Creating new {SourceLinkType} on {TargetId}", sourceLink.GetType().Name, target.Id);
                ExternalLink el = new ExternalLink(sourceLink.ArtifactLinkType, sourceLink.LinkedArtifactUri);
                el.Comment = sourceLink.Comment;
                target.ToWorkItem().Links.Add(el);
                if (save)
                {
                    target.ToWorkItem().Fields["System.ChangedBy"].Value = "Migration";
                    target.ToWorkItem().Save();
                }
            }
            else
            {
                Log.Information("Link {SourceLinkType} on {TargetId} already exists",
                                sourceLink.GetType().Name, target.Id);
            }
        }
Beispiel #5
0
 private static void SetId(ExternalLink item, int id) =>
 item.GetType().GetProperty("Id").SetValue(item, id);