Initial commit
This commit is contained in:
+39
@@ -0,0 +1,39 @@
|
||||
using BritishHorseRacingApi;
|
||||
using BritishHorseRacingApi.Models;
|
||||
using SwiftyMessageHub.Core;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AutoBet.DataRecorded.MessageControllers
|
||||
{
|
||||
public class PostRaceRunnerCollectorController : MessageController
|
||||
{
|
||||
private static SemaphoreSlim _semaphore = new SemaphoreSlim(1);
|
||||
[MessageRoute]
|
||||
public async Task LoadRaces(Db.Race details)
|
||||
{
|
||||
var api = new ApiClient();
|
||||
Console.WriteLine($"Getting results for race {details.RaceId}");
|
||||
_semaphore.Wait();
|
||||
PagedResult<RunnerResult> results;
|
||||
try
|
||||
{
|
||||
results = await api.GetRaceResults(details.RaceDate.Year, details.RaceId, details.DivisionSequence);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_semaphore.Release();
|
||||
}
|
||||
foreach (var result in results.Data)
|
||||
{
|
||||
await CurrentContext.Hub.SendMessage(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user