Esempio n. 1
0
        /// <summary>
        /// Gets the available plugin updates.
        /// </summary>
        /// <param name="applicationVersion">The current server version.</param>
        /// <param name="withAutoUpdateEnabled">if set to <c>true</c> [with auto update enabled].</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task{IEnumerable{PackageVersionInfo}}.</returns>
        public async Task <IEnumerable <PackageVersionInfo> > GetAvailablePluginUpdates(Version applicationVersion, bool withAutoUpdateEnabled, CancellationToken cancellationToken)
        {
            var catalog = await GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false);

            var plugins = _applicationHost.Plugins.ToList();

            if (withAutoUpdateEnabled)
            {
                plugins = plugins
                          .Where(p => _config.CommonConfiguration.EnableAutoUpdate)
                          .ToList();
            }

            var systemUpdateLevel = GetSystemUpdateLevel();

            // Figure out what needs to be installed
            var packages = plugins.Select(p =>
            {
                var latestPluginInfo = GetLatestCompatibleVersion(catalog, p.Name, p.Id.ToString(), applicationVersion, systemUpdateLevel);

                return(latestPluginInfo != null && GetPackageVersion(latestPluginInfo) > p.Version ? latestPluginInfo : null);
            }).Where(i => i != null).ToList();

            return(packages
                   .Where(p => !string.IsNullOrWhiteSpace(p.sourceUrl) && !CompletedInstallations.Any(i => string.Equals(i.AssemblyGuid, p.guid, StringComparison.OrdinalIgnoreCase))));
        }
        protected IEnumerable <PackageVersionInfo> FilterCatalog(IEnumerable <PackageInfo> catalog, bool withAutoUpdateEnabled)
        {
            var plugins = ApplicationHost.Plugins;

            if (withAutoUpdateEnabled)
            {
                plugins = plugins.Where(p => p.Configuration.EnableAutoUpdate);
            }

            // Figure out what needs to be installed
            return(plugins.Select(p =>
            {
                var latestPluginInfo = GetLatestCompatibleVersion(catalog, p.Name, p.Configuration.UpdateClass);

                return latestPluginInfo != null && latestPluginInfo.version > p.Version ? latestPluginInfo : null;
            }).Where(p => !CompletedInstallations.Any(i => string.Equals(i.Name, p.name, StringComparison.OrdinalIgnoreCase)))
                   .Where(p => p != null && !string.IsNullOrWhiteSpace(p.sourceUrl)));
        }
        /// <summary>
        /// Gets the available plugin updates.
        /// </summary>
        /// <param name="withAutoUpdateEnabled">if set to <c>true</c> [with auto update enabled].</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>Task{IEnumerable{PackageVersionInfo}}.</returns>
        public async Task <IEnumerable <PackageVersionInfo> > GetAvailablePluginUpdates(bool withAutoUpdateEnabled, CancellationToken cancellationToken)
        {
            var catalog = await GetAvailablePackages(cancellationToken).ConfigureAwait(false);

            var plugins = ApplicationHost.Plugins;

            if (withAutoUpdateEnabled)
            {
                plugins = plugins.Where(p => p.Configuration.EnableAutoUpdate);
            }

            // Figure out what needs to be installed
            return(plugins.Select(p =>
            {
                var latestPluginInfo = GetLatestCompatibleVersion(catalog, p.Name, p.Configuration.UpdateClass);

                return latestPluginInfo != null && latestPluginInfo.version > p.Version ? latestPluginInfo : null;
            }).Where(p => !CompletedInstallations.Any(i => i.Name.Equals(p.name, StringComparison.OrdinalIgnoreCase)))
                   .Where(p => p != null && !string.IsNullOrWhiteSpace(p.sourceUrl)));
        }