diff --git a/server/AyaNova/Controllers/AttachmentController.cs b/server/AyaNova/Controllers/AttachmentController.cs index 2985f7db..30ae1876 100644 --- a/server/AyaNova/Controllers/AttachmentController.cs +++ b/server/AyaNova/Controllers/AttachmentController.cs @@ -221,7 +221,7 @@ namespace AyaNova.Api.Controllers { foreach (UploadedFileInfo a in uploadFormData.UploadedFiles) { - var v = await FileUtil.StoreFileAttachmentAsync(a.InitialUploadedPathName, a.MimeType, a.OriginalFileName, attachToObject, ct); + var v = await FileUtil.StoreFileAttachmentAsync(a.InitialUploadedPathName, a.MimeType, a.OriginalFileName, a.LastModified, attachToObject, ct); returnList.Add(new NameIdItem() { Name = v.DisplayFileName, diff --git a/server/AyaNova/models/FileAttachment.cs b/server/AyaNova/models/FileAttachment.cs index 975de2e7..e89f1379 100644 --- a/server/AyaNova/models/FileAttachment.cs +++ b/server/AyaNova/models/FileAttachment.cs @@ -1,3 +1,4 @@ +using System; using AyaNova.Biz; using System.ComponentModel.DataAnnotations; @@ -8,8 +9,8 @@ namespace AyaNova.Models { public long Id { get; set; } public uint ConcurrencyToken { get; set; } - - + + //----------------------------------------- [Required] public long AttachToObjectId { get; set; } @@ -21,7 +22,8 @@ namespace AyaNova.Models public string DisplayFileName { get; set; } [Required] public string ContentType { get; set; }//mime type + [Required] + public DateTime LastModified { get; set; } public string Notes { get; set; } - } } \ No newline at end of file diff --git a/server/AyaNova/models/dto/UploadedFileInfo.cs b/server/AyaNova/models/dto/UploadedFileInfo.cs index bc96ba6e..516a7797 100644 --- a/server/AyaNova/models/dto/UploadedFileInfo.cs +++ b/server/AyaNova/models/dto/UploadedFileInfo.cs @@ -1,3 +1,4 @@ +using System; namespace AyaNova.Models { @@ -9,6 +10,7 @@ namespace AyaNova.Models public string InitialUploadedPathName { get; set; } public string OriginalFileName { get; set; } public string MimeType { get; set; } + public DateTime LastModified {get;set;} } } diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index 6e36432b..84bdc4be 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -22,7 +22,7 @@ namespace AyaNova.Util //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!! private const int DESIRED_SCHEMA_LEVEL = 10; - internal const long EXPECTED_COLUMN_COUNT = 103; + internal const long EXPECTED_COLUMN_COUNT = 104; internal const long EXPECTED_INDEX_COUNT = 31; //!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!! @@ -236,7 +236,7 @@ namespace AyaNova.Util await ExecQueryAsync("CREATE TABLE afileattachment (id BIGSERIAL PRIMARY KEY, " + "attachtoobjectid bigint not null, attachtoobjecttype integer not null, " + - "storedfilename text not null, displayfilename text not null, contenttype text, notes text)"); + "storedfilename text not null, displayfilename text not null, contenttype text, lastmodified timestamp not null, notes text)"); //index required for ops that need to check if file already in db (delete, count refs etc) //LOOKAT: isn't this useless without the ID as well or is that not fetched? diff --git a/server/AyaNova/util/FileUtil.cs b/server/AyaNova/util/FileUtil.cs index f24a8662..de91b243 100644 --- a/server/AyaNova/util/FileUtil.cs +++ b/server/AyaNova/util/FileUtil.cs @@ -253,14 +253,10 @@ namespace AyaNova.Util /// /// Store a file attachment - /// - /// - /// - /// - /// - /// + /// /// - internal static async Task StoreFileAttachmentAsync(string tempFilePath, string contentType, string fileName, AyaTypeId attachToObject, AyContext ct) + internal static async Task StoreFileAttachmentAsync(string tempFilePath, string contentType, string fileName, DateTime lastModified, + AyaTypeId attachToObject, AyContext ct) { //calculate hash var hash = FileHash.GetChecksum(tempFilePath); @@ -291,7 +287,8 @@ namespace AyaNova.Util Notes = string.Empty, ContentType = contentType, AttachToObjectId = attachToObject.ObjectId, - AttachToObjectType = attachToObject.ObjectType + AttachToObjectType = attachToObject.ObjectType, + LastModified=lastModified }; //Store in DB