Ejemplo n.º 1
0
        public bool GetLegacyPackages(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 Source 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);

                    LegacyPackage package = new LegacyPackage(connectionManager, driverPackageName, sourceDirectory, targetDirectory)
                    {
                        Vendor = Name
                    };

                    LegacyPackages.Add(package);
                }
                ++num;

                if (progressInformationDialog.ReceivedRequestToClose)
                {
                    return(false);
                }
            }

            return(LegacyPackages.Count > 0 ? true : false);
        }
Ejemplo n.º 2
0
        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);
        }