From a0e18ef9639b6a544366ed1aa6a66720dea5d740 Mon Sep 17 00:00:00 2001 From: Gary Sharp Date: Tue, 3 Jun 2014 12:36:48 +1000 Subject: [PATCH] SignalR Bug Fixes & Minor UI Changes Document Template import status and Device Enrolment status fixes. Attachment download fixes for SignalR foreverFrame transport. Database queries for Devices, Jobs and Users updated. Device attributes (model, profile, batch) now shown in various places. --- .../Searching/DeviceSearchResultItem.cs | 1 + Disco.Services/Searching/Search.cs | 1 + .../Areas/API/Controllers/DeviceController.cs | 4 +- .../Areas/API/Controllers/JobController.cs | 4 +- .../Areas/API/Controllers/UserController.cs | 4 +- .../API/Models/Attachment/_AttachmentModel.cs | 18 ++ .../DocumentTemplate/ImportStatus.cshtml | 24 +- .../ImportStatus.generated.cs | 222 +++++++------- .../Config/Views/Enrolment/Status.cshtml | 19 +- .../Views/Enrolment/Status.generated.cs | 32 +- Disco.Web/Controllers/DeviceController.cs | 4 +- Disco.Web/Controllers/JobController.cs | 9 +- Disco.Web/Controllers/UserController.cs | 6 +- .../Device/DeviceParts/_Resources.cshtml | 33 ++- .../DeviceParts/_Resources.generated.cs | 108 ++++--- Disco.Web/Views/Device/_DeviceTable.cshtml | 12 + .../Views/Device/_DeviceTable.generated.cs | 133 ++++++--- Disco.Web/Views/Job/JobParts/Resources.cshtml | 38 ++- .../Views/Job/JobParts/Resources.generated.cs | 150 ++++++---- .../User/UserParts/_AssignmentHistory.cshtml | 56 +++- .../UserParts/_AssignmentHistory.generated.cs | 280 +++++++++++++++--- .../Views/User/UserParts/_Resources.cshtml | 33 ++- .../User/UserParts/_Resources.generated.cs | 95 +++--- .../Views/User/UserParts/_Subject.cshtml | 58 ++-- .../User/UserParts/_Subject.generated.cs | 209 +++++++++---- 25 files changed, 1088 insertions(+), 465 deletions(-) diff --git a/Disco.Models/Services/Searching/DeviceSearchResultItem.cs b/Disco.Models/Services/Searching/DeviceSearchResultItem.cs index d947243b..c0cd6783 100644 --- a/Disco.Models/Services/Searching/DeviceSearchResultItem.cs +++ b/Disco.Models/Services/Searching/DeviceSearchResultItem.cs @@ -41,6 +41,7 @@ namespace Disco.Models.Services.Searching public string ComputerName { get; set; } public string DeviceModelDescription { get; set; } public string DeviceProfileDescription { get; set; } + public string DeviceBatchName { get; set; } public int JobCount { get; set; } public DateTime? DecommissionedDate { get; set; } diff --git a/Disco.Services/Searching/Search.cs b/Disco.Services/Searching/Search.cs index 8158ed2f..87aa87e0 100644 --- a/Disco.Services/Searching/Search.cs +++ b/Disco.Services/Searching/Search.cs @@ -276,6 +276,7 @@ namespace Disco.Services.Searching ComputerName = d.DeviceDomainId, DeviceModelDescription = d.DeviceModel.Description, DeviceProfileDescription = d.DeviceProfile.Description, + DeviceBatchName = d.DeviceBatch.Name, DecommissionedDate = d.DecommissionedDate, AssignedUserId = d.AssignedUserId, AssignedUserDisplayName = d.AssignedUser.DisplayName, diff --git a/Disco.Web/Areas/API/Controllers/DeviceController.cs b/Disco.Web/Areas/API/Controllers/DeviceController.cs index dcadc480..5e8d6703 100644 --- a/Disco.Web/Areas/API/Controllers/DeviceController.cs +++ b/Disco.Web/Areas/API/Controllers/DeviceController.cs @@ -519,7 +519,7 @@ namespace Disco.Web.Areas.API.Controllers [DiscoAuthorize(Claims.Device.ShowAttachments)] public virtual ActionResult Attachment(int id) { - var da = Database.DeviceAttachments.Include("TechUser").Where(m => m.Id == id).FirstOrDefault(); + var da = Database.DeviceAttachments.Include("DocumentTemplate").Include("TechUser").Where(m => m.Id == id).FirstOrDefault(); if (da != null) { @@ -537,7 +537,7 @@ namespace Disco.Web.Areas.API.Controllers [DiscoAuthorize(Claims.Device.ShowAttachments)] public virtual ActionResult Attachments(string id) { - var d = Database.Devices.Include("DeviceAttachments.TechUser").Where(m => m.SerialNumber == id).FirstOrDefault(); + var d = Database.Devices.Include("DeviceAttachments.DocumentTemplate").Include("DeviceAttachments.TechUser").Where(m => m.SerialNumber == id).FirstOrDefault(); if (d != null) { var m = new Models.Attachment.AttachmentsModel() diff --git a/Disco.Web/Areas/API/Controllers/JobController.cs b/Disco.Web/Areas/API/Controllers/JobController.cs index 6c1da7a3..d6f47bde 100644 --- a/Disco.Web/Areas/API/Controllers/JobController.cs +++ b/Disco.Web/Areas/API/Controllers/JobController.cs @@ -1974,7 +1974,7 @@ namespace Disco.Web.Areas.API.Controllers [DiscoAuthorize(Claims.Job.ShowAttachments)] public virtual ActionResult Attachment(int id) { - var ja = Database.JobAttachments.Include("TechUser").Where(m => m.Id == id).FirstOrDefault(); + var ja = Database.JobAttachments.Include("DocumentTemplate").Include("TechUser").Where(m => m.Id == id).FirstOrDefault(); if (ja != null) { @@ -1992,7 +1992,7 @@ namespace Disco.Web.Areas.API.Controllers [DiscoAuthorize(Claims.Job.ShowAttachments)] public virtual ActionResult Attachments(int id) { - var j = Database.Jobs.Include("JobAttachments.TechUser").Where(m => m.Id == id).FirstOrDefault(); + var j = Database.Jobs.Include("JobAttachments.DocumentTemplate").Include("JobAttachments.TechUser").Where(m => m.Id == id).FirstOrDefault(); if (j != null) { var m = new Models.Attachment.AttachmentsModel() diff --git a/Disco.Web/Areas/API/Controllers/UserController.cs b/Disco.Web/Areas/API/Controllers/UserController.cs index 426cc60b..da260c3b 100644 --- a/Disco.Web/Areas/API/Controllers/UserController.cs +++ b/Disco.Web/Areas/API/Controllers/UserController.cs @@ -102,7 +102,7 @@ namespace Disco.Web.Areas.API.Controllers [DiscoAuthorize(Claims.User.ShowAttachments)] public virtual ActionResult Attachment(int id) { - var ua = Database.UserAttachments.Include("TechUser").Where(m => m.Id == id).FirstOrDefault(); + var ua = Database.UserAttachments.Include("DocumentTemplate").Include("TechUser").Where(m => m.Id == id).FirstOrDefault(); if (ua != null) { @@ -125,7 +125,7 @@ namespace Disco.Web.Areas.API.Controllers else id = Domain + @"\" + id; - var u = Database.Users.Include("UserAttachments.TechUser").Where(m => m.UserId == id).FirstOrDefault(); + var u = Database.Users.Include("UserAttachments.DocumentTemplate").Include("UserAttachments.TechUser").Where(m => m.UserId == id).FirstOrDefault(); if (u != null) { var m = new Models.Attachment.AttachmentsModel() diff --git a/Disco.Web/Areas/API/Models/Attachment/_AttachmentModel.cs b/Disco.Web/Areas/API/Models/Attachment/_AttachmentModel.cs index fee6df51..e109326c 100644 --- a/Disco.Web/Areas/API/Models/Attachment/_AttachmentModel.cs +++ b/Disco.Web/Areas/API/Models/Attachment/_AttachmentModel.cs @@ -11,6 +11,18 @@ namespace Disco.Web.Areas.API.Models.Attachment public string AuthorId { get; set; } public DateTime Timestamp { get; set; } public string Comments { get; set; } + public string DocumentTemplateId { get; set; } + public string DocumentTemplateDescription { get; set; } + public string Description + { + get + { + if (DocumentTemplateId != null && DocumentTemplateDescription != null) + return DocumentTemplateDescription; + else + return Comments; + } + } public string Filename { get; set; } public string MimeType { get; set; } public long TimestampUnixEpoc { get { return Timestamp.ToUnixEpoc(); } } @@ -26,6 +38,8 @@ namespace Disco.Web.Areas.API.Models.Attachment Author = ua.TechUser.ToStringFriendly(), Timestamp = ua.Timestamp, Comments = ua.Comments, + DocumentTemplateId = ua.DocumentTemplateId, + DocumentTemplateDescription = ua.DocumentTemplateId == null ? null : ua.DocumentTemplate.Description, Filename = ua.Filename, MimeType = ua.MimeType }; @@ -40,6 +54,8 @@ namespace Disco.Web.Areas.API.Models.Attachment Author = ja.TechUser.ToStringFriendly(), Timestamp = ja.Timestamp, Comments = ja.Comments, + DocumentTemplateId = ja.DocumentTemplateId, + DocumentTemplateDescription = ja.DocumentTemplateId == null ? null : ja.DocumentTemplate.Description, Filename = ja.Filename, MimeType = ja.MimeType }; @@ -54,6 +70,8 @@ namespace Disco.Web.Areas.API.Models.Attachment Author = da.TechUser.ToStringFriendly(), Timestamp = da.Timestamp, Comments = da.Comments, + DocumentTemplateId = da.DocumentTemplateId, + DocumentTemplateDescription = da.DocumentTemplateId == null ? null : da.DocumentTemplate.Description, Filename = da.Filename, MimeType = da.MimeType }; diff --git a/Disco.Web/Areas/Config/Views/DocumentTemplate/ImportStatus.cshtml b/Disco.Web/Areas/Config/Views/DocumentTemplate/ImportStatus.cshtml index 869bd700..32e2da32 100644 --- a/Disco.Web/Areas/Config/Views/DocumentTemplate/ImportStatus.cshtml +++ b/Disco.Web/Areas/Config/Views/DocumentTemplate/ImportStatus.cshtml @@ -1,6 +1,6 @@ @{ Authorization.Require(Claims.Config.DocumentTemplate.ShowStatus); - + ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Document Templates", MVC.Config.DocumentTemplate.Index(), "Import Status"); Html.BundleDeferred("~/ClientScripts/Modules/Knockout"); Html.BundleDeferred("~/ClientScripts/Modules/jQuery-SignalR"); @@ -99,7 +99,7 @@ var vm; var host = $('#importStatus'); var hostSessions = $('#sessions'); - var liveConnection; + var logHub = null; var urlDeviceShow = '@(Url.Action(MVC.Device.Show()))/' var urlJobShow = '@(Url.Action(MVC.Job.Show()))/' var urlUserShow = '@(Url.Action(MVC.User.Show()))/' @@ -134,10 +134,8 @@ self.sessionPages = ko.observableArray(); self.sessionPagesIndex = {}; self.addSessionPage = function (sessionPage) { - //if (isLive) { self.sessionPages.push(sessionPage); self.sessionPagesIndex[sessionPage.pageNumber] = sessionPage; - //} } } function sessionPageViewModel(sessionId, pageNumber) { @@ -305,11 +303,19 @@ ko.applyBindings(vm); // Init Persistent Connection - liveConnection = $.connection('@(Url.Content("~/API/Logging/Notifications"))', { addToGroups: '@(Disco.BI.DocumentTemplateBI.Importer.DocumentImporterLog.Current.LiveLogGroupName)' }); - liveConnection.received(parseLog); - liveConnection.error(function (e) { if (e.status != 200) alert('Live-Log Error: ' + e.statusText + ': ' + e.responseText); }); - isLive = true; - liveConnection.start(); + logHub = $.connection.logNotifications; + logHub.client.receiveLog = parseLog + + $.connection.hub.qs = { LogModules: '@(Disco.BI.DocumentTemplateBI.Importer.DocumentImporterLog.Current.LiveLogGroupName)' }; + $.connection.hub.error(function (error) { + alert('Live-Log Error: ' + error); + }); + + $.connection.hub.start() + .done(function () { isLive = true; }) + .fail(function (error) { + alert('Live-Log Connection Error: ' + error); + }); } init(); }); diff --git a/Disco.Web/Areas/Config/Views/DocumentTemplate/ImportStatus.generated.cs b/Disco.Web/Areas/Config/Views/DocumentTemplate/ImportStatus.generated.cs index 037a4ea9..80fa4368 100644 --- a/Disco.Web/Areas/Config/Views/DocumentTemplate/ImportStatus.generated.cs +++ b/Disco.Web/Areas/Config/Views/DocumentTemplate/ImportStatus.generated.cs @@ -48,7 +48,7 @@ namespace Disco.Web.Areas.Config.Views.DocumentTemplate #line 1 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml" Authorization.Require(Claims.Config.DocumentTemplate.ShowStatus); - + ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Document Templates", MVC.Config.DocumentTemplate.Index(), "Import Status"); Html.BundleDeferred("~/ClientScripts/Modules/Knockout"); Html.BundleDeferred("~/ClientScripts/Modules/jQuery-SignalR"); @@ -267,8 +267,8 @@ WriteLiteral(@"> WriteLiteral(" type=\"text/javascript\""); WriteLiteral(">\r\n $(function () {\r\n var vm;\r\n var host = $(\'#importStatus\');\r\n" + -" var hostSessions = $(\'#sessions\');\r\n var liveConnection;\r\n " + -" var urlDeviceShow = \'"); +" var hostSessions = $(\'#sessions\');\r\n var logHub = null;\r\n " + +"var urlDeviceShow = \'"); #line 103 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml" @@ -334,101 +334,100 @@ WriteLiteral("\';\r\n var isLive = false;\r\n\r\n function pageVie "= ko.observable();\r\n self.startTime = ko.observable();\r\n s" + "elf.sessionEnded = ko.observable(false);\r\n\r\n self.sessionPages = ko.o" + "bservableArray();\r\n self.sessionPagesIndex = {};\r\n self.ad" + -"dSessionPage = function (sessionPage) {\r\n //if (isLive) {\r\n " + -" self.sessionPages.push(sessionPage);\r\n self.sessionPage" + -"sIndex[sessionPage.pageNumber] = sessionPage;\r\n //}\r\n " + -"}\r\n }\r\n function sessionPageViewModel(sessionId, pageNumber) {\r\n " + -" var self = this;\r\n\r\n self.sessionId = sessionId;\r\n " + -" self.pageNumber = pageNumber;\r\n self.title = \'Page \' + pageNumber;" + -"\r\n self.progressStatus = ko.observable();\r\n self.progressV" + -"alue = ko.observable();\r\n self.undetected = ko.observable(false);\r\n " + -" self.detected = ko.observable(false);\r\n self.documentTempla" + -"teId = ko.observable();\r\n self.documentTemplate = ko.observable();\r\n " + -" self.assignedDataType = ko.observable();\r\n self.assignedDa" + -"taId = ko.observable();\r\n self.assignedData = ko.observable();\r\n " + -" self.thumbnailEnabled = ko.observable(0);\r\n self.updateThumbna" + -"il = function () {\r\n self.thumbnailEnabled(self.thumbnailEnabled(" + -") + 1);\r\n }\r\n self.documentTemplateUrl = ko.computed(funct" + -"ion () {\r\n return urlDocumentTemplate + self.documentTemplateId()" + -";\r\n });\r\n self.manuallyAssignUrl = ko.computed(function ()" + -" {\r\n return urlManuallyAssign + \'#\' + self.sessionId + \'_\' + self" + -".pageNumber;\r\n });\r\n self.assignedDataUrl = ko.computed(fu" + -"nction () {\r\n var t = self.assignedDataType();\r\n v" + -"ar dId = self.assignedDataId();\r\n if (dId !== undefined) {\r\n " + -" switch (t) {\r\n case \'Device\':\r\n " + -" return urlDeviceShow + dId;\r\n case \'Job\'" + -":\r\n return urlJobShow + dId;\r\n " + -" case \'User\':\r\n if (dId.indexOf(\'\\\\\') < 0)\r\n " + -" return urlUserShow + dId;\r\n el" + -"se\r\n return urlUserShow + dId.substr(dId.indexOf(" + -"\'\\\\\') + 1) + \'?domain=\' + dId.substr(0, dId.indexOf(\'\\\\\'));\r\n " + -" }\r\n }\r\n return null;\r\n });\r\n " + -" self.thumbnailUrl = ko.computed(function () {\r\n var enabled = s" + -"elf.thumbnailEnabled();\r\n if (enabled > 0) {\r\n " + -" return \'url(\' + urlPageThumbnail + \'?SessionId=\' + self.sessionId + \'&PageNumbe" + -"r=\' + self.pageNumber + \'&NoCache=\' + enabled + \')\';\r\n }\r\n " + -" return null;\r\n });\r\n }\r\n\r\n function parseLog(l" + -"og) {\r\n if (log.ModuleId === 40 && log.Arguments && log.Arguments.len" + -"gth > 0) {\r\n // find session\r\n var sessionId = log" + -".Arguments[0];\r\n var session = vm.sessionIndex[sessionId];\r\n " + -" if (!session && log.EventTypeId === 10) { // Starting Session (Ignore" + -" \'partial\' sessions)\r\n session = new sessionViewModel(log.Arg" + -"uments[1]);\r\n vm.sessionIndex[sessionId] = session;\r\n " + -" vm.sessions.unshift(session);\r\n vm.noSessions(fal" + -"se);\r\n }\r\n if (session) {\r\n swi" + -"tch (log.EventTypeId) {\r\n case 10: // SessionStarting\r\n " + -" session.startTime(log.FormattedTimestamp.substring(log" + -".FormattedTimestamp.indexOf(\' \') + 1));\r\n break;\r\n " + -" case 11: // SessionProgress\r\n se" + -"ssion.progressValue(log.Arguments[1]);\r\n session.prog" + -"ressStatus(log.Arguments[2]);\r\n break;\r\n " + -" case 12: // SessionFinished\r\n session.sess" + -"ionEnded(true);\r\n session.progressStatus(\'Import Fini" + -"shed\');\r\n break;\r\n case 15: //" + -" SessionWarning\r\n session.messages.unshift(log);\r\n " + -" break;\r\n case 16: // SessionErro" + -"r\r\n session.messages.unshift(log);\r\n " + -" break;\r\n case 100: // ImportPageStarting\r\n " + -" session.addSessionPage(new sessionPageViewModel(sessionI" + -"d, log.Arguments[1]));\r\n break;\r\n " + -" case 104: // ImportPageImageUpdate\r\n var p = sess" + -"ion.sessionPagesIndex[log.Arguments[1]];\r\n if (p) {\r\n" + -" p.updateThumbnail();\r\n " + -" }\r\n break;\r\n case 105: // Im" + -"portPageProgress\r\n var p = session.sessionPagesIndex[" + -"log.Arguments[1]];\r\n if (p) {\r\n " + -" p.progressValue(log.Arguments[2]);\r\n p." + -"progressStatus(log.Arguments[3]);\r\n }\r\n " + -" break;\r\n case 110: // ImportPageDetected\r\n " + -" var p = session.sessionPagesIndex[log.Arguments[1]];\r" + -"\n if (p) {\r\n p.documen" + -"tTemplateId(log.Arguments[2]);\r\n p.documentTempla" + -"te(log.Arguments[3]);\r\n p.assignedDataType(log.Ar" + -"guments[4]);\r\n p.assignedDataId(log.Arguments[5])" + -";\r\n p.assignedData(log.Arguments[6]);\r\n " + -" p.detected(true);\r\n if (!is" + -"Live) {\r\n p.updateThumbnail();\r\n " + -" }\r\n }\r\n " + -" session.messages.unshift(log);\r\n break;\r\n " + -" case 115: // ImportPageUndetected\r\n var " + -"p = session.sessionPagesIndex[log.Arguments[1]];\r\n if" + -" (p) {\r\n p.undetected(true);\r\n " + -" if (!isLive) {\r\n p.updateThumbna" + -"il();\r\n }\r\n }\r\n " + -" session.messages.unshift(log);\r\n " + -" break;\r\n case 150: // Ignore: ImportPageUndetectedStored" + -"\r\n break;\r\n default:\r\n " + -" session.messages.unshift(log);\r\n }\r\n " + -" }\r\n }\r\n }\r\n function init() {\r\n /" + -"/ Create View Model\r\n vm = new pageViewModel();\r\n\r\n // Loa" + -"d Logs\r\n var d = new Date();\r\n var loadData = {\r\n " + -" Format: \"json\",\r\n Start: d.getFullYear() + \'-\' + (d.getMon" + -"th() + 1) + \'-\' + d.getDate(),\r\n End: null,\r\n Modu" + -"leId: 40,\r\n Take: 2000\r\n };\r\n $.ajax({\r\n " + -" url: \'"); +"dSessionPage = function (sessionPage) {\r\n self.sessionPages.push(" + +"sessionPage);\r\n self.sessionPagesIndex[sessionPage.pageNumber] = " + +"sessionPage;\r\n }\r\n }\r\n function sessionPageViewModel(se" + +"ssionId, pageNumber) {\r\n var self = this;\r\n\r\n self.session" + +"Id = sessionId;\r\n self.pageNumber = pageNumber;\r\n self.tit" + +"le = \'Page \' + pageNumber;\r\n self.progressStatus = ko.observable();\r\n" + +" self.progressValue = ko.observable();\r\n self.undetected =" + +" ko.observable(false);\r\n self.detected = ko.observable(false);\r\n " + +" self.documentTemplateId = ko.observable();\r\n self.documentTemp" + +"late = ko.observable();\r\n self.assignedDataType = ko.observable();\r\n " + +" self.assignedDataId = ko.observable();\r\n self.assignedData" + +" = ko.observable();\r\n self.thumbnailEnabled = ko.observable(0);\r\n " + +" self.updateThumbnail = function () {\r\n self.thumbnailEnab" + +"led(self.thumbnailEnabled() + 1);\r\n }\r\n self.documentTempl" + +"ateUrl = ko.computed(function () {\r\n return urlDocumentTemplate +" + +" self.documentTemplateId();\r\n });\r\n self.manuallyAssignUrl" + +" = ko.computed(function () {\r\n return urlManuallyAssign + \'#\' + s" + +"elf.sessionId + \'_\' + self.pageNumber;\r\n });\r\n self.assign" + +"edDataUrl = ko.computed(function () {\r\n var t = self.assignedData" + +"Type();\r\n var dId = self.assignedDataId();\r\n if (d" + +"Id !== undefined) {\r\n switch (t) {\r\n c" + +"ase \'Device\':\r\n return urlDeviceShow + dId;\r\n " + +" case \'Job\':\r\n return urlJobShow + dId" + +";\r\n case \'User\':\r\n if (dId.ind" + +"exOf(\'\\\\\') < 0)\r\n return urlUserShow + dId;\r\n " + +" else\r\n return urlUserShow" + +" + dId.substr(dId.indexOf(\'\\\\\') + 1) + \'?domain=\' + dId.substr(0, dId.indexOf(\'\\" + +"\\\'));\r\n }\r\n }\r\n return null;\r\n " + +" });\r\n self.thumbnailUrl = ko.computed(function () {\r\n " + +" var enabled = self.thumbnailEnabled();\r\n if (enabled >" + +" 0) {\r\n return \'url(\' + urlPageThumbnail + \'?SessionId=\' + se" + +"lf.sessionId + \'&PageNumber=\' + self.pageNumber + \'&NoCache=\' + enabled + \')\';\r\n" + +" }\r\n return null;\r\n });\r\n }\r\n\r\n " + +" function parseLog(log) {\r\n if (log.ModuleId === 40 && log.Argu" + +"ments && log.Arguments.length > 0) {\r\n // find session\r\n " + +" var sessionId = log.Arguments[0];\r\n var session = vm.sessi" + +"onIndex[sessionId];\r\n if (!session && log.EventTypeId === 10) { /" + +"/ Starting Session (Ignore \'partial\' sessions)\r\n session = ne" + +"w sessionViewModel(log.Arguments[1]);\r\n vm.sessionIndex[sessi" + +"onId] = session;\r\n vm.sessions.unshift(session);\r\n " + +" vm.noSessions(false);\r\n }\r\n if (session) " + +"{\r\n switch (log.EventTypeId) {\r\n case " + +"10: // SessionStarting\r\n session.startTime(log.Format" + +"tedTimestamp.substring(log.FormattedTimestamp.indexOf(\' \') + 1));\r\n " + +" break;\r\n case 11: // SessionProgress\r\n " + +" session.progressValue(log.Arguments[1]);\r\n " + +" session.progressStatus(log.Arguments[2]);\r\n " + +" break;\r\n case 12: // SessionFinished\r\n " + +" session.sessionEnded(true);\r\n session.p" + +"rogressStatus(\'Import Finished\');\r\n break;\r\n " + +" case 15: // SessionWarning\r\n session.m" + +"essages.unshift(log);\r\n break;\r\n " + +" case 16: // SessionError\r\n session.messages.unshif" + +"t(log);\r\n break;\r\n case 100: /" + +"/ ImportPageStarting\r\n session.addSessionPage(new ses" + +"sionPageViewModel(sessionId, log.Arguments[1]));\r\n br" + +"eak;\r\n case 104: // ImportPageImageUpdate\r\n " + +" var p = session.sessionPagesIndex[log.Arguments[1]];\r\n " + +" if (p) {\r\n p.updateThumbnail();\r\n" + +" }\r\n break;\r\n " + +" case 105: // ImportPageProgress\r\n var p = " + +"session.sessionPagesIndex[log.Arguments[1]];\r\n if (p)" + +" {\r\n p.progressValue(log.Arguments[2]);\r\n " + +" p.progressStatus(log.Arguments[3]);\r\n " + +" }\r\n break;\r\n case 110" + +": // ImportPageDetected\r\n var p = session.sessionPage" + +"sIndex[log.Arguments[1]];\r\n if (p) {\r\n " + +" p.documentTemplateId(log.Arguments[2]);\r\n " + +" p.documentTemplate(log.Arguments[3]);\r\n " + +" p.assignedDataType(log.Arguments[4]);\r\n p.assign" + +"edDataId(log.Arguments[5]);\r\n p.assignedData(log." + +"Arguments[6]);\r\n p.detected(true);\r\n " + +" if (!isLive) {\r\n p.updateT" + +"humbnail();\r\n }\r\n }\r\n " + +" session.messages.unshift(log);\r\n " + +" break;\r\n case 115: // ImportPageUndetected\r\n " + +" var p = session.sessionPagesIndex[log.Arguments[1]];\r\n " + +" if (p) {\r\n p.undetected(t" + +"rue);\r\n if (!isLive) {\r\n " + +" p.updateThumbnail();\r\n }\r\n " + +" }\r\n session.messages.unshift(log);\r\n " + +" break;\r\n case 150: // Ignore: " + +"ImportPageUndetectedStored\r\n break;\r\n " + +" default:\r\n session.messages.unshift(log);\r\n " + +" }\r\n }\r\n }\r\n }\r\n functi" + +"on init() {\r\n // Create View Model\r\n vm = new pageViewMode" + +"l();\r\n\r\n // Load Logs\r\n var d = new Date();\r\n v" + +"ar loadData = {\r\n Format: \"json\",\r\n Start: d.getFu" + +"llYear() + \'-\' + (d.getMonth() + 1) + \'-\' + d.getDate(),\r\n End: n" + +"ull,\r\n ModuleId: 40,\r\n Take: 2000\r\n };\r" + +"\n $.ajax({\r\n url: \'"); - #line 288 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml" + #line 286 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml" Write(Url.Action(MVC.API.Logging.RetrieveEvents())); @@ -454,29 +453,28 @@ WriteLiteral(@"', ko.applyBindings(vm); // Init Persistent Connection - liveConnection = $.connection('"); + logHub = $.connection.logNotifications; + logHub.client.receiveLog = parseLog + + $.connection.hub.qs = { LogModules: '"); - #line 308 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml" - Write(Url.Content("~/API/Logging/Notifications")); + #line 309 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml" + Write(Disco.BI.DocumentTemplateBI.Importer.DocumentImporterLog.Current.LiveLogGroupName); #line default #line hidden -WriteLiteral("\', { addToGroups: \'"); +WriteLiteral(@"' }; + $.connection.hub.error(function (error) { + alert('Live-Log Error: ' + error); + }); - - #line 308 "..\..\Areas\Config\Views\DocumentTemplate\ImportStatus.cshtml" - Write(Disco.BI.DocumentTemplateBI.Importer.DocumentImporterLog.Current.LiveLogGroupName); - - - #line default - #line hidden -WriteLiteral(@"' }); - liveConnection.received(parseLog); - liveConnection.error(function (e) { if (e.status != 200) alert('Live-Log Error: ' + e.statusText + ': ' + e.responseText); }); - isLive = true; - liveConnection.start(); + $.connection.hub.start() + .done(function () { isLive = true; }) + .fail(function (error) { + alert('Live-Log Connection Error: ' + error); + }); } init(); }); diff --git a/Disco.Web/Areas/Config/Views/Enrolment/Status.cshtml b/Disco.Web/Areas/Config/Views/Enrolment/Status.cshtml index fa5e0548..8c3dd8a3 100644 --- a/Disco.Web/Areas/Config/Views/Enrolment/Status.cshtml +++ b/Disco.Web/Areas/Config/Views/Enrolment/Status.cshtml @@ -136,7 +136,7 @@ var hostDialogSessions = $('#dialogSession'); //var hostDialogSessionsProgress = $('#dialogSession').find('.sessionProgress'); var deviceModels = {}; - var liveConnection; + var logHub; var deviceBaseUrl = '@(Url.Action(MVC.Device.Show()))/' var deviceModelImageUrl = '@(Url.Action(MVC.API.DeviceModel.Image()))/' var iconWarningUrl = 'url(@(Links.ClientSource.Style.Images.Status.warning32_png))'; @@ -356,10 +356,19 @@ vm.isotopeInited = true; // Init Persistent Connection - liveConnection = $.connection('@(Url.Content("~/API/Logging/Notifications"))', { addToGroups: '@(Disco.BI.DeviceBI.EnrolmentLog.Current.LiveLogGroupName)' }); - liveConnection.received(parseLog); - liveConnection.error(function (e) { if (e.status != 200) alert('Live-Log Error: ' + e.statusText + ': ' + e.responseText); }); - liveConnection.start(); + logHub = $.connection.logNotifications; + logHub.client.receiveLog = parseLog + + $.connection.hub.qs = { LogModules: '@(Disco.BI.DeviceBI.EnrolmentLog.Current.LiveLogGroupName)' }; + $.connection.hub.error(function (error) { + alert('Live-Log Error: ' + error); + }); + + $.connection.hub.start() + .done(function () { isLive = true; }) + .fail(function (error) { + alert('Live-Log Connection Error: ' + error); + }); } init(); }); diff --git a/Disco.Web/Areas/Config/Views/Enrolment/Status.generated.cs b/Disco.Web/Areas/Config/Views/Enrolment/Status.generated.cs index f9aa4c5c..df3ab6cf 100644 --- a/Disco.Web/Areas/Config/Views/Enrolment/Status.generated.cs +++ b/Disco.Web/Areas/Config/Views/Enrolment/Status.generated.cs @@ -319,7 +319,7 @@ WriteLiteral(@"> var hostDialogSessions = $('#dialogSession'); //var hostDialogSessionsProgress = $('#dialogSession').find('.sessionProgress'); var deviceModels = {}; - var liveConnection; + var logHub; var deviceBaseUrl = '"); @@ -520,28 +520,28 @@ WriteLiteral(@"', vm.isotopeInited = true; // Init Persistent Connection - liveConnection = $.connection('"); + logHub = $.connection.logNotifications; + logHub.client.receiveLog = parseLog + + $.connection.hub.qs = { LogModules: '"); - #line 359 "..\..\Areas\Config\Views\Enrolment\Status.cshtml" - Write(Url.Content("~/API/Logging/Notifications")); + #line 362 "..\..\Areas\Config\Views\Enrolment\Status.cshtml" + Write(Disco.BI.DeviceBI.EnrolmentLog.Current.LiveLogGroupName); #line default #line hidden -WriteLiteral("\', { addToGroups: \'"); +WriteLiteral(@"' }; + $.connection.hub.error(function (error) { + alert('Live-Log Error: ' + error); + }); - - #line 359 "..\..\Areas\Config\Views\Enrolment\Status.cshtml" - Write(Disco.BI.DeviceBI.EnrolmentLog.Current.LiveLogGroupName); - - - #line default - #line hidden -WriteLiteral(@"' }); - liveConnection.received(parseLog); - liveConnection.error(function (e) { if (e.status != 200) alert('Live-Log Error: ' + e.statusText + ': ' + e.responseText); }); - liveConnection.start(); + $.connection.hub.start() + .done(function () { isLive = true; }) + .fail(function (error) { + alert('Live-Log Connection Error: ' + error); + }); } init(); }); diff --git a/Disco.Web/Controllers/DeviceController.cs b/Disco.Web/Controllers/DeviceController.cs index 76f80ff1..9ca8c3bb 100644 --- a/Disco.Web/Controllers/DeviceController.cs +++ b/Disco.Web/Controllers/DeviceController.cs @@ -202,7 +202,9 @@ namespace Disco.Web.Controllers Database.Configuration.LazyLoadingEnabled = true; m.Device = Database.Devices - .Include("DeviceModel").Include("DeviceDetails").Include("DeviceUserAssignments.AssignedUser").Include("DeviceAttachments") + .Include("DeviceModel").Include("DeviceProfile").Include("DeviceBatch").Include("DeviceDetails") + .Include("DeviceUserAssignments.AssignedUser").Include("AssignedUser").Include("DeviceCertificates") + .Include("DeviceAttachments.TechUser").Include("DeviceAttachments.DocumentTemplate") .FirstOrDefault(d => d.SerialNumber == id); if (m.Device == null) diff --git a/Disco.Web/Controllers/JobController.cs b/Disco.Web/Controllers/JobController.cs index 8b46d20a..cd7fa20f 100644 --- a/Disco.Web/Controllers/JobController.cs +++ b/Disco.Web/Controllers/JobController.cs @@ -294,10 +294,11 @@ namespace Disco.Web.Controllers var m = new Models.Job.ShowModel(); - m.Job = (from j in Database.Jobs.Include("Device.DeviceModel").Include("Device.DeviceBatch").Include("DeviceHeldTechUser").Include("DeviceReadyForReturnTechUser").Include("DeviceReturnedTechUser") - .Include("OpenedTechUser").Include("ClosedTechUser").Include("JobType").Include("JobSubTypes").Include("User").Include("JobLogs.TechUser") - where (j.Id == id.Value) - select j).FirstOrDefault(); + m.Job = Database.Jobs + .Include("Device.DeviceModel").Include("Device.DeviceBatch").Include("DeviceHeldTechUser").Include("DeviceReadyForReturnTechUser").Include("DeviceReturnedTechUser") + .Include("OpenedTechUser").Include("ClosedTechUser").Include("JobType").Include("JobSubTypes").Include("User").Include("JobLogs.TechUser") + .Include("JobAttachments.TechUser").Include("JobAttachments.DocumentTemplate") + .FirstOrDefault(j => j.Id == id.Value); if (m.Job == null) throw new ArgumentException(string.Format("Unknown Job: [{0}]", id), "id"); diff --git a/Disco.Web/Controllers/UserController.cs b/Disco.Web/Controllers/UserController.cs index 28895afe..53f1e592 100644 --- a/Disco.Web/Controllers/UserController.cs +++ b/Disco.Web/Controllers/UserController.cs @@ -56,7 +56,11 @@ namespace Disco.Web.Controllers } m.User = Database.Users - .Include("DeviceUserAssignments.Device.DeviceModel").Include("UserAttachments") + .Include("DeviceUserAssignments.Device.DeviceModel") + .Include("DeviceUserAssignments.Device.DeviceProfile") + .Include("DeviceUserAssignments.Device.DeviceBatch") + .Include("UserAttachments.TechUser") + .Include("UserAttachments.DocumentTemplate") .FirstOrDefault(um => um.UserId == id); if (m.User == null) diff --git a/Disco.Web/Views/Device/DeviceParts/_Resources.cshtml b/Disco.Web/Views/Device/DeviceParts/_Resources.cshtml index f9d5e946..4f22d8bf 100644 --- a/Disco.Web/Views/Device/DeviceParts/_Resources.cshtml +++ b/Disco.Web/Views/Device/DeviceParts/_Resources.cshtml @@ -52,6 +52,7 @@ $(function () { var $Attachments = $('#Attachments'); var $attachmentOutput = $Attachments.find('.attachmentOutput'); + var $attachmentDownloadHost; var $dialogUpload = null; var $dialogRemoveAttachment = null; @@ -114,7 +115,7 @@ e.attr('data-attachmentid', a.Id).attr('data-mimetype', a.MimeType).attr('href', '@(Url.Action(MVC.API.Device.AttachmentDownload()))/' + a.Id); e.find('.icon img').attr('src', '@(Url.Action(MVC.API.Device.AttachmentThumbnail()))/' + a.Id); - e.find('.comments').text(a.Comments); + e.find('.comments').text(a.Description); e.find('.author').text(a.Author); e.find('.timestamp').text(a.TimestampFull).attr('title', a.TimestampFull).livestamp(a.TimestampUnixEpoc); if (canRemove) @@ -126,7 +127,9 @@ if (!quick) e.show('slow'); if (a.MimeType.toLowerCase().indexOf('image/') == 0) - e.shadowbox({ gallery: 'attachments', player: 'img', title: a.Comments }); + e.shadowbox({ gallery: 'attachments', player: 'img', title: a.Description }); + else + e.click(onDownload); } function onRemoveAttachment(id) { @@ -142,6 +145,30 @@ }); } + function onDownload() { + var $this = $(this); + var url = $this.attr('href'); + + if ($.connection && $.connection.hub && $.connection.hub.transport && + $.connection.hub.transport.name == 'foreverFrame') { + // SignalR active with foreverFrame transport - use popup window + window.open(url, '_blank', 'height=150,width=250,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no'); + } else { + // use iFrame + if (!$attachmentDownloadHost) { + $attachmentDownloadHost = $('