/// <summary>
        /// Initializes a new instance of the <see cref="RegisteredPackagesPollingClient" /> class.
        /// </summary>
        /// <param name="globalSettingsService">The global settings service.</param>
        /// <param name="packageService">The package service.</param>
        /// <param name="pollingClients">The polling clients.</param>
        /// <param name="releasePollingClientFactory">The release polling client factory.</param>
        public RegisteredPackagesPollingClient(
            Services.IGlobalSettingsService globalSettingsService,
            Services.IPackageService packageService,
            PollingClientCollection pollingClients,
            ReleasesPollingClient.Factory releasePollingClientFactory
            )
        {
            _globalSettingsService = globalSettingsService;
            _packageService = packageService;
            _pollingClients = pollingClients;

            _releasePollingClientFactory = releasePollingClientFactory;
        }
Example #2
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!disposing || _disposed) { return; }

            if (_pollingCollection != null)
            {
                _pollingCollection.Dispose();
                _pollingCollection = null;
            }
            if (_registeredPackagesPoller != null)
            {
                _registeredPackagesPoller.Dispose();
                _registeredPackagesPoller = null;
            }

            if (_runtimeHubProxy != null)
            {
                _runtimeHubProxy = null;
            }

            if (_hubConnectionManager != null)
            {
                _hubConnectionManager.Dispose();
                _hubConnectionManager = null;
            }

            _disposed = true;
        }
Example #3
0
        private void InitializePollingClients()
        {
            _log.Info("Initializing Polling Clients...");
            var packages = _packageRepository.GetPackages();

            if (_pollingCollection != null)
            {
                _pollingCollection.Dispose();
                _pollingCollection = null;
            }
            if (_registeredPackagesPoller != null)
            {
                _registeredPackagesPoller.Dispose();
                _registeredPackagesPoller = null;
            }

            _log.InfoFormat("Global Settings are valid: {areSettingsValid}, and we are in {mode} mode.", _globalSettings.HasValidSettings(), _configurationManager.Mode);
            if (_globalSettings.HasValidSettings() && _configurationManager.Mode == ExecutionMode.Production)
            {
                _log.Info("Setting up for discovery of packages from reflector.");

                // We need to have valid settings AND we need to be in production mode to start the polling agent(s)
                _registeredPackagesPoller = _packagesPollerFactory.Invoke();
                _pollingCollection = _pollingCollectionFactory.Invoke();
                _pollingCollection.Add(_registeredPackagesPoller);
            }
            else if (_globalSettings.HasValidSettings())
            {
                _log.Info("Resolving packages from local cache.");
                // Just discover the packages from the hard disk drive's hoarde directory and start 'em up.
                packages.Apply(p =>
                    _eventBus.Publish(new ShellRequestArgs
                    {
                        ActionToTake = ShellAction.Startup,
                        PackageId = p.Id,
                        Version = string.Empty,
                        ConfigurationManager = _dbConfigurationSettingsFactory.Invoke(p.Id)
                    })
                );
            }
            else
            {
                _log.Warn("Did not start polling services, nor could we read from the local store.");
                _log.WarnFormat("Global Settings are valid: {hasValidSettings} | Execution Mode: {executionMode}", _globalSettings.HasValidSettings(), _configurationManager.Mode);
            }
        }