コード例 #1
0
 public static void DisconnectQCServer()
 {
     if (IsProjectConnected)
     {
         mTDConn.DisconnectProject();
     }
     if (IsServerConnected)
     {
         mTDConn.Logout();
     }
     if (mTDConn != null && mTDConn.Connected)
     {
         mTDConn.Disconnect();
     }
 }
コード例 #2
0
        protected void Disconnect()
        {
            try
            {
                if (tdc.Connected)
                {
                    if (tdc.LoggedIn)
                    {
                        if (tdc.ProjectConnected)
                        {
                            tdc.Disconnect();
                        }

                        tdc.Logout();
                    }

                    tdc.ReleaseConnection();
                }
            }
            catch (COMException ce)
            {
                rr.AddErrorLine(HandleException(ce));
            }
        }
コード例 #3
0
ファイル: TDConnect.cs プロジェクト: tamutamu/AutoTestCore
 public void Disconnect()
 {
     qc.Disconnect();
 }
コード例 #4
0
ファイル: QC.aspx.cs プロジェクト: nukulb/WebWorks-TabletOS
    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;
    }
コード例 #5
0
        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);
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: kidig/QCDownloader
        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.");
        }
コード例 #7
0
        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.");
        }