Example #1
0
        private void listViewHistory_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
        {
            lock (_document.History)
            {
                if ((e.ItemIndex >= 0) && (e.ItemIndex < _document.History.Count))
                {
                    ConnectionHistoryEntry entry = _document.History[e.ItemIndex];

                    ListViewItem item = new ListViewItem(entry.StartTime.ToString());

                    item.SubItems.Add(entry.EndTime.Subtract(entry.StartTime).ToString());
                    item.SubItems.Add(entry.NetworkDescription);
                    item.Tag = entry;

                    e.Item = item;
                }
                else
                {
                    // Return a dummy item
                    ListViewItem item = new ListViewItem("");
                    item.SubItems.Add("");
                    item.SubItems.Add("");
                    e.Item = item;
                }
            }
        }
Example #2
0
        public ConnectionStatisticsForm(ConnectionHistoryEntry entry, LogPacket[] packets)
        {
            InitializeComponent();

            if (entry != null)
            {
                foreach (KeyValuePair <string, object> pair in entry.Properties)
                {
                    ListViewItem item = listViewProperties.Items.Add(pair.Key);
                    item.SubItems.Add(pair.Value.ToString());
                    item.Tag = pair.Value;
                }
            }
            else
            {
                tabControl.TabPages.Remove(tabPageProperties);
            }

            if (packets != null && packets.Length > 0)
            {
                packetLogControl.SetPackets(packets);
                tagStatisticsChartControl.SetPackets(packets);
                histogramChartControl.SetPackets(packets);
                networkTrafficChartControl.SetPackets(packets);
            }
            else
            {
                tabControl.TabPages.Remove(tabPageHistogram);
                tabControl.TabPages.Remove(tabPagePackets);
                tabControl.TabPages.Remove(tabPageTagStatistics);
                tabControl.TabPages.Remove(tabPageNetworkTraffic);
            }
        }
Example #3
0
        private void CloseConnection(ConnectionEntry entry)
        {
            NetGraph graph = entry.Graph;

            lock (entry)
            {
                if (!graph.IsDisposed)
                {
                    ConnectionHistoryEntry history = new ConnectionHistoryEntry(graph.NetworkDescription, graph.Uuid, graph.Created, DateTime.Now);
                    bool noConnections             = false;

                    foreach (KeyValuePair <string, object> pair in graph.ConnectionProperties)
                    {
                        if (pair.Value.GetType().IsSerializable)
                        {
                            history.Properties[pair.Key] = pair.Value;
                        }
                    }

                    try
                    {
                        entry.Dispose();
                    }
                    catch
                    {
                        // Shouldn't throw but just in case
                    }

                    lock (_history)
                    {
                        _history.Add(history);
                    }

                    lock (_connections)
                    {
                        _connections.Remove(entry);
                        if (_connections.Count == 0)
                        {
                            noConnections = true;
                        }
                    }

                    if (CloseConnectionEvent != null)
                    {
                        CloseConnectionEvent(this, new ConnectionEventArgs(graph));
                    }

                    if (_logger != null)
                    {
                        _logger.LogVerbose(CANAPE.Net.Properties.Resources.NetworkServiceBase_ConnectionClosed, graph.NetworkDescription);
                    }

                    if ((_state == (int)ServiceState.StopPending) && noConnections)
                    {
                        CompleteStop();
                    }
                }
            }
        }
Example #4
0
        private void viewStatisticsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ConnectionHistoryEntry entry = GetSelectedEntry();

            if (entry != null)
            {
                LogPacket[] packets = _document.Packets.GetPacketsForNetwork(entry.NetId);

                ConnectionStatisticsForm frm = new ConnectionStatisticsForm(entry, packets);

                frm.Show();
            }
        }
Example #5
0
        private void viewPacketsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ConnectionHistoryEntry entry = GetSelectedEntry();

            if (entry != null)
            {
                LogPacket[] packets = _document.Packets.GetPacketsForNetwork(entry.NetId);
                if (packets.Length > 0)
                {
                    PacketLogViewerForm frm = new PacketLogViewerForm(packets[0], packets);

                    components.Add(frm);

                    frm.Show();
                }
                else
                {
                    MessageBox.Show(this, Properties.Resources.ConnectionHistoryControl_NoPackets,
                                    Properties.Resources.MessageBox_ErrorString, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }