示例#1
0
        private void AddList(IEnumerable <string> fileList)
        {
            foreach (
                var myClass in
                fileList.Where(
                    myClass =>
                    _installList.Any(c => c.Location.EqualsIgnoreCase(myClass)) ||
                    _installList.Any(c => c.Name.EqualsIgnoreCase(Path.GetFileNameWithoutExtension(myClass)))))
            {
                fileList = fileList.Where(u => u.EqualsIgnoreCase(myClass)).ToList();
            }


            var incompatible = 0;

            Parallel.ForEach(fileList,
                             new ParallelOptions {
                MaxDegreeOfParallelism = Options.MaxThreads
            },
                             currentFile =>
            {
                _Update newItem = null;
                if (currentFile.EndsWithIgnoreCase(".MSU"))
                {
                    newItem = new MsuUpdate(currentFile);
                }
                else if (currentFile.EndsWithIgnoreCase(".CAB"))
                {
                    newItem = new CabUpdate(currentFile);
                }

                if (newItem == null || newItem.AppliesTo != OS.Version.ToString())
                {
                    incompatible++;
                    //return;
                }

                lock (_installList)
                {
                    _installList.Add(newItem);
                }
            });

            if (incompatible > 0)
            {
                MessageBox.Show(string.Format("{0} item(s) are not compatible with your OS.", incompatible),
                                "Invalid Updates");
            }


            _installList = _installList.GroupBy(x => x.Name.ToLowerInvariant()).Select(x => x.First()).ToList();

            //Updates status
            dgUpdates.ItemsSource = _installList;
            lblStatus.Text        = _installList.Count + " " + Localization.GetString("Global", 54);

            dgUpdates.Update();
        }
示例#2
0
        public void InstallUpdateMSU_Win10LDR()
        {
            var U = new MsuUpdate(_Global.TestDirectory + "Windows6.4-KB3002675-x64.msu");

            if (U.InstallLDR() != Status.Success)
            {
                Assert.Fail();
            }
        }
示例#3
0
        public void InitializeAkwardUpdate2()
        {
            var U = new MsuUpdate(_Global.TestDirectory + "Windows6.1-KB2756651-x64_INV.msu");

            if (U.PackageName == null)
            {
                Assert.Fail();
            }
        }
示例#4
0
        public void ConvertUpdate()
        {
            var newUpdate = new MsuUpdate(_Global.TestDirectory + "Windows6.1-KB917607-x86_GDR.msu");
            var outDir    = _Global.TestDirectory + "Output" + Misc.RandomString() + "\\";

            FileHandling.DeleteDirectory(outDir, true);

            var result = newUpdate.Convert(outDir);

            FileHandling.DeleteDirectory(outDir);

            if (result != Status.Success)
            {
                Assert.Fail();
            }
        }
示例#5
0
        private async void addUpdate(IEnumerable <string> files)
        {
            dgUpdates.Disable();
            pbProgress.Value    = 0;
            lblProgress.Content = "0%";

            var source = files.ToArray();

            pbProgress.Maximum = source.Count();

            _tim = new ElapsedTimer(ref txtTime);
            _tim.Start();

            await Task.Factory.StartNew(delegate
            {
                Parallel.ForEach(source, new ParallelOptions {
                    MaxDegreeOfParallelism = Options.MaxThreads
                }, currentFile =>
                {
                    _Update newUpdate = null;
                    if (currentFile.EndsWithIgnoreCase(".cab"))
                    {
                        newUpdate = new CabUpdate(currentFile);
                    }
                    else if (currentFile.EndsWithIgnoreCase(".msu"))
                    {
                        newUpdate = new MsuUpdate(currentFile);
                    }

                    pbProgress.Increment(lblProgress);

                    if (newUpdate == null)
                    {
                        return;
                    }
                    _updates.Add(newUpdate);
                });
            });

            _tim.Stop();
            dgUpdates.ItemsSource = _updates;
            dgUpdates.Update();
        }
示例#6
0
        private static void Main(string[] args)
        {
            Cleanup();

            try
            {
                Console.WindowHeight = 50;
            }
            catch
            {
            }

            if (args.Length == 0)
            {
                WriteText("No directory specified", ConsoleColor.Red);
                return;
            }

            var files    = new List <string>();
            var foundDir = new List <UpdateDirectory>();

            WriteText("Deleting [" + UpdateCache.CACHE_PATH_XML + "]...", ConsoleColor.Yellow);
            FileHandling.DeleteFile(UpdateCache.CACHE_PATH_XML);

            WriteText("Deleting [" + UpdateCache.CACHE_ERROR_XML + "]...", ConsoleColor.Yellow);
            FileHandling.DeleteFile(UpdateCache.CACHE_ERROR_XML);
            Console.WriteLine();

            foreach (var directory in args.AsParallel())
            {
                try
                {
                    if (!Directory.Exists(directory))
                    {
                        WriteText("Invalid directory [" + directory + "]", ConsoleColor.Red);
                        return;
                    }
                    WriteText("Searching [" + directory + "]...", ConsoleColor.Yellow);

                    var foundFiles = Directory.GetFileSystemEntries(directory, "*.*", SearchOption.AllDirectories)
                                     .Where(
                        f =>
                        Path.GetExtension(f)
                        .EndsWithIgnoreCase(".MSU", StringComparison.InvariantCultureIgnoreCase) ||
                        Path.GetExtension(f)
                        .EndsWithIgnoreCase(".CAB", StringComparison.InvariantCultureIgnoreCase))
                                     .ToArray();

                    lock (files)
                    {
                        var updDirectory = new UpdateDirectory
                        {
                            Path      = directory,
                            FileCount = foundFiles.Length
                        };

                        foundDir.Add(updDirectory);
                        files.AddRange(foundFiles);
                    }
                }
                catch (Exception Ex)
                {
                    Console.WriteLine(Ex.Message);
                    Console.ReadKey();
                }
            }


            Console.Title  = "Building Update Cache";
            Options.GetMD5 = true;
            WriteText("Found " + files.Count + " files.");

            WriteText("Loading Cache...");
            UpdateCache.Load();

            var i     = 1;
            var Cache = UpdateCache.Count;
            var total = files.Count;

            foreach (var update in files)
            {
                Console.Clear();
                var progress = ((float)i / total);
                WriteText("Building Cache " + i + " of " + total + " [" + progress.ToString("0.00%") + "]",
                          ConsoleColor.Cyan);
                Console.WriteLine();
                foreach (var updDirectory in foundDir)
                {
                    WriteText(" [" + updDirectory.Path + "] :: " + updDirectory.FileCount);
                }

                Console.WriteLine();
                WriteText("Cache: " + Cache);
                WriteText("Total: " + UpdateCache.Count + " | New: " +
                          (UpdateCache.Count - Cache - UpdateCache.UnknownCount));
                Console.WriteLine();

                WriteText("GDR: " + UpdateCache.GDRCount);
                WriteText("LDR: " + UpdateCache.LDRCount);
                WriteText("Unknown: " + UpdateCache.UnknownCount);
                Console.WriteLine();
                WriteText("----------------------------------------");
                Console.WriteLine();
                string cabFile;
                var    temp = Directories.Application + "\\Temp\\" + i;

                MsuUpdate msuItem = null;
                WriteText("Name: " + Path.GetFileName(update));
                WriteText("Size: " + FileHandling.GetSize(update, true));
                Console.WriteLine();
                if (update.EndsWithIgnoreCase("MSU", StringComparison.InvariantCultureIgnoreCase))
                {
                    WriteText("Checking MSU [" + update + "]");
                    if (UpdateCache.Find(Path.GetFileName(update), FileHandling.GetSize(update)) != null)
                    {
                        i++;
                        continue;
                    }

                    WriteText("Preparing MSU [" + update + "]");
                    msuItem = new MsuUpdate(update);

                    WriteText("Extracting CAB [" + update + "]");
                    Extraction.Expand(update, "*.cab", temp);

                    cabFile = Directory.GetFiles(temp, "*.cab", SearchOption.TopDirectoryOnly).FirstOrDefault();

                    if (cabFile == null)
                    {
                        msuItem.UpdateType = UpdateType.GDR;
                        UpdateCache.Add(msuItem);
                    }
                }
                else
                {
                    cabFile = update;
                }

                if (!string.IsNullOrWhiteSpace(cabFile))
                {
                    if (msuItem != null)
                    {
                        Console.WriteLine();
                    }

                    WriteText("Checking CAB [" + update + "]");
                    if (UpdateCache.Find(Path.GetFileName(cabFile), FileHandling.GetSize(cabFile)) == null)
                    {
                        WriteText("Preparing CAB [" + cabFile + "]");
                        var cabItem = new CabUpdate(cabFile);

                        WriteText("Extracting CAB Files [" + cabFile + "]");
                        Extraction.Expand(cabFile, "update-bf.mum", temp);

                        cabItem.UpdateType = UpdateType.GDR;

                        if (File.Exists(temp + "\\update-bf.mum"))
                        {
                            cabItem.UpdateType = UpdateType.LDR;
                        }
                        Console.WriteLine();
                        WriteText("Update is " + cabItem.UpdateType, ConsoleColor.Green);
                        UpdateCache.Add(cabItem);
                        if (msuItem != null)
                        {
                            msuItem.UpdateType = cabItem.UpdateType;
                            UpdateCache.Add(msuItem);
                        }
                    }
                }

                FileHandling.DeleteDirectory(temp);
                i++;
            }
            Cleanup();

            Console.WriteLine();
            WriteText("Build complete. Press any key to close.", ConsoleColor.Green);
            Console.ReadKey();
        }
示例#7
0
        private void AddList(IEnumerable <string> fileList)
        {
            foreach (
                var myClass in
                fileList.Where(
                    myClass =>
                    _conversionList.Any(c => c.Location.EqualsIgnoreCase(myClass)) ||
                    _conversionList.Any(c => c.Name.EqualsIgnoreCase(Path.GetFileNameWithoutExtension(myClass))))
                )
            {
                fileList = fileList.Where(u => u.EqualsIgnoreCase(myClass)).ToList();
            }


            var getMD5 = chkGetMD5.IsChecked == true;

            Parallel.ForEach(fileList,
                             new ParallelOptions {
                MaxDegreeOfParallelism = Options.MaxThreads
            },
                             currentFile =>
            {
                if (currentFile.EndsWithIgnoreCase(".MSU"))
                {
                    var newItem = new MsuUpdate(currentFile);
                    lock (_conversionList)
                    {
                        _conversionList.Add(newItem);
                    }
                    return;
                }

                if (Office.ValidOfficeFile(currentFile))
                {
                    var newItem = new Office(currentFile);
                    lock (_conversionList)
                    {
                        _conversionList.Add(newItem);
                    }
                    return;
                }

                if (LangPack.IsValidLangPack(currentFile))
                {
                    var newItem = new LangPack(currentFile);
                    lock (_conversionList)
                    {
                        _conversionList.Add(newItem);
                    }
                }
            });


            _conversionList = _conversionList.GroupBy(x => x.Name.ToLowerInvariant()).Select(x => x.First()).ToList();

            //Updates status
            dgUpdates.ItemsSource = _conversionList;
            lblStatus.Text        = _conversionList.Count + " " + Localization.GetString("Global", 54);

            dgUpdates.Update();
        }