diff --git a/Disco.Services/Attachments/AttachmentActionExtensions.cs b/Disco.Services/Attachments/AttachmentActionExtensions.cs index b67d5cb5..2bb47a54 100644 --- a/Disco.Services/Attachments/AttachmentActionExtensions.cs +++ b/Disco.Services/Attachments/AttachmentActionExtensions.cs @@ -4,8 +4,10 @@ using Disco.Services.Authorization; using Disco.Services.Documents.ManagedGroups; using Disco.Services.Users; using System; +using System.Data.Entity; using System.Drawing; using System.IO; +using System.Threading; namespace Disco.Services { @@ -215,12 +217,37 @@ namespace Disco.Services return ua; } + public static bool WaitForThumbnailGeneration(this IAttachment attachment, DiscoDataContext database, out string thumbnailPath, out string mimeType) + { + thumbnailPath = attachment.RepositoryThumbnailFilename(database); + if (thumbnailPath.EndsWith(".png")) + mimeType = "image/png"; + else + mimeType = "image/jpeg"; + + if (File.Exists(thumbnailPath)) + return true; + + // recently created attachments may not have a thumbnail yet + var timestamp = attachment.Timestamp; + if (timestamp > DateTime.Now.AddSeconds(-5) && attachment.SupportsThumbnailGeneration(out _, out _)) + { + while (!File.Exists(thumbnailPath) && timestamp > DateTime.Now.AddSeconds(-5)) + Thread.Sleep(250); + + if (File.Exists(thumbnailPath)) + return true; + } + + return false; + } + public static string GenerateThumbnail(this IAttachment attachment, DiscoDataContext Database, Stream AttachmentStream) { string thumbnailFilePath = attachment.RepositoryThumbnailFilename(Database); Image thumbnail; - if (GenerateThumbnail(AttachmentStream, attachment.MimeType, out thumbnail)) + if (attachment.GenerateThumbnail(AttachmentStream, out thumbnail)) { thumbnail.SaveJpg(90, thumbnailFilePath); } @@ -235,7 +262,7 @@ namespace Disco.Services using (var attachmentStream = File.OpenRead(attachment.RepositoryFilename(Database))) { Image thumbnail; - if (GenerateThumbnail(attachmentStream, attachment.MimeType, out thumbnail)) + if (attachment.GenerateThumbnail(attachmentStream, out thumbnail)) { thumbnail.SaveJpg(90, thumbnailFilePath); } @@ -244,61 +271,101 @@ namespace Disco.Services return thumbnailFilePath; } - public static bool GenerateThumbnail(Stream Source, string SourceMimeType, out Image Thumbnail) + + private const string pdfMimeType = "application/pdf"; + private const string pdfExtension = "pdf"; + private static readonly string[] imageMimeTypes = new string[] { "image/jpeg", "image/png", "image/gif", "image/bmp" }; + private static readonly string[] imageExtensions = new string[] { ".jpg", ".jpeg", ".png", ".gif", ".bmp" }; + public static (bool supported, bool isImage, bool isPdf) SupportsThumbnailGeneration(string mimeType, string fileName) { - if (Source != null) + if (!string.IsNullOrEmpty(mimeType)) { - // GDI+ (jpg, png, gif, bmp) - if (SourceMimeType.Equals("image/jpeg", StringComparison.OrdinalIgnoreCase) || SourceMimeType.Contains("jpg") || - SourceMimeType.Equals("image/png", StringComparison.OrdinalIgnoreCase) || SourceMimeType.Contains("png") || - SourceMimeType.Equals("image/gif", StringComparison.OrdinalIgnoreCase) || SourceMimeType.Contains("gif") || - SourceMimeType.Equals("image/bmp", StringComparison.OrdinalIgnoreCase) || SourceMimeType.Contains("bmp")) + if (pdfMimeType.Equals(mimeType, StringComparison.OrdinalIgnoreCase)) + return (true, false, true); + foreach (var imageMimeType in imageMimeTypes) + if (mimeType.Equals(imageMimeType, StringComparison.OrdinalIgnoreCase)) + return (true, true, false); + } + + if (!string.IsNullOrEmpty(fileName)) + { + if (fileName.EndsWith(pdfExtension, StringComparison.OrdinalIgnoreCase)) + return (true, false, true); + foreach (var imageExtension in imageExtensions) + if (fileName.EndsWith(imageExtension, StringComparison.OrdinalIgnoreCase)) + return (true, true, false); + } + + return (false, false, false); + } + + public static bool SupportsThumbnailGeneration(this IAttachment attachment, out bool isImage, out bool isPdf) + { + var result = SupportsThumbnailGeneration(attachment.MimeType, attachment.Filename); + + isImage = result.isImage; + isPdf = result.isPdf; + + return result.supported; + } + + public static bool GenerateThumbnail(this IAttachment attachment, Stream source, out Image thumbnail) + { + if (source != null) + { + var (supported, isImage, isPdf) = SupportsThumbnailGeneration(attachment.MimeType, attachment.Filename); + + if (supported) { - try + // GDI+ (jpg, png, gif, bmp) + if (isImage) { - using (Image sourceImage = Image.FromStream(Source)) + try { - Thumbnail = sourceImage.ResizeImage(48, 48, Brushes.Black); - using (Image mimeTypeIcon = Properties.Resources.MimeType_img16) + using (Image sourceImage = Image.FromStream(source)) { - Thumbnail.EmbedIconOverlay(mimeTypeIcon); - } - return true; - } - } - catch (Exception) { } - - } - - // PDF - if (SourceMimeType.Equals("application/pdf", StringComparison.OrdinalIgnoreCase) || SourceMimeType.Contains("pdf")) - { - try - { - using (var pdfiumDocument = PdfiumViewer.PdfDocument.Load(Source)) - { - - if (pdfiumDocument.PageCount > 0) - { - var pageSize = pdfiumDocument.PageSizes[0]; - var size = ImagingExtensions.CalculateResize((int)pageSize.Width, (int)pageSize.Height, 48, 48); - - using (var sourceImage = pdfiumDocument.Render(0, (int)size.Width, (int)size.Height, 72, 72, true)) + thumbnail = sourceImage.ResizeImage(48, 48, Brushes.Black); + using (Image mimeTypeIcon = Properties.Resources.MimeType_img16) { - Thumbnail = sourceImage.ResizeImage(48, 48, Brushes.White); - using (Image mimeTypeIcon = Properties.Resources.MimeType_pdf16) + thumbnail.EmbedIconOverlay(mimeTypeIcon); + } + return true; + } + } + catch (Exception) { } + + } + + // PDF + if (isPdf) + { + try + { + using (var pdfiumDocument = PdfiumViewer.PdfDocument.Load(source)) + { + + if (pdfiumDocument.PageCount > 0) + { + var pageSize = pdfiumDocument.PageSizes[0]; + var size = ImagingExtensions.CalculateResize((int)pageSize.Width, (int)pageSize.Height, 48, 48); + + using (var sourceImage = pdfiumDocument.Render(0, (int)size.Width, (int)size.Height, 72, 72, true)) { - Thumbnail.EmbedIconOverlay(mimeTypeIcon); + thumbnail = sourceImage.ResizeImage(48, 48, Brushes.White); + using (Image mimeTypeIcon = Properties.Resources.MimeType_pdf16) + { + thumbnail.EmbedIconOverlay(mimeTypeIcon); + } + return true; } - return true; } } } + catch (Exception) { } } - catch (Exception) { } } } - Thumbnail = null; + thumbnail = null; return false; } } diff --git a/Disco.Services/Disco.Services.csproj b/Disco.Services/Disco.Services.csproj index bac559b4..343b38cf 100644 --- a/Disco.Services/Disco.Services.csproj +++ b/Disco.Services/Disco.Services.csproj @@ -141,6 +141,9 @@ ..\packages\Rx-PlatformServices.2.2.5\lib\net45\System.Reactive.PlatformServices.dll + + ..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll + diff --git a/Disco.Services/packages.config b/Disco.Services/packages.config index 4be4295d..ce827ba7 100644 --- a/Disco.Services/packages.config +++ b/Disco.Services/packages.config @@ -29,5 +29,6 @@ + \ No newline at end of file diff --git a/Disco.Web/Areas/API/Controllers/DeviceController.cs b/Disco.Web/Areas/API/Controllers/DeviceController.cs index 3e235852..545a7ed1 100644 --- a/Disco.Web/Areas/API/Controllers/DeviceController.cs +++ b/Disco.Web/Areas/API/Controllers/DeviceController.cs @@ -1,7 +1,6 @@ using Disco.Models.Repository; using Disco.Models.Services.Devices.Exporting; using Disco.Models.Services.Devices.Importing; -using System.Data.Entity; using Disco.Services; using Disco.Services.Authorization; using Disco.Services.Devices.Exporting; @@ -9,17 +8,18 @@ using Disco.Services.Devices.Importing; using Disco.Services.Exporting; using Disco.Services.Interop; using Disco.Services.Interop.ActiveDirectory; +using Disco.Services.Logging; using Disco.Services.Users; using Disco.Services.Web; using Disco.Web.Extensions; using Disco.Web.Models.Device; using System; using System.Collections.Generic; +using System.Data.Entity; using System.Linq; using System.Web; using System.Web.Caching; using System.Web.Mvc; -using Disco.Services.Logging; namespace Disco.Web.Areas.API.Controllers { @@ -498,14 +498,8 @@ namespace Disco.Web.Areas.API.Controllers var da = Database.DeviceAttachments.Find(id); if (da != null) { - var thumbPath = da.RepositoryThumbnailFilename(Database); - if (System.IO.File.Exists(thumbPath)) - { - if (thumbPath.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) - return File(thumbPath, "image/png"); - else - return File(thumbPath, "image/jpeg"); - } + if (da.WaitForThumbnailGeneration(Database, out var thumbPath, out var mimeType)) + return File(thumbPath, mimeType); else return File(ClientSource.Style.Images.AttachmentTypes.MimeTypeIcons.Icon(da.MimeType), "image/png"); } diff --git a/Disco.Web/Areas/API/Controllers/JobController.cs b/Disco.Web/Areas/API/Controllers/JobController.cs index 70b917fc..b8bff874 100644 --- a/Disco.Web/Areas/API/Controllers/JobController.cs +++ b/Disco.Web/Areas/API/Controllers/JobController.cs @@ -16,7 +16,6 @@ using Disco.Web.Models.Job; using System; using System.Collections.Generic; using System.Data.Entity; -using System.IO; using System.Linq; using System.Web; using System.Web.Caching; @@ -1904,15 +1903,8 @@ namespace Disco.Web.Areas.API.Controllers var ja = Database.JobAttachments.Find(id); if (ja != null) { - var thumbPath = ja.RepositoryThumbnailFilename(Database); - var thumbFileInfo = new FileInfo(thumbPath); - if (thumbFileInfo.Exists && thumbFileInfo.Length > 0) - { - if (thumbPath.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) - return File(thumbPath, "image/png"); - else - return File(thumbPath, "image/jpeg"); - } + if (ja.WaitForThumbnailGeneration(Database, out var thumbPath, out var mimeType)) + return File(thumbPath, mimeType); else return File(ClientSource.Style.Images.AttachmentTypes.MimeTypeIcons.Icon(ja.MimeType), "image/png"); } diff --git a/Disco.Web/Areas/API/Controllers/UserController.cs b/Disco.Web/Areas/API/Controllers/UserController.cs index 15f251fe..a9638f2e 100644 --- a/Disco.Web/Areas/API/Controllers/UserController.cs +++ b/Disco.Web/Areas/API/Controllers/UserController.cs @@ -6,6 +6,7 @@ using Disco.Services.Plugins.Features.DetailsProvider; using Disco.Services.Users; using Disco.Services.Web; using System; +using System.Data.Entity; using System.Linq; using System.Web.Mvc; @@ -42,14 +43,8 @@ namespace Disco.Web.Areas.API.Controllers var ua = Database.UserAttachments.Find(id); if (ua != null) { - var thumbPath = ua.RepositoryThumbnailFilename(Database); - if (System.IO.File.Exists(thumbPath)) - { - if (thumbPath.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) - return File(thumbPath, "image/png"); - else - return File(thumbPath, "image/jpeg"); - } + if (ua.WaitForThumbnailGeneration(Database, out var thumbPath, out var mimeType)) + return File(thumbPath, mimeType); else return File(ClientSource.Style.Images.AttachmentTypes.MimeTypeIcons.Icon(ua.MimeType), "image/png"); } diff --git a/Disco.Web/ClientSource/Style/Images/AttachmentTypes/MimeTypeIcons.cs b/Disco.Web/ClientSource/Style/Images/AttachmentTypes/MimeTypeIcons.cs index db140175..d281c822 100644 --- a/Disco.Web/ClientSource/Style/Images/AttachmentTypes/MimeTypeIcons.cs +++ b/Disco.Web/ClientSource/Style/Images/AttachmentTypes/MimeTypeIcons.cs @@ -1,27 +1,73 @@ using System; +using System.Collections.Generic; +using System.Linq; namespace Disco.Web.ClientSource.Style.Images.AttachmentTypes { public static class MimeTypeIcons { + private static IEnumerable DocumentMimeTypes() + { + yield return "application/msword"; + yield return "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; + yield return "application/vnd.ms-word.document.macroEnabled.12"; + } + private static IEnumerable SpreadsheetMimeTypes() + { + yield return "application/vnd.ms-excel"; + yield return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; + yield return "application/vnd.ms-excel.sheet.macroEnabled.12"; + } + private static IEnumerable ArchiveMimeTypes() + { + yield return "application/zip"; + yield return "application/gzip"; + yield return "application/x-tar"; + yield return "application/x-zip-compressed"; + yield return "application/x-7z-compressed"; + yield return "application/x-bzip"; + yield return "application/x-bzip2"; + yield return "application/x-gzip"; + } + public static string Icon(string MimeType) { + // PDF + if ("application/pdf".Equals(MimeType, StringComparison.OrdinalIgnoreCase)) + return Links.ClientSource.Style.Images.AttachmentTypes.pdf_png; - switch (MimeType.ToLower()) - { - case "application/pdf": - return Links.ClientSource.Style.Images.AttachmentTypes.pdf_png; - case "application/msword": - case "application/vnd.openxmlformats-officedocument.wordprocessingml.document": - case "application/vnd.ms-word.document.macroEnabled.12": - return Links.ClientSource.Style.Images.AttachmentTypes.document_png; - } + // Document icon + if (DocumentMimeTypes().Any(t => t.Equals(MimeType, StringComparison.OrdinalIgnoreCase))) + return Links.ClientSource.Style.Images.AttachmentTypes.document_png; + + // Spreadsheet icon + if (SpreadsheetMimeTypes().Any(t => t.Equals(MimeType, StringComparison.OrdinalIgnoreCase))) + return Links.ClientSource.Style.Images.AttachmentTypes.spreadsheet_png; // Generic 'image' icon if (MimeType.StartsWith("image/", StringComparison.OrdinalIgnoreCase)) return Links.ClientSource.Style.Images.AttachmentTypes.image_png; + // Generic 'video' icon + if (MimeType.StartsWith("video/", StringComparison.OrdinalIgnoreCase)) + return Links.ClientSource.Style.Images.AttachmentTypes.video_png; + + if (MimeType.StartsWith("audio/", StringComparison.OrdinalIgnoreCase)) + return Links.ClientSource.Style.Images.AttachmentTypes.audio_png; + + // Generic 'text' icon + if (MimeType.StartsWith("text/", StringComparison.OrdinalIgnoreCase)) + return Links.ClientSource.Style.Images.AttachmentTypes.txt_png; + + // Archive icons + if (ArchiveMimeTypes().Any(t => t.Equals(MimeType, StringComparison.OrdinalIgnoreCase))) + return Links.ClientSource.Style.Images.AttachmentTypes.archive_png; + + if ("application/binary".Equals(MimeType, StringComparison.OrdinalIgnoreCase) || + "application/octet-stream".Equals(MimeType, StringComparison.OrdinalIgnoreCase)) + return Links.ClientSource.Style.Images.AttachmentTypes.binary_png; + // All other Attachments return Links.ClientSource.Style.Images.AttachmentTypes.unknown_png; } diff --git a/Disco.Web/ClientSource/Style/Images/AttachmentTypes/archive.png b/Disco.Web/ClientSource/Style/Images/AttachmentTypes/archive.png new file mode 100644 index 00000000..cb683674 Binary files /dev/null and b/Disco.Web/ClientSource/Style/Images/AttachmentTypes/archive.png differ diff --git a/Disco.Web/ClientSource/Style/Images/AttachmentTypes/audio.png b/Disco.Web/ClientSource/Style/Images/AttachmentTypes/audio.png new file mode 100644 index 00000000..626baf9f Binary files /dev/null and b/Disco.Web/ClientSource/Style/Images/AttachmentTypes/audio.png differ diff --git a/Disco.Web/ClientSource/Style/Images/AttachmentTypes/binary.png b/Disco.Web/ClientSource/Style/Images/AttachmentTypes/binary.png new file mode 100644 index 00000000..99a380aa Binary files /dev/null and b/Disco.Web/ClientSource/Style/Images/AttachmentTypes/binary.png differ diff --git a/Disco.Web/ClientSource/Style/Images/AttachmentTypes/spreadsheet.png b/Disco.Web/ClientSource/Style/Images/AttachmentTypes/spreadsheet.png new file mode 100644 index 00000000..0375318c Binary files /dev/null and b/Disco.Web/ClientSource/Style/Images/AttachmentTypes/spreadsheet.png differ diff --git a/Disco.Web/ClientSource/Style/Images/AttachmentTypes/txt.png b/Disco.Web/ClientSource/Style/Images/AttachmentTypes/txt.png new file mode 100644 index 00000000..fa1420d2 Binary files /dev/null and b/Disco.Web/ClientSource/Style/Images/AttachmentTypes/txt.png differ diff --git a/Disco.Web/ClientSource/Style/Images/AttachmentTypes/unknown.png b/Disco.Web/ClientSource/Style/Images/AttachmentTypes/unknown.png index 671ab040..15b2b156 100644 Binary files a/Disco.Web/ClientSource/Style/Images/AttachmentTypes/unknown.png and b/Disco.Web/ClientSource/Style/Images/AttachmentTypes/unknown.png differ diff --git a/Disco.Web/ClientSource/Style/Images/AttachmentTypes/video.png b/Disco.Web/ClientSource/Style/Images/AttachmentTypes/video.png new file mode 100644 index 00000000..471703a7 Binary files /dev/null and b/Disco.Web/ClientSource/Style/Images/AttachmentTypes/video.png differ diff --git a/Disco.Web/Disco.Web.csproj b/Disco.Web/Disco.Web.csproj index c947ef1d..1b25c3d6 100644 --- a/Disco.Web/Disco.Web.csproj +++ b/Disco.Web/Disco.Web.csproj @@ -1634,6 +1634,12 @@ tinymce.js Always + + + + + + Always diff --git a/Disco.Web/Extensions/T4MVC/API.DeviceController.generated.cs b/Disco.Web/Extensions/T4MVC/API.DeviceController.generated.cs index d387e176..a9381709 100644 --- a/Disco.Web/Extensions/T4MVC/API.DeviceController.generated.cs +++ b/Disco.Web/Extensions/T4MVC/API.DeviceController.generated.cs @@ -480,7 +480,7 @@ namespace Disco.Web.Areas.API.Controllers public class ActionParamsClass_AttachmentUpload { public readonly string id = "id"; - public readonly string Comments = "Comments"; + public readonly string comments = "comments"; } static readonly ActionParamsClass_Attachment s_params_Attachment = new ActionParamsClass_Attachment(); [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] @@ -812,15 +812,15 @@ namespace Disco.Web.Areas.API.Controllers } [NonAction] - partial void AttachmentUploadOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id, string Comments); + partial void AttachmentUploadOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id, string comments); [NonAction] - public override System.Web.Mvc.ActionResult AttachmentUpload(string id, string Comments) + public override System.Web.Mvc.ActionResult AttachmentUpload(string id, string comments) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.AttachmentUpload); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id); - ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Comments", Comments); - AttachmentUploadOverride(callInfo, id, Comments); + ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "comments", comments); + AttachmentUploadOverride(callInfo, id, comments); return callInfo; } diff --git a/Disco.Web/Extensions/T4MVC/API.JobController.generated.cs b/Disco.Web/Extensions/T4MVC/API.JobController.generated.cs index 7ba2ad30..41eb76e8 100644 --- a/Disco.Web/Extensions/T4MVC/API.JobController.generated.cs +++ b/Disco.Web/Extensions/T4MVC/API.JobController.generated.cs @@ -1175,7 +1175,7 @@ namespace Disco.Web.Areas.API.Controllers public class ActionParamsClass_AttachmentUpload { public readonly string id = "id"; - public readonly string Comments = "Comments"; + public readonly string comments = "comments"; } static readonly ActionParamsClass_Attachment s_params_Attachment = new ActionParamsClass_Attachment(); [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] @@ -1253,7 +1253,7 @@ namespace Disco.Web.Areas.API.Controllers [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] public class ActionParamsClass_Export { - public readonly string Model = "Model"; + public readonly string model = "model"; } static readonly ActionParamsClass_ExportRetrieve s_params_ExportRetrieve = new ActionParamsClass_ExportRetrieve(); [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] @@ -2052,15 +2052,15 @@ namespace Disco.Web.Areas.API.Controllers } [NonAction] - partial void AttachmentUploadOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int id, string Comments); + partial void AttachmentUploadOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int id, string comments); [NonAction] - public override System.Web.Mvc.ActionResult AttachmentUpload(int id, string Comments) + public override System.Web.Mvc.ActionResult AttachmentUpload(int id, string comments) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.AttachmentUpload); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id); - ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Comments", Comments); - AttachmentUploadOverride(callInfo, id, Comments); + ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "comments", comments); + AttachmentUploadOverride(callInfo, id, comments); return callInfo; } @@ -2189,14 +2189,14 @@ namespace Disco.Web.Areas.API.Controllers } [NonAction] - partial void ExportOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Disco.Web.Models.Job.ExportModel Model); + partial void ExportOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, Disco.Web.Models.Job.ExportModel model); [NonAction] - public override System.Web.Mvc.ActionResult Export(Disco.Web.Models.Job.ExportModel Model) + public override System.Web.Mvc.ActionResult Export(Disco.Web.Models.Job.ExportModel model) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Export); - ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Model", Model); - ExportOverride(callInfo, Model); + ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "model", model); + ExportOverride(callInfo, model); return callInfo; } diff --git a/Disco.Web/Extensions/T4MVC/API.SystemController.generated.cs b/Disco.Web/Extensions/T4MVC/API.SystemController.generated.cs index 4494a5b3..6d0fb76a 100644 --- a/Disco.Web/Extensions/T4MVC/API.SystemController.generated.cs +++ b/Disco.Web/Extensions/T4MVC/API.SystemController.generated.cs @@ -260,7 +260,7 @@ namespace Disco.Web.Areas.API.Controllers [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] public class ActionParamsClass_DeleteOrganisationAddress { - public readonly string Id = "Id"; + public readonly string id = "id"; public readonly string redirect = "redirect"; } static readonly ActionParamsClass_UpdateMultiSiteMode s_params_UpdateMultiSiteMode = new ActionParamsClass_UpdateMultiSiteMode(); @@ -498,15 +498,15 @@ namespace Disco.Web.Areas.API.Controllers } [NonAction] - partial void DeleteOrganisationAddressOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int Id, bool redirect); + partial void DeleteOrganisationAddressOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, int id, bool redirect); [NonAction] - public override System.Web.Mvc.ActionResult DeleteOrganisationAddress(int Id, bool redirect) + public override System.Web.Mvc.ActionResult DeleteOrganisationAddress(int id, bool redirect) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.DeleteOrganisationAddress); - ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Id", Id); + ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "redirect", redirect); - DeleteOrganisationAddressOverride(callInfo, Id, redirect); + DeleteOrganisationAddressOverride(callInfo, id, redirect); return callInfo; } diff --git a/Disco.Web/Extensions/T4MVC/API.UserController.generated.cs b/Disco.Web/Extensions/T4MVC/API.UserController.generated.cs index f026a6b5..24e1c13d 100644 --- a/Disco.Web/Extensions/T4MVC/API.UserController.generated.cs +++ b/Disco.Web/Extensions/T4MVC/API.UserController.generated.cs @@ -179,7 +179,7 @@ namespace Disco.Web.Areas.API.Controllers { public readonly string id = "id"; public readonly string Domain = "Domain"; - public readonly string Comments = "Comments"; + public readonly string comments = "comments"; } static readonly ActionParamsClass_Attachment s_params_Attachment = new ActionParamsClass_Attachment(); [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] @@ -278,16 +278,16 @@ namespace Disco.Web.Areas.API.Controllers } [NonAction] - partial void AttachmentUploadOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id, string Domain, string Comments); + partial void AttachmentUploadOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id, string Domain, string comments); [NonAction] - public override System.Web.Mvc.ActionResult AttachmentUpload(string id, string Domain, string Comments) + public override System.Web.Mvc.ActionResult AttachmentUpload(string id, string Domain, string comments) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.AttachmentUpload); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Domain", Domain); - ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Comments", Comments); - AttachmentUploadOverride(callInfo, id, Domain, Comments); + ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "comments", comments); + AttachmentUploadOverride(callInfo, id, Domain, comments); return callInfo; } diff --git a/Disco.Web/Extensions/T4MVC/T4MVC.cs b/Disco.Web/Extensions/T4MVC/T4MVC.cs index 1ea0e2b7..8854d476 100644 --- a/Disco.Web/Extensions/T4MVC/T4MVC.cs +++ b/Disco.Web/Extensions/T4MVC/T4MVC.cs @@ -648,11 +648,17 @@ namespace Links public const string UrlPath = "~/ClientSource/Style/Images/AttachmentTypes"; public static string Url() { return T4MVCHelpers.ProcessVirtualPath(UrlPath); } public static string Url(string fileName) { return T4MVCHelpers.ProcessVirtualPath(UrlPath + "/" + fileName); } + public static readonly string archive_png = Url("archive.png"); + public static readonly string audio_png = Url("audio.png"); + public static readonly string binary_png = Url("binary.png"); public static readonly string document_png = Url("document.png"); public static readonly string expressionBrowserIcons_png = Url("expressionBrowserIcons.png"); public static readonly string image_png = Url("image.png"); public static readonly string pdf_png = Url("pdf.png"); + public static readonly string spreadsheet_png = Url("spreadsheet.png"); + public static readonly string txt_png = Url("txt.png"); public static readonly string unknown_png = Url("unknown.png"); + public static readonly string video_png = Url("video.png"); } public static readonly string BackgroundDocument_png = Url("BackgroundDocument.png"); diff --git a/Disco.Web/Views/Job/JobParts/Resources.cshtml b/Disco.Web/Views/Job/JobParts/Resources.cshtml index a31de59e..a94c6798 100644 --- a/Disco.Web/Views/Job/JobParts/Resources.cshtml +++ b/Disco.Web/Views/Job/JobParts/Resources.cshtml @@ -69,7 +69,7 @@ @{if (!string.IsNullOrEmpty(ja.DocumentTemplateId)) { @ja.DocumentTemplate.Description} else - { @ja.Comments }} + { @(ja.Comments ?? ja.Filename) }} @ja.TechUser.ToStringFriendly()@if (canRemoveAnyAttachments || (canRemoveOwnAttachments && ja.TechUserId.Equals(CurrentUser.UserId, StringComparison.OrdinalIgnoreCase))) {}@ja.Timestamp.ToFullDateTime() diff --git a/Disco.Web/Views/Job/JobParts/Resources.generated.cs b/Disco.Web/Views/Job/JobParts/Resources.generated.cs index 6cda1bb9..32d6fd6e 100644 --- a/Disco.Web/Views/Job/JobParts/Resources.generated.cs +++ b/Disco.Web/Views/Job/JobParts/Resources.generated.cs @@ -489,14 +489,14 @@ WriteLiteral(">\r\n"); #line hidden #line 72 "..\..\Views\Job\JobParts\Resources.cshtml" - Write(ja.Comments); + Write(ja.Comments ?? ja.Filename); #line default #line hidden #line 72 "..\..\Views\Job\JobParts\Resources.cshtml" - } + } #line default #line hidden @@ -549,14 +549,14 @@ WriteLiteral(" data-livestamp=\""); #line hidden WriteLiteral("\""); -WriteAttribute("title", Tuple.Create(" title=\"", 4634), Tuple.Create("\"", 4672) +WriteAttribute("title", Tuple.Create(" title=\"", 4651), Tuple.Create("\"", 4689) #line 74 "..\..\Views\Job\JobParts\Resources.cshtml" - , Tuple.Create(Tuple.Create("", 4642), Tuple.Create(ja.Timestamp.ToFullDateTime() + , Tuple.Create(Tuple.Create("", 4659), Tuple.Create(ja.Timestamp.ToFullDateTime() #line default #line hidden -, 4642), false) +, 4659), false) ); WriteLiteral(">"); diff --git a/Disco.Web/Views/User/UserParts/_Resources.cshtml b/Disco.Web/Views/User/UserParts/_Resources.cshtml index 0e138ad2..9d4bada7 100644 --- a/Disco.Web/Views/User/UserParts/_Resources.cshtml +++ b/Disco.Web/Views/User/UserParts/_Resources.cshtml @@ -37,7 +37,7 @@ @{if (!string.IsNullOrEmpty(ua.DocumentTemplateId)) { @ua.DocumentTemplate.Description} else - { @ua.Comments }} + { @(ua.Comments ?? ua.Filename) }} @ua.TechUser.ToStringFriendly()@if (canRemoveAnyAttachments || (canRemoveOwnAttachments && ua.TechUserId.Equals(CurrentUser.UserId, StringComparison.OrdinalIgnoreCase))) {}@ua.Timestamp.ToFullDateTime() diff --git a/Disco.Web/Views/User/UserParts/_Resources.generated.cs b/Disco.Web/Views/User/UserParts/_Resources.generated.cs index 81d784a7..67ccf713 100644 --- a/Disco.Web/Views/User/UserParts/_Resources.generated.cs +++ b/Disco.Web/Views/User/UserParts/_Resources.generated.cs @@ -250,14 +250,14 @@ WriteLiteral(">\r\n"); #line hidden #line 40 "..\..\Views\User\UserParts\_Resources.cshtml" - Write(ua.Comments); + Write(ua.Comments ?? ua.Filename); #line default #line hidden #line 40 "..\..\Views\User\UserParts\_Resources.cshtml" - } + } #line default #line hidden @@ -310,14 +310,14 @@ WriteLiteral(" data-livestamp=\""); #line hidden WriteLiteral("\""); -WriteAttribute("title", Tuple.Create(" title=\"", 2671), Tuple.Create("\"", 2709) +WriteAttribute("title", Tuple.Create(" title=\"", 2688), Tuple.Create("\"", 2726) #line 42 "..\..\Views\User\UserParts\_Resources.cshtml" - , Tuple.Create(Tuple.Create("", 2679), Tuple.Create(ua.Timestamp.ToFullDateTime() + , Tuple.Create(Tuple.Create("", 2696), Tuple.Create(ua.Timestamp.ToFullDateTime() #line default #line hidden -, 2679), false) +, 2696), false) ); WriteLiteral(">");