Exemplo n.º 1
0
        public List <MonitorInfo> GetInfo()
        {
            string pathtolsMonitors = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "lsMonitors.xml");

            this.lsMonitors = GeneralStaticMethods.ReadFromXmlFile <List <MonitorModel> >(pathtolsMonitors);
            List <MonitorInfo>    lsMonitor  = new List <MonitorInfo>();
            string                key        = String.Empty;
            List <MonitorFromWMI> monFromWMI = (new MonitorFromWMI()).Get();

            foreach (MonitorFromWMI item in monFromWMI)
            {
                key = $"{item.ManufacturerName}_{item.UserFriendlyName}";
                if (lsMonitors.Any(x => x.ID == key))
                {
                    lsMonitor.Add(new MonitorInfo(lsMonitors.First(x => x.ID == key), item.SerialNumberID));
                }
                else
                {
                    lsMonitor.Add(new MonitorInfo(item));
                }
            }

            return(lsMonitor);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            #region check  machine is virtual?
            if (GeneralStaticMethods.IsVirtualMachine())
            {
                Environment.Exit(0);
            }
            #endregion



            GeneralOptions generaloptions = GeneralOptions.Getinstance();
            ComputerInfo   PC1            = new ComputerInfo(Environment.MachineName);
            GeneralStaticMethods.MySleep(1000, 150000);

            GeneralStaticMethods.SaveXMLToShare(generaloptions.PathToTempXmlFile, generaloptions.PathToFile, PC1);
            ComputerInfo PC = GeneralStaticMethods.ReadFromXmlFile <ComputerInfo>(generaloptions.PathToFile);


            //Console.WriteLine($"Computer name: {PC.Name}\n" +
            //    $" Date collected info: {PC.DateCollectedInfo}");
            //Console.WriteLine($"Processor name: { PC.CPU.Name}\n" +
            //                   $"Processor ID: {PC.CPU.ProcessorId}\n" +
            //                   $"Mainboard model: {PC.MainBoard.Product}\n" +
            //                   $"Product by: {PC.MainBoard.Manufacturer}\n" +
            //                   $"Mainboard SN: {PC.MainBoard.SerialNumber}\n" +
            //                   $"Version BIOS: {PC.MainBoard.SMBIOSBIOSVersion}\n");


            //Console.WriteLine($"Total memory: {PC.Memory.Sum(x => x.Capacity)} GB.");
            //Console.WriteLine("--------- Storage info -------------------------");
            //Console.WriteLine();
            //foreach (DiskInfo dinfo in PC.Storage)
            //{
            //    Console.WriteLine($"\tIndex: {dinfo.Index}\n" +
            //                      $"\tModel: {dinfo.Model}\n" +
            //                      $"\tIs SSD: {dinfo.IsSSD}\n" +
            //                      $"\tSize: {dinfo.Size} Gb.");
            //    Console.WriteLine();

            //}
            //Console.WriteLine(" ------------ Partition info ---------------------");
            //Console.WriteLine();
            //foreach (PartitionInfo pinfo in PC.Partitions)
            //{
            //    Console.WriteLine($"\tName partition: {pinfo.Name}\n" +
            //                      $"\tPartition is system?: {pinfo.IsSystem}\n" +
            //                      $"\tName disk where store partition: {PC.Storage.FirstOrDefault(x => x.Index == pinfo.IndexDisc).Model}\n" +
            //                      $"\tFull size : {pinfo.FullSize} Gb.\n" +
            //                      $"\tAvailable size: {pinfo.AvailableFreeSpace} Gb.");
            //    Console.WriteLine();

            ////}
            //Console.WriteLine("---------------- OS info ------------------------");
            //Console.WriteLine();
            //Console.WriteLine($"\tOS name: {PC.OS.ProductName}\n" +
            //                  $"\tOS full Version:{PC.OS.Version} {PC.OS.Build}\n" +
            //                  $"\tOS is X64?: {PC.OS.IsX64}\n" +
            //                  $"\tOS install date: {PC.OS.InstallDate}");

            //Console.WriteLine("---------------- Monitors info --------------------");
            //Console.WriteLine();
            //foreach (MonitorInfo minfo in PC.Monitors)
            //{
            //    Console.WriteLine($"\tModel made by: {minfo.ManufacturerName}\n" +
            //                      $"\tSN monitor: {minfo.SerialNumberID}\n" +
            //                      $"\tModel monitor: {minfo.UserFriendlyName}\n");
            //}
        }