【问题标题】:Create QC Resource with uft使用 uft 创建 QC 资源
【发布时间】:2018-08-08 07:56:00
【问题描述】:

我发现了很多关于通过 UFT 将资源上传到 ALM 的示例。 但是,总是在 ALM 中创建了一个资源。 如何使用 UFT 创建资源并将其上传到 ALM? 我的问题是我不知道我需要多少资源,所以我必须动态地创建资源然后上传它们。 我不想将文件作为附件上传到运行中。

谢谢

【问题讨论】:

    标签: vbscript upload resources hp-uft alm


    【解决方案1】:

    我想我在这里找到了答案:http://www.codetweet.com/other/create-new-resource-almqc-using-ota/

    Sub CreateNewResource(resourceFolderId As Integer, fileType As String, fileName As String, fileParentFolderPath As String)
    
        On Error GoTo Errhandler:
    
        '--- Represents a file or folder stored in the Quality Center repository
        Dim resource As QCResource
        '--- Represents a QC resource folder.
        Dim resourceFolder As QCResourceFolder
        '--- Services for managing QC resources.
        Dim resourceFactory As QCResourceFactory
        '--- Services for managing QC resource folders.
        Dim resourceFolderFactory As QCResourceFolderFactory
        '--- Services to manage resource storage.
        Dim testResourceStorage As IResourceStorage
        Dim resourceItem
        Dim resourceFound As Boolean
    
        ' ***TDConn is TDConnection class object.Create this object before using this function.
        Set resourceFolderFactory = TDConn.QCResourceFolderFactory
        Set resourceFolder = resourceFolderFactory.Item(resourceFolderId)
        Set resourceFactory = resourceFolder.QCResourceFactory
        Set currResourceList = resourceFactory.NewList("")
    
        For ItemCount = 1 To currResourceList.Count
            currItem = currResourceList.Item(ItemCount).Name
            If UCase(currItem) = UCase(fileName) Then
                Set resourceItem = currResourceList.Item(ItemCount)
                resourceFound = True
                Exit For
            End If
        Next
    
       If Not resourceFound Then
            '--- Create a resource
            Set resourceItem = resourceFactory.AddItem(fileName)
            resourceItem.ResourceType = fileType
            resourceItem.fileName = fileName
            resourceItem.Post
    
            '--- Check if the resources added successfully
            Set currResourceList = resourceFactory.NewList("")
            For ItemCount = 1 To currResourceList.Count
                currItem = currResourceList.Item(ItemCount).Name
                If UCase(currItem) = UCase(fileName) Then
                    resourceFound = True
                    Exit For
                End If
            Next
    
            If resourceFound Then
                '--- Attach the file to resource
                resourceItem.vC.CheckOut ""
                Set testResourceStorage = resourceItem
                testResourceStorage.UploadResource fileParentFolderPath, False
                resourceItem.vC.CheckIn "Automated check-in by utility" & Now
            Else
                 oFile.WriteLine ("Recently added new resource not found on ALM.Try again later.")
                 Exit Sub
            End If
        Else
            resourceItem.vC.CheckOut ""
            Set testResourceStorage = resourceItem
            testResourceStorage.UploadResource fileParentFolderPath, False
            resourceItem.vC.CheckIn "Automated check-in by utility" & Now
        End If
    
        Set resourceFolderFactory = Nothing
        Set resourceFolder = Nothing
        Set resourceFactory = Nothing
        Set currResourceList = Nothing
    
        Exit Sub
    
    Errhandler:
       MsgBox("Error Executing - `CreateNewResource`  ; Error Uploading file " & fileName)
       Exit Sub
    End Sub
    

    【讨论】:

      猜你喜欢
      • 2022-07-24
      • 2021-01-21
      • 1970-01-01
      • 1970-01-01
      • 2020-11-18
      • 2019-05-19
      • 2020-04-28
      • 2019-12-24
      • 1970-01-01
      相关资源
      最近更新 更多