#pragma warning disable 1591 //------------------------------------------------------------------------------ // // This code was generated by a tool. // Runtime Version:4.0.30319.34014 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ namespace Disco.Web.Views.Device.DeviceParts { using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Text; using System.Web; using System.Web.Helpers; using System.Web.Mvc; using System.Web.Mvc.Ajax; using System.Web.Mvc.Html; using System.Web.Routing; using System.Web.Security; using System.Web.UI; using System.Web.WebPages; using Disco; using Disco.BI.Extensions; using Disco.Models.Repository; using Disco.Services; using Disco.Services.Authorization; using Disco.Services.Web; using Disco.Web; using Disco.Web.Extensions; [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")] [System.Web.WebPages.PageVirtualPathAttribute("~/Views/Device/DeviceParts/_Resources.cshtml")] public partial class Resources : Disco.Services.Web.WebViewPage { public Resources() { } public override void Execute() { #line 2 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Authorization.Require(Claims.Device.ShowAttachments); var canAddAttachments = Authorization.Has(Claims.Device.Actions.AddAttachments); var canRemoveAnyAttachments = Authorization.Has(Claims.Device.Actions.RemoveAnyAttachments); var canRemoveOwnAttachments = Authorization.Has(Claims.Device.Actions.RemoveOwnAttachments); Html.BundleDeferred("~/Style/Shadowbox"); Html.BundleDeferred("~/ClientScripts/Modules/Shadowbox"); Html.BundleDeferred("~/ClientScripts/Modules/jQuery-SignalR"); if (canAddAttachments) { Html.BundleDeferred("~/ClientScripts/Modules/Silverlight"); } #line default #line hidden WriteLiteral("\r\n\r\n \r\n \r\n (canAddAttachments ? "canAddAttachments" : "cannotAddAttachments" #line default #line hidden , 834), false) ); WriteLiteral(">\r\n \r\n"); #line 23 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line default #line hidden #line 23 "..\..\Views\Device\DeviceParts\_Resources.cshtml" if (Model.Device.DeviceAttachments != null) { foreach (var da in Model.Device.DeviceAttachments) { #line default #line hidden WriteLiteral(" (Url.Action(MVC.API.Device.AttachmentDownload(da.Id)) #line default #line hidden , 1178), false) ); WriteLiteral(" data-attachmentid=\""); #line 27 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(da.Id); #line default #line hidden WriteLiteral("\""); WriteLiteral(" data-mimetype=\""); #line 27 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(da.MimeType); #line default #line hidden WriteLiteral("\""); WriteLiteral(">\r\n (da.Filename #line default #line hidden , 1345), false) ); WriteLiteral(">\r\n (Url.Action(MVC.API.Device.AttachmentThumbnail(da.Id)) #line default #line hidden , 1430), false) ); WriteLiteral(" />\r\n (da.Comments #line default #line hidden , 1557), false) ); WriteLiteral(">\r\n"); #line 31 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line default #line hidden #line 31 "..\..\Views\Device\DeviceParts\_Resources.cshtml" if (!string.IsNullOrEmpty(da.DocumentTemplateId)) { #line default #line hidden #line 32 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(da.DocumentTemplate.Description); #line default #line hidden #line 32 "..\..\Views\Device\DeviceParts\_Resources.cshtml" } else { #line default #line hidden #line 34 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(da.Comments); #line default #line hidden #line 34 "..\..\Views\Device\DeviceParts\_Resources.cshtml" } #line default #line hidden WriteLiteral("\r\n "); #line 35 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(da.TechUser.ToString()); #line default #line hidden WriteLiteral(""); #line 35 "..\..\Views\Device\DeviceParts\_Resources.cshtml" if (canRemoveAnyAttachments || (canRemoveOwnAttachments && da.TechUserId == CurrentUser.UserId)) { #line default #line hidden WriteLiteral(""); #line 36 "..\..\Views\Device\DeviceParts\_Resources.cshtml" } #line default #line hidden WriteLiteral("(da.Timestamp.ToFullDateTime() #line default #line hidden , 2186), false) ); WriteLiteral(" data-livestamp=\""); #line 36 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(da.Timestamp.ToUnixEpoc()); #line default #line hidden WriteLiteral("\""); WriteLiteral(">"); #line 36 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(da.Timestamp.ToFullDateTime()); #line default #line hidden WriteLiteral("\r\n \r\n"); #line 38 "..\..\Views\Device\DeviceParts\_Resources.cshtml" } } #line default #line hidden WriteLiteral(" \r\n"); #line 41 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line default #line hidden #line 41 "..\..\Views\Device\DeviceParts\_Resources.cshtml" if (canAddAttachments) { #line default #line hidden WriteLiteral(" \r\n \r\n \r\n"); #line 46 "..\..\Views\Device\DeviceParts\_Resources.cshtml" } #line default #line hidden WriteLiteral(" Shadowbox.init({ skipSetup: true, modal: true }); $(function () { var $Attachments = $('#Attachments'); var $attachmentOutput = $Attachments.find('.attachmentOutput'); var $dialogUpload = null; var $dialogRemoveAttachment = null; // Connect to Hub var hub = $.connection.deviceUpdates; // Map Functions hub.client.addAttachment = onAddAttachment; hub.client.removeAttachment = onRemoveAttachment; $.connection.hub.qs = { DeviceSerialNumber: '"); #line 66 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(Model.Device.SerialNumber); #line default #line hidden WriteLiteral(@"' }; $.connection.hub.error(onHubError); // Start Connection $.connection.hub.start().fail(onHubError); function onHubError(error) { alert('Live-update Error: ' + error); } function onAddAttachment(id, quick) { var data = { id: id }; $.ajax({ url: '"); #line 79 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(Url.Action(MVC.API.Device.Attachment())); #line default #line hidden WriteLiteral(@"', dataType: 'json', data: data, success: function (d) { if (d.Result == 'OK') { var a = d.Attachment; "); #line 85 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line default #line hidden #line 85 "..\..\Views\Device\DeviceParts\_Resources.cshtml" if (canRemoveAnyAttachments) { #line default #line hidden WriteLiteral(" "); WriteLiteral("buildAttachment(a, true, quick);"); WriteLiteral("\r\n"); #line 88 "..\..\Views\Device\DeviceParts\_Resources.cshtml" } else if (canRemoveOwnAttachments) { #line default #line hidden WriteLiteral(" "); WriteLiteral("buildAttachment(a, (a.AuthorId === \'"); #line 91 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(CurrentUser.UserId); #line default #line hidden WriteLiteral("\'), quick);"); WriteLiteral("\r\n"); #line 92 "..\..\Views\Device\DeviceParts\_Resources.cshtml" } else { #line default #line hidden WriteLiteral(" "); WriteLiteral("buildAttachment(a, false, quick);"); WriteLiteral("\r\n"); #line 96 "..\..\Views\Device\DeviceParts\_Resources.cshtml" } #line default #line hidden WriteLiteral(@" } else { alert('Unable to add attachment: ' + d.Result); } }, error: function (jqXHR, textStatus, errorThrown) { alert('Unable to add attachment: ' + textStatus); } }); } function buildAttachment(a, canRemove, quick) { var t = ''; if (canRemove) t += ''; t += ''; var e = $(t); e.attr('data-attachmentid', a.Id).attr('data-mimetype', a.MimeType).attr('href', '"); #line 115 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(Url.Action(MVC.API.Device.AttachmentDownload())); #line default #line hidden WriteLiteral("/\' + a.Id);\r\n e.find(\'.icon img\').attr(\'src\', \'"); #line 116 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(Url.Action(MVC.API.Device.AttachmentThumbnail())); #line default #line hidden WriteLiteral("/\' + a.Id);\r\n e.find(\'.comments\').text(a.Comments);\r\n " + " e.find(\'.author\').text(a.Author);\r\n " + " e.find(\'.timestamp\').text(a.TimestampFull).attr(\'title\', a.TimestampFu" + "ll).livestamp(a.TimestampUnixEpoc);\r\n if (canRemove)\r" + "\n e.find(\'.remove\').click(removeAttachment);\r\n " + " if (!quick)\r\n e.hide();\r" + "\n $attachmentOutput.append(e);\r\n " + " onUpdate();\r\n if (!quick)\r\n " + " e.show(\'slow\');\r\n if (a.MimeType.toLower" + "Case().indexOf(\'image/\') == 0)\r\n e.shadowbox({ ga" + "llery: \'attachments\', player: \'img\', title: a.Comments });\r\n " + " }\r\n\r\n function onRemoveAttachment(id) {\r\n " + " var a = $attachmentOutput.find(\'a[data-attachmentid=\' + id + \']\'" + ");\r\n\r\n a.hide(300).delay(300).queue(function () {\r\n " + " var $this = $(this);\r\n " + " if ($this.attr(\'data-mimetype\').toLowerCase().indexOf(\'image/\') == 0)\r\n " + " Shadowbox.removeCache(this);\r\n " + " $this.find(\'.timestamp\').livestamp(\'destroy\');\r\n " + " $this.remove();\r\n onUpdate();\r\n " + " });\r\n }\r\n\r\n " + " function onUpdate() {\r\n var attachmentCount = $attac" + "hmentOutput.children(\'a\').length;\r\n var tabHeading = " + "\'Attachments [\' + attachmentCount + \']\';\r\n $(\'#Device" + "DetailTab-ResourcesLink\').text(tabHeading);\r\n }\r\n\r\n"); #line 151 "..\..\Views\Device\DeviceParts\_Resources.cshtml" #line default #line hidden #line 151 "..\..\Views\Device\DeviceParts\_Resources.cshtml" if (canAddAttachments) { #line default #line hidden WriteLiteral("\r\n //#region Add Attachments\r\n if (" + "!document.DiscoFunctions) {\r\n document.DiscoFunctions" + " = {};\r\n }\r\n document.DiscoFunctio" + "ns.addAttachment = function (Id) { return; /* Silverlight notification, do nothi" + "ng use SignalR */ };\r\n\r\n var $attachmentInput = $Attachme" + "nts.find(\'.attachmentInput\');\r\n $attachmentInput.find(\'.p" + "hoto\').click(function () {\r\n showDialog(\'/WebCam\');\r\n" + " });\r\n $attachmentInput.find(\'.upl" + "oad\').click(function () {\r\n showDialog(\'/File\');\r\n " + " });\r\n\r\n var silverlightOnLoadNavigat" + "ion = null;\r\n var silverlightIsLoaded = null;\r\n\r\n " + " function showDialog(navigationPath) {\r\n " + " if (!$dialogUpload) {\r\n $dialogUpload = $(\'#di" + "alogUpload\').dialog({\r\n autoOpen: false,\r\n " + " draggable: false,\r\n " + " modal: true,\r\n resizable: false,\r\n " + " width: 860,\r\n " + " height: 550,\r\n close: function () {\r\n " + " var sl = $(\'#silverlightUploadAttachment\').get" + "(0);\r\n if (sl.content)\r\n " + " sl.content.Navigator.Navigate(\'/Hidden\');\r\n " + " }\r\n });\r\n\r\n " + " Silverlight.createObject(\'"); #line 186 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(Links.ClientBin.Disco_Silverlight_AttachmentUpload_xap); #line default #line hidden WriteLiteral(@"', $('#silverlightHostUploadAttachment').get(0), 'silverlightUploadAttachment', { width: '840px', height: '500px', background: 'white', version: '4.0.60310.0' }, { onLoad: function () { if (silverlightOnLoadNavigation) { $('#silverlightUploadAttachment').get(0).content.Navigator.Navigate(silverlightOnLoadNavigation); silverlightIsLoaded = true; } } }, 'UploadUrl="); #line 198 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(Url.Action(MVC.API.Device.AttachmentUpload(Model.Device.SerialNumber, null))); #line default #line hidden WriteLiteral(@"'); } $dialogUpload.dialog('open'); if (silverlightIsLoaded) { $('#silverlightUploadAttachment').get(0).content.Navigator.Navigate(navigationPath); } else { silverlightOnLoadNavigation = navigationPath; } }; //#endregion "); #line 210 "..\..\Views\Device\DeviceParts\_Resources.cshtml" } #line default #line hidden WriteLiteral(" "); #line 211 "..\..\Views\Device\DeviceParts\_Resources.cshtml" if (canRemoveAnyAttachments || canRemoveOwnAttachments) { #line default #line hidden WriteLiteral(@" //#region Remove Attachments $attachmentOutput.find('span.remove').click(removeAttachment); function removeAttachment() { $this = $(this).closest('a'); var data = { id: $this.attr('data-attachmentid') }; if (!$dialogRemoveAttachment) { $dialogRemoveAttachment = $('#dialogRemoveAttachment').dialog({ resizable: false, height: 140, modal: true, autoOpen: false }); } $dialogRemoveAttachment.dialog(""enable""); $dialogRemoveAttachment.dialog('option', 'buttons', { ""Remove"": function () { $dialogRemoveAttachment.dialog(""disable""); $dialogRemoveAttachment.dialog(""option"", ""buttons"", null); $.ajax({ url: '"); #line 236 "..\..\Views\Device\DeviceParts\_Resources.cshtml" Write(Url.Action(MVC.API.Device.AttachmentRemove())); #line default #line hidden WriteLiteral(@"', dataType: 'json', data: data, success: function (d) { if (d == 'OK') { // Do nothing, await SignalR notification } else { alert('Unable to remove attachment: ' + d); } $dialogRemoveAttachment.dialog(""close""); }, error: function (jqXHR, textStatus, errorThrown) { alert('Unable to remove attachment: ' + textStatus); $dialogRemoveAttachment.dialog(""close""); } }); }, Cancel: function () { $dialogRemoveAttachment.dialog(""close""); } }); $dialogRemoveAttachment.dialog('open'); return false; } //#endregion "); #line 263 "..\..\Views\Device\DeviceParts\_Resources.cshtml" } #line default #line hidden WriteLiteral(@" $attachmentOutput.children('a').each(function () { $this = $(this); if ($this.attr('data-mimetype').toLowerCase().indexOf('image/') == 0) $this.shadowbox({ gallery: 'attachments', player: 'img', title: $this.find('.comments').text() }); }); }); \r\n \r\n \r\n \r\n \r\n

\r\n  Are you sure?\r\n

\r\n \r\n \r\n\r\n"); } } } #pragma warning restore 1591