Exemplo n.º 1
0
        public object Clone()
        {
            var cpi = new CompanyProfile
            {
                Id              = Id,
                Name            = Name,
                Street          = Street,
                City            = City,
                State           = State,
                Zip             = Zip,
                Country         = Country,
                TaxCode         = TaxCode,
                VatCode         = VatCode,
                Email           = Email,
                Web             = Web,
                Phone           = Phone,
                Mobile          = Mobile,
                Note            = Note,
                ContactName     = ContactName,
                ContactEmail    = ContactEmail,
                ContactPhone    = ContactPhone,
                ProfileRate     = (CompanyProfileRate)ProfileRate.Clone(),
                ComparerOptions = (ComparerSettings)ComparerOptions.Clone(),
                MetricGroup     = (QualityMetricGroup)MetricGroup.Clone()
            };



            return(cpi);
        }
Exemplo n.º 2
0
        public async Task IncrementAsync(ImdbType type, Profile profile)
        {
            State.Count++;

            var rate = new ProfileRate(profile, State.Count);

            var id    = new ActorId(type.ToString());
            var proxy = ActorProxy.Create <IImdbTopRated>(id);
            await proxy.OferCandidateAsync(rate);

            #region Log

            var logId    = Constants.Singleton;
            var logProxy = ActorProxy.Create <IImdbFaults>(logId);
            await logProxy.Report($"{profile.Name} Counter: {State.Count}");

            #endregion // Log
        }
Exemplo n.º 3
0
        public async Task OferCandidateAsync(ProfileRate profile)
        {
            ProfileRate existing = _topItems.FirstOrDefault(m => m.Name == profile.Name);

            if (existing != null)
            {
                existing.Count++; // increment the item which already in the state
                Publish();
                return;
            }

            ProfileRate barierProfile = _topItems
                                        .OrderBy(m => m.Count)
                                        .FirstOrDefault();
            int barier = barierProfile?.Count ?? 0;

            if (_topItems.Count == LIMIT && profile.Count <= barier)
            {
                return;
            }

            _topItems.Add(profile);

            if (_topItems.Count > LIMIT)
            {
                var removeCandidate =
                    _topItems.OrderBy(m => m.Count)
                    .First();
                _topItems.Remove(removeCandidate);
            }

            State = _topItems.OrderByDescending(m => m.Count)
                    .ToArray();

            Publish();

            #region Log

            var logId    = Constants.Singleton;
            var logProxy = ActorProxy.Create <IImdbFaults>(logId);
            await logProxy.Report($"Top {_type}");

            #endregion // Log
        }