예제 #1
0
        private static void LogInit()
        {
            var msg    = "MtsSdk initialization. Version: " + SdkInfo.GetVersion();
            var logger = SdkLoggerFactory.GetLoggerForFeedTraffic(typeof(MtsSdk));

            logger.LogInformation(msg);
            logger = SdkLoggerFactory.GetLoggerForCache(typeof(MtsSdk));
            logger.LogInformation(msg);
            logger = SdkLoggerFactory.GetLoggerForClientInteraction(typeof(MtsSdk));
            logger.LogInformation(msg);
            logger = SdkLoggerFactory.GetLoggerForRestTraffic(typeof(MtsSdk));
            logger.LogInformation(msg);
            logger = SdkLoggerFactory.GetLoggerForStats(typeof(MtsSdk));
            logger.LogInformation(msg);
            logger = SdkLoggerFactory.GetLoggerForExecution(typeof(MtsSdk));
            logger.LogInformation(msg);
        }
예제 #2
0
        private void LogInit()
        {
            var msg    = "UF SDK .NET initialization. Version: " + SdkInfo.GetVersion();
            var logger = SdkLoggerFactory.GetLoggerForFeedTraffic(typeof(Feed));

            logger.Info(msg);
            logger = SdkLoggerFactory.GetLoggerForCache(typeof(Feed));
            logger.Info(msg);
            logger = SdkLoggerFactory.GetLoggerForClientInteraction(typeof(Feed));
            logger.Info(msg);
            logger = SdkLoggerFactory.GetLoggerForRestTraffic(typeof(Feed));
            logger.Info(msg);
            logger = SdkLoggerFactory.GetLoggerForExecution(typeof(Feed));
            logger.Info(msg);
            logger = SdkLoggerFactory.GetLoggerForStats(typeof(Feed));
            logger.Info(msg);
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SportEvent"/> class
        /// </summary>
        /// <param name="id">A <see cref="URN"/> uniquely identifying the sport event</param>
        /// <param name="sportId">A <see cref="URN"/> identifying the sport current instance belong to</param>
        /// <param name="executionLog">The <see cref="ILog"/> instance used for execution logging</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> instance containing <see cref="SportEventCI"/></param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying how the instance will handle potential exceptions</param>
        public SportEvent(URN id,
                          URN sportId,
                          ILog executionLog,
                          ISportEventCache sportEventCache,
                          IEnumerable <CultureInfo> cultures,
                          ExceptionHandlingStrategy exceptionStrategy)
        {
            Guard.Argument(id, nameof(id)).NotNull();
            Guard.Argument(sportEventCache, nameof(sportEventCache)).NotNull();
            Guard.Argument(cultures, nameof(cultures)).NotNull().NotEmpty();

            Id                = id;
            SportId           = sportId;
            ExecutionLog      = executionLog ?? SdkLoggerFactory.GetLoggerForExecution(typeof(SportEvent));
            ExceptionStrategy = exceptionStrategy;
            Cultures          = cultures;
            SportEventCache   = sportEventCache;
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Feed"/> class
        /// </summary>
        /// <param name="config">A <see cref="IOddsFeedConfiguration"/> instance representing feed configuration</param>
        /// <param name="isReplay">Value indicating whether the constructed instance will be used to connect to replay server</param>
        protected Feed(IOddsFeedConfiguration config, bool isReplay)
        {
            Guard.Argument(config, nameof(config)).NotNull();

            FeedInitialized = false;

            UnityContainer = new UnityContainer();
            UnityContainer.RegisterBaseTypes(config);
            InternalConfig = UnityContainer.Resolve <IOddsFeedConfigurationInternal>();
            if (isReplay || InternalConfig.Environment == SdkEnvironment.Replay)
            {
                InternalConfig.EnableReplayServer();
            }

            _log = SdkLoggerFactory.GetLoggerForExecution(typeof(Feed));

            LogInit();
        }
예제 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SportEvent"/> class
        /// </summary>
        /// <param name="id">A <see cref="URN"/> uniquely identifying the sport event</param>
        /// <param name="sportId">A <see cref="URN"/> identifying the sport current instance belong to</param>
        /// <param name="executionLog">The <see cref="ILog"/> instance used for execution logging</param>
        /// <param name="sportEventCache">A <see cref="ISportEventCache"/> instance containing <see cref="SportEventCI"/></param>
        /// <param name="cultures">A <see cref="IEnumerable{CultureInfo}"/> specifying languages the current instance supports</param>
        /// <param name="exceptionStrategy">A <see cref="ExceptionHandlingStrategy"/> enum member specifying how the instance will handle potential exceptions</param>
        public SportEvent(URN id,
                          URN sportId,
                          ILog executionLog,
                          ISportEventCache sportEventCache,
                          IEnumerable <CultureInfo> cultures,
                          ExceptionHandlingStrategy exceptionStrategy)
        {
            Contract.Requires(id != null);
            Contract.Requires(sportEventCache != null);
            Contract.Requires(cultures != null && cultures.Any());

            Id                = id;
            SportId           = sportId;
            ExecutionLog      = executionLog ?? SdkLoggerFactory.GetLoggerForExecution(typeof(SportEvent));
            ExceptionStrategy = exceptionStrategy;
            Cultures          = cultures;
            SportEventCache   = sportEventCache;
        }
예제 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CompetitorCI"/> class
        /// </summary>
        /// <param name="exportable">A <see cref="ExportableCompetitorCI"/> containing information about the sport entity</param>
        internal void Import(ExportableCompetitorCI exportable)
        {
            try
            {
                Names                = exportable.Name.IsNullOrEmpty() ? new Dictionary <CultureInfo, string>() : new Dictionary <CultureInfo, string>(exportable.Name);
                _countryNames        = exportable.CountryNames.IsNullOrEmpty() ? new Dictionary <CultureInfo, string>() : new Dictionary <CultureInfo, string>(exportable.CountryNames);
                _abbreviations       = exportable.Abbreviations.IsNullOrEmpty() ? new Dictionary <CultureInfo, string>() : new Dictionary <CultureInfo, string>(exportable.Abbreviations);
                _associatedPlayerIds = exportable.AssociatedPlayerIds.IsNullOrEmpty() ? new List <URN>() : new List <URN>(exportable.AssociatedPlayerIds.Select(URN.Parse));
                _isVirtual           = exportable.IsVirtual;
                _referenceId         = exportable.ReferenceIds.IsNullOrEmpty() ? null : new ReferenceIdCI(exportable.ReferenceIds);
                _jerseys             = exportable.Jerseys.IsNullOrEmpty() ? new List <JerseyCI>() : new List <JerseyCI>(exportable.Jerseys.Select(j => new JerseyCI(j)));
                _countryCode         = exportable.CountryCode;
                _state               = exportable.State;
                _manager             = exportable.Manager == null ? null : new ManagerCI(exportable.Manager);
                _venue               = exportable.Venue == null ? null : new VenueCI(exportable.Venue);
                _gender              = exportable.Gender;
                _ageGroup            = exportable.AgeGroup;
                _fetchedCultures     = exportable.FetchedCultures.IsNullOrEmpty() ? new List <CultureInfo>() : new List <CultureInfo>(exportable.FetchedCultures);
                _primaryCulture      = exportable.PrimaryCulture;
                _raceDriverProfile   = exportable.RaceDriverProfile == null ? null : new RaceDriverProfileCI(exportable.RaceDriverProfile);
                _referenceId         = exportable.ReferenceIds.IsNullOrEmpty() ? null : new ReferenceIdCI(exportable.ReferenceIds);
                _lastTimeCompetitorProfileFetched = DateTime.MinValue;
                if (exportable.LastTimeCompetitorProfileIsFetched.HasValue)
                {
                    _lastTimeCompetitorProfileFetched = exportable.LastTimeCompetitorProfileIsFetched.Value;
                }
                _cultureCompetitorProfileFetched = new List <CultureInfo>();
                if (exportable.CultureCompetitorProfileFetched != null)
                {
                    _cultureCompetitorProfileFetched = exportable.CultureCompetitorProfileFetched.ToList();
                }
                _sportId = exportable.SportId != null?URN.Parse(exportable.SportId) : null;

                _categoryId = exportable.CategoryId != null?URN.Parse(exportable.CategoryId) : null;

                _shortName = exportable.ShortName;
            }
            catch (Exception e)
            {
                SdkLoggerFactory.GetLoggerForExecution(typeof(CompetitorCI)).Error("Importing CompetitorCI", e);
            }
        }
예제 #7
0
        private void LogInit()
        {
            var msg    = "UF SDK .NET Core initialization. Version: " + SdkInfo.GetVersion();
            var logger = SdkLoggerFactory.GetLoggerForExecution(typeof(Feed));

            if (logger == null)
            {
                return;
            }
            logger.Log(SdkLoggerFactory.GetWriteLogLevel(logger, LogLevel.Information), $"{msg}. LogLevel: {SdkLoggerFactory.GetLoggerLogLevel(logger)}");
            logger = SdkLoggerFactory.GetLoggerForCache(typeof(Feed));
            logger.Log(SdkLoggerFactory.GetWriteLogLevel(logger, LogLevel.Information), $"{msg}. LogLevel: {SdkLoggerFactory.GetLoggerLogLevel(logger)}");
            logger = SdkLoggerFactory.GetLoggerForClientInteraction(typeof(Feed));
            logger.Log(SdkLoggerFactory.GetWriteLogLevel(logger, LogLevel.Information), $"{msg}. LogLevel: {SdkLoggerFactory.GetLoggerLogLevel(logger)}");
            logger = SdkLoggerFactory.GetLoggerForRestTraffic(typeof(Feed));
            logger.Log(SdkLoggerFactory.GetWriteLogLevel(logger, LogLevel.Information), $"{msg}. LogLevel: {SdkLoggerFactory.GetLoggerLogLevel(logger)}");
            logger = SdkLoggerFactory.GetLoggerForFeedTraffic(typeof(Feed));
            logger.Log(SdkLoggerFactory.GetWriteLogLevel(logger, LogLevel.Information), $"{msg}. LogLevel: {SdkLoggerFactory.GetLoggerLogLevel(logger)}");
            logger = SdkLoggerFactory.GetLoggerForStats(typeof(Feed));
            logger.Log(SdkLoggerFactory.GetWriteLogLevel(logger, LogLevel.Information), $"{msg}. LogLevel: {SdkLoggerFactory.GetLoggerLogLevel(logger)}");
        }
예제 #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Feed"/> class
        /// </summary>
        /// <param name="config">A <see cref="IOddsFeedConfiguration"/> instance representing feed configuration</param>
        /// <param name="isReplay">Value indicating whether the constructed instance will be used to connect to replay server</param>
        /// <param name="loggerFactory">A <see cref="ILoggerFactory"/> used to create <see cref="ILogger"/> used within sdk</param>
        /// <param name="metricsRoot">A <see cref="IMetricsRoot"/> used to provide metrics within sdk</param>
        protected Feed(IOddsFeedConfiguration config, bool isReplay, ILoggerFactory loggerFactory = null, IMetricsRoot metricsRoot = null)
        {
            Guard.Argument(config, nameof(config)).NotNull();

            FeedInitialized = false;

            UnityContainer = new UnityContainer();
            UnityContainer.RegisterBaseTypes(config, loggerFactory, metricsRoot);
            InternalConfig = UnityContainer.Resolve <IOddsFeedConfigurationInternal>();
            if (isReplay || InternalConfig.Environment == SdkEnvironment.Replay)
            {
                InternalConfig.EnableReplayServer();
            }

            _log = SdkLoggerFactory.GetLoggerForExecution(typeof(Feed));

            LogInit();

            MetricsRoot           = UnityContainer.Resolve <IMetricsRoot>();
            _metricsLogger        = SdkLoggerFactory.GetLoggerForStats(typeof(Feed));
            _metricsTaskScheduler = new AppMetricsTaskScheduler(TimeSpan.FromSeconds(InternalConfig.StatisticsTimeout), async() => await LogMetricsAsync().ConfigureAwait(false));
        }