예제 #1
0
        private void ChangeUpdateMechanism(UpdateMechanism updateMechanism)
        {
            var config = new Dictionary <string, object>
            {
                [nameof(_configFileProvider.UpdateMechanism)] = updateMechanism
            };

            _configFileProvider.SaveConfigDictionary(config);
        }
예제 #2
0
        public UpdatePackage AvailableUpdate()
        {
            if (OsInfo.IsNotWindows && !_configFileProvider.UpdateAutomatically)
            {
                return(null);
            }

            var latestAvailable = _updatePackageProvider.GetLatestUpdate(_configFileProvider.Branch, BuildInfo.Version);

            if (latestAvailable == null)
            {
                _logger.ProgressDebug("No update available.");
            }
            else if (latestAvailable.Branch != _configFileProvider.Branch)
            {
                try
                {
                    _logger.Info("Branch [{0}] is being redirected to [{1}]]", _configFileProvider.Branch, latestAvailable.Branch);
                    var config = _configFileProvider.GetConfigDictionary();
                    config["Branch"] = latestAvailable.Branch;
                    _configFileProvider.SaveConfigDictionary(config);
                }
                catch (Exception e)
                {
                    _logger.ErrorException("Couldn't save the branch redirect.", e);
                }
            }

            return(latestAvailable);
        }
예제 #3
0
        public UpdatePackage AvailableUpdate()
        {
            if (OsInfo.IsMono && !_configFileProvider.UpdateAutomatically)
            {
                return(null);
            }

            var latestAvailable = _updatePackageProvider.GetLatestUpdate(_configFileProvider.Branch, BuildInfo.Version);

            if (latestAvailable == null)
            {
                _logger.ProgressDebug("No update available.");
            }
            else if (latestAvailable.Branch != _configFileProvider.Branch)
            {
                try
                {
                    _logger.Warn("[{0}] isn't a valid branch. Switching back to [master]", _configFileProvider.Branch);
                    var config = _configFileProvider.GetConfigDictionary();
                    config["Branch"] = _configFileProvider.Branch;
                    _configFileProvider.SaveConfigDictionary(config);
                }
                catch (Exception e)
                {
                    _logger.ErrorException("Couldn't revert back to master.", e);
                }
            }

            return(latestAvailable);
        }
예제 #4
0
        private void SaveHostConfig(HostConfigResource resource)
        {
            var dictionary = resource.GetType()
                             .GetProperties(BindingFlags.Instance | BindingFlags.Public)
                             .ToDictionary(prop => prop.Name, prop => prop.GetValue(resource, null));

            _configFileProvider.SaveConfigDictionary(dictionary);
        }
예제 #5
0
        private Response SaveHostSettings()
        {
            var request = Request.Body.FromJson <Dictionary <string, object> >();

            _configFileProvider.SaveConfigDictionary(request);

            return(GetHostSettings());
        }
예제 #6
0
        public ActionResult <DevelopmentConfigResource> SaveDevelopmentConfig(DevelopmentConfigResource resource)
        {
            var dictionary = resource.GetType()
                             .GetProperties(BindingFlags.Instance | BindingFlags.Public)
                             .ToDictionary(prop => prop.Name, prop => prop.GetValue(resource, null));

            _configFileProvider.SaveConfigDictionary(dictionary);
            _configService.SaveConfigDictionary(dictionary);

            return(Accepted(resource.Id));
        }
예제 #7
0
        private void SaveHostConfig(HostConfigResource resource)
        {
            var dictionary = resource.GetType()
                             .GetProperties(BindingFlags.Instance | BindingFlags.Public)
                             .ToDictionary(prop => prop.Name, prop => prop.GetValue(resource, null));

            _configFileProvider.SaveConfigDictionary(dictionary);

            if (resource.Username.IsNotNullOrWhiteSpace() && resource.Password.IsNotNullOrWhiteSpace())
            {
                _userService.Upsert(resource.Username, resource.Password);
            }
        }
예제 #8
0
        private void EnsureValidBranch(UpdatePackage package)
        {
            var currentBranch = _configFileProvider.Branch;

            if (package.Branch != currentBranch)
            {
                try
                {
                    _logger.Info("Branch [{0}] is being redirected to [{1}]]", currentBranch, package.Branch);
                    var config = new Dictionary <string, object>();
                    config["Branch"] = package.Branch;
                    _configFileProvider.SaveConfigDictionary(config);
                }
                catch (Exception e)
                {
                    _logger.Error(e, "Couldn't change the branch from [{0}] to [{1}].", currentBranch, package.Branch);
                }
            }
        }