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; }
public static void Main() { String qcUrl = "http://qcurl.com:8080/qcbin"; String qcDomain = ""; // Nearly all our projects are under DEFAULT domain String qcProject = ""; // Project we want to log a defect to String qcLoginName = ""; // User account we'll use to log it String qcPassword = ""; // Password for user account TDConnection connection = new TDConnection(); // Open blank connection connection.InitConnectionEx(qcUrl); // Go to qcUrl connection.ConnectProjectEx(qcDomain, qcProject, qcLoginName, qcPassword); // Validate credentials through API BugFactory bugFactory = connection.BugFactory; // Create an object from BugFactory Bug newBug = bugFactory.AddItem(System.DBNull.Value); // Create a new blank bug, must convert C# Null object type into value of Null type // Set values for mandatory fields in new bug // Values are arbitrary newBug.Status = "New"; newBug.AssignedTo = qcLoginName; newBug.DetectedBy = qcLoginName; newBug.Summary = "This is a test defect"; newBug["BG_SEVERITY"] = "3-Test"; newBug["BG_DESCRIPTION"] = "This is a test defect"; newBug["BG_DETECTED_IN_RCYC"] = 1002; // This takes the Release ID from release module, not the string value of its name, unlike every other field. newBug["BG_DETECTION_DATE"] = System.DateTime.Today; // Post the bug newBug.Post(); }
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); }
/// <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; }
/** * 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); }
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."); }
/// <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; } }