コード例 #1
0
        public FolderQueueStore(string queuePath, IExceptionlessLogAccessor logAccessor) {
            LogAccessor = logAccessor;
            _queuePath = queuePath;

            try {
                if (!Directory.Exists(_queuePath))
                    Directory.CreateDirectory(_queuePath);
            } catch {}
        }
コード例 #2
0
        public WebLastErrorIdManager(IExceptionlessLogAccessor logAccessor)
        {
            if (logAccessor == null)
            {
                throw new ArgumentNullException("logAccessor");
            }

            LogAccessor = logAccessor;
        }
コード例 #3
0
        private static void ReadAttribute(ClientConfiguration configuration, IExceptionlessLogAccessor logAccessor)
        {
            ExceptionlessAttribute exceptionlessAttribute = null;

            // first try entry
            Assembly assembly = AssemblyHelper.GetRootAssembly();

            if (assembly != null)
            {
                exceptionlessAttribute = GetAttribute(assembly);
            }

            // search all loaded assemblies
            if (exceptionlessAttribute == null)
            {
                foreach (Assembly a in AssemblyHelper.GetAssemblies())
                {
                    assembly = a;
                    exceptionlessAttribute = GetAttribute(assembly);
                    if (exceptionlessAttribute != null)
                    {
                        break;
                    }
                }
            }

            if (exceptionlessAttribute == null)
            {
                return;
            }

            if (assembly != null)
            {
                logAccessor.Log.FormattedInfo(typeof(ClientConfigurationReader), "Found exceptionless attribute in assembly '{0}'", assembly.FullName);
            }

            if (exceptionlessAttribute.ApiKey != null)
            {
                configuration.ApiKey = exceptionlessAttribute.ApiKey;
            }
            if (exceptionlessAttribute.QueuePath != null)
            {
                configuration.QueuePath = exceptionlessAttribute.QueuePath;
            }
            if (exceptionlessAttribute.ServerUrl != null)
            {
                configuration.ServerUrl = exceptionlessAttribute.ServerUrl;
            }
            configuration.EnableSSL     = exceptionlessAttribute.EnableSSL;
            configuration.EnableLogging = exceptionlessAttribute.EnableLogging;
            if (exceptionlessAttribute.LogPath != null)
            {
                configuration.LogPath = exceptionlessAttribute.LogPath;
            }
            configuration.Enabled = exceptionlessAttribute.Enabled;
        }
コード例 #4
0
        public FolderQueueStore(string queuePath, IExceptionlessLogAccessor logAccessor)
        {
            LogAccessor = logAccessor;
            _queuePath  = queuePath;

            try {
                if (!Directory.Exists(_queuePath))
                {
                    Directory.CreateDirectory(_queuePath);
                }
            } catch {}
        }
コード例 #5
0
        private static void ReadAttributes(ClientConfiguration configuration, IExceptionlessLogAccessor logAccessor) {
            ReadAttribute(configuration, logAccessor);

            var settingAttributes = new List<ExceptionlessSettingAttribute>();

            // search all loaded assemblies
            GetSettingAttributes(settingAttributes);

            foreach (ExceptionlessSettingAttribute attribute in settingAttributes) {
                if (!String.IsNullOrEmpty(attribute.Name))
                    configuration[attribute.Name] = attribute.Value;
            }
        }
コード例 #6
0
        public static ExceptionlessSection GetApplicationConfiguration(IExceptionlessLogAccessor logAccessor)
        {
            if (!_configRead)
            {
                try {
                    _configRead    = true;
                    _configSection = ConfigurationManager.GetSection("exceptionless") as ExceptionlessSection;
                } catch (Exception ex) {
                    logAccessor.Log.FormattedError(typeof(ClientConfigurationReader), ex, "Error getting ExceptionlessSection: {0}", ex.Message);
                }
            }

            return(_configSection);
        }
コード例 #7
0
        internal static LocalConfigurationDictionary Create(string storeId, IExceptionlessLogAccessor logAccessor)
        {
            var localStorage = new LocalConfigurationDictionary {
                LogAccessor = logAccessor,
                StoreId     = storeId,
                CurrentConfigurationVersion = 0,
                NextConfigurationUpdate     = DateTime.MinValue
            };

            try {
                using (new SingleGlobalInstance(String.Concat(storeId, FileName).GetHashCode().ToString(), 500)) {
                    // retry loop
                    for (int retry = 0; retry < 2; retry++)
                    {
                        using (var dir = new IsolatedStorageDirectory(storeId)) {
                            try {
                                if (!dir.FileExists(FileName))
                                {
                                    break;
                                }

                                var config = dir.ReadFile <LocalConfigurationDictionary>(FileName);
                                foreach (string key in config.Keys)
                                {
                                    localStorage[key] = config[key];
                                }

                                localStorage.IsDirty = false;
                                break;
                            } catch (Exception ex) {
                                // File is being used by another process or thread or the file does not exist.
                                logAccessor.Log.FormattedError(typeof(LocalConfigurationDictionary), ex, "Unable to read data from local storage: {0}", ex.Message);
                                Thread.Sleep(50);
                            }
                        } // using stream
                    }     // retry

                    // TODO: Why are we doing this even if the configuration couldn't be read or didn't exist??
                    localStorage.LoadDefaults();
                    localStorage.Save();

                    return(localStorage);
                } // lock
            } catch (Exception ex) {
                logAccessor.Log.Error(ex, "An error occurred while saving local configuration");
                localStorage.LoadDefaults();
                return(localStorage);
            }
        }
コード例 #8
0
        private static void ReadAttributes(ClientConfiguration configuration, IExceptionlessLogAccessor logAccessor)
        {
            ReadAttribute(configuration, logAccessor);

            var settingAttributes = new List <ExceptionlessSettingAttribute>();

            // search all loaded assemblies
            GetSettingAttributes(settingAttributes);

            foreach (ExceptionlessSettingAttribute attribute in settingAttributes)
            {
                if (!String.IsNullOrEmpty(attribute.Name))
                {
                    configuration[attribute.Name] = attribute.Value;
                }
            }
        }
コード例 #9
0
        private static void ReadAttribute(ClientConfiguration configuration, IExceptionlessLogAccessor logAccessor) {
            ExceptionlessAttribute exceptionlessAttribute = null;

            // first try entry
            Assembly assembly = AssemblyHelper.GetRootAssembly();
            if (assembly != null)
                exceptionlessAttribute = GetAttribute(assembly);

            // search all loaded assemblies
            if (exceptionlessAttribute == null) {
                foreach (Assembly a in AssemblyHelper.GetAssemblies()) {
                    assembly = a;
                    exceptionlessAttribute = GetAttribute(assembly);
                    if (exceptionlessAttribute != null)
                        break;
                }
            }

            if (exceptionlessAttribute == null)
                return;

            if (assembly != null)
                logAccessor.Log.FormattedInfo(typeof(ClientConfigurationReader), "Found exceptionless attribute in assembly '{0}'", assembly.FullName);

            if (exceptionlessAttribute.ApiKey != null)
                configuration.ApiKey = exceptionlessAttribute.ApiKey;
            if (exceptionlessAttribute.QueuePath != null)
                configuration.QueuePath = exceptionlessAttribute.QueuePath;
            if (exceptionlessAttribute.ServerUrl != null)
                configuration.ServerUrl = exceptionlessAttribute.ServerUrl;
            configuration.EnableSSL = exceptionlessAttribute.EnableSSL;
            configuration.EnableLogging = exceptionlessAttribute.EnableLogging;
            if (exceptionlessAttribute.LogPath != null)
                configuration.LogPath = exceptionlessAttribute.LogPath;
            configuration.Enabled = exceptionlessAttribute.Enabled;
        }
コード例 #10
0
        private static void ReadSavedConfiguration(ClientConfiguration configuration, IExceptionlessLogAccessor logAccessor) {
            try {
                for (int retry = 0; retry < 2; retry++) {
                    using (var dir = new IsolatedStorageDirectory(configuration.StoreId)) {
                        try {
                            if (!dir.FileExists(ClientConfiguration.CachedServerConfigFile))
                                return;

                            var savedConfig = dir.ReadFile<Dictionary<string, string>>(ClientConfiguration.CachedServerConfigFile);
                            if (savedConfig == null)
                                return;

                            foreach (string key in savedConfig.Keys)
                                configuration[key] = savedConfig[key];

                            return;
                        } catch (JsonReaderException) {
                            // try deleting the invalid config file so we don't keep trying to read it.
                            try {
                                dir.DeleteFile(ClientConfiguration.CachedServerConfigFile);
                            } catch {}
                        } catch (Exception ex) {
                            // File is being used by another process or thread or the file does not exist.
                            logAccessor.Log.FormattedError(typeof(ClientConfigurationReader), ex, "Error while reading settings from the configuration file: {0}", ex.Message);
                            Thread.Sleep(50);
                        }
                    } // storage
                } // retry
            } catch (Exception ex) {
                logAccessor.Log.FormattedError(typeof(ClientConfigurationReader), ex, "Error while reading settings from the configuration file: {0}", ex.Message);
            }
        }
コード例 #11
0
        public static ExceptionlessSection GetApplicationConfiguration(IExceptionlessLogAccessor logAccessor) {
            if (!_configRead) {
                try {
                    _configRead = true;
                    _configSection = ConfigurationManager.GetSection("exceptionless") as ExceptionlessSection;
                } catch (Exception ex) {
                    logAccessor.Log.FormattedError(typeof(ClientConfigurationReader), ex, "Error getting ExceptionlessSection: {0}", ex.Message);
                }
            }

            return _configSection;
        }
コード例 #12
0
        private static void ReadApplicationConfiguration(ClientConfiguration configuration, IExceptionlessLogAccessor logAccessor) {
            try {
                ExceptionlessSection exceptionlessSection = GetApplicationConfiguration(logAccessor);
                if (exceptionlessSection == null)
                    return;

                // only update if not null
                if (!String.IsNullOrEmpty(exceptionlessSection.ApiKey))
                    configuration.ApiKey = exceptionlessSection.ApiKey;

                // if an appsetting is present for apikey, then it will override the other api keys
                string apiKeyOverride = ConfigurationManager.AppSettings["Exceptionless:ApiKey"] ?? String.Empty;
                if (!String.IsNullOrEmpty(apiKeyOverride))
                    configuration.ApiKey = apiKeyOverride;

                if (!String.IsNullOrEmpty(exceptionlessSection.QueuePath))
                    configuration.QueuePath = exceptionlessSection.QueuePath;

                if (!String.IsNullOrEmpty(exceptionlessSection.ServerUrl))
                    configuration.ServerUrl = exceptionlessSection.ServerUrl;

                configuration.Enabled = exceptionlessSection.Enabled;

                if (exceptionlessSection.EnableSSL.HasValue)
                    configuration.EnableSSL = exceptionlessSection.EnableSSL.Value;

                if (exceptionlessSection.EnableLogging.HasValue)
                    configuration.EnableLogging = exceptionlessSection.EnableLogging.Value;

                if (!String.IsNullOrEmpty(exceptionlessSection.LogPath))
                    configuration.LogPath = exceptionlessSection.LogPath;

                // if a log path is specified and enable logging setting isn't specified, then enable logging.
                if (!String.IsNullOrEmpty(exceptionlessSection.LogPath) && !exceptionlessSection.EnableLogging.HasValue)
                    configuration.EnableLogging = true;

                if (exceptionlessSection.Settings == null)
                    return;

                foreach (NameValueConfigurationElement setting in exceptionlessSection.Settings) {
                    if (!String.IsNullOrEmpty(setting.Name))
                        configuration[setting.Name] = setting.Value;
                }
            } catch (ConfigurationErrorsException ex) {
                logAccessor.Log.FormattedError(typeof(ClientConfigurationReader), ex, "Error getting ExceptionlessSection: {0}", ex.Message);
            }
        }
コード例 #13
0
        private static void ReadSavedConfiguration(ClientConfiguration configuration, IExceptionlessLogAccessor logAccessor)
        {
            try {
                for (int retry = 0; retry < 2; retry++)
                {
                    using (var dir = new IsolatedStorageDirectory(configuration.StoreId)) {
                        try {
                            if (!dir.FileExists(ClientConfiguration.CachedServerConfigFile))
                            {
                                return;
                            }

                            var savedConfig = dir.ReadFile <Dictionary <string, string> >(ClientConfiguration.CachedServerConfigFile);
                            if (savedConfig == null)
                            {
                                return;
                            }

                            foreach (string key in savedConfig.Keys)
                            {
                                configuration[key] = savedConfig[key];
                            }

                            return;
                        } catch (JsonReaderException) {
                            // try deleting the invalid config file so we don't keep trying to read it.
                            try {
                                dir.DeleteFile(ClientConfiguration.CachedServerConfigFile);
                            } catch {}
                        } catch (Exception ex) {
                            // File is being used by another process or thread or the file does not exist.
                            logAccessor.Log.FormattedError(typeof(ClientConfigurationReader), ex, "Error while reading settings from the configuration file: {0}", ex.Message);
                            Thread.Sleep(50);
                        }
                    } // storage
                }     // retry
            } catch (Exception ex) {
                logAccessor.Log.FormattedError(typeof(ClientConfigurationReader), ex, "Error while reading settings from the configuration file: {0}", ex.Message);
            }
        }
コード例 #14
0
        private static void ReadApplicationConfiguration(ClientConfiguration configuration, IExceptionlessLogAccessor logAccessor)
        {
            try {
                ExceptionlessSection exceptionlessSection = GetApplicationConfiguration(logAccessor);
                if (exceptionlessSection == null)
                {
                    return;
                }

                // only update if not null
                if (!String.IsNullOrEmpty(exceptionlessSection.ApiKey))
                {
                    configuration.ApiKey = exceptionlessSection.ApiKey;
                }

                // if an appsetting is present for apikey, then it will override the other api keys
                string apiKeyOverride = ConfigurationManager.AppSettings["Exceptionless:ApiKey"] ?? String.Empty;
                if (!String.IsNullOrEmpty(apiKeyOverride))
                {
                    configuration.ApiKey = apiKeyOverride;
                }

                if (!String.IsNullOrEmpty(exceptionlessSection.QueuePath))
                {
                    configuration.QueuePath = exceptionlessSection.QueuePath;
                }

                if (!String.IsNullOrEmpty(exceptionlessSection.ServerUrl))
                {
                    configuration.ServerUrl = exceptionlessSection.ServerUrl;
                }

                configuration.Enabled = exceptionlessSection.Enabled;

                if (exceptionlessSection.EnableSSL.HasValue)
                {
                    configuration.EnableSSL = exceptionlessSection.EnableSSL.Value;
                }

                if (exceptionlessSection.EnableLogging.HasValue)
                {
                    configuration.EnableLogging = exceptionlessSection.EnableLogging.Value;
                }

                if (!String.IsNullOrEmpty(exceptionlessSection.LogPath))
                {
                    configuration.LogPath = exceptionlessSection.LogPath;
                }

                // if a log path is specified and enable logging setting isn't specified, then enable logging.
                if (!String.IsNullOrEmpty(exceptionlessSection.LogPath) && !exceptionlessSection.EnableLogging.HasValue)
                {
                    configuration.EnableLogging = true;
                }

                if (exceptionlessSection.Settings == null)
                {
                    return;
                }

                foreach (NameValueConfigurationElement setting in exceptionlessSection.Settings)
                {
                    if (!String.IsNullOrEmpty(setting.Name))
                    {
                        configuration[setting.Name] = setting.Value;
                    }
                }
            } catch (ConfigurationErrorsException ex) {
                logAccessor.Log.FormattedError(typeof(ClientConfigurationReader), ex, "Error getting ExceptionlessSection: {0}", ex.Message);
            }
        }
コード例 #15
0
 public IsolatedStorageQueueStore(string subDirectory, IExceptionlessLogAccessor logAccessor) {
     LogAccessor = logAccessor;
     SubDirectory = subDirectory;
 }
コード例 #16
0
 public IsolatedStorageQueueStore(string subDirectory, IExceptionlessLogAccessor logAccessor)
 {
     LogAccessor  = logAccessor;
     SubDirectory = subDirectory;
 }
コード例 #17
0
        public WebLastErrorIdManager(IExceptionlessLogAccessor logAccessor) {
            if (logAccessor == null)
                throw new ArgumentNullException("logAccessor");

            LogAccessor = logAccessor;
        }