示例#1
0
        /// <summary>
        /// Populates the control with a list of clients.
        /// </summary>
        /// <param name="clients"></param>
        /// <param name="sessionMap"></param>
        public void Populate(IList <LogClient> clients, IDictionary <long, IList <LogSession> > sessionMap)
        {
            listView.Items.Clear();

            foreach (LogClient client in clients)
            {
                IList <LogSession> sessions;
                if (!sessionMap.TryGetValue(client.Id, out sessions))
                {
                    sessions = new List <LogSession>();
                }
                ClientAndSessions tag = new ClientAndSessions()
                {
                    Client = client, Sessions = sessions
                };
                ListViewItem item = new ListViewItem(new string[] {
                    client.IpAddress,
                    client.IsLocal ? Strings.Local : Strings.Internet,
                    client.ReverseDns,
                    tag.FirstSession.ToLocalTime().ToString(),
                    tag.LastSession.ToLocalTime().ToString(),
                    String.Format("{0:N0}", sessions.Count),
                    Describe.TimeSpan(tag.TotalDuration),
                    Describe.Bytes(tag.TotalBytesSent)
                });
                item.Tag = tag;
                listView.Items.Add(item);
            }
        }
示例#2
0
        /// <summary>
        /// Returns the list view row corresponding to the client passed across or null if no such row exists.
        /// </summary>
        /// <param name="client"></param>
        /// <returns></returns>
        private ListViewItem FindItem(LogClient client)
        {
            ListViewItem result = null;

            foreach (ListViewItem item in listView.Items)
            {
                ClientAndSessions tag = (ClientAndSessions)item.Tag;
                if (tag.Client == client)
                {
                    result = item;
                    break;
                }
            }

            return(result);
        }