none
List Projects如何連sever RRS feed

  • 問題

  • 請問各位,我想用HCK API Samples中的List Projects去連sever,

    (範例網址  http://msdn.microsoft.com/en-us/library/windows/hardware/jj125307.aspx)

    在範例當中有段程式如下

         string controllerName = args[1];

         // first, connect to the server
         ProjectManager manager = new DatabaseProjectManager(controllerName);

    我把controllerName改成sever的名字發生錯誤,

    跑出下列文字

    第一個可能發生的例外狀況類型 'Microsoft.Windows.Kits.Hardware.ObjectModel.ProjectManagerException' 發生於 Microsoft.Windows.Kits.Hardware.ObjectModel.DBConnection.dll

    其他資訊: Failed to connect to the database

    如果這個例外狀況有處理常式,程式即可安全繼續執行。

    是我修改的方式錯誤嗎?  要怎麼做才能成功連線?

    ----------------------------------------------------------------------------------------------------

    範例完整程式碼如下

    namespace Samples
    {
        using System;
        using Microsoft.Windows.Kits.Hardware.ObjectModel;
        using Microsoft.Windows.Kits.Hardware.ObjectModel.DBConnection;
    
        class ListProjects
        {
            public static void Main(string[] args)
            {
                string controllerName = args[1];
    
                // first, connect to the server
                ProjectManager manager = new DatabaseProjectManager(controllerName);
    
                // list all projects
                Console.WriteLine("Listing all projects");
                foreach (string name in manager.GetProjectNames())
                {
                    Console.WriteLine("Project {0}", name);
                }
                
                // list all projects, and get the basic status of each
                Console.WriteLine("\nGetting all project status");
                foreach (ProjectInfo info in manager.GetProjectInfoList())
                {
                    Console.WriteLine("Project {0}", info.Name);
                    Console.WriteLine("\t status : {0}", info.Status);
                    Console.WriteLine("\t not run: {0}", info.NotRunCount);
                    Console.WriteLine("\t passed : {0}", info.PassedCount);
                    Console.WriteLine("\t Failed : {0}", info.FailedCount);
                    Console.WriteLine("\t Running: {0}", info.RunningCount);
                }
    
                // list all the tests for each project
                Console.WriteLine("\nGetting all projects and their tests");
                foreach (string name in manager.GetProjectNames())
                {
                    Project project = manager.GetProject(name);
    
                    Console.WriteLine("Project name : {0}, status: {1}", project.Name, project.Info.Status);
    
                    foreach (ProductInstance pi in project.GetProductInstances())
                    {
                        Console.WriteLine("Product Instance : {0}, Machine Pool : {1}, Platform type : {2}", pi.Name, pi.MachinePool.Name, pi.OSPlatform.Description);
    
                        foreach (Target target in pi.GetTargets())
                        {
                            Console.WriteLine("Target Name : {0}", target.Name);
    
                            foreach (Test test in target.GetTests())
                            {
                                Console.WriteLine("\tTest : {0}, status : {1}", test.Name, test.Status);
                            }
                        }
                    }
                }
    
            }
        }
    }



    • 已編輯 silvia1324 2014年7月11日 上午 07:44
    2014年7月11日 上午 06:06