public override void InitializePageControl() { base.InitializePageControl(); browseFolderControlSource.Controls.OfType <SmsOsdTextBox>().First().Text = registry.ReadString("DriverSourceFolder"); browseFolderControlPackage.Controls.OfType <SmsOsdTextBox>().First().Text = registry.ReadString("DriverPackageFolder"); //checkBoxQuickMerge.Checked = registry.ReadBool("DriverPackageQuickMerge"); textBoxConsoleFolder.Text = registry.ReadString("DriverPackageConsoleFolder"); checkBoxLegacyFolder.Checked = registry.ReadBool("LegacyFolderStructure"); ControlsInspector = new ControlsInspector(); controlsValidator = new ControlsValidator(ControlsInspector); browseFolderControlSource.SetErrorMessageFolderPath("Specify a valid UNC path"); browseFolderControlSource.SetCustomValidateFilePath(new ControlDataStateEvaluator(ValidateSourceDirectory)); browseFolderControlSource.SetValidator(controlsValidator); browseFolderControlPackage.SetErrorMessageFolderPath("Specify a valid UNC path"); browseFolderControlPackage.SetCustomValidateFilePath(new ControlDataStateEvaluator(ValidatePackageDirectory)); browseFolderControlPackage.SetValidator(controlsValidator); ControlsInspector.InspectAll(); Dirty = false; Initialized = true; }
public override void InitializePageControl() { base.InitializePageControl(); browseFolderControlLegacyPackage.Controls.OfType <SmsOsdTextBox>().First().Text = registry.ReadString("LegacyPackageFolder"); checkBoxZipContent.Checked = registry.ReadBool("LegacyPackageZipContent"); textBoxConsoleFolder.Text = registry.ReadString("LegacyConsoleFolder"); }
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); }
private void InitializeDataGridView() { List <ManagementObject> signedDrivers = (List <ManagementObject>)UserData["SignedDrivers"]; dataGridViewDrivers.Rows.Clear(); foreach (ManagementObject item in signedDrivers) { string provider = (string)item["DriverProviderName"]; string description = (string)item["DeviceName"]; string oeminf = (string)item["InfName"]; if (provider.Length > 0 && description.Length > 0) { if (DriverExists(description, oeminf)) { continue; } DataGridViewRow dataGridViewRow = new DataGridViewRow(); dataGridViewRow.CreateCells(dataGridViewDrivers); dataGridViewRow.Cells[0].Value = false; dataGridViewRow.Cells[1].Value = provider; dataGridViewRow.Cells[2].Value = description; dataGridViewRow.Cells[3].Value = (string)item["DriverVersion"]; dataGridViewRow.Cells[4].Value = oeminf; dataGridViewRow.Tag = item; dataGridViewDrivers.Rows.Add(dataGridViewRow); } } string osName; ManagementObject operatingSystem = (ManagementObject)UserData["OperatingSystem"]; string currentversion = (string)operatingSystem["Version"]; string v2 = "10.0"; var version1 = new Version(currentversion); var version2 = new Version(v2); var result = version1.CompareTo(version2); if (result > 0) { osName = "Win10"; } else { switch (currentversion) { case "6.1.7601": osName = "Win7"; break; case "6.2.9200": osName = "Win8"; break; case "6.3.9600": osName = "Win81"; break; default: osName = "Unknown"; break; } } if ((string)operatingSystem["OSArchitecture"] == "64-bit") { architecture = "x64"; } else { architecture = "x86"; } ManagementObject computerSystem = (ManagementObject)UserData["ComputerSystem"]; if (registry.ReadBool("LegacyFolderStructure")) { textBoxDestination.Text = string.Format(@"{0}\{1}\{2}-{3}", ((string)computerSystem["Manufacturer"]).Trim(), ((string)computerSystem["Model"]).Trim(), osName, architecture); } else { textBoxDestination.Text = string.Format(@"{0}-{1}-{2}-{3}", ((string)computerSystem["Manufacturer"]).Trim(), ((string)computerSystem["Model"]).Trim(), osName, architecture); } Initialized = true; }
private void ExtractFiles() { if (_extractFiles.Any()) { KeyValuePair <HPDriverPackage, string> data = _extractFiles.Dequeue(); // add model so we can re-use it in functions HPDriverPackage package = data.Key; currentModel = package.Model; // update my best friend the progress bar backgroundWorker.ReportProgress(Convert.ToInt32(50 + ((50 / totalPacks * extracted) * 0.5)), string.Format("Processing {0} : extracting to temp folder", currentModel)); // generate model folder name // hp sp extract does not work directly to network share, put in temp folder first and than copy to share string tempFolder = Path.Combine(tempFolderPath, "extract", package.FolderName); string destinationFolder = Path.Combine(sourceFolderPath, package.FolderName); using (extractProcess = new Process()) { try { // Start a process to print a file and raise an event when done. extractProcess.StartInfo.FileName = data.Value; extractProcess.StartInfo.Arguments = string.Format("-pdf -f \"{0}\" -s -e", tempFolder); extractProcess.StartInfo.CreateNoWindow = true; extractProcess.StartInfo.UseShellExecute = true; extractProcess.StartInfo.Verb = "RunAs"; extractProcess.Start(); extractProcess.WaitForExit(); extractProcess.Close(); // update my best friend the progress bar backgroundWorker.ReportProgress(Convert.ToInt32(50 + ((100 / totalPacks * extracted) * 0.5) - 1), string.Format("Processing {0} : moving to destination folder", currentModel)); if (!Directory.Exists(tempFolder)) { throw new DirectoryNotFoundException("Temp folder not found " + tempFolder); } // add a version file to the folder so we can check later if there is an update to the download string versionFile = Path.Combine(tempFolderPath, "extract", package.FolderName, package.VersionFile); File.Create(versionFile).Close(); // wipe old soruce folder if (registry.ReadBool("WipeSource") && Directory.Exists(destinationFolder)) { Directory.Delete(destinationFolder, true); } // remove old version file if (Directory.Exists(destinationFolder)) { string[] fileList = Directory.GetFiles(destinationFolder, "*.version"); foreach (string file in fileList) { File.Delete(file); } } Utility.Copy(tempFolder, destinationFolder, true); Directory.Delete(tempFolder, true); } catch (Exception ex) { error.Add(currentModel, "Cannot extract driver pack: " + ex.Message); CheckExtractQueueCompleted(); return; } } successful.Add(currentModel); CheckExtractQueueCompleted(); return; } }
private void ExtractFiles() { if (_extractFiles.Any()) { KeyValuePair <DellDriverPackage, string> data = _extractFiles.Dequeue(); // add model so we can re-use it in functions DellDriverPackage package = data.Key; currentModel = package.Model; // update my best friend the progress bar backgroundWorker.ReportProgress(Convert.ToInt32(50 + ((40 / totalPacks * extracted) * 0.5)), string.Format("Processing {0} : extracting to temp folder", currentModel)); // generate model folder name // hp sp extract does not work directly to network share, put in temp folder first and than copy to share string tempFolder = Path.Combine(tempFolderPath, "extract", package.FolderName); string destinationFolder = Path.Combine(sourceFolderPath, package.FolderName); try { var cab = new CabInfo(data.Value); cab.Unpack(tempFolder); // update my best friend the progress bar backgroundWorker.ReportProgress(Convert.ToInt32(50 + ((80 / totalPacks * extracted) * 0.5)), string.Format("Processing {0} : moving to destination folder", currentModel)); if (!Directory.Exists(tempFolder)) { throw new DirectoryNotFoundException("Temp folder not found " + tempFolder); } // add a version file to the folder so we can check later if there is an update to the download string versionFile = Path.Combine(tempFolderPath, "extract", package.FolderName, package.VersionFile); File.Create(versionFile).Close(); // wipe old soruce folder if (registry.ReadBool("WipeSource") && Directory.Exists(destinationFolder)) { Directory.Delete(destinationFolder, true); } // remove old version file if (Directory.Exists(destinationFolder)) { string[] fileList = Directory.GetFiles(destinationFolder, "*.version"); foreach (string file in fileList) { File.Delete(file); } } Utility.Copy(tempFolder, destinationFolder, true); Directory.Delete(tempFolder, true); } catch (Exception ex) { error.Add(package.Model, "Cannot extract driver pack: " + ex.Message); CheckExtractQueueCompleted(); return; } successful.Add(currentModel); CheckExtractQueueCompleted(); return; } // fix if all download fails, dont get stuck in this loop else if (_extractFiles.Count == 0) { extractQueueFinished = true; return; } }
private bool ProcessSource(BackgroundWorker progressWorker) { bool flag; List <LegacyPackage> packages = new List <LegacyPackage>(); string sourceDirectory = registry.ReadString("DriverSourceFolder"); UserData["sourceDirectory"] = sourceDirectory; string legacyDirectory = registry.ReadString("LegacyPackageFolder"); 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 Source 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.GetLegacyPackages(progressInformationDialog)) { foreach (LegacyPackage package in vendor.LegacyPackages) { packages.Add(package); } } ++num; if (progressInformationDialog.ReceivedRequestToClose) { return(false); } } flag = true; } else { string[] subdirectoryEntries = Directory.GetDirectories(sourceDirectory, "*", SearchOption.TopDirectoryOnly); int totalPackges = subdirectoryEntries.Length; int num = 0; foreach (string packageDirectory in subdirectoryEntries) { string packageName = new DirectoryInfo(packageDirectory).Name; int start = 100 / totalPackges * num; progressWorker.ReportProgress(start, string.Format("Processing Driver Source: {0}", packageName)); // create vendor object string vendor = packageName.Split(new[] { '-' }, 2)[0]; string targetDirectory = Path.Combine(legacyDirectory, packageName); LegacyPackage package = new LegacyPackage(ConnectionManager, packageName, packageDirectory, targetDirectory) { Vendor = vendor }; packages.Add(package); ++num; if (progressInformationDialog.ReceivedRequestToClose) { return(false); } } flag = true; } UserData["LegacyPackages"] = packages; progressWorker.ReportProgress(100, "Done"); return(flag); }
public override void PostApply(BackgroundWorker worker, DoWorkEventArgs e) { try { Dictionary <string, string> error = new Dictionary <string, string>(); List <string> successful = new List <string>(); int num = 0; int stepCount = 2; List <LegacyPackage> legacyPackages = (List <LegacyPackage>)UserData["LegacyPackageItems"]; int totalPackages = legacyPackages.Count; foreach (LegacyPackage package in legacyPackages) { int startProgress = num * 100 / totalPackages; worker.ReportProgress(startProgress, string.Format("Importing Package: {0}", package.Name)); if (Directory.Exists(package.Target)) { Directory.Delete(package.Target, true); } if (package.Create()) { importProgresPercent = 100 / stepCount / totalPackages * 1; if (registry.ReadBool("LegacyPackageZipContent")) { worker.ReportProgress(startProgress + (importProgresPercent), string.Format("Zipping driver source for: {0}", package.Name)); string zipPath = Path.Combine(package.Target, string.Format("{0}.zip", package.Name.Replace(' ', '_'))); ZipFile.CreateFromDirectory(package.Source, zipPath); } else { worker.ReportProgress(startProgress + (importProgresPercent), string.Format("Copying driver source for: {0}", package.Name)); Utility.Copy(package.Source, package.Target, true); } // I still hate calculating progress bars importProgresPercent = 100 / stepCount / totalPackages * 2; worker.ReportProgress(startProgress + (importProgresPercent), string.Format("Importing Package: {0}\n - updating distribution point", package.Name)); package.Package.ExecuteMethod("RefreshPkgSource", null); package.CreateHashFile(); package.UpdatePackageVersion(); } ++num; } PrepareCompletion(); base.PostApply(worker, e); } catch (Exception ex) { AddRefreshResultObject(null, PropertyDataUpdateAction.RefreshAll); PrepareError(ex.Message); } }
public override void InitializePageControl() { base.InitializePageControl(); if (string.IsNullOrEmpty(registry.ReadString("DellCatalogURI"))) { registry.Write("DellCatalogURI", "http://downloads.dell.com/catalog/DriverPackCatalog.cab"); } if (string.IsNullOrEmpty(registry.ReadString("HPCatalogURI"))) { registry.Write("HPCatalogURI", "https://ftp.hp.com/pub/caps-softpaq/cmit/HPClientDriverPackCatalog.cab"); } if (string.IsNullOrEmpty(registry.ReadString("TempDownloadPath"))) { registry.Write("TempDownloadPath", Path.GetTempPath()); } if (string.IsNullOrEmpty(registry.ReadString("DellFolderPrefix"))) { registry.Write("DellFolderPrefix", "Dell"); } if (string.IsNullOrEmpty(registry.ReadString("HPFolderPrefix"))) { registry.Write("HPFolderPrefix", "HP"); } checkBoxWipeSource.Checked = registry.ReadString("WipeSource") == "" ? true : registry.ReadBool("WipeSource"); textBoxDellCatalogUri.Text = registry.ReadString("DellCatalogURI"); textBoxDellPrefix.Text = registry.ReadString("DellFolderPrefix"); textBoxHPCatalogUri.Text = registry.ReadString("HPCatalogURI"); textBoxHPPrefix.Text = registry.ReadString("HPFolderPrefix"); browseFolderControlDownload.Controls.OfType <SmsOsdTextBox>().First().Text = registry.ReadString("TempDownloadPath"); ControlsInspector = new ControlsInspector(); controlsValidator = new ControlsValidator(ControlsInspector); browseFolderControlDownload.SetErrorMessageFolderPath("Specify a valid path"); browseFolderControlDownload.SetCustomValidateFilePath(new ControlDataStateEvaluator(ValidateDownloadDirectory)); browseFolderControlDownload.SetValidator(controlsValidator); ControlsInspector.InspectAll(); Dirty = false; Initialized = true; }