private static bool CheckGpu(SystemConfiguration systemConfiguration, List <string> requierementGpu) { try { if (requierementGpu.Count > 0) { for (int i = 0; i < requierementGpu.Count; i++) { var gpu = requierementGpu[i]; Gpu gpuCheck = new Gpu(systemConfiguration, gpu); if (gpuCheck.IsBetter()) { if (gpuCheck.IsWithNoCard && i > 0) { return(false); } else { return(true); } } } } else { return(true); } } catch (Exception ex) { Common.LogError(ex, "SystemChecker", $"Error on CheckGpu() with {systemConfiguration.GpuName} & {JsonConvert.SerializeObject(requierementGpu)}"); } return(false); }
public SystemConfiguration GetPcInfo() { string FilePlugin = Path.Combine(PluginDatabaseDirectory, "pc.json"); SystemConfiguration systemConfiguration = new SystemConfiguration(); List <SystemDisk> Disks = GetInfoDisks(); if (File.Exists(FilePlugin)) { try { string JsonStringData = File.ReadAllText(FilePlugin); systemConfiguration = JsonConvert.DeserializeObject <SystemConfiguration>(JsonStringData); systemConfiguration.Disks = Disks; return(systemConfiguration); } catch (Exception ex) { Common.LogError(ex, "SystemChecker", $"Failed to load item from {FilePlugin}"); } } string Name = Environment.MachineName; string Os = string.Empty; string Cpu = string.Empty; uint CpuMaxClockSpeed = 0; string GpuName = string.Empty; long GpuRam = 0; uint CurrentHorizontalResolution = 0; uint CurrentVerticalResolution = 0; long Ram = 0; // OS try { ManagementObjectSearcher myOperativeSystemObject = new ManagementObjectSearcher("select * from Win32_OperatingSystem"); foreach (ManagementObject obj in myOperativeSystemObject.Get()) { Os = (string)obj["Caption"]; } } catch (Exception ex) { Common.LogError(ex, "SystemChecker", "Error on Win32_OperatingSystem"); } // CPU try { ManagementObjectSearcher myProcessorObject = new ManagementObjectSearcher("select * from Win32_Processor"); foreach (ManagementObject obj in myProcessorObject.Get()) { Cpu = (string)obj["Name"]; CpuMaxClockSpeed = (uint)obj["MaxClockSpeed"]; } } catch (Exception ex) { Common.LogError(ex, "SystemChecker", "Error on Win32_Processor"); } // GPU try { ManagementObjectSearcher myVideoObject = new ManagementObjectSearcher("select * from Win32_VideoController"); foreach (ManagementObject obj in myVideoObject.Get()) { string GpuNameTemp = (string)obj["Name"]; #if DEBUG logger.Debug($"SystemChecker - GpuName: {GpuNameTemp}"); #endif if (Gpu.CallIsNvidia(GpuNameTemp)) { GpuName = (string)obj["Name"]; GpuRam = (long)Convert.ToDouble(obj["AdapterRAM"]); CurrentHorizontalResolution = (uint)obj["CurrentHorizontalResolution"]; CurrentVerticalResolution = (uint)obj["CurrentVerticalResolution"]; break; } if (Gpu.CallIsAmd(GpuNameTemp)) { GpuName = (string)obj["Name"]; GpuRam = (long)Convert.ToDouble(obj["AdapterRAM"]); CurrentHorizontalResolution = (uint)obj["CurrentHorizontalResolution"]; CurrentVerticalResolution = (uint)obj["CurrentVerticalResolution"]; break; } if (Gpu.CallIsIntel(GpuNameTemp)) { GpuName = (string)obj["Name"]; GpuRam = (long)Convert.ToDouble(obj["AdapterRAM"]); CurrentHorizontalResolution = (uint)obj["CurrentHorizontalResolution"]; CurrentVerticalResolution = (uint)obj["CurrentVerticalResolution"]; } } } catch (Exception ex) { Common.LogError(ex, "SystemChecker", "Error on Win32_VideoController"); } // RAM try { ManagementObjectSearcher myComputerSystemObject = new ManagementObjectSearcher("select * from Win32_ComputerSystem"); foreach (ManagementObject obj in myComputerSystemObject.Get()) { double TempRam = Math.Ceiling(Convert.ToDouble(obj["TotalPhysicalMemory"]) / 1024 / 1024 / 1024); Ram = (long)(TempRam * 1024 * 1024 * 1024); } } catch (Exception ex) { Common.LogError(ex, "SystemChecker", "Error on Win32_ComputerSystem"); } systemConfiguration.Name = Name.Trim(); systemConfiguration.Os = Os.Trim(); systemConfiguration.Cpu = Cpu.Trim(); systemConfiguration.CpuMaxClockSpeed = CpuMaxClockSpeed; systemConfiguration.GpuName = GpuName.Trim(); systemConfiguration.GpuRam = GpuRam; systemConfiguration.CurrentHorizontalResolution = CurrentHorizontalResolution; systemConfiguration.CurrentVerticalResolution = CurrentVerticalResolution; systemConfiguration.Ram = Ram; systemConfiguration.RamUsage = RequierementMetadata.SizeSuffix(Ram, true); systemConfiguration.Disks = Disks; File.WriteAllText(FilePlugin, JsonConvert.SerializeObject(systemConfiguration)); return(systemConfiguration); }