From 57acc97e1f9d76c2edbb4eeabae4ea3dd635bb77 Mon Sep 17 00:00:00 2001 From: Ian C Date: Wed, 27 Mar 2024 18:58:09 +0000 Subject: Updated for new download table format. --- Download.cs | 8 +++----- Pages/Report.cshtml | 16 ++++++++++------ Pages/Report.cshtml.cs | 7 +++---- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Download.cs b/Download.cs index ff0f3ce..eda8967 100644 --- a/Download.cs +++ b/Download.cs @@ -19,15 +19,13 @@ namespace download_admin; public class Download { public string Key {get; private set;} - public string IpAddress {get; private set;} - public string UserAgent {get; private set;} + public string[] Info {get; private set;} public DateTime Time {get; private set;} - public Download(string key, string ip_address, string user_agent, DateTime time) + public Download(string key, string[] info, DateTime time) { Key = key; - IpAddress = ip_address; - UserAgent = user_agent; + Info = info; Time = time; } } diff --git a/Pages/Report.cshtml b/Pages/Report.cshtml index ed7dbfa..624d61f 100644 --- a/Pages/Report.cshtml +++ b/Pages/Report.cshtml @@ -26,18 +26,22 @@ - - - - + + + @foreach(Download obj in Model.Rows) { - - + }
TimeKeyIP AddressUser AgentTimeKeyInfo
@obj.Time @obj.Key@obj.IpAddress@obj.UserAgent + @foreach (string s in obj.Info) + { + @s +
+ } +
\ No newline at end of file diff --git a/Pages/Report.cshtml.cs b/Pages/Report.cshtml.cs index 365041f..76cfabf 100644 --- a/Pages/Report.cshtml.cs +++ b/Pages/Report.cshtml.cs @@ -36,17 +36,16 @@ public class ReportModel : PageModel conn.Open(); - using var cmd = new NpgsqlCommand("SELECT key, ip_address, user_agent, time FROM download ORDER BY time", conn); + using var cmd = new NpgsqlCommand("SELECT key, info, time FROM download ORDER BY time", conn); using var reader = cmd.ExecuteReader(); while(reader.Read()) { string key = (string)reader["key"]; - string ip_address = (string)reader["ip_address"]; - string user_agent = (string)reader["user_agent"]; + string[] info = (string[])reader["info"]; DateTime time = (DateTime)reader["time"]; - Rows.Add(new Download(key, ip_address, user_agent, time)); + Rows.Add(new Download(key, info, time)); } } catch(Exception e) -- cgit v1.2.3