private bool ProcessDrivers(DriverPackage driverPackage, IResultObject driverObject, BackgroundWorker worker) { worker.ReportProgress( progressStart + (progresPercent), string.Format("Importing Driver Package: {0}\n - retriving driver '{1} ({2})'", driverPackage.Name, driverObject["LocalizedDisplayName"].StringValue, driverObject["DriverVersion"].StringValue ) ); if (driverPackage.Drivers.TryGetValue(driverObject["DriverINFFile"].StringValue + driverObject["DriverVersion"].StringValue, out Driver driver)) { if (driver.Version == driverObject["DriverVersion"].StringValue) { driver.AddObject(driverObject); if (driverPackage.DriverContentExists(driver)) { driverPackage.AddDriverToCategory(driver); driver.Import = false; } } } else { worker.ReportProgress( progressStart + (progresPercent), string.Format("Importing Driver Package: {0}\n - removing driver: {1} ({2})", driverPackage.Name, driverObject["LocalizedDisplayName"].StringValue, driverObject["DriverVersion"].StringValue) ); // remove from driver package and category if source folder have been removed driverPackage.RemoveDriverFromCategory(driverObject); if (driverPackage.RemoveDriverFromDriverPack(driverObject)) { refreshDP = true; } } return(true); }
private bool ImportDrivers(DriverPackage driverPackage, Driver driver, BackgroundWorker worker) { ++progressCount; progresPercent = progressStepPercent + Convert.ToInt32(((double)progressCount / progressTotal * 100) / progressStepCount / totalDriverPackages); worker.ReportProgress( progressStart + (progresPercent), string.Format("Importing Driver Package: {0}\n - importing driver ({1}/{2}) '{3} ({4})'", driverPackage.Name, progressCount, progressTotal, driver.Model, driver.Version ) ); log.Debug("Importing driver: " + driver.Model); // this is a great idea but throws an file hash error when adding driver to package if (registry.ReadBool("DriverPackageQuickMerge") && driver.CheckIfExists(ConnectionManager)) { log.Debug("QuickMergeCheckIfExists: " + driver.Model); driverPackage.AddDriverToCategory(driver); } else if (driver.CreateObjectFromInfFile(ConnectionManager)) { log.Debug("CreateObjectFromInfFile: " + driver.Model); // add category to driver object driverPackage.AddDriverToCategory(driver); } log.Debug("Done importing driver: " + driver.Model); refreshPackage = true; refreshDP = true; return(true); }
public bool GetDriverPackages(ProgressInformationDialog progressInformationDialog) { string[] modelEntries = Directory.GetDirectories(SourceLocation, "*", SearchOption.TopDirectoryOnly); int num = 0; foreach (string modelDirectory in modelEntries) { string modelName = new DirectoryInfo(modelDirectory).Name; int percent = num * 100 / modelEntries.Length; backgroundWorker.ReportProgress(ProgressStart + (percent / TotalVendors), string.Format("Processing Driver Packages for Vendor: {0}\n\n Model: {1}", Name, modelName)); string[] architectureEntries = Directory.GetDirectories(modelDirectory, "*", SearchOption.TopDirectoryOnly); foreach (string sourceDirectory in architectureEntries) { string architectureName = new DirectoryInfo(sourceDirectory).Name; string driverPackageName = string.Join("-", Name, modelName, architectureName); string packageName = string.Join("-", Name, modelName, architectureName); string targetDirectory = Path.Combine(PackageLocation, Name, packageName); DriverPackage package = new DriverPackage(connectionManager, driverPackageName, sourceDirectory, targetDirectory) { Vendor = Name }; DriverPackages.Add(package); } ++num; if (progressInformationDialog.ReceivedRequestToClose) { return(false); } } return(DriverPackages.Count > 0 ? true : false); }
private bool ProcessSource(BackgroundWorker progressWorker) { bool flag; List <DriverPackage> driverPackages = new List <DriverPackage>(); string sourceDirectory = registry.ReadString("DriverSourceFolder"); UserData["sourceDirectory"] = sourceDirectory; string packageDirectory = registry.ReadString("DriverPackageFolder"); progressWorker.ReportProgress(0, "Validating source folder"); if (registry.ReadBool("LegacyFolderStructure")) { string[] subdirectoryEntries = Directory.GetDirectories(sourceDirectory, "*", SearchOption.TopDirectoryOnly); int totalVendors = subdirectoryEntries.Length; int num = 0; foreach (string vendorDirectory in subdirectoryEntries) { string name = new DirectoryInfo(vendorDirectory).Name; int start = 100 / totalVendors * num; progressWorker.ReportProgress(start, string.Format("Processing Driver Packages for Vendor: {0}", name)); // create vendor object Vendor vendor = new Vendor(progressWorker, ConnectionManager, vendorDirectory) { ProgressStart = start, TotalVendors = totalVendors }; // get driver packages for vendor if (vendor.GetDriverPackages(progressInformationDialog)) { foreach (DriverPackage package in vendor.DriverPackages) { driverPackages.Add(package); } } ++num; if (progressInformationDialog.ReceivedRequestToClose) { return(false); } } flag = true; } else { string[] subdirectoryEntries = Directory.GetDirectories(sourceDirectory, "*", SearchOption.TopDirectoryOnly); int totalDriverPackges = subdirectoryEntries.Length; int num = 0; foreach (string driverPackageDirectory in subdirectoryEntries) { string driverPackageName = new DirectoryInfo(driverPackageDirectory).Name; int start = 100 / totalDriverPackges * num; progressWorker.ReportProgress(start, string.Format("Processing Driver Packages: {0}", driverPackageName)); // create vendor object string vendor = driverPackageName.Split(new[] { '-' }, 2)[0]; string targetDirectory = Path.Combine(packageDirectory, driverPackageName); DriverPackage package = new DriverPackage(ConnectionManager, driverPackageName, driverPackageDirectory, targetDirectory) { Vendor = vendor }; driverPackages.Add(package); ++num; if (progressInformationDialog.ReceivedRequestToClose) { return(false); } } flag = true; } UserData["DriverPackages"] = driverPackages; progressWorker.ReportProgress(100, "Done"); return(flag); }