예제 #1
0
        private void Upload()
        {
            lock (_uploadLock)
            {
                _log.Debug("Upload started");

                Batch batch;
                var   uploadedBatchCounter = 0;
                var   allBatchCounter      = 0;
                while ((batch = _batchPersister.GetNext()) != null)
                {
                    allBatchCounter++;

                    _log.DebugFormat("Starting send batch with id={0}", batch.GetBatchId());
                    if (_httpRequestService.SendRequest(_url, _token, batch))
                    {
                        _log.DebugFormat("Successfuly send batch with id={0}", batch.GetBatchId());

                        _batchPersister.Remove();
                        uploadedBatchCounter++;

                        _log.DebugFormat("Batch {0} successfully uploaded", batch.GetBatchId());
                    }
                    else
                    {
                        _log.ErrorFormat("Error while upload batch {0}", batch.GetBatchId());
                        break;
                    }
                }

                _log.DebugFormat("{0} from {1} batches uploaded", uploadedBatchCounter, allBatchCounter);
            }
        }
예제 #2
0
        private void Upload()
        {
            lock (_uploadLock)
            {
                if (Log.IsDebugEnabled)
                {
                    Log.Debug("Upload started");
                }

                Batch batch;
                int   uploadedBatchCounter = 0;
                int   allBatchCounter      = 0;
                while ((batch = _batchPersister.GetNext()) != null)
                {
                    allBatchCounter++;

                    if (HttpRequestService.SendRequest(_url, _token, batch))
                    {
                        _batchPersister.Remove();
                        uploadedBatchCounter++;

                        if (Log.IsDebugEnabled)
                        {
                            Log.DebugFormat("Batch {0} successfully uploaded", batch.GetBatchId());
                        }
                    }
                    else
                    {
                        Log.ErrorFormat("Error while upload batch {0}", batch.GetBatchId());
                        break;
                    }
                }

                if (Log.IsDebugEnabled)
                {
                    Log.DebugFormat("{0} from {1} batches uploaded", uploadedBatchCounter, allBatchCounter);
                }
            }
        }