public DefaultCommand(MessageStatistics statistics, IStatisticsGridView gridView) { Image = Resources.Synchronize_16x16; Text = CultureService.Instance.GetString(CultureText.menuItem_Default_Text); _statistics = statistics; _gridView = gridView; }
/// <summary> /// 统计我的消息 /// </summary> /// <returns></returns> public MessageStatistics StatisticsForMessage() { int count = MessagesAccessor.GetCountFor(ID, false); var result = new MessageStatistics(); result.TotalNoRead = count; return(result); }
public ClearNodeCommand(MessageStatistics statistics) { Image = Resources.Delete32x32; Text = CultureService.Instance.GetString(CultureText.menuItem_Reset_Text); _statistics = statistics; EventAggregator.Instance.Subscribe <TreeViewSelectionChangedAppEvent>(e => { Visible = (e.SelectedNode is MessagesTreeNode); }); }
public DefaultNodeCommand(MessageStatistics statistics, IStatisticsGridView gridView) { Image = Resources.Synchronize_16x16; Text = CultureService.Instance.GetString(CultureText.menuItem_Default_Text); _statistics = statistics; _gridView = gridView; EventAggregator.Instance.Subscribe <TreeViewSelectionChangedAppEvent>(e => { Visible = (e.SelectedNode is MessagesTreeNode); }); }
public void MessageStatistics() { var payload = new MessageStatisticsPayload { MessagesSent = 2, MessagesUnder4KB = 5, TotalFailed = 9 }; var obj = new MessageStatistics(new MessageStatisticsPayload[] { payload }); obj.ValidateSchema(); }
public MessagesTreeNode(MessageStatistics statistics, IAdapterService adapter, ProjectParameters parameters) { _statistics = statistics; _adapter = adapter; _parameters = parameters; Text = CultureService.Instance.GetString(CultureText.node_MessagesStatistics_Text); SelectedImageKey = ImageKey = @"mails16"; EventAggregator.Instance.Subscribe <StorageAppEvent>(e1 => { switch (e1.ChangingType) { case FileChangingType.LoadComplete: { if (e1.Storage.Parameters.MessageStatisticsEnabled) { Text = CultureService.Instance.GetString(CultureText.node_MessagesStatistics_Text); } else { Text = CultureService.Instance.GetString(CultureText.node_MessagesStatistics_Text); Text += string.Format(" [{0}] ", CultureService.Instance.GetString(CultureText.text_DISABLED)); } break; } case FileChangingType.ContentChanged: { if (e1.Details.DataObjects == DataObjects.ParameterProperty && e1.Details.PropertyDescriptor.Name == PropertyPlus.GetPropertyName(() => e1.Storage.Parameters.MessageStatisticsEnabled)) { if (e1.Storage.Parameters.MessageStatisticsEnabled) { Text = CultureService.Instance.GetString(CultureText.node_MessagesStatistics_Text); } else { Text = CultureService.Instance.GetString(CultureText.node_MessagesStatistics_Text); Text += string.Format(" [{0}] ", CultureService.Instance.GetString(CultureText.text_DISABLED)); } } break; }; } }); _statistics.Messages.ListChanged += new ListChangedEventHandler(Messages_ListChanged); }
public AdapterService( MessageTraceCollection tracer, ProjectParameters paramters, IAdapterStatistics adapterStat, MessageStatistics messageStat, Storage project, ToolTableCollection toolTables) { _messageTrace = tracer; _adapterStat = adapterStat; _messageStat = messageStat; _paramters = paramters; _project = project; _toolTables = toolTables; _txQueue = new SafeQueue <CommonCanMessage>(); }
/// <summary> /// Generates telemetry events from the given data /// </summary> /// <param name="counterData"></param> /// <returns></returns> private List <IEvent> GenerateTelemetryEventsFromCounterData(IDictionary <CounterType, int> counterData) { var messageStatsEvent = new MessageStatistics(new[] { new MessageStatisticsPayload { MessagesUnder4KB = counterData[CounterType.MessagesUnder4KB], TotalFailed = counterData[CounterType.SendFailed], MessagesSent = counterData[CounterType.SendSuccesfully] + counterData[CounterType.SendFailed] } }); var droppedEventsEvent = new DroppedEventsStatistics(new[] { new DroppedEventsStatisticsPayload { Queue = EventPriority.High, CollectedEvents = counterData[CounterType.EnqueuedHighPriorityEvent], DroppedEvents = counterData[CounterType.DroppedHighPriorityEvent] }, new DroppedEventsStatisticsPayload { Queue = EventPriority.Low, CollectedEvents = counterData[CounterType.EnqueuedLowPriorityEvent], DroppedEvents = counterData[CounterType.DroppedLowPriorityEvent] }, new DroppedEventsStatisticsPayload { Queue = EventPriority.Operational, CollectedEvents = counterData[CounterType.EnqueuedOperationalEvent], DroppedEvents = counterData[CounterType.DroppedOperationalEvent] } }); return(new List <IEvent> { messageStatsEvent, droppedEventsEvent }); }
public ClearCommand(MessageStatistics statistics) { Image = Resources.Delete32x32; Text = CultureService.Instance.GetString(CultureText.menuItem_Reset_Text); _statistics = statistics; }
public Presenter( IStatisticsGridView gridView, MessageStatistics statistics, Storage project) { gridView.Source = statistics.Messages; gridView.Menu.Items.AddRange( new ToolStripItem[] { new ClearCommand(statistics), new DefaultCommand(statistics, gridView), new EnabledCommand(project), new ExportCommand(project, gridView), }); #region Project események EventAggregator.Instance.Subscribe <StorageAppEvent>(e1 => { switch (e1.ChangingType) { case FileChangingType.Loading: { break; } case FileChangingType.LoadComplete: { project = e1.Storage; gridView.AllowClick = true; gridView.GridLayout = e1.Storage.StatisticsGridLayout; gridView.TimestampFormat = e1.Storage.Parameters.TimestampFormat; if (e1.Storage.Parameters.MessageStatisticsEnabled) { gridView.BackgroundText = CultureService.Instance.GetString(CultureText.text_STATISTICS); } else { gridView.BackgroundText = CultureService.Instance.GetString(CultureText.text_STATISTICS); gridView.BackgroundText += " "; gridView.BackgroundText += CultureService.Instance.GetString(CultureText.text_DISABLED); } gridView.Refresh(); break; } case FileChangingType.Saving: { /*GridLayout hozza létre a default értéket és nem a project File.. ezért * mentés előtt átt kell adni a projectnek a layout listákat.*/ gridView.GridLayout.CopyTo(e1.Storage.StatisticsGridLayout); break; } case FileChangingType.ContentChanged: { /*Célzott frssítések*/ if (e1.Details.DataObjects == DataObjects.ParameterProperty) { if (e1.Details.PropertyDescriptor.Name == PropertyPlus.GetPropertyName(() => e1.Storage.Parameters.ArbitrationIdFormat) || e1.Details.PropertyDescriptor.Name == PropertyPlus.GetPropertyName(() => e1.Storage.Parameters.DataFormat)) { /*Converterek miatt újra kell rajzolni a Grid-et*/ /*Ez kritikus! ha egy sor törlésekor jön egy esemény ami frssíti a DGV-az DGV hibhoz vezet!*/ gridView.Refresh(); } else if (e1.Details.PropertyDescriptor.Name == PropertyPlus.GetPropertyName(() => e1.Storage.Parameters.TimestampFormat)) { gridView.TimestampFormat = e1.Storage.Parameters.TimestampFormat; } else if (e1.Details.PropertyDescriptor.Name == PropertyPlus.GetPropertyName(() => e1.Storage.Parameters.MessageStatisticsEnabled)) { if (e1.Storage.Parameters.MessageStatisticsEnabled) { gridView.BackgroundText = CultureService.Instance.GetString(CultureText.text_STATISTICS); } else { gridView.BackgroundText = CultureService.Instance.GetString(CultureText.text_STATISTICS); gridView.BackgroundText += " "; gridView.BackgroundText += CultureService.Instance.GetString(CultureText.text_DISABLED); } } } break; } } }); #endregion #region Adapter események EventAggregator.Instance.Subscribe <PlayAppEvent>(e => { /*Periodikus frsstés itt indul.*/ gridView.Start(); gridView.RefreshRate = Settings.Default.dataGridViewStatisticsRefreshRateMs; }); EventAggregator.Instance.Subscribe <StopAppEvent>(e => { /*Periodikus frsstés itt leáll.*/ gridView.Stop(); }); #endregion }
protected override void ChannelRead0(IChannelHandlerContext context, P2pMessage message) { Logger.Debug( string.Format("Receive message : {0}", message.Type.ToString())); this.message_quque.ReceivedMessage(message); MessageStatistics message_statistics = this.channel.NodeStatistics.MessageStatistics; switch (message.Type) { case MessageTypes.MsgType.P2P_PING: { int count = message_statistics.P2pInPing.GetCount(10); if (count > 3) { string reason = string.Format("TCP attack found: {0} with ping count({1})", context.Channel.RemoteAddress, count); Logger.Warning(reason); this.channel.Disconnect(Protocol.ReasonCode.BadProtocol, reason); return; } this.message_quque.SendMessage(new PongMessage()); } break; case MessageTypes.MsgType.P2P_PONG: { if (message_statistics.P2pInPong.TotalCount > message_statistics.P2pOutPing.TotalCount) { string reason = string.Format("TCP attack found: {0} with ping count({1}), pong count({2})", context.Channel.RemoteAddress, message_statistics.P2pOutPing.TotalCount, message_statistics.P2pInPong.TotalCount); Logger.Warning(reason); this.channel.Disconnect(Protocol.ReasonCode.BadProtocol, reason); return; } this.has_ping = false; this.channel.NodeStatistics.LastPongReplyTime = Helper.CurrentTimeMillis(); this.channel.PeerStatistics.Pong(this.send_ping_time); } break; case MessageTypes.MsgType.P2P_DISCONNECT: { this.channel.NodeStatistics.NodeDisconnectedRemote(((DisconnectMessage)message).Reason); this.channel.Close(); } break; default: { this.channel.Close(); } break; } }