コード例 #1
0
 private void _connectionReceive_StatisticsUpdated(object sender, StatisticsEventArgs e)
 {
     App.Current.Dispatcher.Invoke((Action)(() =>
     {
         StatisticsUpdated?.Invoke(sender, e);
     }));
 }
コード例 #2
0
ファイル: SummaryViewModel.cs プロジェクト: JontyMC/ravendb
        void IHandle <StatisticsUpdated> .Handle(StatisticsUpdated message)
        {
            if (!message.HasDocumentCountChanged)
            {
                return;
            }

            RetrieveSummary();
        }
コード例 #3
0
        private void Status(Cache cache)
        {
            if ((DateTime.UtcNow - _lastStatusCheck).TotalMilliseconds < Settings.Instance.StatusInterval)
            {
                return;
            }

            _lastStatusCheck = DateTime.UtcNow;

            // Сообщим всем наши данные
            var contactSelf = new Contact()
            {
                ID                = Settings.Instance.PublicKey,
                Name              = Settings.Instance.Name,
                Version           = Settings.Version,
                LastOnline        = _lastStatusCheck,
                RequireEncryption = Settings.Instance.RequireEncryption
            };

            byte[]   profileBytes = Helpers.SerializeToStream(contactSelf).ToArray();
            DateTime start        = DateTime.Now;

            cache.Set("#PROFILE#" + contactSelf.ID, profileBytes, Settings.Instance.LifetimeInterval, TIMEOUT);
            double lag = (DateTime.Now - start).TotalMilliseconds;

            // Соберем профили всех пользователей онлайн
            var contacts = new List <Contact>();
            var profiles = cache.BatchGet("#PROFILE#", TIMEOUT);

            if (profiles != null)
            {
                foreach (var profile in profiles)
                {
                    if (profile.Value == null)
                    {
                        continue;
                    }

                    using (var ms = new MemoryStream(profile.Value))
                        contacts.Add((Contact)Helpers.DeserializeFromStream(ms));
                }
            }

            ContactsUpdated?.Invoke(this, new ContactsUpdatedEventArgs(contacts.ToArray()));
            StatisticsUpdated?.Invoke(this, new StatisticsEventArgs(lag));
        }
コード例 #4
0
 /// <summary>
 ///     Invokes the <see cref="StatisticsUpdated"/> event asynchronously. (Can be override
 ///     for event catching)
 /// </summary>
 /// <param name="eventArgs">the event arguments</param>
 /// <returns>a task that represents the asynchronous operation</returns>
 protected virtual Task OnStatisticsUpdateAsync(NodeStatisticsUpdateEventArgs eventArgs)
 => StatisticsUpdated.InvokeAsync(this, eventArgs);
コード例 #5
0
 /// <summary>
 /// Fires the statistics updated event.
 /// </summary>
 protected virtual void OnStatisticsUpdated()
 {
     StatisticsUpdated?.Invoke(this, new StatisticalEventArgs(_scheme.Statistics));
 }
コード例 #6
0
 protected virtual void OnStatisticsUpdated(StatisticOperation operation, Statistic stat)
 {
     ReloadStatistics(operation, stat);
     StatisticsUpdated?.Invoke(this, new StatisticsUpdatedEventArgs(operation, stat));
 }