public void SetupCompatibleDriver(string workingDirectory, IDriverConfig browserConfig, string browserVersion, bool use32bit = true, WDMProxy proxy = null) { var driverArchitecture = use32bit ? Architecture.X32 : ArchitectureHelper.GetArchitecture(); List <Tuple <string, string> > driverInfo; driverInfo = GetDriverInfo(browserConfig, driverArchitecture, browserVersion); //these are all the variables we need to be setup var url = driverInfo[0].Item1; var driverLocation = Path.Combine(workingDirectory, driverInfo[0].Item2); if (File.Exists(driverLocation)) { SetUpLocalDriver(driverLocation); } else { var tempDirectory = FileHelper.GetTempDirectory(); var driverName = browserConfig.GetBinaryName(); var downloadedFileName = FileHelper.GetFileNameFromUrl(url); var zipLocation = ZipHelper.DownloadZip(url, tempDirectory, downloadedFileName, proxy); FileHelper.CreateDestinationDirectory(driverLocation); ZipHelper.UnZipToDriverLocation(zipLocation, driverLocation, driverName); ZipHelper.DeleteZip(zipLocation); SetUpLocalDriver(driverLocation); } }
/// <summary> /// This method use the ArchitectureHelper.GetArchitecture() to get the system's Architecture /// and return the name of the folder that needed to be used /// </summary> /// <returns>string foldersName</returns> private static string GetArchitectureNameFolder() { // Declare a new string, to hold the folder's name string folderName = null; // Switch the enum Architecture switch (ArchitectureHelper.GetArchitecture()) { // Case 32 bits case Architecture.Architecture.x86: folderName = "32 bit"; break; // Case 64 bits case Architecture.Architecture.x64: folderName = "64 bit"; break; // Another case default: break; } // Return the folder names return(folderName); }
public static string DriverDirectoryFullPath(this IDriverConfig driverConfig) { if (driverConfig == null) { throw new ArgumentNullException(nameof(driverConfig)); } return(Path.Combine(Environment.CurrentDirectory, driverConfig.GetName(), driverConfig.GetLatestVersion(), $"{ArchitectureHelper.GetArchitecture():F}")); }
public void SetUpDriver(IDriverConfig config, string version = "Latest", Architecture architecture = Architecture.Auto) { architecture = architecture.Equals(Architecture.Auto) ? ArchitectureHelper.GetArchitecture() : architecture; version = version.Equals("Latest") ? config.GetLatestVersion() : version; var url = architecture.Equals(Architecture.X32) ? config.GetUrl32() : config.GetUrl64(); url = UrlHelper.BuildUrl(url, version); var binaryPath = FileHelper.GetBinDestination(config.GetName(), version, architecture, config.GetBinaryName()); SetUpDriver(url, binaryPath, config.GetBinaryName()); }
/// <summary> /// Downloads driver from repo /// </summary> /// <param name="type">Driver type</param> /// <param name="version">Version number</param> /// <returns>Path of driver location</returns> private static string GetDriverVersion(DriverFactory.DriverTypes type, string version = "") { string driverFullPath = ""; string executingPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory); string binaryName = ""; string url = ""; string latestVersionNumber = version == "" ? GetLatestVersionNumber(type) : version; Architecture currnetArchitecture = ArchitectureHelper.GetArchitecture(); switch (type) { case DriverFactory.DriverTypes.Chrome: ChromeConfig cConfig = new ChromeConfig(); binaryName = cConfig.GetBinaryName(); url = currnetArchitecture == Architecture.X32 ? cConfig.GetUrl32() : cConfig.GetUrl64(); url = UrlHelper.BuildUrl(url, latestVersionNumber); break; case DriverFactory.DriverTypes.Firefox: FirefoxConfig fConfig = new FirefoxConfig(); binaryName = fConfig.GetBinaryName(); url = currnetArchitecture == Architecture.X32 ? fConfig.GetUrl32() : fConfig.GetUrl64(); url = UrlHelper.BuildUrl(url, latestVersionNumber); break; case DriverFactory.DriverTypes.IE: InternetExplorerConfig ieConfig = new InternetExplorerConfig(); binaryName = ieConfig.GetBinaryName(); url = currnetArchitecture == Architecture.X32 ? ieConfig.GetUrl32() : ieConfig.GetUrl64(); url = UrlHelper.BuildUrl(url, latestVersionNumber); break; default: break; } string driverLocationPath = version == "" ? Path.Combine(executingPath, type.ToString()) : Path.Combine(Path.Combine(executingPath, type.ToString()), version); driverFullPath = Path.Combine(driverLocationPath, binaryName); if (!IsLocalVersionLatestVersion(type, driverLocationPath, version)) { if (File.Exists(driverFullPath)) { File.Delete(driverFullPath); } new Manager.DriverManager().SetUpDriver(url, driverFullPath, binaryName); } return(driverLocationPath); }
public void SetUpDriver(IDriverConfig config, string version = VersionResolveStrategy.Latest, Architecture architecture = Architecture.Auto) { lock (Object) { architecture = architecture.Equals(Architecture.Auto) ? ArchitectureHelper.GetArchitecture() : architecture; version = GetVersionToDownload(config, version); var url = architecture.Equals(Architecture.X32) ? config.GetUrl32() : config.GetUrl64(); url = UrlHelper.BuildUrl(url, version); var binaryPath = FileHelper.GetBinDestination(config.GetName(), version, architecture, config.GetBinaryName()); SetUpDriver(url, binaryPath, config.GetBinaryName()); } }
private static void SetUpDriver(IDriverConfig driverConfig, IDriverSettings driverSettings) { var architecture = driverSettings.SystemArchitecture.Equals(Architecture.Auto) ? ArchitectureHelper.GetArchitecture() : driverSettings.SystemArchitecture; var version = driverSettings.WebDriverVersion.Equals(VersionResolveStrategy.Latest) ? driverConfig.GetLatestVersion() : driverSettings.WebDriverVersion; version = version.Equals(VersionResolveStrategy.MatchingBrowser) ? driverConfig.GetMatchingBrowserVersion() : version; var url = UrlHelper.BuildUrl(architecture.Equals(Architecture.X32) ? driverConfig.GetUrl32() : driverConfig.GetUrl64(), version); var binaryPath = FileHelper.GetBinDestination(driverConfig.GetName(), version, architecture, driverConfig.GetBinaryName()); if (!File.Exists(binaryPath) || !Environment.GetEnvironmentVariable("PATH").Contains(binaryPath)) { lock (WebDriverDownloadingLock) { new DriverManager().SetUpDriver(url, binaryPath, driverConfig.GetBinaryName()); } } }
public ComputerModel GetAllData() { CpuModel[] cpus = null; try { var cpusProperties = devicePropertiesAdapter.GetMultipleProperties("Win32_Processor"); cpus = cpusProperties.Select(cp => { var cpu = new CpuModel() { Specification = cp["Name"].ToString() ?? "Unknown", CpuClocks = new CpuClocks() { CoreSpeed = cp["CurrentClockSpeed"] != null ? Convert.ToSingle((uint)(cp["CurrentClockSpeed"])) : 0f, BusSpeed = cp["ExtClock"] != null ? Convert.ToSingle((uint)(cp["ExtClock"])) : 0f, }, NumberOfCores = cp["NumberOfCores"] != null ? (uint)(cp["NumberOfCores"]) : 1, NumberOfLogicalProcessors = cp["NumberOfLogicalProcessors"] != null ? (uint)(cp["NumberOfLogicalProcessors"]) : 1, Architecture = ArchitectureHelper.GetArchitecture((ushort)cp["Architecture"], (ushort)cp["DataWidth"]), Manufacturer = cp["Manufacturer"]?.ToString() }; cpu = SetModelFamilyStepping(cpu, cp["Caption"].ToString()); SetSupportedInstructions(cpu, (ushort)cp["Architecture"]); SetCaches(cpu); SetCpuDetails(cpu); return(cpu); }).ToArray(); WindowsProcessor.GetSupportedInstructions(); } finally { if (cpus == null || cpus.Length == 0) { cpus = new CpuModel[] { new CpuModel() { CpuClocks = new CpuClocks() { }, Caches = new CpuCaches() { Level1Data = new CpuCacheItem(), Level1Instructions = new CpuCacheItem(), Level2 = new CpuCacheItem(), Level3 = new CpuCacheItem() }, CpuFamilyModelStepping = new CpuFamilyModelStepping() { } }, }; } } return(new ComputerModel() { Cpus = new AllCpus() { Cpus = cpus, RootCpu = cpus[0], TotalOfCores = cpus.Length > 1 ? (uint)cpus.Sum(c => c.NumberOfCores) : cpus[0].NumberOfCores, TotalOfLogicalProcessors = cpus.Length > 1 ? (uint)cpus.Sum(c => c.NumberOfLogicalProcessors) : cpus[0].NumberOfLogicalProcessors, } }); }
public ComputerModel GetAllData() { computer.Open(); computer.CpuEnabled = true; computer.MainboardEnabled = true; computer.RAMEnabled = true; computer.GPUEnabled = true; hardware = computer.Hardware; CpuModel[] cpus = new CpuModel[] { }; var hwd = hardware.OfType <GenericCPU>().ToArray(); var hwCpus = hwd.OfType <GenericCPU>(); var hwBios = hardware.OfType <Mainboard>()?.FirstOrDefault()?.BIOS; cpus = hwCpus.Select(cp => { var l1CacheData = cp.Caches.ContainsKey(CacheLevels.Level1) ? cp.Caches[CacheLevels.Level1].FirstOrDefault(ch => ch.CacheType == CacheType.Data) : null; var l1CacheInstructions = cp.Caches.ContainsKey(CacheLevels.Level1) ? cp.Caches[CacheLevels.Level1].FirstOrDefault(ch => ch.CacheType == CacheType.Instructions) : null; var l2Cache = cp.Caches.ContainsKey(CacheLevels.Level2) ? cp.Caches[CacheLevels.Level2].FirstOrDefault() : null; var l3Cache = cp.Caches.ContainsKey(CacheLevels.Level3) ? cp.Caches[CacheLevels.Level3].FirstOrDefault() : null; IntelCPU intelCpu = cp as IntelCPU; var specificCpu = (intelCpu != null) ? intelCpu : ((cp is AMDCPU amdCPu) ? amdCPu : cp); var cpuModel = new CpuModel() { Architecture = ArchitectureHelper.GetArchitecture((uint)(specificCpu.Is64bit ? 9 : 0), 0), Name = specificCpu.Name, CodeName = specificCpu.CodeName, Specification = cp.BrandString, NumberOfCores = (uint)cp.Cores, NumberOfLogicalProcessors = (uint)cp.Threads, Technology = cp.Technology, CpuClocks = new CpuClocks() { }, CpuFamilyModelStepping = new CpuFamilyModelStepping() { FullFamily = (byte)cp.Family, Family = (byte)cp.FamilyId, FullModel = (byte)cp.Model, Stepping = (byte)cp.Stepping, }, Instructions = GetInstructions(specificCpu, cp.InstructionsExtensions), Caches = new CpuCaches() { Level1Data = l1CacheData != null ? new CpuCacheItem() { Level = 1, Associativity = (byte)l1CacheData.Associativity, Size = l1CacheData.SizeKbytes * 1024, LineSize = l1CacheData.LineSize, NumberOfCores = (uint)cp.Cores } : new CpuCacheItem() { }, Level1Instructions = l1CacheInstructions != null ? new CpuCacheItem() { Level = 1, Associativity = (byte)l1CacheInstructions.Associativity, Size = l1CacheInstructions.SizeKbytes * 1024, LineSize = l1CacheInstructions.LineSize, NumberOfCores = (uint)cp.Cores } : new CpuCacheItem() { }, Level2 = l2Cache != null ? new CpuCacheItem() { Level = 2, Associativity = (byte)l2Cache.Associativity, Size = l2Cache.SizeKbytes * 1024, LineSize = l2Cache.LineSize, NumberOfCores = (uint)cp.Cores } : new CpuCacheItem() { }, Level3 = l3Cache != null ? new CpuCacheItem() { Level = 3, Associativity = (byte)l3Cache.Associativity, LineSize = l3Cache.LineSize, Size = l3Cache.SizeKbytes * 1024 } : new CpuCacheItem() { }, } }; SetCpuClocks(cp, hwBios, cpuModel.CpuClocks); return(cpuModel); }).ToArray(); Motherboard motherboard = null; if (hwBios != null && hwBios.Board != null) { motherboard = new Motherboard() { Manufacturer = hwBios.Board.ManufacturerName, Model = hwBios.Board.ProductName, Version = hwBios.Board.Version }; } else { motherboard = new Motherboard() { Manufacturer = string.Empty, Model = string.Empty, Version = string.Empty }; } Bios bios = null; if (hwBios != null && hwBios.BIOS != null) { bios = new Bios() { Brand = hwBios.BIOS.Vendor, Date = hwBios.BIOS.Date, Version = hwBios.BIOS.Version }; } else { bios = new Bios() { Brand = string.Empty, Date = string.Empty, Version = string.Empty }; } return(new ComputerModel() { Cpus = new AllCpus() { Cpus = cpus, RootCpu = cpus?[0], TotalOfCores = cpus.Length > 1 ? (uint)cpus.Sum(c => c.NumberOfCores) : (cpus?[0]?.NumberOfCores ?? 0), TotalOfLogicalProcessors = cpus.Length > 1 ? (uint)cpus.Sum(c => c.NumberOfLogicalProcessors) : (cpus?[0]?.NumberOfLogicalProcessors ?? 0), }, Motherboard = motherboard, Bios = bios }); }