Re: Run Script to Extract all Bugs from all domains and projects (324 Views)
Reply
Honored Contributor
john scarpino
Posts: 1,344
Registered: ‎02-15-2008
Message 1 of 8 (360 Views)

Run Script to Extract all Bugs from all domains and projects

What am I doing incorrect? I am trying to run the following script to extract all bugs from all domains and projects. It runs without fail but nothing is brought back. I am running in QC 10.0

 

Sub XProjectReport(ADD_USERNAME_HERE, ADD_PASSWORD_HERE, ADD_SERVERNAME_HERE)
URL = "http://ADD_URL_HERE/qcbin"
Set TDConnection = CreateObject("TDApiOle80.TDConnection.1")
TDConnection.InitConnectionEx URL
TDConnection.Login UserName, Password
For Each Domain In TDConnection.VisibleDomains
For Each Project In TDConnection.VisibleProjects(Domain)
TDConnection.Connect Domain, Project
If TDConnection.ProjectConnected Then
Set Com = TDConnection.Command
Com.CommandText = "select count(*) from BUG"
Set RecSet = Com.Execute
Rw = Rw + 1
Cells(Rw, 1) = Project
Cells(Rw, 2) = Domain
Cells(Rw, 3) = RecSet.FieldValue(0)
End If
TDConnection.Disconnect
Next
Next
TDConnection.Logout
TDConnection.ReleaseConnection
Set Com = Nothing: Set TDConnection = Nothing
End Sub

 

Thank you.

John

Please use plain text.
Honored Contributor
Massimo De Rosa
Posts: 656
Registered: ‎03-02-2009
Message 2 of 8 (349 Views)

Re: Run Script to Extract all Bugs from all domains and projects

Hi John,

 

this is seems correct... I suppose UserName, Password that you use are the argument of the Sub... Cells also is something like objWks.Cells excel object...

 

 

try to insert the destroy instruction for the Command object and also for the RecSet object. Other thing, to make a clear program, move always the RecSet to the Beginning with the .First method

 

Maybe the problem isn't in the manage of QC object but in the Excel object.... When do you save them?

 

Ciao,

Massimo.

Please use plain text.
Honored Contributor
john scarpino
Posts: 1,344
Registered: ‎02-15-2008
Message 3 of 8 (343 Views)

Re: Run Script to Extract all Bugs from all domains and projects

Hi Massimo,

 

Thank you for your help.

 

I also tried the following and it also failed. I am not sure why it is not working?

 

'Sub XProjectReport(UserName, Password, Server)
'URL = "http://" & Server & "/qcbin"
Set TDConnection = CreateObject("TDApiOle80.TDConnection.1")
TDConnection.InitConnectionEx "ADD-QUALITY-CENTER-URL-HERE/qcbin/"
TDConnection.Login "ADD-USER-NAME-HERE", "ADD-PASSWORD-HERE"
Cells.Clear: Ro = 1
For Each Domain In TDConnection.VisibleDomains
For Each Project In TDConnection.VisibleProjects(Domain)
TDConnection.Connect Domain, Project
If TDConnection.ProjectConnected Then
Set Cmd = TDConnection.Command
Cmd.CommandText = "select ts_test_id, ts_name, ts_responsible, ts_creation_date, ts_description, ts_type from test"
Set RecSet = Cmd.Execute
If Ro = 1 Then
For Co = 1 To RecSet.ColCount
Cells(Ro, Co + 2).Value = RecSet.ColName(Co - 1)
Next
End If
Do While Not RecSet.EOR
Ro = Ro + 1
Cells(Ro, 1) = Domain
Cells(Ro, 2) = Project
For Co = 1 To RecSet.ColCount
Cells(Ro, Co + 2).Value = RecSet.FieldValue(Co - 1)
Next
RecSet.Next
Loop
End If
Next
TDConnection.Disconnect
Next
TDConnection.Logout
TDConnection.ReleaseConnection
Set RecSet = Nothing: Set Cmd = Nothing: Set TDConnection = Nothing

Please use plain text.
Honored Contributor
Massimo De Rosa
Posts: 656
Registered: ‎03-02-2009
Message 4 of 8 (324 Views)

Re: Run Script to Extract all Bugs from all domains and projects

Ciao John,

I send you my vbscript in the attachment. The script failed after a lots of cycle. Maybe you need to do not too much cycle... so split the script one for each domain... I think it goes.

 

have a nice day.

Regards, Massimo.

Please use plain text.
Honored Contributor
Jan Czajkowski
Posts: 2,105
Registered: ‎12-12-2007
Message 5 of 8 (319 Views)

Re: Run Script to Extract all Bugs from all domains and projects

Have you tried to display the values before writing them to Excel? It could be that you don't save the Excel document.

If I were you I would avoid the Command object. You could use the BugFactory object instead. This will give you the number of defects in a project:

TDConnection.BugFactory.NewList("").Count
Jan Czajkowski

[Please do not contact me off line for receiving support. Use the forum!]
Please use plain text.
Honored Contributor
john scarpino
Posts: 1,344
Registered: ‎02-15-2008
Message 6 of 8 (316 Views)

Re: Run Script to Extract all Bugs from all domains and projects

Massimo,

 

Thank you. That worked well.

 

Best regards and Happy Holidays.

John

Please use plain text.
Honored Contributor
john scarpino
Posts: 1,344
Registered: ‎02-15-2008
Message 7 of 8 (314 Views)

Re: Run Script to Extract all Bugs from all domains and projects

Hi Jan,

 

Thank you. I will give that a try.

 

Best regards and Happy Holidays.

John

Please use plain text.
Honored Contributor
Massimo De Rosa
Posts: 656
Registered: ‎03-02-2009
Message 8 of 8 (308 Views)

Re: Run Script to Extract all Bugs from all domains and projects

Hi Jan, Hi John,

it's always a pleasure meet you guys here.

 

Best Regards and Ciao,

Massimo

Please use plain text.
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation