/// <summary>
        /// Raises the <see cref="ConfigurationUpdated" /> event.
        /// </summary>
        /// <param name="e">The <see cref="ConfigurationUpdatedEventArgs" /> instance containing the event data.</param>
        protected void OnConfigurationUpdated(ConfigurationUpdatedEventArgs e) {
            if (e.Error != null)
                Log.FormattedError(typeof(ExceptionlessClient), "Error updating configuration: {0}", e.Error.Message);
            else if (e.Configuration != null)
                Log.FormattedInfo(typeof(ExceptionlessClient), "Updated configuration to version {0}.", e.Configuration.Version);

            if (ConfigurationUpdated != null)
                ConfigurationUpdated(this, e);
        }
Exemple #2
0
        /// <summary>
        /// Raises the <see cref="ConfigurationUpdated" /> event.
        /// </summary>
        /// <param name="e">The <see cref="ConfigurationUpdatedEventArgs" /> instance containing the event data.</param>
        protected void OnConfigurationUpdated(ConfigurationUpdatedEventArgs e)
        {
            if (e.Configuration != null)
            {
                _log.Value.FormattedInfo(typeof(ExceptionlessClient), "Updated configuration to version {0}.", e.Configuration.Version);
            }

            if (ConfigurationUpdated != null)
            {
                ConfigurationUpdated(this, e);
            }
        }
Exemple #3
0
        /// <summary>
        /// Raises the <see cref="ConfigurationUpdated" /> event.
        /// </summary>
        /// <param name="e">The <see cref="ConfigurationUpdatedEventArgs" /> instance containing the event data.</param>
        protected void OnConfigurationUpdated(ConfigurationUpdatedEventArgs e)
        {
            if (e.Error != null)
            {
                Log.FormattedError(typeof(ExceptionlessClient), "Error updating configuration: {0}", e.Error.Message);
            }
            else if (e.Configuration != null)
            {
                Log.FormattedInfo(typeof(ExceptionlessClient), "Updated configuration to version {0}.", e.Configuration.Version);
            }

            if (ConfigurationUpdated != null)
            {
                ConfigurationUpdated(this, e);
            }
        }
Exemple #4
0
        /// <summary>
        /// Updates the configuration.
        /// </summary>
        /// <param name="forceUpdate">if set to <c>true</c> to force update.</param>
        public void UpdateConfiguration(bool forceUpdate = false)
        {
            if (LocalConfiguration == null || _updatingConfiguration || (!forceUpdate && !IsConfigurationUpdateNeeded()))
            {
                Log.Info(typeof(ExceptionlessClient), "Configuration is up to date.");
                return;
            }

            Log.Info(typeof(ExceptionlessClient), "Updating configuration settings.");

            _updatingConfiguration = true;

            ClientConfiguration configuration = null;
            Exception           error;

            try {
                RestClient client = CreateClient();
                configuration = client.Get <ClientConfiguration>("project/config");
                error         = client.Error;
            } catch (Exception ex) {
                error = ex;
            }

            var args = new ConfigurationUpdatedEventArgs(configuration, error, false, _configuration);

            if (configuration == null)
            {
                Log.FormattedError(typeof(ExceptionlessClient), "Configuration response was null: {0}", error != null ? error.Message : "");
                LocalConfiguration.NextConfigurationUpdate = DateTime.UtcNow.AddHours(1);
            }
            else
            {
                Config.ClientConfiguration.ProcessServerConfigResponse(this, configuration.Settings, _configuration.StoreId);
                LocalConfiguration.CurrentConfigurationVersion = configuration.Version;
                LocalConfiguration.NextConfigurationUpdate     = DateTime.UtcNow.AddDays(1);
            }

            // TODO: This can be removed once we fix the bug in the ObservableConcurrentDictionary where IsDirty is not set immediately.
            LocalConfiguration.IsDirty = true;

            LocalConfiguration.Save();

            _updatingConfiguration = false;

            OnConfigurationUpdated(args);
        }
        /// <summary>
        /// Updates the configuration.
        /// </summary>
        /// <param name="forceUpdate">if set to <c>true</c> to force update.</param>
        public void UpdateConfiguration(bool forceUpdate = false) {
            if (LocalConfiguration == null || _updatingConfiguration || (!forceUpdate && !IsConfigurationUpdateNeeded())) {
                Log.Info(typeof(ExceptionlessClient), "Configuration is up to date.");
                return;
            }

            Log.Info(typeof(ExceptionlessClient), "Updating configuration settings.");

            _updatingConfiguration = true;

            ClientConfiguration configuration = null;
            Exception error;

            try {
                RestClient client = CreateClient();
                configuration = client.Get<ClientConfiguration>("project/config");
                error = client.Error;
            } catch (Exception ex) {
                error = ex;
            }

            var args = new ConfigurationUpdatedEventArgs(configuration, error, false, _configuration);
            if (configuration == null) {
                Log.FormattedError(typeof(ExceptionlessClient), "Configuration response was null: {0}", error != null ? error.Message : "");
                LocalConfiguration.NextConfigurationUpdate = DateTime.UtcNow.AddHours(1);
            } else {
                Config.ClientConfiguration.ProcessServerConfigResponse(this, configuration.Settings, _configuration.StoreId);
                LocalConfiguration.CurrentConfigurationVersion = configuration.Version;
                LocalConfiguration.NextConfigurationUpdate = DateTime.UtcNow.AddDays(1);
            }

            // TODO: This can be removed once we fix the bug in the ObservableConcurrentDictionary where IsDirty is not set immediately.
            LocalConfiguration.IsDirty = true;

            LocalConfiguration.Save();

            _updatingConfiguration = false;

            OnConfigurationUpdated(args);
        }