Exemple #1
0
        public async Task <bool> WriteBandwidthTestResults(BandwidthTestResult testResults)
        {
            using (var conn = GetConnection())
            {
                var sql = @"
          insert into NetTests
          (DownloadSpeed, UploadSpeed)
          values
          (@DownloadSpeed, @UploadSpeed)";

                conn.Open();

                var rowsAffected = await conn.ExecuteAsync(sql, testResults);

                return(rowsAffected == 1);
            }
        }
Exemple #2
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            var bandwidthTester = new BandwidthTester(_client, _apiUrl, _apiSecret, _filePath);

            while (!stoppingToken.IsCancellationRequested)
            {
                _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);

                var downloadSpeed = await bandwidthTester.GetDownloadSpeedMbSec();

                var uploadSpeed = await bandwidthTester.GetUploadSpeedMbSec();

                var resultObject = new BandwidthTestResult(downloadSpeed, uploadSpeed);

                var result = await _repo.WriteBandwidthTestResults(resultObject);

                await Task.Delay(_interval, stoppingToken);
            }
        }