Initial commit

This commit is contained in:
2020-04-13 15:16:46 +01:00
commit 17a40cb95f
81 changed files with 10120 additions and 0 deletions
@@ -0,0 +1,41 @@
using BritishHorseRacingApi.Models;
using SwiftyMessageHub.Core;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace AutoBet.DataRecorded.PreRaceRunnerCollector
{
public class PreRaceRunnerCollectorController : MessageController
{
public static SemaphoreSlim semaphore = new SemaphoreSlim(1);
[MessageRoute]
public async Task CollectPreRaceData(PreRaceRunnerCollectDetails details)
{
var client = new BritishHorseRacingApi.ApiClient();
var date = details.DateToCollect;
Console.WriteLine($"Preparing to load runners for race id {details.RaceId}");
await semaphore.WaitAsync();
try
{
Console.WriteLine($"Loading runners for race id {details.RaceId}");
var runners = await client.GetRaceRunners(date.Year, details.RaceId);
foreach (var runner in runners.Data)
{
Console.WriteLine($"Loaded runner {runner.RacehorseName} id {details.RaceId}");
await CurrentContext.Hub.SendMessage(runner);
}
}
catch(Exception ex)
{
throw;
}
finally
{
semaphore.Release();
}
}
}
}