Exemple #1
0
        public void TestGenericQuery_Devices()
        {
            var devices = _Helper.Query <Models.Device>().ToList();

            Assert.That(devices.Any(), "Found no devices whatsoever");

            var intelOrAMDDevices = devices.Where(p => p.Name != null &&
                                                  (p.Name.Contains("Intel") || p.Name.Contains("AMD")));

            Assert.That(intelOrAMDDevices.Any(), "Found no Intel devices");
        }
Exemple #2
0
        //***************************************************************************************************
        // Port série
        //***************************************************************************************************
        private String GetPortName()
        {
            String    str    = "";
            WMIHelper helper = new WMIHelper("root\\CimV2");
            Device    device = helper.Query <Device>().ToList()
                               .Where(p => (p.Name ?? "")
                                      .Contains("u-blox GNSS Receiver")).SingleOrDefault();

            if (device != null)
            {
                str = device.Name;
                int i = str.IndexOf("(");
                int j = str.LastIndexOf(")");
                str = str.Substring(i + 1, j - i - 1);
            }
            return(str);
        }
Exemple #3
0
        static void Main(string[] args)
        {
            WMIHelper helper = new WMIHelper("root\\CimV2");

            //List<NetworkAdapterConfiguration> interfaces = helper.Query<NetworkAdapterConfiguration>().ToList();

            //Printer printer = helper.QueryFirstOrDefault<Printer>();

            //List<Printer> printers = helper.Query<Printer>().ToList();

            //foreach (Printer p in printers)
            //{
            //    p.RenamePrinter("Newly renamed printer");
            //}

            //Output outp = new Output
            //{
            //    PanelID = 10,
            //    ReaderID = 1,
            //    Hostname = "ONGUARD01",
            //    Name = "ONGUARD01"
            //};

            //outp.Activate();

            //List<Process> processes = helper.Query<Process>().ToList();

            //foreach (Process p in processes)
            //{
            //    //dynamic d = p.GetOwnerSid();
            //    ProcessOwner po = p.GetOwner();
            //    //int res = p.AttachDebugger();
            //}

            //var dynDevices = helper.Query("SELECT * FROM Win32_PnPEntity");

            //var processors = helper.Query<Processor>();

            //List<Processor> procesors = helper.Query<Processor>().ToList();

            List <Device> devices = helper.Query <Device>().ToList()
                                    .Where(p => (p.Name ?? "")
                                           .Contains("Intel")).ToList();

            foreach (Device d in devices)
            {
                Console.WriteLine(d.Name);
            }

            //Person person = new Person
            //{
            //    FirstName = "John",
            //    DocumentNumber = "9995",
            //};

            //helper.AddInstance(person);

            //Person queryPersonSingle = helper.Query<Person>("SELECT * FROM Lnl_Cardholder WHERE LASTNAME = 'Doe Modified'").SingleOrDefault();

            //queryPersonSingle.Lastname = "Doe Modified";

            //helper.UpdateInstance(queryPersonSingle);

            //List<Person> queryPerson = helper.Query<Person>("SELECT * FROM Lnl_Cardholder WHERE LASTNAME = 'Lopez'").ToList();

            //WMIWatcher watcher = new WMIWatcher("root\\CimV2", "SELECT * FROM Win32_ProcessStartTrace", typeof(Process));
            //WMIWatcher watcher = new WMIWatcher("root\\CimV2", "SELECT * FROM Win32_ProcessStartTrace");
            //watcher.WMIEventArrived += Watcher_WMIEventArrived;

            Console.ReadLine();
        }