Exemplo n.º 1
0
 public void ProcessAttachemnts(WorkItem sourceWorkItem, WorkItem targetWorkItem, bool save = true)
 {
     _exportWiPath = Path.Combine(_exportBasePath, sourceWorkItem.Id.ToString());
     if (System.IO.Directory.Exists(_exportWiPath))
     {
         System.IO.Directory.Delete(_exportWiPath, true);
     }
     System.IO.Directory.CreateDirectory(_exportWiPath);
     foreach (Attachment wia in sourceWorkItem.Attachments)
     {
         try
         {
             string filepath = null;
             filepath = ExportAttachment(sourceWorkItem, wia, _exportWiPath);
             WorkItemMigrationContext.TraceWriteLine(sourceWorkItem, $"Exported {System.IO.Path.GetFileName(filepath)} to disk");
             if (filepath != null)
             {
                 ImportAttachemnt(targetWorkItem, filepath, save);
                 WorkItemMigrationContext.TraceWriteLine(sourceWorkItem, $"Imported {System.IO.Path.GetFileName(filepath)} from disk");
             }
         }
         catch (Exception)
         {
             WorkItemMigrationContext.TraceWriteLine(sourceWorkItem, $"ERROR: Unable to process atachment from source wi {sourceWorkItem.Id} called {wia.Name}");
         }
     }
     if (save)
     {
         WorkItemMigrationContext.SaveWorkItem(targetWorkItem);
         WorkItemMigrationContext.TraceWriteLine(sourceWorkItem, $" Work iTem now has {sourceWorkItem.Attachments.Count} attachemnts");
         CleanUpAfterSave(targetWorkItem);
     }
 }
Exemplo n.º 2
0
        public void TestFixAreaPath_WhenNoAreaPathOrIterationPath_DoesntChangeQuery()
        {
            string WIQLQueryBit = @"AND  [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan')";

            string targetWIQLQueryBit = WorkItemMigrationContext.FixAreaPathAndIterationPathForTargetQuery(WIQLQueryBit, "SourceServer", "TargetServer", null);

            Assert.AreEqual(WIQLQueryBit, targetWIQLQueryBit);
        }
Exemplo n.º 3
0
        public void TestFixAreaPathAndIteration_WhenMultipleOccuranceWithMixtureOrEqualAndUnderOperatorsInQuery_ChangesQuery()
        {
            string WIQLQueryBit         = @"AND ([System.AreaPath] = 'SourceServer\Area\Path1' OR [System.AreaPath] UNDER 'SourceServer\Area\Path2') AND ([System.IterationPath] UNDER 'SourceServer\Iteration\Path1' OR [System.IterationPath] = 'SourceServer\Iteration\Path2') AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan')";
            string expectTargetQueryBit = @"AND ([System.AreaPath] = 'TargetServer\Area\Path1' OR [System.AreaPath] UNDER 'TargetServer\Area\Path2') AND ([System.IterationPath] UNDER 'TargetServer\Iteration\Path1' OR [System.IterationPath] = 'TargetServer\Iteration\Path2') AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan')";

            string targetWIQLQueryBit = WorkItemMigrationContext.FixAreaPathAndIterationPathForTargetQuery(WIQLQueryBit, "SourceServer", "TargetServer", null);

            Assert.AreEqual(expectTargetQueryBit, targetWIQLQueryBit);
        }
Exemplo n.º 4
0
        public void TestFixAreaPath_WhenAreaPathAtEndOfQuery_ChangesQuery()
        {
            string WIQLQueryBit         = @"AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan') AND [System.AreaPath] = 'SourceServer\Area\Path1'";
            string expectTargetQueryBit = @"AND [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan') AND [System.AreaPath] = 'TargetServer\Area\Path1'";

            string targetWIQLQueryBit = WorkItemMigrationContext.FixAreaPathAndIterationPathForTargetQuery(WIQLQueryBit, "SourceServer", "TargetServer", null);

            Assert.AreEqual(expectTargetQueryBit, targetWIQLQueryBit);
        }
        public void TestFixAreaPath_WhenNoAreaPathAndTwoNodeBasePaths_DoesntChangeQuery()
        {
            string WIQLQueryBit = @"AND  [Microsoft.VSTS.Common.ClosedDate] = '' AND [System.WorkItemType] NOT IN ('Test Suite', 'Test Plan')";

            string[] nodeBasePaths      = { "SourceServer\\Area\\Path1", "SourceServer\\Area\\Path1" };
            string   targetWIQLQueryBit = WorkItemMigrationContext.FixAreaPathInTargetQuery(WIQLQueryBit, "SourceServer", "TargetServer", nodeBasePaths, null);

            Assert.AreEqual(WIQLQueryBit, targetWIQLQueryBit);
        }