Exemplo n.º 1
0
 public void Uninstall(PackageKey pck)
 {
     if (InstalledPackages.Contains(pck))
     {
         InstalledPackages.Remove(pck);
     }
 }
Exemplo n.º 2
0
        public async Task GetDependencies(HashSet <int> dependecies, HashSet <int> returnDependencies)
        {
            foreach (int depPackageId in dependecies)
            {
                if (!returnDependencies.Contains(depPackageId) && !InstalledPackages.Any(x => x.PackageId == depPackageId))
                {
                    Package dependencyPackage = CachedPackages.FirstOrDefault(x => x.PackageId == depPackageId);
                    if (dependencyPackage == default)
                    {
                        dependencyPackage = await WebWrapper.GetPackage(depPackageId);

                        lock (CachedPackages)
                        {
                            CachedPackages.Add(dependencyPackage);
                        }
                    }

                    if (!dependencyPackage.IsPaid)
                    {
                        returnDependencies.Add(depPackageId);
                    }

                    await GetDependencies(dependencyPackage.Dependencies.ToHashSet(), returnDependencies);
                }
            }
        }
Exemplo n.º 3
0
        private static void DownloadPackages(ILogger logger, Arguments arguments)
        {
            var obsoleteFolders = new string[] { Path.Combine(Paths.RhetosServerRootPath, "DslScripts"), Path.Combine(Paths.RhetosServerRootPath, "DataMigration") };
            var obsoleteFolder  = obsoleteFolders.FirstOrDefault(folder => Directory.Exists(folder));

            if (obsoleteFolder != null)
            {
                throw new UserException("Backup all Rhetos server folders and delete obsolete folder '" + obsoleteFolder + "'. It is no longer used.");
            }

            if (!arguments.DeployDatabaseOnly)
            {
                logger.Trace("Getting packages.");
                var config = new DeploymentConfiguration(DeploymentUtility.InitializationLogProvider);
                var packageDownloaderOptions = new PackageDownloaderOptions {
                    IgnorePackageDependencies = arguments.IgnorePackageDependencies
                };
                var packageDownloader = new PackageDownloader(config, DeploymentUtility.InitializationLogProvider, packageDownloaderOptions);
                var packages          = packageDownloader.GetPackages();

                InstalledPackages.Save(packages);
            }
            else
            {
                logger.Info("Skipped download packages (DeployDatabaseOnly).");
            }
        }
Exemplo n.º 4
0
        public void Execute(string[] args)
        {
            if (args.Contains("--local"))
            {
                var current_dir = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar;
                var installed   = InstalledPackages.Deserialize(current_dir);

                Console.WriteLine($"{installed.Packages.Count} packages found.");
                foreach (var package in installed.Packages)
                {
                    Console.WriteLine($"- {package.Key}");
                }
            }
            else
            {
                var finder = new PackageFinder();
                var list   = finder.FindAll();

                Console.WriteLine($"{list.Count} packages found.");
                foreach (var name in list)
                {
                    Console.WriteLine($"- {name}");
                }
            }
        }
            public override Task <ProjectPackages> GetInstalledAndTransitivePackagesAsync(CancellationToken token)
            {
                var transitivePackages = TransitivePackages.Select(p => new TransitivePackageReference(p));

                var projectPackages = new ProjectPackages(InstalledPackages.ToList(), transitivePackages.ToList());

                return(Task.FromResult(projectPackages));
            }
 /// <param name="pluginAssemblies">List of assemblies (DLL file paths) that will be scanned for plugins.</param>
 public ApplicationBuild(IConfiguration configuration, ILogProvider logProvider, IEnumerable <string> pluginAssemblies, InstalledPackages installedPackages)
 {
     _logger            = logProvider.GetLogger(GetType().Name);
     _configuration     = configuration;
     _logProvider       = logProvider;
     _pluginAssemblies  = pluginAssemblies;
     _installedPackages = installedPackages;
 }
Exemplo n.º 7
0
        public void RemovePackage(int pkgId)
        {
            InstalledPackages.RemoveAll(x => x.PackageId == pkgId);
            List <string> removedFiles = Utils.RemoveFiles(SqLiteAdapter.LoadPackageFiles(pkgId));

            SqLiteAdapter.RemovePackageFiles(removedFiles);
            SqLiteAdapter.RemoveInstalledPackage(pkgId);
            SqLiteAdapter.FlushToFile(true);
        }
Exemplo n.º 8
0
        private async Task LoadInstalledSmartInkPackagesAsync()
        {
            InstalledPackages.Clear();
            _packages = await _packageManager.GetInstalledPackagesAsync();

            foreach (var package in _packages)
            {
                InstalledPackages.Add(package);
            }
        }
Exemplo n.º 9
0
 protected override async Task OkAsync()
 {
     if (InstalledPackages.Count > 0)
     {
         await InstalledPackages.Select(p => NugetHelper.EnsurePackageInstalled(p.Name, NuGetVersion.Parse(p.Version)))
         .WhenAll()
         .ConfigureAwait(false)
         ;
     }
     await base.OkAsync();
 }
Exemplo n.º 10
0
        public void Install(PackageKey pck)
        {
            PackageKey installedPackage = InstalledPackages.FirstOrDefault(k => k.LooseEquals(pck));

            if (installedPackage != null)
            {
                InstalledPackages.Remove(installedPackage);
            }

            InstalledPackages.Add(pck);
        }
Exemplo n.º 11
0
        public async Task <List <int> > FindFile(string file_name, bool withDeps = true)
        {
            Package package = InstalledPackages.FirstOrDefault(x => x.FilesContained.Contains(file_name));

            if (package != default)
            {
                return new List <int>()
                       {
                           package.PackageId
                       }
            }
            ;

            lock (CachedPackages)
                package = CachedPackages.FirstOrDefault(x => x.FilesContained.Contains(file_name));

            if (package != default)
            {
                return new List <int>()
                       {
                           package.PackageId
                       }
            }
            ;

            Package onlinePackage = await WebWrapper.SearchForFile(file_name);

            if (onlinePackage != null && onlinePackage.PackageId > 0)
            {
                lock (CachedPackages)
                {
                    if (!CachedPackages.Any(x => x.PackageId == onlinePackage.PackageId))
                    {
                        CachedPackages.Add(onlinePackage);
                    }
                }

                HashSet <int> dependencyPkgIds = new HashSet <int>();

                if (withDeps)
                {
                    await GetDependencies(new HashSet <int>() { onlinePackage.PackageId }, dependencyPkgIds);
                }

                return(new List <int>()
                {
                    onlinePackage.PackageId
                }.Union(dependencyPkgIds).ToList());
            }

            return(new List <int>());
        }
Exemplo n.º 12
0
        private void HandleRemovePackageComplete(Action action)
        {
            var package = (AvailablePackage)action.Payload;

            IsWorking.SetValue(false);
            Operation.SetValue(null);

            var installedPackages = InstalledPackages.Value;

            installedPackages.Packages.RemoveAll(p => p.Name == package.Name);
            InstalledPackages.SetValue(installedPackages);

            WritePackagesJson();
        }
Exemplo n.º 13
0
        private void HandlePackageInstallationComplete(Action action)
        {
            var args = (InstallPackageArgs)action.Payload;

            var installedPackages = InstalledPackages.Value;

            installedPackages.Packages.Add(new InstalledPackage(args.PackageName, args.Version, args.GitUrl));

            InstalledPackages.SetValue(installedPackages);
            IsWorking.SetValue(false);
            Operation.SetValue(null);

            WritePackagesJson();
        }
Exemplo n.º 14
0
        private static void DownloadPackages(ILogger logger, DeployArguments arguments)
        {
            if (!arguments.DeployDatabaseOnly)
            {
                logger.Trace("Getting packages.");
                var config = new DeploymentConfiguration(DeploymentUtility.InitializationLogProvider);
                var packageDownloaderOptions = new PackageDownloaderOptions { IgnorePackageDependencies = arguments.IgnorePackageDependencies };
                var packageDownloader = new PackageDownloader(config, DeploymentUtility.InitializationLogProvider, packageDownloaderOptions);
                var packages = packageDownloader.GetPackages();

                InstalledPackages.Save(packages);
            }
            else
                logger.Info("Skipped download packages (DeployDatabaseOnly).");
        }
Exemplo n.º 15
0
        private void HandleSwitchPackageVersionComplete(Action action)
        {
            var args = (SwitchPackageArgs)action.Payload;

            var installedPackages = InstalledPackages.Value;
            var package           = installedPackages.Packages.FirstOrDefault(p => p.Name == args.Package.Name);

            package.Version = args.Version;

            InstalledPackages.SetValue(installedPackages);

            WritePackagesJson();

            IsWorking.SetValue(false);
            Operation.SetValue(null);
        }
Exemplo n.º 16
0
        public void CheckUpdates()
        {
            Task.Run(async() =>
            {
                Dictionary <int, int> pkgsToUpdate = new Dictionary <int, int>();
                List <int> packagesId = InstalledPackages.Select(x => x.PackageId).ToList();
                Dictionary <int, int> serverVersions = await WebWrapper.GetVersions(packagesId);
                if (serverVersions.Count == 0)
                {
                    return;
                }

                foreach (Package package in InstalledPackages)
                {
                    if (serverVersions.ContainsKey(package.PackageId) && package.Version < serverVersions[package.PackageId])
                    {
                        Task <ContentDialogResult> t = null;
                        MainWindow.Dispatcher.Invoke(() =>
                        {
                            MainWindow.ContentDialog.Title               = "Newer package found!";
                            MainWindow.ContentDialog.Content             = string.Format("Newer version of following package was found on server:\n{0}\nDo you want to update it?", package.DisplayName);
                            MainWindow.ContentDialog.PrimaryButtonText   = "Yes, update";
                            MainWindow.ContentDialog.SecondaryButtonText = "No, keep local";
                            MainWindow.ContentDialog.Owner               = MainWindow;
                            t = MainWindow.ContentDialog.ShowAsync();
                        });

                        ContentDialogResult result = await t;
                        if (result == ContentDialogResult.Primary)
                        {
                            pkgsToUpdate[package.PackageId] = serverVersions[package.PackageId];
                        }
                    }
                }

                if (await CheckLogin(1) < 0 || pkgsToUpdate.Count == 0 || App.IsDownloading)
                {
                    return;
                }

                App.IsDownloading = true;
                MainWindow.Dispatcher.Invoke(() => { MainWindow.DownloadDialog.ShowAsync(); }); // TODO: Check if works
                MainWindow.DownloadDialog.UpdatePackages(pkgsToUpdate, InstalledPackages, WebWrapper, SqLiteAdapter).Wait();
                App.IsDownloading = false;
                MainWindow.RW_CrawlingComplete();
            });
        }
Exemplo n.º 17
0
        private void UpdateInstalledVersion()
        {
            var installed = InstalledPackages.Where(p =>
                                                    StringComparer.OrdinalIgnoreCase.Equals(p.Id, Id)).OrderByDescending(p => p.Version, VersionComparer.Default);

            if (installed.Any())
            {
                InstalledVersion = string.Format(
                    CultureInfo.CurrentCulture,
                    Resources.Text_InstalledVersion,
                    installed.First().Version.ToNormalizedString());
            }
            else
            {
                InstalledVersion = null;
            }
        }
Exemplo n.º 18
0
        public void Execute(string[] args)
        {
            var isLocal = false;

            if (args.Contains("--local"))
            {
                isLocal = true;
                args    = args.Where(arg => arg != "--local")
                          .ToArray();
            }

            if (args.Length < 1)
            {
                LogTracer.LogError("[ERROR] The command, \"plpm check\" requires 1 arg.");
                return;
            }

            var package_name = args[0];

            if (isLocal)
            {
                var current_dir = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar;
                var installed   = InstalledPackages.Deserialize(current_dir);
                var packageID   = installed.Packages.FirstOrDefault(pkg => pkg.Key == package_name).Value;
                var is_latest   = PackageInfo.LoadInfo(package_name).Identification == packageID;

                Console.WriteLine($"Package name : {package_name}");
                Console.WriteLine($"Package ID : {packageID}");
                Console.WriteLine($"Is latest : {is_latest}");
            }
            else
            {
                var info = PackageInfo.LoadInfo(package_name);

                Console.WriteLine($"Package name : {package_name}");
                Console.WriteLine($"Package ID : {info.Identification}");
                Console.WriteLine($"Description : {info.Description}");
                Console.WriteLine($"Files : |");
                foreach (var file in info.Files)
                {
                    Console.WriteLine($"- {file}");
                }
            }
        }
        private string GenerateDataMigrationScriptsAssetsFile(string[] files)
        {
            var contentFiles = files.Select(file => new ContentFile {
                PhysicalPath = $@"TestScripts\{file}", InPackagePath = $@"DataMigration\{file}"
            }).ToList();
            var installedPackages = new InstalledPackages
            {
                Packages = new List <InstalledPackage>
                {
                    new InstalledPackage("TestPackage", null, null, null, null, null, contentFiles)
                }
            };
            var filesUtility             = new FilesUtility(new ConsoleLogProvider());
            var dataMigrationScriptsFile = new DataMigrationScriptsFileMock();
            var dmsGenerator             = new DataMigrationScriptsGenerator(installedPackages, filesUtility, dataMigrationScriptsFile);

            dmsGenerator.Generate();
            return(TestUtility.Dump(dataMigrationScriptsFile.DataMigrationScripts.Scripts,
                                    s => $"{Path.GetFileName(s.Path)}:{RemoveHeader(s.Content)}/{RemoveHeader(s.Down)}"));
        }
Exemplo n.º 20
0
        private void ServePackagesToUninstall()
        {
            GlobalProgressMessage = string.Format("Removing packages...");

            var packagesToUnisntall = KoinoniaSettings.PackagesToUninstall
                                      .Where(id => InstalledPackages.FirstOrDefault(p => p.Id == id) != null)
                                      .Select(id => InstalledPackages.FirstOrDefault(p => p.Id == id)).ToArray();

            foreach (var package in packagesToUnisntall)
            {
                package.Uninstall();
            }

            KoinoniaSettings.PackagesToUninstall.Clear();
            Settings.Commit();

            foreach (var package in packagesToUnisntall)
            {
                DeletePackageFiles(package);
            }

            ThreadingUtils.DispatchOnMainThread(AssetDatabase.Refresh);
        }
Exemplo n.º 21
0
        public async Task <HashSet <string> > GetDownloadableDependencies(HashSet <string> globalDependencies, HashSet <string> existing, MainWindow mw)
        {
            InstalledPackages = SqLiteAdapter.LoadInstalledPackages();

            HashSet <string> allDownloadableDeps = await WebWrapper.QueryArray("listFiles");

            HashSet <string> conflictDeps = existing.Intersect(allDownloadableDeps).Except(InstalledPackages.SelectMany(x => x.FilesContained)).ToHashSet();

            HashSet <int> conflictPackages = new HashSet <int>();

            int maxThreads = Math.Min(Environment.ProcessorCount, conflictDeps.Count);

            Parallel.For(0, maxThreads, workerId =>
            {
                Task.Run(async() =>
                {
                    int max = conflictDeps.Count * (workerId + 1) / maxThreads;
                    for (int i = conflictDeps.Count * workerId / maxThreads; i < max; i++)
                    {
                        List <int> packages = await FindFile(conflictDeps.ElementAt(i), false);

                        Trace.Assert(packages.Count > 0, $"FindFile for {conflictDeps.ElementAt(i)} returned no packages!");

                        if (packages.Count > 0)
                        {
                            int id = packages.First();
                            lock (conflictPackages)
                            {
                                if (conflictPackages.Contains(id))
                                {
                                    continue;
                                }

                                conflictPackages.Add(id);
                            }
                        }
                    }
                }).Wait();
            });

            bool rewriteAll = false;
            bool keepAll    = false;

            for (int i = 0; i < conflictPackages.Count; i++)
            {
                int id = conflictPackages.ElementAt(i);

                if (Settings.Default.IgnoredPackages?.Contains(id) == true)
                {
                    continue;
                }

                Package p = CachedPackages.FirstOrDefault(x => x.PackageId == id);

                bool rewrite = false;
                if (!rewriteAll && !keepAll)
                {
                    Task <ContentDialogResult> t = null;
                    mw.Dispatcher.Invoke(() =>
                    {
                        MainWindow.ContentDialog = new ConflictPackageDialog(p.DisplayName);
                        t = MainWindow.ContentDialog.ShowAsync();
                    });

                    ContentDialogResult result = await t;

                    ConflictPackageDialog dlg = (ConflictPackageDialog)MainWindow.ContentDialog;

                    rewrite    = dlg.RewriteLocal;
                    rewriteAll = dlg.RewriteAll;
                    keepAll    = dlg.KeepAll;
                }

                if (rewrite || rewriteAll)
                {
                    PkgsToDownload.Add(id);
                    HashSet <int> depsPkgs = new HashSet <int>();
                    await GetDependencies(new HashSet <int>() { id }, depsPkgs);

                    PkgsToDownload.UnionWith(depsPkgs);
                }
                else
                {
                    if (Settings.Default.IgnoredPackages == null)
                    {
                        Settings.Default.IgnoredPackages = new List <int>();
                    }

                    Settings.Default.IgnoredPackages.Add(id);
                    Settings.Default.Save();
                }
            }

            CheckUpdates();

            DownloadableDeps = allDownloadableDeps.Intersect(globalDependencies).ToHashSet();
            return(DownloadableDeps);
        }
Exemplo n.º 22
0
        public async Task ReceiveMSMQ()
        {
            string           queueFile  = Path.Combine(Path.GetTempPath(), "DLS.queue");
            HashSet <string> queuedPkgs = File.Exists(queueFile) ? File.ReadAllText(queueFile).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToHashSet() : new HashSet <string>();

            if (queuedPkgs.Count > 0)
            {
                MainWindow.Dispatcher.Invoke(() => { MainWindow.Activate(); });
                if (!await Utils.CheckLogin(async delegate
                {
                    await ReceiveMSMQ();
                    MSMQRunning = false;
                }, MainWindow, ApiUrl) || App.IsDownloading)
                {
                    //File.WriteAllText(queueFile, string.Empty);
                    return;
                }

                int idToDownload = Convert.ToInt32(queuedPkgs.PopOne());

                if (!InstalledPackages.Exists(x => x.PackageId == idToDownload))
                {
                    Task.Run(async() =>
                    {
                        Package packageToDownload = await WebWrapper.GetPackage(idToDownload);
                        lock (CachedPackages)
                        {
                            if (!CachedPackages.Any(x => x.PackageId == packageToDownload.PackageId))
                            {
                                CachedPackages.Add(packageToDownload);
                            }
                        }

                        if (packageToDownload.IsPaid)
                        {
                            App.Window.Dispatcher.Invoke(() =>
                            {
                                MainWindow.ErrorDialog = new ContentDialog()
                                {
                                    Title               = Localization.Strings.CantDownload,
                                    Content             = Localization.Strings.PaidPackageFail,
                                    SecondaryButtonText = Localization.Strings.Ok,
                                    Owner               = App.Window
                                };

                                MainWindow.ErrorDialog.ShowAsync();
                            });

                            return;
                        }

                        HashSet <int> depsPkgs = new HashSet <int>();
                        await GetDependencies(new HashSet <int>()
                        {
                            packageToDownload.PackageId
                        }, depsPkgs);
                        HashSet <int> packageIds = new HashSet <int>()
                        {
                            packageToDownload.PackageId
                        }.Union(depsPkgs).ToHashSet();

                        if (packageIds.Count > 0)
                        {
                            App.IsDownloading = true;
                            MainWindow.Dispatcher.Invoke(() => { MainWindow.DownloadDialog.ShowAsync(); });
                            await MainWindow.DownloadDialog.DownloadPackages(packageIds, CachedPackages, InstalledPackages, WebWrapper, SqLiteAdapter);
                            App.IsDownloading = false;
                        }
                        else
                        {
                            new Task(() =>
                            {
                                App.Window.Dispatcher.Invoke(() =>
                                {
                                    MainWindow.ErrorDialog = new ContentDialog()
                                    {
                                        Title               = Localization.Strings.CantDownload,
                                        Content             = Localization.Strings.InstalFail,
                                        SecondaryButtonText = Localization.Strings.Ok,
                                        Owner               = App.Window
                                    };

                                    MainWindow.ErrorDialog.ShowAsync();
                                });
                            }).Start();
                        }
                    }).Wait();
                }
                else
                {
                    App.Window.Dispatcher.Invoke(() =>
                    {
                        MainWindow.ErrorDialog = new ContentDialog()
                        {
                            Title               = Localization.Strings.CantDownload,
                            Content             = Localization.Strings.AlreadyInstalFail,
                            SecondaryButtonText = Localization.Strings.Ok,
                            Owner               = App.Window
                        };

                        MainWindow.ErrorDialog.ShowAsync();
                    });
                }

                File.WriteAllText(queueFile, string.Join(",", queuedPkgs));
                await ReceiveMSMQ();
            }
        }
Exemplo n.º 23
0
 private List <DslScript> LoadScripts(InstalledPackages installedPackages)
 {
     return(installedPackages.Packages.SelectMany(LoadPackageScripts).ToList());
 }
Exemplo n.º 24
0
 public DiskDslScriptLoader(InstalledPackages installedPackages, FilesUtility filesUtility)
 {
     _scripts      = new Lazy <List <DslScript> >(() => LoadScripts(installedPackages));
     _filesUtility = filesUtility;
 }
Exemplo n.º 25
0
        public async Task ReceiveMSMQ()
        {
            string           queueFile  = Path.Combine(Path.GetTempPath(), "DLS.queue");
            HashSet <string> queuedPkgs = File.Exists(queueFile) ? File.ReadAllText(queueFile).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToHashSet() : new HashSet <string>();

            if (queuedPkgs.Count > 0)
            {
                MainWindow.Dispatcher.Invoke(() => { MainWindow.Activate(); });
                if (await CheckLogin(1) < 0 || App.IsDownloading)
                {
                    File.WriteAllText(queueFile, string.Empty);
                    return;
                }

                int idToDownload = Convert.ToInt32(queuedPkgs.PopOne());

                if (!InstalledPackages.Exists(x => x.PackageId == idToDownload))
                {
                    Task.Run(async() =>
                    {
                        Package packageToDownload = await WebWrapper.GetPackage(idToDownload);
                        lock (CachedPackages)
                        {
                            if (!CachedPackages.Any(x => x.PackageId == packageToDownload.PackageId))
                            {
                                CachedPackages.Add(packageToDownload);
                            }
                        }

                        if (packageToDownload.IsPaid)
                        {
                            App.Window.Dispatcher.Invoke(() =>
                            {
                                MainWindow.ErrorDialog = new ContentDialog()
                                {
                                    Title               = "Cannot download package",
                                    Content             = "This is paid package. Paid packages cannot be downloaded through this app.",
                                    SecondaryButtonText = "OK",
                                    Owner               = App.Window
                                };

                                MainWindow.ErrorDialog.ShowAsync();
                            });

                            return;
                        }

                        HashSet <int> depsPkgs = new HashSet <int>();
                        await GetDependencies(new HashSet <int>()
                        {
                            packageToDownload.PackageId
                        }, depsPkgs);
                        HashSet <int> packageIds = new HashSet <int>()
                        {
                            packageToDownload.PackageId
                        }.Union(depsPkgs).ToHashSet();

                        if (packageIds.Count > 0)
                        {
                            App.IsDownloading = true;
                            MainWindow.Dispatcher.Invoke(() => { MainWindow.DownloadDialog.ShowAsync(); });
                            await MainWindow.DownloadDialog.DownloadPackages(packageIds, CachedPackages, InstalledPackages, WebWrapper, SqLiteAdapter);
                            App.IsDownloading = false;
                        }
                        else
                        {
                            new Task(() =>
                            {
                                App.Window.Dispatcher.Invoke(() =>
                                {
                                    MainWindow.ErrorDialog = new ContentDialog()
                                    {
                                        Title               = "Cannot download packages",
                                        Content             = "An error ocured when trying to install package.",
                                        SecondaryButtonText = "OK",
                                        Owner               = App.Window
                                    };

                                    MainWindow.ErrorDialog.ShowAsync();
                                });
                            }).Start();
                        }
                    }).Wait();
                }
                else
                {
                    App.Window.Dispatcher.Invoke(() =>
                    {
                        MainWindow.ErrorDialog = new ContentDialog()
                        {
                            Title               = "Cannot download package",
                            Content             = "This package is already downloaded.",
                            SecondaryButtonText = "OK",
                            Owner               = App.Window
                        };

                        MainWindow.ErrorDialog.ShowAsync();
                    });
                }

                File.WriteAllText(queueFile, string.Join(",", queuedPkgs));
                await ReceiveMSMQ();
            }
        }
Exemplo n.º 26
0
 private void HandleReadPackagesJson(Action action)
 {
     InstalledPackages.SetValue((InstalledPackageList)action.Payload);
 }
Exemplo n.º 27
0
 protected override bool CanDowngrade()
 {
     return(InstalledPackages.Any(i =>
                                  StringComparer.OrdinalIgnoreCase.Equals(i.Id, Id) &&
                                  i.Version > _allPackages.Min()));
 }
Exemplo n.º 28
0
        protected override void CreateVersions()
        {
            _versions = new List <VersionForDisplay>();
            var installedVersion = InstalledPackages.Where(p =>
                                                           StringComparer.OrdinalIgnoreCase.Equals(p.Id, Id)).SingleOrDefault();

            var allVersions         = _allPackages.OrderByDescending(v => v);
            var latestPrerelease    = allVersions.FirstOrDefault(v => v.IsPrerelease);
            var latestStableVersion = allVersions.FirstOrDefault(v => !v.IsPrerelease);

            if (SelectedAction == Resources.Action_Uninstall)
            {
                _versions.Add(new VersionForDisplay(installedVersion.Version, string.Empty));
            }
            else if (SelectedAction == Resources.Action_Install)
            {
                if (latestPrerelease != null && (latestStableVersion == null || latestPrerelease > latestStableVersion))
                {
                    _versions.Add(new VersionForDisplay(latestPrerelease, Resources.Version_LatestPrerelease));
                }

                if (latestStableVersion != null)
                {
                    _versions.Add(new VersionForDisplay(latestStableVersion, Resources.Version_LatestStable));
                }

                // add a separator
                if (_versions.Count > 0)
                {
                    _versions.Add(null);
                }

                foreach (var version in allVersions)
                {
                    _versions.Add(new VersionForDisplay(version, string.Empty));
                }
            }
            else if (SelectedAction == Resources.Action_Upgrade)
            {
                if (latestStableVersion != null &&
                    latestStableVersion != installedVersion.Version)
                {
                    _versions.Add(new VersionForDisplay(latestStableVersion, Resources.Version_LatestStable));

                    // add a separator
                    _versions.Add(null);
                }

                foreach (var version in allVersions.Where(v => v > installedVersion.Version))
                {
                    _versions.Add(new VersionForDisplay(version, string.Empty));
                }
            }
            else if (SelectedAction == Resources.Action_Downgrade)
            {
                foreach (var version in allVersions.Where(v => v < installedVersion.Version))
                {
                    _versions.Add(new VersionForDisplay(version, string.Empty));
                }
            }
            else
            {
                Debug.Fail("Unexpected Action: " + SelectedAction.ToString());
            }

            SelectVersion();

            OnPropertyChanged("Versions");
        }
Exemplo n.º 29
0
 public DataMigrationScriptsGeneratorAccessor(InstalledPackages installedPackages, FilesUtility filesUtility, IDataMigrationScriptsFile dataMigrationScriptsFile) : base(installedPackages, filesUtility, dataMigrationScriptsFile)
 {
 }
Exemplo n.º 30
0
        public async Task ResolveConflicts()
        {
            HashSet <string> conflictDeps = MainWindow.RW.AllInstalledDeps.Intersect(DownloadableDeps).Except(InstalledPackages.SelectMany(x => x.FilesContained)).ToHashSet();

            HashSet <int> conflictPackages = new HashSet <int>();

            while (conflictDeps.Count > 0)
            {
                Package pkg = CachedPackages.First(x => x.FilesContained.Contains(conflictDeps.First()));
                conflictPackages.Add(pkg.PackageId);
                conflictDeps.ExceptWith(pkg.FilesContained);
            }

            //HashSet<int> conflictPackages = conflictPkgs.Select(x => x.PackageId).ToHashSet();

            bool rewriteAll = false;
            bool keepAll    = false;

            for (int i = 0; i < conflictPackages.Count; i++)
            {
                int id = conflictPackages.ElementAt(i);

                if (Settings.Default.IgnoredPackages?.Contains(id) == true)
                {
                    continue;
                }

                Package p = CachedPackages.FirstOrDefault(x => x.PackageId == id);

                bool rewrite = false;
                if (!rewriteAll && !keepAll)
                {
                    Task <ContentDialogResult> t = null;
                    MainWindow.Dispatcher.Invoke(() =>
                    {
                        MainWindow.ContentDialog = new ConflictPackageDialog(p.DisplayName);
                        t = MainWindow.ContentDialog.ShowAsync();
                    });

                    ContentDialogResult result = await t;

                    ConflictPackageDialog dlg = (ConflictPackageDialog)MainWindow.ContentDialog;

                    rewrite    = dlg.RewriteLocal;
                    rewriteAll = dlg.RewriteAll;
                    keepAll    = dlg.KeepAll;
                }

                if (rewrite || rewriteAll)
                {
                    PkgsToDownload.Add(id);
                    HashSet <int> depsPkgs = new HashSet <int>();
                    await GetDependencies(new HashSet <int>() { id }, depsPkgs);

                    PkgsToDownload.UnionWith(depsPkgs);
                }
                else
                {
                    if (Settings.Default.IgnoredPackages == null)
                    {
                        Settings.Default.IgnoredPackages = new List <int>();
                    }

                    Settings.Default.IgnoredPackages.Add(id);
                    Settings.Default.Save();
                }
            }
        }