private void GetNetList() { netList.Clear(); int x = 1; foreach (NetMeterValues nmv in netMeter.values) { netList.Add(new Entities.Config.Net(x++, nmv.name, nmv.description, nmv.speed, nmv.addr, "\t\t\t")); } }
private void GetNetLoad() { netList.Clear(); netMeter.Do(); int x = 1; foreach (var v in netMeter.values) { netList.Add(new Entities.Load.Net(x++, v.rx, v.tx, v.prx, v.ptx, "\t\t\t")); } }
private void GetHDDLoad() { hddList.Clear(); widgets.disks.Clear(); var searcherPhysicalDrives = new ManagementObjectSearcher("select * from Win32_DiskDrive"); try { int x = 1; var driveQuery = new ManagementObjectSearcher("select * from Win32_DiskDrive"); foreach (ManagementObject d in driveQuery.Get()) { Entities.List logicals = new Entities.List("ldisks", "\t\t\t\t"); Entities.List widgetLogicals = new Entities.List("ldisks", "\t\t\t\t"); var partitionQueryText = string.Format("associators of {{{0}}} where AssocClass = Win32_DiskDriveToDiskPartition", d.Path.RelativePath); var partitionQuery = new ManagementObjectSearcher(partitionQueryText); foreach (ManagementObject p in partitionQuery.Get()) { var logicalDriveQueryText = string.Format("associators of {{{0}}} where AssocClass = Win32_LogicalDiskToPartition", p.Path.RelativePath); var logicalDriveQuery = new ManagementObjectSearcher(logicalDriveQueryText); foreach (ManagementObject ld in logicalDriveQuery.Get()) { var driveName = Convert.ToString(ld.Properties["Name"].Value); double free = Convert.ToDouble(ld.Properties["FreeSpace"].Value) / 1000000000; double total = Convert.ToDouble(ld.Properties["Size"].Value) / 1000000000; double used = total - free; int load = 100 - (int)((free / total) * 100); logicals.Add(new Entities.Load.Logical(free, load, used, driveName, "\t\t\t\t\t")); widgetLogicals.Add(new Entities.Load.WidgetLogical(load, driveName, "\t\t\t\t\t")); } } hddList.Add(new Entities.Load.HDD(x, logicals, "\t\t\t")); widgets.disks.Add(new Entities.Load.WidgetHDD(x, widgetLogicals, "\t\t\t")); ++x; } } catch (Exception exp) { Logger.Log.Error("HardwareGetter.GetHDDList :: " + exp.Message); } }
private void GetCPUList() { cpuList.Clear(); var searcherCPUs = new ManagementObjectSearcher("select * from Win32_Processor"); try { int x = 1; foreach (var cpu in searcherCPUs.Get()) { cpuList.Add(new Entities.Config.CPU(x++, cpu["Name"].ToString(), "\t\t\t")); } } catch (Exception exp) { Logger.Log.Error("HardwareGetter.GetCPUList :: " + exp.Message); } }
private void GetHDDList() { hddList.Clear(); var searcherPhysicalDrives = new ManagementObjectSearcher("select * from Win32_DiskDrive"); try { int x = 1; var driveQuery = new ManagementObjectSearcher("select * from Win32_DiskDrive"); foreach (ManagementObject d in driveQuery.Get()) { var model = Convert.ToString(d.Properties["Model"].Value); var size = Convert.ToInt64(d.Properties["Size"].Value) / 1000000000; var logicals = new List <string>(); var partitionQueryText = string.Format("associators of {{{0}}} where AssocClass = Win32_DiskDriveToDiskPartition", d.Path.RelativePath); var partitionQuery = new ManagementObjectSearcher(partitionQueryText); foreach (ManagementObject p in partitionQuery.Get()) { var logicalDriveQueryText = string.Format("associators of {{{0}}} where AssocClass = Win32_LogicalDiskToPartition", p.Path.RelativePath); var logicalDriveQuery = new ManagementObjectSearcher(logicalDriveQueryText); foreach (ManagementObject ld in logicalDriveQuery.Get()) { var driveName = Convert.ToString(ld.Properties["Name"].Value); logicals.Add(driveName); } } hddList.Add(new Entities.Config.HDD(x++, model, size, logicals, "\t\t\t")); } } catch (Exception exp) { Logger.Log.Error("HardwareGetter.GetHDDList :: " + exp.Message); } }
private void GetCPULoad() { if (!chwOpened) { chwOpened = true; computerHardware.Open(); } cpuList.Clear(); var hardwareCount = computerHardware.Hardware.Count(); for (var i = 0; i != hardwareCount; ++i) { computerHardware.Hardware[i].Update(); var loads = new Entities.List("load", "\t\t\t\t", Entities.BracketType.scCurly); var temps = new Entities.List("temp", "\t\t\t\t", Entities.BracketType.scCurly); var subcount = computerHardware.Hardware[i].SubHardware.Count(); // NEED Update to view Subhardware for (var j = 0; j != subcount; ++j) { computerHardware.Hardware[i].SubHardware[j].Update(); } var sensorcount = computerHardware.Hardware[i].Sensors.Count(); int l = 1, t = 1; if (sensorcount > 0) { for (var z = 0; z != sensorcount; ++z) { var name = computerHardware.Hardware[i].Sensors[z].Name; var type = computerHardware.Hardware[i].Sensors[z].SensorType.ToString(); var value = computerHardware.Hardware[i].Sensors[z].Value; if (type.Contains("Load")) { string valueName = (name.Contains("CPU Core #") ? "core_" + (l++).ToString() : "total"); loads.Add(new Entities.Load.Core(valueName, Convert.ToInt32(value), "\t\t\t\t\t")); if (name.Contains("CPU Total") || name == "CPU Core") { widgets.cpuLoad = Convert.ToInt32(value); } } else if (type.Contains("Temperature")) { string valueName = (name.Contains("Core") ? "core_" + (t++).ToString() : "total"); temps.Add(new Entities.Load.Core(valueName, Convert.ToInt32(Convert.ToDouble(value)), "\t\t\t\t\t")); if (name.Contains("CPU Package")) { widgets.cpuTemp = Convert.ToInt32(Convert.ToDouble(value)); } } } } cpuList.Add(new Entities.Load.CPU(i + 1, loads, temps, "\t\t\t")); } }