예제 #1
0
        public void MultipleQueueManager() {
            int manifestsProcessed = 0;
            var manager = new QueueManager(_accessor, new IsolatedStorageQueueStore("test", _accessor));
            List<Manifest> manifests = manager.GetManifests().ToList();
            foreach (Manifest manifest in manifests)
                manager.Delete(manifest.Id);

            const int NUMBER_TO_PROCESS = 20;
            for (int i = 0; i < NUMBER_TO_PROCESS; i++)
                manager.Enqueue(CreateSampleError());

            var mutex = new Mutex(false, "test");
            Parallel.For(0, 5, i => {
                mutex.WaitOne();
                var localManager = new QueueManager(_accessor, new IsolatedStorageQueueStore("test", _accessor));
                List<Manifest> localManifests = localManager.GetManifests().ToList();
                foreach (Manifest m in localManifests)
                    localManager.Delete(m.Id);
                Interlocked.Add(ref manifestsProcessed, localManifests.Count);
                Assert.NotNull(localManifests);
                mutex.ReleaseMutex();
            });

            Assert.Equal(NUMBER_TO_PROCESS, manifestsProcessed);

            foreach (Manifest manifest in manifests)
                manager.Delete(manifest.Id);
        }
예제 #2
0
        public void QueueManager() {
            Error error = CreateSampleError();
            var manager = new QueueManager(_accessor, new IsolatedStorageQueueStore("test", _accessor));

            manager.Enqueue(error);
            // verify that the extended data objects were serialized to JSON
            ValidateSampleError(error);

            IEnumerable<Manifest> manifests = manager.GetManifests();
            Assert.NotNull(manifests);
            Assert.Equal(1, manifests.Count());

            Error e = manager.GetError(manifests.First().Id);
            ValidateSampleError(e);

            manager.Delete(error.Id);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ExceptionlessClient" /> class.
        /// </summary>
        internal ExceptionlessClient(IQueueStore store = null, IExceptionlessLog log = null) {
            _queueTimer = new Timer(OnQueueTimer, null, Timeout.Infinite, Timeout.Infinite);
            _log = log ?? new NullExceptionlessLog();

            try {
                _configuration = Config.ClientConfiguration.Create(this);
                Log.FormattedTrace(typeof(ExceptionlessClient), "Configuration Values: ApiKey={0}, EnableSSL={1}, Enabled={2}, ServerUrl={3}", _configuration.ApiKey, _configuration.EnableSSL, _configuration.Enabled, _configuration.ServerUrl);
            } catch (Exception ex) {
                Log.FormattedError(typeof(ExceptionlessClient), "Critical error in ExceptionlessClient constructor: {0}", ex.Message);
            }

            try {
                _localConfiguration = Config.LocalConfigurationDictionary.Create(_configuration.StoreId, this);
            } catch (Exception ex) {
                Log.FormattedError(typeof(ExceptionlessClient), "Critical error in ExceptionlessClient constructor: {0}", ex.Message);
            }

            _queue = new QueueManager(this, store);
            _queueTimer.Change(LocalConfiguration.QueuePoll, TimeSpan.Zero);
#if SILVERLIGHT
            NetworkChange.NetworkAddressChanged += NetworkChange_NetworkAddressChanged;
#else
            NetworkChange.NetworkAvailabilityChanged += NetworkChangeNetworkAvailabilityChanged;
#endif
        }