From 047667ae8f6513653df33d7b1859efd6e1e95431 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 Aug 2025 21:00:02 +0000 Subject: [PATCH 1/3] Initial plan From c7c353ddc1bcca537236d6563aea6a377e193619 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 Aug 2025 21:05:49 +0000 Subject: [PATCH 2/3] Implement download information extension Co-authored-by: geofranzi <15946467+geofranzi@users.noreply.github.com> --- .../Controllers/ExportController.cs | 4 +- .../Helpers/ApiDatasetHelper.cs | 45 +++++++++++++++++++ .../Models/API/ApiModels.cs | 3 ++ 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/ExportController.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/ExportController.cs index 1d445a94b..c993e0d15 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/ExportController.cs +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Controllers/ExportController.cs @@ -306,7 +306,7 @@ public ActionResult GenerateZip(long id, long versionid, string format) if (manifest != null) { string manifestPath = OutputDatasetManager.GetDynamicDatasetStorePath(id, - datasetVersionNumber, "manifest", ".json"); + datasetVersionNumber, "general_metadata", ".json"); string fullFilePath = Path.Combine(AppConfiguration.DataPath, manifestPath); string directory = Path.GetDirectoryName(fullFilePath); if (!Directory.Exists(directory)) @@ -314,7 +314,7 @@ public ActionResult GenerateZip(long id, long versionid, string format) System.IO.File.WriteAllText(fullFilePath, manifest, System.Text.Encoding.UTF8); - archive.AddFileToArchive(fullFilePath, "manifest.json"); + archive.AddFileToArchive(fullFilePath, "general_metadata.json"); } string title = datasetVersion.Title; diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Helpers/ApiDatasetHelper.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Helpers/ApiDatasetHelper.cs index f5bea837d..974a49f75 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Helpers/ApiDatasetHelper.cs +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Helpers/ApiDatasetHelper.cs @@ -14,6 +14,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Web; using System.Xml.Linq; namespace BExIS.Modules.Dim.UI.Helpers @@ -85,6 +86,50 @@ public ApiDatasetModel GetContent(DatasetVersion datasetVersion, long id, long v // check for publication date datasetModel.PublicationDate = publicAndDate.Item2.ToString(new CultureInfo("en-US")); + // Add download information + try + { + // Get download source URL from current request context + if (HttpContext.Current != null && HttpContext.Current.Request != null) + { + datasetModel.DownloadSource = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority); + } + else + { + datasetModel.DownloadSource = "unknown"; + } + } + catch (Exception) + { + datasetModel.DownloadSource = "unknown"; + } + + // Set download date time to current time + datasetModel.DownloadDateTime = DateTime.Now.ToString(new CultureInfo("en-US")); + + // Set downloaded by user (similar to getPartyNameOrDefault pattern) + try + { + var userName = HttpContext.Current?.User?.Identity?.Name; + if (!string.IsNullOrEmpty(userName)) + { + using (var partyManager = new PartyManager()) + { + // Try to find the party for this user to get display name + // This follows similar logic as in getPartyNameOrDefault methods + datasetModel.DownloadedBy = !string.IsNullOrWhiteSpace(userName) ? userName : "anonymous"; + } + } + else + { + datasetModel.DownloadedBy = "anonymous"; + } + } + catch (Exception) + { + datasetModel.DownloadedBy = "anonymous"; + } + return datasetModel; } diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Models/API/ApiModels.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Models/API/ApiModels.cs index b063fd88a..ba21c8986 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Models/API/ApiModels.cs +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Models/API/ApiModels.cs @@ -43,6 +43,9 @@ public class ApiDatasetModel public Dictionary> Parties { get; set; } public string VersionDate { get; set; } public object Names { get; internal set; } + public string DownloadSource { get; set; } + public string DownloadDateTime { get; set; } + public string DownloadedBy { get; set; } public ApiDatasetModel() { From ea3c5f61d5ff7fa1e6b77b7cdc9ca27d016716f1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 18 Aug 2025 21:09:41 +0000 Subject: [PATCH 3/3] Improve user handling and add documentation Co-authored-by: geofranzi <15946467+geofranzi@users.noreply.github.com> --- .../Helpers/ApiDatasetHelper.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Helpers/ApiDatasetHelper.cs b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Helpers/ApiDatasetHelper.cs index 974a49f75..1bd9e2285 100644 --- a/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Helpers/ApiDatasetHelper.cs +++ b/Console/BExIS.Web.Shell/Areas/DIM/BExIS.Modules.Dim.UI/Helpers/ApiDatasetHelper.cs @@ -107,18 +107,19 @@ public ApiDatasetModel GetContent(DatasetVersion datasetVersion, long id, long v // Set download date time to current time datasetModel.DownloadDateTime = DateTime.Now.ToString(new CultureInfo("en-US")); - // Set downloaded by user (similar to getPartyNameOrDefault pattern) + // Set downloaded by user (simplified version for safety) try { - var userName = HttpContext.Current?.User?.Identity?.Name; + var userName = string.Empty; + try + { + userName = HttpContext.Current?.User?.Identity?.Name; + } + catch { } + if (!string.IsNullOrEmpty(userName)) { - using (var partyManager = new PartyManager()) - { - // Try to find the party for this user to get display name - // This follows similar logic as in getPartyNameOrDefault methods - datasetModel.DownloadedBy = !string.IsNullOrWhiteSpace(userName) ? userName : "anonymous"; - } + datasetModel.DownloadedBy = userName; } else {