如何使用 QC OTA 提取具有链接 TC 的缺陷

How to extract Defects with linked TCs using QC OTA

我可以使用以下代码成功下载缺陷,但是如何针对每个缺陷获取状态为 'Failed or Blocked' 的链接 TC 的计数?

Sub GetDefectsByFilter()

On Error Resume Next
Dim a
Dim intIndex As Integer
Dim sngPercent As Single

Dim BugFactory, BugList, BgFilter
Dim Response As VbMsgBoxResult
Dim DefectID As String
If TDC Is Nothing Then ConnecttoQC
Set BugFactory = TDC.BugFactory
Set BgFilter = BugFactory.Filter
DefectID = frmDefectFilter.txtDefectID
BgFilter.Filter("BG_BUG_ID") = DefectID
Set BugList = BgFilter.NewList

Dim Bug, Row, Count As Integer
Count = 1
Row = 2
ActiveSheet.Cells(1, 1).Value = "Defect ID"
ActiveSheet.Cells(1, 2).Value = "Application"
ActiveSheet.Cells(1, 3).Value = "Status"

For Each Bug In BugList
    ActiveSheet.Cells(Row, 1).Value = Bug.Field("BG_BUG_ID")
    ActiveSheet.Cells(Row, 2).Value = Bug.Field("BG_USER_06")
    ActiveSheet.Cells(Row, 3).Value = Bug.Field("BG_STATUS")
    Row = Row + 1
    Count = Count + 1
Next
frmDefectFilter.Hide
End Sub

谢谢@Roland。下面的代码片段帮助了我。

Sub ViewLinks()
'------------------------------------------------------
' Output all bug links.

Dim BugF As BugFactory, bList As List
Dim aBug As Bug
Dim bugL As ILinkable, LinkList As List, linkF As LinkFactory

   'tdc is the global TDConnection object.
Set BugF = tdc.BugFactory
Set bList = BugF.NewList("")

For Each aBug In bList
'Cast the Bug object to an ILinkable reference
' to get the link factory.
    Set bugL = aBug
    Set linkF = bugL.LinkFactory
    Set LinkList = linkF.NewList("")
    Dim SourceObj As Object, TargetObj As Object, InitObj As Object, lnk As Link
    Debug.Print: Debug.Print "---------------------------------"
    Debug.Print "Source Type"; Tab; "ID"; Tab; "Target Type"; _
        Tab; "ID"; Tab; "Initiated by"
    For Each lnk In LinkList
        With lnk
            Set SourceObj = .SourceEntity
            Set TargetObj = .TargetEntity
            Set InitObj = .LinkedByEntity
            Debug.Print TypeName(SourceObj); Tab; CStr(SourceObj.ID); _
                Tab; TypeName(TargetObj); Tab; CStr(TargetObj.ID); _
                Tab; TypeName(InitObj); Spc(3); InitObj.ID
        End With
    Next lnk
Next aBug

End Sub