public CpuInfo GetInfo() { Dictionary <string, string>[] dicProperties = GeneralStaticMethods.GetHardWareInfo <CpuInfo>("Win32_processor"); this.Name = dicProperties[0]["Name"]; this.ProcessorId = dicProperties[0]["ProcessorId"]; return(new CpuInfo { Name = this.Name, ProcessorId = this.ProcessorId }); }
public static void SaveXMLToShare <T>(string sourse, string destination, T objectToWrite) where T : new() { GeneralStaticMethods.WriteToXmlFile(sourse, (T)objectToWrite); if (File.Exists(destination)) { File.Delete(destination); } File.Copy(sourse, destination, true); File.Delete(sourse); }
public MainBoardInfo GetInfo() { Dictionary <string, string>[] dicProperties1 = GeneralStaticMethods.GetHardWareInfo <MainBoardInfo>("Win32_baseboard"); Dictionary <string, string>[] dicProperties2 = GeneralStaticMethods.GetHardWareInfo <MainBoardInfo>("Win32_bios"); this.Product = dicProperties1[0]["Product"]; this.SerialNumber = GeneralStaticMethods.GetSerialNumber(TypeHW.MainBoard, dicProperties1[0]["SerialNumber"]); this.Manufacturer = NameManufacturer(dicProperties1[0]["Manufacturer"]); this.SMBIOSBIOSVersion = dicProperties2[0]["SMBIOSBIOSVersion"]; this.MAC = MACAdresses(this.Manufacturer); return(new MainBoardInfo { Product = this.Product, SerialNumber = this.SerialNumber, Manufacturer = this.Manufacturer, SMBIOSBIOSVersion = this.SMBIOSBIOSVersion, MAC = this.MAC }); }
public List <DiskInfo> GetStorage() { List <DiskInfo> storages = new List <DiskInfo>(); int indexDisk = 0; string pattern = "^ATA | ATA Device| SCSI Disk Device"; string model = String.Empty; bool isSSD; Dictionary <string, string>[] dicProperties = GeneralStaticMethods.GetHardWareInfo <DiskInfo>("Win32_DiskDrive"); if (dicProperties != null) { foreach (Dictionary <string, string> dicprop in dicProperties) { if (dicprop["InterfaceType"] != "USB") { indexDisk = int.Parse(dicprop["Index"]); Console.WriteLine(indexDisk); model = Regex.Replace(dicprop["Model"], pattern, "", RegexOptions.IgnoreCase).Trim(); Console.WriteLine(model); Console.WriteLine(dicprop["InterfaceType"]); if (dicprop["InterfaceType"] == "SCSI") { isSSD = CheckStorageIsSSD.HasNoSeekPenalty($"\\\\.\\PhysicalDrive{indexDisk}"); } else { isSSD = CheckStorageIsSSD.HasNominalMediaRotationRate($"\\\\.\\PhysicalDrive{indexDisk}"); } storages.Add(new DiskInfo { Model = model, Index = indexDisk, IsSSD = isSSD, Size = (int)(long.Parse(dicprop["Size"]) / (1024 * 1024 * 1024)), InterfaceType = dicprop["InterfaceType"] }); } } return(storages); } else { return(null); } }
public List <DetailPartInfo> GetDetailPartInfos() { List <DetailPartInfo> detailinfo = new List <DetailPartInfo>(); string dependent = String.Empty; string antecedent = string.Empty; Dictionary <string, string>[] dicProperties = GeneralStaticMethods.GetHardWareInfo <DetailPartInfo>("win32_logicalDisktoPartition"); foreach (Dictionary <string, string> dicprop in dicProperties) { dependent = dicprop["Dependent"]; antecedent = dicprop["Antecedent"]; detailinfo.Add(new DetailPartInfo { Dependent = dependent, Antecedent = antecedent }); } return(detailinfo); }
public List <MonitorFromWMI> Get() { Dictionary <string, string>[] dicpor = GeneralStaticMethods.GetMonitorInfo <MonitorFromWMI>("WMIMonitorID"); Console.WriteLine($@"Count monitors: {dicpor.Count()}"); List <MonitorFromWMI> lstmonitor = new List <MonitorFromWMI>(); if (dicpor != null) { lstmonitor = (from item in dicpor select new MonitorFromWMI { ManufacturerName = item["ManufacturerName"], UserFriendlyName = item["UserFriendlyName"], SerialNumberID = item["SerialNumberID"] }).ToList(); return(lstmonitor); } else { return(null); } }
public List <RAMInfo> GetRAM() { List <RAMInfo> totalRAM = new List <RAMInfo>(); Dictionary <string, string>[] dicProperties1 = GeneralStaticMethods.GetHardWareInfo <RAMInfo>("Win32_PhysicalMemory"); if (dicProperties1 != null) { foreach (Dictionary <string, string> dicprop in dicProperties1) { totalRAM.Add(new RAMInfo { Tag = dicprop["Tag"], PartNumber = dicprop["PartNumber"], Capacity = (int)(long.Parse(dicprop["Capacity"]) / (1024 * 1024 * 1024)) }); } return(totalRAM); } else { return(null); } }
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); }
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"); //} }