private void AddCompetitor(ExportableCompetitorCI item)
 {
     if (_cache.Contains(item.Id))
     {
         try
         {
             var ci = (CompetitorCI)_cache.Get(item.Id);
             _semaphoreCacheMerge.Wait();
             ci?.Import(item);
         }
         catch (Exception ex)
         {
             ExecutionLog.LogError($"Error importing competitor for id={item.Id}.", ex);
         }
         finally
         {
             if (!_isDisposed)
             {
                 _semaphoreCacheMerge.Release();
             }
         }
     }
     else
     {
         _cache.Add(item.Id, new CompetitorCI(item, _dataRouterManager), GetCorrectCacheItemPolicy(URN.Parse(item.Id)));
     }
 }
Esempio n. 2
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)
        {
            Names                = new Dictionary <CultureInfo, string>(exportable.Name);
            _countryNames        = new Dictionary <CultureInfo, string>(exportable.CountryNames);
            _abbreviations       = new Dictionary <CultureInfo, string>(exportable.Abbreviations);
            _associatedPlayerIds = new List <URN>(exportable.AssociatedPlayerIds.Select(URN.Parse));
            _isVirtual           = exportable.IsVirtual;
            _referenceId         = new ReferenceIdCI(exportable.ReferenceIds);
            _jerseys             = new List <JerseyCI>(exportable.Jerseys.Select(j => new JerseyCI(j)));
            _countryCode         = exportable.CountryCode;
            _state               = exportable.State;
            _manager             = exportable.Manager != null ? new ManagerCI(exportable.Manager) : null;
            _venue               = exportable.Venue != null ? new VenueCI(exportable.Venue) : null;
            _gender              = exportable.Gender;
            _ageGroup            = exportable.AgeGroup;
            _fetchedCultures     = new List <CultureInfo>(exportable.FetchedCultures);
            _primaryCulture      = exportable.PrimaryCulture;
            _raceDriverProfile   = exportable.RaceDriverProfile != null ? new RaceDriverProfileCI(exportable.RaceDriverProfile) : null;
            _referenceId         = new ReferenceIdCI(exportable.ReferenceIds);
            _lastTimeCompetitorProfileFetched = DateTime.MinValue;
            if (exportable.LastTimeCompetitorProfileIsFetched.HasValue)
            {
                _lastTimeCompetitorProfileFetched = exportable.LastTimeCompetitorProfileIsFetched.Value;
            }
            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;
        }
Esempio n. 3
0
 private void AddCompetitor(ExportableCompetitorCI item)
 {
     if (_cache.Contains(item.Id))
     {
         var itemId = URN.Parse(item.Id);
         try
         {
             var ci = (CompetitorCI)_cache.Get(item.Id);
             WaitTillIdIsAvailable(_mergeUrns, itemId);
             ci?.Import(item);
         }
         catch (Exception ex)
         {
             ExecutionLog.LogError(ex, $"Error importing competitor for id={item.Id}.");
         }
         finally
         {
             if (!_isDisposed)
             {
                 ReleaseId(_mergeUrns, itemId);
             }
         }
     }
     else
     {
         if (!string.IsNullOrEmpty(item.Id))
         {
             _cache.Add(item.Id, new CompetitorCI(item, _dataRouterManager), GetCorrectCacheItemPolicy(URN.Parse(item.Id)));
         }
     }
 }
Esempio n. 4
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>
        /// <param name="dataRouterManager">The <see cref="IDataRouterManager"/> used to fetch <see cref="CompetitorDTO"/></param>
        internal CompetitorCI(ExportableCompetitorCI exportable, IDataRouterManager dataRouterManager)
            : base(exportable)
        {
            _dataRouterManager = dataRouterManager ?? throw new ArgumentNullException(nameof(dataRouterManager));

            Import(exportable);
        }
        /// <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);
            }
        }