示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SportEventStatus"/> class.
        /// </summary>
        /// <param name="cacheItem">A <see cref="SportEventStatusCI"/> containing information about sport event status, which will be used to initialize a new instance</param>
        /// <param name="matchStatusCache">A <see cref="ILocalizedNamedValueCache"/> used to retrieve event status</param>
        public SportEventStatus(SportEventStatusCI cacheItem, ILocalizedNamedValueCache matchStatusCache)
        {
            Contract.Requires(cacheItem != null);
            Contract.Requires(matchStatusCache != null);

            _cacheItem        = cacheItem;
            _matchStatusCache = matchStatusCache;
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SportEventStatus"/> class
        /// </summary>
        /// <param name="cacheItem">A <see cref="SportEventStatusCI"/> containing information about sport event status, which will be used to initialize a new instance</param>
        /// <param name="matchStatusCache">A <see cref="ILocalizedNamedValueCache"/> used to retrieve event status</param>
        public SportEventStatus(SportEventStatusCI cacheItem, ILocalizedNamedValueCache matchStatusCache)
        {
            Guard.Argument(cacheItem, nameof(cacheItem)).NotNull();
            Guard.Argument(matchStatusCache, nameof(matchStatusCache)).NotNull();

            _cacheItem        = cacheItem;
            _matchStatusCache = matchStatusCache;
        }
示例#3
0
 public SoccerStatus(SportEventStatusCI ci, ILocalizedNamedValueCache matchStatusesCache)
     : base(ci, matchStatusesCache)
 {
     if (ci?.SportEventStatistics != null)
     {
         Statistics = new SoccerStatistics(ci.SportEventStatistics.TotalStatisticsDTOs,
                                           ci.SportEventStatistics.PeriodStatisticsDTOs);
     }
 }
示例#4
0
        /// <summary>
        /// Adds the sport event status to the internal cache
        /// </summary>
        /// <param name="eventId">The eventId of the sport event status to be cached</param>
        /// <param name="sportEventStatus">The sport event status to be cached</param>
        /// <param name="statusOnEvent">The sport event status received directly on event level</param>
        /// <param name="source">The source of the SES</param>
        private void AddSportEventStatus(URN eventId, SportEventStatusCI sportEventStatus, string statusOnEvent, string source)
        {
            if (_isDisposed)
            {
                return;
            }

            if (sportEventStatus == null)
            {
                return;
            }

            Guard.Argument(eventId, nameof(eventId)).NotNull();

            if (string.IsNullOrEmpty(source) ||
                source.Equals("OddsChange", StringComparison.InvariantCultureIgnoreCase) ||
                source.Equals("SportEventSummary", StringComparison.InvariantCultureIgnoreCase) ||
                !_sportEventStatusCache.Contains(eventId.ToString()))
            {
                lock (_lock)
                {
                    if (!string.IsNullOrEmpty(source))
                    {
                        if (OperationManager.IgnoreBetPalTimelineSportEventStatus && source.Contains("Timeline") && _ignoreEventsTimelineCache.Contains(eventId.ToString()))
                        {
                            ExecutionLog.LogDebug($"Received SES for {eventId} from {source} with EventStatus:{sportEventStatus.Status} (timeline ignored) {statusOnEvent}");
                            return;
                        }

                        source = $" from {source}";
                    }

                    ExecutionLog.LogDebug($"Received SES for {eventId}{source} with EventStatus:{sportEventStatus.Status}");
                    var cacheItem = _sportEventStatusCache.AddOrGetExisting(
                        eventId.ToString(),
                        sportEventStatus,
                        new CacheItemPolicy
                    {
                        AbsoluteExpiration =
                            DateTimeOffset.Now.AddSeconds(OperationManager.SportEventStatusCacheTimeout.TotalSeconds)
                    })
                                    as SportEventStatusCI;
                    if (cacheItem != null)
                    {
                        cacheItem.SetFeedStatus(sportEventStatus.FeedStatusDTO);
                        cacheItem.SetSapiStatus(sportEventStatus.SapiStatusDTO);
                    }
                }
            }
            else
            {
                ExecutionLog.LogDebug($"Received SES for {eventId} from {source} with EventStatus:{sportEventStatus.Status} (ignored)");
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CompetitionStatus"/> class.
        /// </summary>
        /// <param name="ci">The status cache item</param>
        /// <param name="matchStatusesCache">The <see cref="ILocalizedNamedValueCache"/> used to get match status id and description</param>
        public CompetitionStatus(SportEventStatusCI ci, ILocalizedNamedValueCache matchStatusesCache)
        {
            Guard.Argument(ci, nameof(ci)).NotNull();

            SportEventStatusCI = ci;

            WinnerId        = ci.WinnerId;
            Status          = ci.Status;
            ReportingStatus = ci.ReportingStatus;
            if (ci.EventResults != null)
            {
                EventResults = ci.EventResults.Select(s => new EventResult(s, matchStatusesCache));
            }
            Properties = ci.Properties;
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="CompetitionStatus" /> class.
        /// </summary>
        /// <param name="ci">The status cache item</param>
        /// <param name="matchStatusesCache">
        ///     The <see cref="ILocalizedNamedValueCache" /> used to get match status id and
        ///     description
        /// </param>
        public CompetitionStatus(SportEventStatusCI ci, ILocalizedNamedValueCache matchStatusesCache)
        {
            Contract.Requires(ci != null);

            SportEventStatusCI = ci;

            WinnerId        = ci.WinnerId;
            Status          = ci.Status;
            ReportingStatus = ci.ReportingStatus;
            if (ci.EventResults != null)
            {
                EventResults = ci.EventResults.Select(s => new EventResult(s, matchStatusesCache));
            }
            Properties = ci.Properties;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MatchStatus"/> class
 /// </summary>
 /// <param name="ci">The cache item</param>
 /// <param name="matchStatusesCache">The match statuses cache</param>
 public MatchStatus(SportEventStatusCI ci, ILocalizedNamedValueCache matchStatusesCache)
     : base(ci, matchStatusesCache)
 {
     if (ci.EventClock != null)
     {
         EventClock = new EventClock(ci.EventClock);
     }
     if (ci.PeriodScores != null)
     {
         PeriodScores = ci.PeriodScores.Select(s => new PeriodScore(s, MatchStatusCache));
     }
     _homeScore       = ci.HomeScore;
     _awayScore       = ci.AwayScore;
     HomePenaltyScore = ci.HomePenaltyScore;
     AwayPenaltyScore = ci.AwayPenaltyScore;
     DecidedByFed     = ci.DecidedByFed;
 }
示例#8
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="MatchStatus" /> class
        /// </summary>
        /// <param name="ci">The cache item</param>
        /// <param name="matchStatusesCache">The match statuses cache</param>
        public MatchStatus(SportEventStatusCI ci, ILocalizedNamedValueCache matchStatusesCache)
            : base(ci, matchStatusesCache)
        {
            Contract.Requires(ci != null);
            Contract.Requires(matchStatusesCache != null);

            if (ci.EventClock != null)
            {
                EventClock = new EventClock(ci.EventClock);
            }
            if (ci.PeriodScores != null)
            {
                PeriodScores = ci.PeriodScores.Select(s => new PeriodScore(s, _matchStatusesCache));
            }
            HomeScore           = ci.HomeScore ?? 0;
            AwayScore           = ci.AwayScore ?? 0;
            _matchStatusesCache = matchStatusesCache;
            HomePenaltyScore    = ci.HomePenaltyScore;
            AwayPenaltyScore    = ci.AwayPenaltyScore;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MatchStatus"/> class
        /// </summary>
        /// <param name="ci">The cache item</param>
        /// <param name="matchStatusesCache">The match statuses cache</param>
        public MatchStatus(SportEventStatusCI ci, ILocalizedNamedValueCache matchStatusesCache)
            : base(ci, matchStatusesCache)
        {
            Guard.Argument(ci, nameof(ci)).NotNull();
            Guard.Argument(matchStatusesCache, nameof(matchStatusesCache)).NotNull();

            if (ci.EventClock != null)
            {
                EventClock = new EventClock(ci.EventClock);
            }
            if (ci.PeriodScores != null)
            {
                PeriodScores = ci.PeriodScores.Select(s => new PeriodScore(s, _matchStatusesCache));
            }
            _homeScore          = ci.HomeScore;
            _awayScore          = ci.AwayScore;
            _matchStatusesCache = matchStatusesCache;
            HomePenaltyScore    = ci.HomePenaltyScore;
            AwayPenaltyScore    = ci.AwayPenaltyScore;
            DecidedByFed        = ci.DecidedByFed;
        }
示例#10
0
        /// <summary>
        ///     Adds the sport event status to the internal cache
        /// </summary>
        /// <param name="eventId">The eventId of the sport event status to be cached</param>
        /// <param name="sportEventStatus">The sport event status to be cached</param>
        /// <param name="source">The source of the SES</param>
        private void AddSportEventStatus(URN eventId, SportEventStatusCI sportEventStatus, string source)
        {
            if (_isDisposed)
            {
                return;
            }

            lock (_lock)
            {
                if (string.IsNullOrEmpty(source) ||
                    source.Equals("OddsChange", StringComparison.InvariantCultureIgnoreCase) ||
                    source.Equals("SportEventSummary", StringComparison.InvariantCultureIgnoreCase) ||
                    !_sportEventStatusCache.Contains(eventId.ToString()))
                {
                    if (!string.IsNullOrEmpty(source))
                    {
                        source = $" from {source}";
                    }
                    ExecutionLog.Debug(
                        $"Received SES for {eventId}{source} with EventStatus:{sportEventStatus.Status}");
                    var cacheItem = _sportEventStatusCache.AddOrGetExisting(eventId.ToString(),
                                                                            sportEventStatus,
                                                                            new CacheItemPolicy
                    {
                        AbsoluteExpiration = DateTimeOffset.Now.AddSeconds(_cacheItemExpireTime.TotalSeconds)
                    })
                                    as SportEventStatusCI;
                    if (cacheItem != null)
                    {
                        cacheItem.SetFeedStatus(sportEventStatus.FeedStatusDTO);
                        cacheItem.SetSapiStatus(sportEventStatus.SapiStatusDTO);
                    }
                }
                else
                {
                    ExecutionLog.Debug(
                        $"Received SES for {eventId} from {source} with EventStatus:{sportEventStatus.Status} (ignored)");
                }
            }
        }
示例#11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MatchStatus"/> class
 /// </summary>
 /// <param name="ci">The cache item</param>
 /// <param name="matchStatusesCache">The match statuses cache</param>
 public StageStatus(SportEventStatusCI ci, ILocalizedNamedValueCache matchStatusesCache)
     : base(ci, matchStatusesCache)
 {
 }
示例#12
0
 public void AddSportEventStatus(URN eventId, SportEventStatusCI sportEventStatus)
 {
     Contract.Requires(eventId != null);
     Contract.Requires(sportEventStatus != null);
 }