Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -306,15 +306,15 @@ 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))
FileHelper.CreateDicrectoriesIfNotExist(directory);

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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -85,6 +86,51 @@ 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 (simplified version for safety)
try
{
var userName = string.Empty;
try
{
userName = HttpContext.Current?.User?.Identity?.Name;
}
catch { }

if (!string.IsNullOrEmpty(userName))
{
datasetModel.DownloadedBy = userName;
}
else
{
datasetModel.DownloadedBy = "anonymous";
}
}
catch (Exception)
{
datasetModel.DownloadedBy = "anonymous";
}

return datasetModel;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public class ApiDatasetModel
public Dictionary<string, Dictionary<string, string>> 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()
{
Expand Down