private static IFixtureDetails GenerateMockedFixtureOverview(string fixtureId) { var tmp = new FixtureDetails { Id = fixtureId, IsStreaming = true, State = FixtureState.Ready, Competition = "French Division 1", CompetitionId = "1qqqqqq", StartTime = new DateTime(2014, 3, 17, 17, 0, 0), Description = "PSG v Lion", IsOver = false, IsDeleted = false }; tmp.AddProcessingEntry(new FixtureProcessingEntry { Sequence = "1", Epoch = "1", IsUpdate = false, State = FixtureProcessingState.PROCESSED, Timestamp = new DateTime(2013, 06, 11, 14, 33, 0) }); tmp.AddProcessingEntry(new FixtureProcessingEntry { Sequence = "2", Epoch = "1", IsUpdate = true, State = FixtureProcessingState.PROCESSED, Timestamp = new DateTime(2013, 06, 11, 14, 34, 0), Exception = "Null pointer exception" }); tmp.AddProcessingEntry(new FixtureProcessingEntry { Sequence = "2", Epoch = "1", IsUpdate = false, State = FixtureProcessingState.PROCESSED, Timestamp = new DateTime(2013, 06, 11, 14, 34, 30) }); tmp.AddProcessingEntry(new FixtureProcessingEntry { Sequence = "3", Epoch = null, IsUpdate = true, State = FixtureProcessingState.SKIPPED, Timestamp = new DateTime(2013, 06, 11, 14, 35, 0) }); tmp.AddProcessingEntry(new FixtureProcessingEntry { Sequence = "4", Epoch = null, IsUpdate = true, State = FixtureProcessingState.PROCESSED, Timestamp = new DateTime(2013, 06, 11, 14, 37, 0) }); tmp.AddProcessingEntry(new FixtureProcessingEntry { Sequence = "5", Epoch = "2", IsUpdate = true, State = FixtureProcessingState.SKIPPED, Timestamp = new DateTime(2013, 06, 11, 14, 38, 45), EpochChangeReasons = new[] { 10 }, }); tmp.AddProcessingEntry(new FixtureProcessingEntry { Sequence = "5", Epoch = "2", IsUpdate = false, State = FixtureProcessingState.PROCESSING, Timestamp = new DateTime(2013, 06, 11, 14, 39, 0) }); return tmp; }
private void UpdateSupervisorStateMsgHandler(UpdateSupervisorStateMsg msg) { _logger.Info($"Updating supervisor state for {msg.FixtureId} IsSnapshot={msg.IsSnapshot}"); var fixtureOverview = GetFixtureOverview(msg.FixtureId); fixtureOverview.FeedUpdate = new FeedUpdateOverview() { Epoch = msg.Epoch, IsSnapshot = msg.IsSnapshot, Sequence = msg.CurrentSequence, LastEpochChangeReason = msg.LastEpochChangeReason, IsProcessed = true, Issued = DateTime.Now }; fixtureOverview.TimeStamp = DateTime.UtcNow; fixtureOverview.Sport = msg.Sport; fixtureOverview.Name = msg.Name ?? fixtureOverview.Name; fixtureOverview.ListenerOverview.Sequence = msg.CurrentSequence; fixtureOverview.ListenerOverview.Epoch = msg.Epoch; fixtureOverview.ListenerOverview.StartTime = msg.StartTime ?? fixtureOverview.ListenerOverview.StartTime; fixtureOverview.ListenerOverview.LastEpochChangeReason = msg.LastEpochChangeReason ?? fixtureOverview.ListenerOverview.LastEpochChangeReason; fixtureOverview.ListenerOverview.MatchStatus = msg.MatchStatus ?? fixtureOverview.ListenerOverview.MatchStatus; fixtureOverview.ListenerOverview.IsDeleted = msg.IsDeleted; fixtureOverview.ListenerOverview.IsStreaming = msg.IsStreaming; fixtureOverview.ListenerOverview.IsSuspended = msg.IsSuspended; fixtureOverview.ListenerOverview.IsOver = msg.IsOver; fixtureOverview.ListenerOverview.IsErrored = msg.IsErrored; if (msg.IsSnapshot) { fixtureOverview.CompetitionId = msg.CompetitionId; fixtureOverview.CompetitionName = msg.CompetitionName; } ServiceModel.FixtureDetails details = fixtureOverview.ToServiceModel(); details.Id = msg.FixtureId; details.IsDeleted = msg.IsDeleted; details.IsOver = msg.IsOver; _streamingService.OnFixtureUpdate(details); if (msg.IsErrored.HasValue && msg.IsErrored.Value && msg.Exception != null) { var error = new ServiceModel.ProcessingEntryError { Timestamp = DateTime.UtcNow, Message = msg.Exception.Message, FixtureId = msg.FixtureId, FixtureDescription = fixtureOverview.Name, Sequence = msg.CurrentSequence }; _streamingService.OnError(error); } UpdateSportDetails(msg.Sport); SaveState(); }
public IFixtureDetails GetFixtureDetail(string fixtureId) { if(string.IsNullOrEmpty(fixtureId)) return null; var overview = Supervisor.GetFixtureOverview(fixtureId); FixtureDetails details = new FixtureDetails(); FillFixtureOverview(details, overview); foreach(var update in overview.GetFeedAudit()) { FixtureProcessingEntry entry = new FixtureProcessingEntry(); FillProcessingEntry(entry, update); details.AddProcessingEntry(entry); } return details; }
private void OnFixtureUpdate(IFixtureOverviewDelta fixture) { if (fixture == null) return; FixtureDetails details = new FixtureDetails {Id = fixture.Id}; // ListenerOverview is not suitable to use here.... // we have to get the FixtureOverview to have all data var overview = Supervisor.GetFixtureOverview(fixture.Id); FillFixtureOverview(details, overview); if (fixture.ListenerOverview != null) { details.IsDeleted = fixture.ListenerOverview.IsDeleted.GetValueOrDefault(); details.IsOver = fixture.ListenerOverview.IsOver.GetValueOrDefault(); } if(fixture.FeedUpdate != null) { FixtureProcessingEntry entry = new FixtureProcessingEntry(); FillProcessingEntry(entry, fixture.FeedUpdate); details.AddProcessingEntry(entry); } Supervisor.Service.StreamingService.OnFixtureUpdate(details); if(fixture.LastError != null && fixture.LastError.IsErrored) { ProcessingEntryError error = new ProcessingEntryError { FixtureId = fixture.Id, FixtureDescription = overview.Name, Sequence = fixture.LastError.Sequence }; FillProcessingEntryError(error, fixture.LastError); Supervisor.Service.StreamingService.OnError(error); } }