public TDConnection Connect(string qcUrl, string qcDomain, string qcProject, string qcLoginName, string qcPassword) { connection = new TDConnection(); connection.InitConnectionEx(qcUrl); connection.ConnectProjectEx(qcDomain, qcProject, qcLoginName, qcPassword); return connection; }
/// <summary> /// This method will download an attachment from a folder in Quality Center /// </summary> /// <param name="qcFolderLocation">Folder Location from where attachment needs to be downloaded</param> /// <param name="strFileName">Name of the file that needs to be downloaded from specified location. /// Name should be specified along with extenstion </param> /// <returns>Location of local (usually temp) path where file has been downloaded. Returns empty string if file could not be downloaded.</returns> public string DownloadAttachment(string qcFolderLocation, string strFileName) { //Connect with Quality Center TDConnection qctd = new TDConnection(); qctd.InitConnectionEx(qcServer); qctd.ConnectProjectEx(strDomainName, strProjectName, strQCUserName, strQCUserPassword); if (qctd.Connected) { //Define objects that will be used to download files SubjectNode otaSysTreeNode = new SubjectNode(); AttachmentFactory otaAttachmentFactory = new AttachmentFactory(); TDFilter otaAttachmentFilter = new TDFilter(); List otaAttachmentList = new List(); ExtendedStorage attStorage = new ExtendedStorage(); otaSysTreeNode = qctd.TreeManager.NodeByPath(qcFolderLocation); //Returns node object from test plan in Quality Center otaAttachmentFactory = otaSysTreeNode.Attachments(); //Returns all attachments for the folder in QC otaAttachmentFilter = otaAttachmentFactory.Filter(); //Can be used to filter list of attachments otaAttachmentList = otaAttachmentFilter.NewList(); //Creates list of attached files //Check if there is any attachment available for the specified folder if (otaAttachmentList.Count > 0) { foreach (Attachment otaAttachment in otaAttachmentList) { //Check if file names are same if (otaAttachment.FileName.ToLower() == strFileName.ToLower()) { attStorage = otaAttachment.AttachmentStorage(); _localFileLocation = otaAttachment.DirectLink; //Load method will download file to local workstation. true to used for synchronised download. attStorage.Load(_localFileLocation, true); //Client path refers to local path where file has been downloaded _localFileLocation = attStorage.ClientPath; break; } } } } //Return empty string if connection to QC was not successfull. else { _localFileLocation = string.Empty; } return _localFileLocation; }
// Opening QC Connection public static bool ConnectQCServer(string QCServerUrl, string QCUserName, string QCPassword) { if (string.IsNullOrEmpty(QCServerUrl) || string.IsNullOrEmpty(QCUserName) || string.IsNullOrEmpty(QCPassword)) { return(false); } bool qcConn = false; DisconnectQCServer(); mTDConn.InitConnectionEx(QCServerUrl); mTDConn.Login(QCUserName, QCPassword); qcConn = true; return(qcConn); }
public QCHelperTest() { qcConnect = new TDConnection(); qcConnect.InitConnectionEx("http://qualitycenter-v10.homedepot.com/qcbin"); qcConnect.Login("PXS8677", "tree$123"); qcConnect.Connect("ONLINE", "EBWCS"); if (qcConnect.Connected) { Console.WriteLine("Connected to QC"); } else { Console.WriteLine("Not Connected to QC"); } }
public TDConnect(string UserName, string PWD, string Domain, string Project, string Address) { _UserName = UserName; _PWD = PWD; _Domain = Domain; _Project = Project; _Address = Address; qc = new TDConnection(); qc.InitConnectionEx(Address); qc.Login(UserName, PWD); qc.Connect(Domain, Project); if (qc.Connected) { Console.WriteLine("Login Success"); } }
public QCHelper() { try { qcConnect = new TDConnection(); qcConnect.InitConnectionEx("http://qualitycenter-v10.homedepot.com/qcbin"); qcConnect.Login(HelperClass.QCUserName, HelperClass.QCPassword); qcConnect.Connect("ONLINE", "EBWCS"); if (qcConnect.Connected) { Console.WriteLine("Connected to QC"); } else { Console.WriteLine("Not Connected to QC"); } } catch (Exception ex) { Logger.Log(ex.ToString()); } }
/** * Establish a connection to Quality Center * * @param string qcUrl * @param string qcDomain * @param string qcProject * @param string qcLoginName * @param string qcPassword * @return TDConnection */ public TDConnection connectToQC(string qcUrl, string qcDomain, string qcProject, string qcLoginName, string qcPassword) { try { tdConn.InitConnectionEx(qcUrl); tdConn.ConnectProjectEx(qcDomain, qcProject, qcLoginName, qcPassword); } catch (Exception e) { log.Warn("unable to connect to project in QC"); log.Warn(e.Message); throw; } if (tdConn.Connected) { message = "connected"; if (tdConn.ProjectConnected) { message += " to QC project " + tdConn.ProjectName; log.Info(message); } else { message += " to QC but unable to connect to QC Project " + qcProject; log.Warn(message); throw new QCException(message); } } else { message = "failed to connect to QC"; log.Warn(message); throw new QCException(message); } return(tdConn); }
public static string ReportResults(List<Results> results, string runName, string userName, string password) { string rc = "Nothing Reported"; if (runName != null && userName != null && password != null) { TDConnection connection = null; try { connection = new TDConnection(); String URL = "http://hpqualitycenter/qcbin/"; String domainName = "Default"; String projectName = "Production"; //Response.Write("Server:" + URL + " Domain:" + domainName + " Project:" + projectName + "<br/>"); //Prompt for QC credentials. connection.InitConnectionEx(URL); connection.Login(userName, password); connection.Connect(domainName, projectName); //Response.Write("Opening Connection <br/>"); //Response.Write("Connection Status: " + (connection.Connected ? "connected" : "not connected") + "<br/>"); if (connection != null && connection.Connected) { foreach (Results r in results) { TestSetTreeManager treeManager = (TestSetTreeManager)connection.TestSetTreeManager; //Response.Write("Folder: " + rootPathPrefix + path + " <br/>"); TestSetFolder folder = (TestSetFolder)treeManager.get_NodeByPath(rootPathPrefix + r.Path); TestSetFactory tFactory = (TestSetFactory)folder.TestSetFactory; TDFilter tFilter = (TDFilter)tFactory.Filter; tFilter["TS_TEST_ID"] = r.Id; //http://atg05-yyz/YUI/ReportResultToQC.aspx?id=2367453&path=BlackBerry%20Developer%20Tools\Sandbox&result=0 if (r.Id != null) { //Response.Write("testId= " + testId + " result= " + result + "<br/>"); List tests = folder.FindTestInstances("", false, tFilter.Text); if (tests.Count == 1) { TSTest t = (TSTest)tests[1]; //Response.Write(t.ID + " " + t.Status + " " + t.Name + " " + "<br/>"); RunFactory runFactory = (RunFactory)t.RunFactory; Run newRun = (Run)runFactory.AddItem(runName); switch (r.Result) { case 0: newRun.Status = @"FAILED"; break; case 1: newRun.Status = @"PASSED"; break; case 2: newRun.Status = @"N/A"; break; } //Response.Write("Status = " + newRun.Status + "<br/>"); newRun.Post(); rc = "Success"; } else { rc = "Error: Multiple Tests Returned for ID # " + r.Id; break; } } else { rc = "No Test Specified"; break; } }//foreach result }//if connection else rc = "Connection to QC could not be established"; } catch (Exception ex) { rc = ex.Message; } finally { if (connection != null) { if (connection.Connected) connection.Disconnect(); if (connection.LoggedIn) connection.Logout(); connection.ReleaseConnection(); connection = null; } } } return rc; }
private void Button_Click_1(object sender, RoutedEventArgs e) { try { TDConnection tdConn = new TDConnection(); tdConn.InitConnectionEx(qcUrl.Text); tdConn.ConnectProjectEx(qcDomain.Text, qcProject.Text, qcLogin.Text, qcPassword.Password); //MessageBox.Show((string)qcUrl.Text); //MessageBox.Show((string)qcDomain.Text); //MessageBox.Show((string)qcProject.Text); //MessageBox.Show((string)qcLogin.Text); //MessageBox.Show((string)qcPassword.Password); //MessageBox.Show((string)qcDomain.Text); //MessageBox.Show((string)testFolder.Text); //MessageBox.Show((string)testSet.Text); //RunFactory runFactory = (RunFactory)test.RunFactory;// //string testFolder = "^" + @"Root\MULTUM\Monthly Testing\SDK v4\"; //string testSet = "BNF SDKv4 Server and Update"; TestSetFactory tsFactory = (TestSetFactory)tdConn.TestSetFactory; TestSetTreeManager tsTreeMgr = (TestSetTreeManager)tdConn.TestSetTreeManager; TestSetFolder tsFolder = (TestSetFolder)tsTreeMgr.get_NodeByPath(testFolder.Text); TDAPIOLELib.List tsList = (TDAPIOLELib.List)tsFolder.FindTestSets((string)testSet.Text, false, null); //TDAPIOLELib.List tsTestList = tsFactory.NewList(""); //List tsList = tsFolder.FindTestSets(testSet, false, "status=No Run"); //Feature\Multum\Black Box\Monthly Testing\SDK v4 foreach (TestSet testset in tsList) { Console.WriteLine("Test Set Folder Path: {0}", testFolder); Console.WriteLine("Test Set: {0}", testset.Name); TestSetFolder tsfolder = (TestSetFolder)testset.TestSetFolder; //string testFolder = "^" + @"Root\MULTUM\Monthly Testing\SDK v4\"; TSTestFactory tsTestFactory = (TSTestFactory)testset.TSTestFactory; TDAPIOLELib.List tsTestList = tsTestFactory.NewList(""); //} foreach (TSTest tsTest in tsTestList)//no such interface supported { Console.WriteLine("Test Set: {0}", tsTest.Name); //Console.ReadLine(); string status = (string)tsTest.Status; Console.WriteLine("STATUS {0}", status); //Console.WriteLine("PARAMS {0}",tsTest.Params); Console.WriteLine("PARAMS {0}", tsTest.History); TDAPIOLELib.Run lastRun = (TDAPIOLELib.Run)tsTest.LastRun; // don't update test if it may have been modified by someone else if (lastRun == null) { RunFactory runFactory = (RunFactory)tsTest.RunFactory; TDAPIOLELib.List runs = runFactory.NewList(""); Console.WriteLine("test runs: {0}", runs.Count); String date = DateTime.Now.ToString("MM-dd_hh-mm-ss"); TDAPIOLELib.Run run = (TDAPIOLELib.Run)runFactory.AddItem("Run_" + date); //Run_5-23_14-49-52 var oRunInstance = (RunFactory)tsTest.RunFactory; //var oRun = (Run)oRunInstance.AddItem("Performance Test"); //run.Status = "Passed"; //run.Post(); //run.Refresh(); var oTest = (Test)tsTest.Test; var tsDesignStepList = oTest.DesignStepFactory.NewList(""); var oStepFactory = (StepFactory)run.StepFactory; foreach (DesignStep oDesignStep in tsDesignStepList) { var oStep = (Step)oStepFactory.AddItem(oDesignStep.StepName); //oStep.Status = "Passed"; //oStep.Post(); } } } } tdConn.DisconnectProject(); tdConn.Disconnect(); } catch (Exception ex) { MessageBox.Show(ex.Message); MessageBox.Show(ex.StackTrace); } }
private static void ExportRequirements() { string server_url = ConfigurationManager.AppSettings["SERVER_URL"]; string username = ConfigurationManager.AppSettings["USER_NAME"]; string password = ConfigurationManager.AppSettings["PASSWORD"]; string domain = ConfigurationManager.AppSettings["DOMAIN"]; string project = ConfigurationManager.AppSettings["PROJECT"]; string req_file = ConfigurationManager.AppSettings["REQUIREMENTS_FILE"]; string att_file = ConfigurationManager.AppSettings["ATTACHMENTS_FILE"]; string att_path = ConfigurationManager.AppSettings["ATTACHMENTS_PATH"]; if (!Directory.Exists(att_path)) { Directory.CreateDirectory(att_path); } TDConnection tdc = new TDConnection(); tdc.InitConnectionEx(server_url); tdc.ConnectProjectEx(domain, project, username, password); Console.WriteLine("Connected to QC Server"); ReqFactory req_factory = (ReqFactory)tdc.ReqFactory; TDFilter req_filter = (TDFilter)req_factory.Filter; /** * Set your own filters for requirements below */ // req_filter["RQ_REQ_PATH"] = "AAAAAGAAE*"; StreamWriter rfs = new StreamWriter(File.Open(req_file, FileMode.Create), Encoding.Default, 1024); StreamWriter afs = new StreamWriter(File.Open(att_file, FileMode.Create), Encoding.Default, 1024); foreach (Req r in req_filter.NewList()) { string name = r.Name.Replace("\"","").Replace("\t","").Trim(); Console.WriteLine("Req \"{0}\"", name); rfs.WriteLine(String.Join("\t", new String[]{ r.ID.ToString(), r.ParentId.ToString(), r["RQ_REQ_PATH"], name, r["RQ_VTS"].ToString() })); if (!r.HasAttachment) continue; AttachmentFactory att_factory = r.Attachments; foreach (Attachment a in att_factory.NewList("")) { Console.WriteLine("Attachment \"{0}\"", a.Name); afs.WriteLine(String.Join("\t", new String[]{ r.ID.ToString(), a.ID.ToString(), a.Name, a.FileSize.ToString(), a.LastModified.ToShortDateString() })); IExtendedStorage storage = a.AttachmentStorage; storage.ClientPath = Path.GetFullPath(att_path) + "\\"; storage.Load(a.Name, true); } } rfs.Close(); afs.Close(); tdc.Disconnect(); tdc.Logout(); Console.WriteLine("Disconnected."); }
private static void ExportRequirements() { string server_url = ConfigurationManager.AppSettings["SERVER_URL"]; string username = ConfigurationManager.AppSettings["USER_NAME"]; string password = ConfigurationManager.AppSettings["PASSWORD"]; string domain = ConfigurationManager.AppSettings["DOMAIN"]; string project = ConfigurationManager.AppSettings["PROJECT"]; string req_file = ConfigurationManager.AppSettings["REQUIREMENTS_FILE"]; string att_file = ConfigurationManager.AppSettings["ATTACHMENTS_FILE"]; string att_path = ConfigurationManager.AppSettings["ATTACHMENTS_PATH"]; if (!Directory.Exists(att_path)) { Directory.CreateDirectory(att_path); } TDConnection tdc = new TDConnection(); tdc.InitConnectionEx(server_url); tdc.ConnectProjectEx(domain, project, username, password); Console.WriteLine("Connected to QC Server"); ReqFactory req_factory = (ReqFactory)tdc.ReqFactory; TDFilter req_filter = (TDFilter)req_factory.Filter; /** * Set your own filters for requirements below */ // req_filter["RQ_REQ_PATH"] = "AAAAAGAAE*"; StreamWriter rfs = new StreamWriter(File.Open(req_file, FileMode.Create), Encoding.Default, 1024); StreamWriter afs = new StreamWriter(File.Open(att_file, FileMode.Create), Encoding.Default, 1024); foreach (Req r in req_filter.NewList()) { string name = r.Name.Replace("\"", "").Replace("\t", "").Trim(); Console.WriteLine("Req \"{0}\"", name); rfs.WriteLine(String.Join("\t", new String[] { r.ID.ToString(), r.ParentId.ToString(), r["RQ_REQ_PATH"], name, r["RQ_VTS"].ToString() })); if (!r.HasAttachment) { continue; } AttachmentFactory att_factory = r.Attachments; foreach (Attachment a in att_factory.NewList("")) { Console.WriteLine("Attachment \"{0}\"", a.Name); afs.WriteLine(String.Join("\t", new String[] { r.ID.ToString(), a.ID.ToString(), a.Name, a.FileSize.ToString(), a.LastModified.ToShortDateString() })); IExtendedStorage storage = a.AttachmentStorage; storage.ClientPath = Path.GetFullPath(att_path) + "\\"; storage.Load(a.Name, true); } } rfs.Close(); afs.Close(); tdc.Disconnect(); tdc.Logout(); Console.WriteLine("Disconnected."); }
private void ConnectToQC() { _conn= new TDConnectionClass(); try { _conn.InitConnectionEx(_config.QCAddress); _conn.Login(_config.UserName, _config.Pwd); _conn.Connect(_config.Domain, _config.Project); } catch(Exception e) { } }
/// <summary> /// OVERRIDE FUNCTIONS /// </summary> /// <returns></returns> public override bool Connect() { bool blnResult = false; this.Message = ""; try { td = new TDConnection(); td.InitConnectionEx(this.Settings.Address); td.ConnectProjectEx(this.Settings.Domain, this.Settings.Database, this.Settings.User, this.Settings.Password); blnResult = td.Connected; } catch (Exception ex) { Framework.Log.AddError("Cannot connect to QC / ALM", ex.Message, ex.StackTrace); } if (blnResult) { Framework.Log.AddCorrect("Connected with HP QC / ALM"); } else { Framework.Log.AddIssue("Cannot connect to QC / ALM"); } return blnResult; }
public void ParseDataSet(params object[] parameters) { lstTestPlanSteps = new List <string[]>(); lstStrEvidenceID = new List <string>(); try { string strQCURL = (string)parameters[0]; string strTargetFolderPath = (string)parameters[1]; string strproject = (string)parameters[2]; string strdomain = (string)parameters[3]; string strpass = (string)parameters[4]; string strTestPlanFileName = Path.GetFileNameWithoutExtension((string)parameters[5]); bool bIsCandidateEvidence = false; string strscreenprint = string.Empty; TDConnection qctd = new TDConnection(); Test tst; qctd.InitConnectionEx(strQCURL); qctd.ConnectProjectEx(strdomain, strproject, Environment.UserName, strpass); if (qctd.Connected) { TestFactory testFactory = (TestFactory)qctd.TestFactory; TDFilter testFilter = testFactory.Filter; TDAPIOLELib.List testList; testFilter["TS_NAME"] = "\"" + strTestPlanFileName + "\""; // testFilter["TS_PATH"] = "\"" + strTargetFolderPath + "\""; TDAPIOLELib.List listOfTests = testFilter.NewList(); testList = (TDAPIOLELib.List)testFactory.NewList(testFilter.Text); string strdescription = string.Empty; int itestcount = testList.Count; int stepscount = 0; if (testList.Count == 0) { throw new FileNotFoundException("No test plans Found .Check the testplan name"); } else if (testList.Count > 1) { MessageBox.Show("Multiple Test plans found , Click Ok to view and select the Right Test Plan", "Mutiple Test Plans"); DisplayListOFTestPlan(testList, testFactory); tst = SelectedTest; strTestplanPath = testFactory[tst.ID]["TS_SUBJECT"].Path; } else { tst = testList[1]; } if (tst == null) { throw new Exception("No Test plans selected "); } strTestPlanName = tst.Name; // string noHTML = Regex.Replace(tst["TS_DESCRIPTION"], @"<[^>]+>| ", "").Trim(); // noHTML = WebUtility.HtmlDecode(noHTML); string noHTML = RemoveHTML(tst["TS_DESCRIPTION"]); // Match m = Regex.Match(noHTML, "(?s)[Pp]rerequisites.*[Cc]hange [Cc]ontrol"); Match m = Regex.Match(noHTML, "(?s)[Pp]rerequisites.*"); strPrerequisites = m.Value; DesignStepFactory dsf = tst.DesignStepFactory; TDAPIOLELib.List dslflist = dsf.NewList(""); stepscount = dslflist.Count; foreach (DesignStep ds in dslflist) { arrStepData = new string[3]; arrStepData[0] = ds.StepName; arrStepData[1] = RemoveHTML(ds.StepDescription); arrStepData[2] = RemoveHTML(ds.StepExpectedResult); lstTestPlanSteps.Add(arrStepData); bIsCandidateEvidence = false; strscreenprint = (string)ds["DS_USER_01"]; if (!string.IsNullOrEmpty(strscreenprint)) { if (string.Compare(strscreenprint.ToLower(), "none") != 0) { foreach (char ch in strscreenprint) { if ((int)ch >= 33 && (int)ch <= 126) { bIsCandidateEvidence = true; break; } } if (bIsCandidateEvidence) { lstStrEvidenceID.Add(ds.StepName); } } } } } } catch (Exception ex) { throw ex; } }