如何使用C#和ASP.net连接惠普质量中心 [英] How to connect HP Quality Center using C# and ASP.net

查看:223
本文介绍了如何使用C#和ASP.net连接惠普质量中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找使用C#和ASP.net连接惠普质量中心。是否有人可以给我建议的方式使用的.NET Web应用程序连接它。另外,做我需要做在我的应用程序托管在我的服务器上的任何安装?

下面是一些Java code,我发现,我想是这样的。

  //连接到QC
    ITDConnection该局= ClassFactory.createTDConnection();
    的System.out.println(itdc.connected());
    itdc.initConnectionEx(http://QC.com/qcbin);
    的System.out.println(itdc.connected());
    itdc.connectProjectEx(DomainA中,项目B,用户名,密码);


解决方案

好吧,这样做有两种方式。这些是使用:


  1. OTA客户端(开放式测试架构)

    这是从第三方应用程序与HP QC / ALM连接的传统方式。该API已经使用了很多年,是它与QC允许的相互作用方面相当成熟。然而,这种API,我相信是基于COM,并迅速成为过时。因此,我不建议使用它来构建定制的广泛线束QC


  2. REST API

    HP已经开始在他们的最后几个版本提供一个QC REST API。在QC的最新版本(现在称为HP ALM 11.5)的REST API似乎是相当成熟。我说的这个主要优点是速度和更好的互操作性,因为我相信REST正在迅速成为主流标准暴露远程服务之一。


这是对你的选择一些背景。但是给在C#中code的一些示例,请参阅以下code片段。

 使用TDAPIOLELib; //这是QTP互操作库
私人TDConnection qcConnection;私人字符串连接()
{
    字符串状态;
    状态=正在初始化;        qcConnection.InitConnectionEx(&下; QC网址>中);
        qcConnection.ConnectProjectEx(&下; QC域>中,&所述; QC项目>中,&所述; LoginUserId>中,&所述; userPassword的>中);
        如果(qcConnection.ProjectConnected)
        {
            状态=已连接;
        }
    返回状态;
}
公共无效GetTestsInTestSet(字符串testFolder,串testSetName)
{
    TDAPIOLELib.List tsTestList =新TDAPIOLELib.List();
    尝试
    {
        如果(qcConnection.ProjectConnected)
        {
            TestSetFactory tSetFact =(TestSetFactory)qcConnection.TestSetFactory;
            TestSetTreeManager tsTreeMgr =(TestSetTreeManager)qcConnection.TestSetTreeManager;            TestSetFolder tsFolder =(TestSetFolder)tsTreeMgr.get_NodeByPath(testFolder);            清单tsList = tsFolder.FindTestSets(testSetName,假,空);
            的foreach(TestSet testSet在tsList)
            {
                TestSetFolder TSFolder =(TestSetFolder)testSet.TestSetFolder;
                TSTestFactory TSTestFactory =(TSTestFactory)testSet.TSTestFactory;
                tsTestList = TSTestFactory.NewList();
            }            的foreach(在tsTestList TSTest测试)
            {                System.Diagnostics.Debug.Writeln(测试[qcFrameworkTestIDFieldName]);
            }        }
        其他
        {
            Console.WriteLine(QC连接失败);
        }
    }
    赶上(例外五)
    {
        Ë扔掉;
    }
}

注:


  1. 要获得QC互操作库,寻找OTAClient.dll。这是下载到本地计算机,一旦你第一次成功地从你的机器访问QC。

  2. HP ALM 11.50 - REST API Refrence:<一href=\"http://support.openview.hp.com/selfsolve/document/KM1413621/binary/ALM11.50_REST_API_Ref.html?searchIdentifier=4a65d813%3a140830b7b59%3a6cfa&resultType=document\" rel=\"nofollow\">http://support.openview.hp.com/selfsolve/document/KM1413621/binary/ALM11.50_REST_API_Ref.html?searchIdentifier=4a65d813%3a140830b7b59%3a6cfa&resultType=document

  3. HP ALM 11.50 - OTA API Refrence:<一href=\"http://support.openview.hp.com/selfsolve/document/KM1413612/binary/ALM11.50_OpenTest_Architect_API_Ref.html?searchIdentifier=4a65d813%3a140830b7b59%3a6e9b&resultType=document\" rel=\"nofollow\">http://support.openview.hp.com/selfsolve/document/KM1413612/binary/ALM11.50_OpenTest_Architect_API_Ref.html?searchIdentifier=4a65d813%3a140830b7b59%3a6e9b&resultType=document

  4. 一般来说,我觉得这是很乏味的,在C#中的OTA API工作。即使从参考指南,它是相当困难的有时摸出一些对象类型和铸造。使用VB.Net可能使它更容易一些,因为我相信你不会需要做这么多的铸造。但是,如果我不得不做一遍的话,我肯定会首先考虑REST API。

所有最优秀的。

取值

I am looking to connect HP quality center using C# and ASP.net. Can someone please suggest me a way to connect it using .net web application. Also, do i need to do any installation on my server where my application is hosted?

Below is some java code i found, I want something like this

//Connect to QC    
    ITDConnection itdc= ClassFactory.createTDConnection();    
    System.out.println(itdc.connected());    
    itdc.initConnectionEx("http://QC.com/qcbin");    
    System.out.println(itdc.connected());    
    itdc.connectProjectEx("DomainA", "ProjectB", "UserID", "Password");    

解决方案

Well, there are two ways of doing this. These are using:

  1. OTA Client (Open Test Architecture)

    This is the traditional way of connecting with HP QC/ALM from a third party app. This API has been available for many years and is quite mature in terms of the interactions it allows with QC. However this API I believe is COM based and is fast becoming outdated. Therefore I wouldn't recommend using this to build extensive custom QC harnesses.

  2. REST API

    HP has started providing a REST API for QC in their last few version. The REST API in the latest version of QC (now known as HP ALM 11.5) seems to be quite mature. I'd say the main advantage of this would be speed and better interoperability as I believe REST is fast becoming one of the main stream standards for exposing remote services.

That was some background on your options. However to give some examples of the code in C#, see the following code snippet.

using TDAPIOLELib; // This is the QTP interop library 
private TDConnection qcConnection;

private string Connect()
{
    string status;
    status = "Initialising";

        qcConnection.InitConnectionEx("<QC URL>");
        qcConnection.ConnectProjectEx("<QC Domain>", "<QC Project>", "<LoginUserId>", "<UserPassword>");
        if (qcConnection.ProjectConnected)
        {
            status = "Connected";
        }
    return status;
}
public void GetTestsInTestSet(string testFolder, string testSetName)
{
    TDAPIOLELib.List tsTestList = new TDAPIOLELib.List();
    try
    {
        if (qcConnection.ProjectConnected)
        {
            TestSetFactory tSetFact = (TestSetFactory)qcConnection.TestSetFactory;
            TestSetTreeManager tsTreeMgr = (TestSetTreeManager)qcConnection.TestSetTreeManager;

            TestSetFolder tsFolder = (TestSetFolder)tsTreeMgr.get_NodeByPath(testFolder);

            List tsList = tsFolder.FindTestSets(testSetName, false, null);


            foreach (TestSet testSet in tsList)
            {
                TestSetFolder TSFolder = (TestSetFolder)testSet.TestSetFolder;
                TSTestFactory TSTestFactory = (TSTestFactory)testSet.TSTestFactory;
                tsTestList = TSTestFactory.NewList("");
            }

            foreach (TSTest test in tsTestList)
            {

                System.Diagnostics.Debug.Writeln(test[qcFrameworkTestIDFieldName]);
            }

        }
        else
        {
            Console.WriteLine("QC connection failed");
        }
    }
    catch (Exception e)
    {
        throw e;
    }    
}

Notes:

  1. To get the QC interop library, look for OTAClient.dll. This is downloaded onto your local machine once you first successfully access QC from you machine.
  2. HP ALM 11.50 - REST API Refrence: http://support.openview.hp.com/selfsolve/document/KM1413621/binary/ALM11.50_REST_API_Ref.html?searchIdentifier=4a65d813%3a140830b7b59%3a6cfa&resultType=document
  3. HP ALM 11.50 - OTA API Refrence: http://support.openview.hp.com/selfsolve/document/KM1413612/binary/ALM11.50_OpenTest_Architect_API_Ref.html?searchIdentifier=4a65d813%3a140830b7b59%3a6e9b&resultType=document
  4. Generally, I found it quite tedious to work with the OTA API in C#. Even from the reference guides it's quite difficult to some times work out some of the object types and casting. Using VB.Net may make it a little easier as I believe you wouldn't need to do so much casting. However, if I had to do it all over again, I would definitely consider the REST API first.

All the best.

S

这篇关于如何使用C#和ASP.net连接惠普质量中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆