Exemplo n.º 1
0
        public ActionResult <IEnumerable <InstalledPackage> > RunMigrations([FromQuery] string packageName)
        {
            try
            {
                _packageMigrationRunner.RunPackageMigrationsIfPending(packageName);
                return(_packagingService.GetAllInstalledPackages().ToList());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Package migration failed on package {Package}", packageName);

                return(ValidationErrorResult.CreateNotificationValidationErrorResult(
                           $"Package migration failed on package {packageName} with error: {ex.Message}. Check log for full details."));
            }
        }
Exemplo n.º 2
0
        public override bool RequiresExecution(Guid?model)
        {
            //Don't execute if it's an empty GUID - meaning the user has chosen not to install one
            if (model.HasValue && model.Value == Guid.Empty)
            {
                return(false);
            }

            //Don't continue if there's already packages installed
            if (_packageService.GetAllInstalledPackages().Any())
            {
                return(false);
            }

            if (_contentService.GetRootContent().Any())
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        private bool IsPackageVersionAlreadyInstalled(string name, string version, out bool sameVersion, out int packageId)
        {
            var allInstalled = _packagingService.GetAllInstalledPackages();
            var found        = allInstalled.Where(x => x.Name == name).ToArray();

            sameVersion = false;

            if (found.Length > 0)
            {
                var foundVersion = found.FirstOrDefault(x =>
                {
                    //match the exact version
                    if (x.Version == version)
                    {
                        return(true);
                    }
                    //now try to compare the versions
                    if (Version.TryParse(x.Version, out Version installed) && Version.TryParse(version, out Version selected))
                    {
                        if (installed >= selected)
                        {
                            return(true);
                        }
                    }
                    return(false);
                });

                sameVersion = foundVersion != null;

                //this package is already installed, find the highest package id for this package name that is installed
                packageId = found.Max(x => x.Id);
                return(true);
            }

            packageId = -1;
            return(false);
        }