/// <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); } }
public void Describe_Bytes_Formats_Bytes_Correctly() { var worksheet = new ExcelWorksheetData(TestContext); using (var switcher = new CultureSwitcher(worksheet.String("Region"))) { Assert.AreEqual(worksheet.String("Description"), Describe.Bytes(worksheet.Long("Bytes"))); } }
/// <summary> /// Displays the clients and sessions passed across. /// </summary> /// <param name="clients"></param> /// <param name="sessions"></param> public void Populate(IEnumerable <LogClient> clients, IEnumerable <LogSession> sessions) { listView.Items.Clear(); if (sessions != null) { foreach (LogSession session in sessions) { LogClient client = clients.Where(c => c.Id == session.ClientId).FirstOrDefault(); if (client != null) { List <string> subItems = new List <string>(); subItems.Add(session.StartTime.ToLocalTime().ToString()); if (_ShowClientDetails) { subItems.Add(client.IpAddress); subItems.Add(client.IsLocal ? Strings.Local : Strings.Internet); } subItems.Add(session.UserName ?? ""); subItems.Add(Describe.TimeSpan(session.Duration)); subItems.Add(String.Format("{0:N0}", session.CountRequests)); subItems.Add(Describe.Bytes(session.TotalBytesSent)); subItems.Add(Describe.Bytes(session.HtmlBytesSent)); subItems.Add(Describe.Bytes(session.JsonBytesSent)); subItems.Add(Describe.Bytes(session.ImageBytesSent)); subItems.Add(Describe.Bytes(session.AudioBytesSent)); subItems.Add(Describe.Bytes(session.OtherBytesSent)); ListViewItem item = new ListViewItem(subItems.ToArray()); item.Tag = new ClientAndSession() { Client = client, Session = session }; listView.Items.Add(item); } } } }