0

我有一个包含许多记录的列表,我想根据条件提取记录,如果条件满足,那么我需要将满足条件的记录添加到新列表中。

下面是我写到现在的代码:

Module Module2
Sub Main()
    Dim td
    td = CreateObject("TDApiOle80.TDConnection")
    td.InitConnectionEx("http://qc10dev/qcbin")
    'Note: For Quality Center, connect by using the URL below:
    'td.InitConnectionEx "http://<servername>:port/qcbin"
    td.ConnectProjectEx("DEFAULT", "GPS_PROGRAM", "PQRST", "XYX@123")
    Dim tsfact 'As TDAPIOLELib.TestSetFactory
    Dim tslist 'As TDAPIOLELib.List
    'Getting Random Test Set ID
    '************************ACCESS ALL THE TEST SETS ********************************************************************        '
    tsfact = td.TestSetFactory
    tslist = tsfact.NewList("")

    '************************GET THE COUNT OF TEST SETS ******************************************************************
    Dim Count_Of_TestSets
    Count_Of_TestSets = tslist.Count
    Console.WriteLine("Count of Test Sets" + Count_Of_TestSets.ToString)

    '************************GET A RANDOM TEST SET INDEX ***************************************************************  
    Dim TestSetID As Integer
    Dim TestSetName = Nothing
    Dim SerialNumber As Integer = 0
    Dim AttachmentPresent
    Dim tslist_Having_Attachments = Nothing

    For Each TestSet In tslist

        TestSetID = TestSet.ID
        TestSetName = TestSet.Name
        'Console.WriteLine("TestSet ID::" + TestSetID.ToString() + "Test Set Name" + TestSetName)
        AttachmentPresent = TestSet.HasAttachment()
        If StrComp(AttachmentPresent, "True") = 0 Then
            Console.WriteLine("TestSet ID::" + TestSetID.ToString() + "Test Set Name" + TestSetName)
        End If
    Next

    Console.WriteLine("Logic Completed, Press enter")
    Console.ReadLine()
    tslist = Nothing
    tsfact = Nothing
    td = Nothing
End Sub

端模块

如果您浏览上面的代码,则基本列表是 tslist。

从这个曾经记录满足条件的tslistStrComp(AttachmentPresent, "True") = 0

必须添加到新列表中说 tslist_attachment。

如何创建新列表并添加值?

请告诉我步骤,。

问候, 斯里哈里

4

2 回答 2

0

根据您的描述,您似乎想要一个所有附件的列表。您想通过迭代来做到这一点TestSet,看看它是否包含附件,如果是,将其添加到列表中。

SQA 论坛上的这篇文章解释了如何使用 TestSetTreeManager 直接从给定的测试集中检索附件列表,并通过节点 ID 从中检索测试集。然后可以一次收集来自该节点的所有附件:

片段:

Set TestSetTreeManager = TDConnection.TestSetTreeManager
Set TestSetFolder = TestSetTreeManager.NodeById(provideId)
If TestSetFolder.HasAttachments Then    
    Set Attachment = TestSetFolder.Attachments  
    Set AttachmentList = Attachment.NewList(" ")
End if
于 2013-11-06T07:33:51.643 回答
0

以下是我为处理此问题而编写的逻辑:)

Module Module2
Sub Main()
    Dim td
    td = CreateObject("TDApiOle80.TDConnection")
    td.InitConnectionEx("http://qc10dev/qcbin")
    'Note: For Quality Center, connect by using the URL below:
    'td.InitConnectionEx "http://<servername>:port/qcbin"
    td.ConnectProjectEx("DEFAULT", "GPS_PROGRAM", "svanumu", "ABCD")
    Dim tsfact As TDAPIOLELib.TestSetFactory
    Dim tslist As TDAPIOLELib.List

    Dim Temporary_List As TDAPIOLELib.List = Nothing
    Temporary_List = New TDAPIOLELib.List()

    'Getting Random Test Set ID
    '************************ACCESS ALL THE TEST SETS **************************************************​******************        '
    tsfact = td.TestSetFactory
    tslist = tsfact.NewList("")
    '************************GET THE COUNT OF TEST SETS **************************************************​****************
    Dim Count_Of_TestSets
    Count_Of_TestSets = tslist.Count
    Console.WriteLine("Count of Test Sets" + Count_Of_TestSets.ToString)
    '************************GET A RANDOM TEST SET INDEX **************************************************​*************  
    Dim TestSetID As Integer
    Dim TestSetName = Nothing
    Dim SerialNumber As Integer = 0
    Dim AttachmentPresent
    'Dim tslist_Having_Attachments As TDAPIOLELib.TestSetFactory

    Dim TestSetID1 = Nothing
    Dim TestSetName1 = Nothing

    For Each TestSet In tslist
        TestSetID = TestSet.ID
        TestSetName = TestSet.Name

        AttachmentPresent = TestSet.HasAttachment()
        If StrComp(AttachmentPresent, "True") = 0 Then
            Temporary_List.Add(TestSet)
            'Console.WriteLine("TestSetID::" + TestSetID.ToString + "TestSetName::" + TestSetName + "is Added from temporary list")
        End If
    Next

    '************************GET THE COUNT OF TEST SETS IN THE TEMPORARY LIST **************************************************​****************
    Dim Count_Of_TestSets_In_Temporary_List
    Count_Of_TestSets_In_Temporary_List = Temporary_List.Count
    Console.WriteLine("Count_Of_TestSets_In_Temporary_​List" + Count_Of_TestSets_In_Temporary_List.ToString)
    Console.WriteLine("Logic Completed, Press enter")
    Console.ReadLine()
    tslist = Nothing
    tsfact = Nothing
    td = Nothing
End Sub

端模块

问候, 斯里哈里

于 2013-11-07T04:01:01.900 回答