How to get a list of defects in QC11.0 via C# OTA using BugFilter

bcd picture bcd · Jan 26, 2012 · Viewed 8.8k times · Source

I have successfully connected to QC using VBscript via the OTA interface. In VbScript I had the following code to filter out defects and get load them in a list.

BugFilter.Filter("BG_STATUS") = "Not Canceled and NOT Closed" 
BugFilter.Filter("BG_PROJECT") = "Business*"


Set BugList = BugFilter.NewList()

The above worked flawlessly in Vbscript.

In C#.NET (4.0), I am able to connect to QC successfully but when I try to apply the filter , it give me a error..

TDConnection qcc = new TDConnection();
qcc.InitConnectionEx(sr);

qcc.ConnectProjectEx("XXXX", "------", "----", "-----");

            if (qcc.Connected)
            {
                Console.WriteLine("connected");
                BugFactory bf = (BugFactory)qcc.BugFactory;



                bf.Filter["BG_STATUS"] = "Not Canceled and NOT Closed";
                bf.Filter["BG_PROJECT"] = "Business*";

                List bugs = (List)bf.NewList(bf.Filter); 

on the last line of code , it gives me the following error "Could not convert argument 0 for call to NewList."

I am relative new to C#, Can anybody help me here?

Answer

Sudipto picture Sudipto · May 4, 2012

Try bg.Filter.text()

You'd need to check the method, 'cause I do that in java. But there is a method by that name. How I normally do that is like this:

List bugs = (List)bg.NewList();