#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//     Runtime Version:4.0.30319.17929
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

namespace Disco.Web.Areas.Config.Views.Enrolment
{
    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.BI.Extensions;
    using Disco.Models.Repository;
    using Disco.Web;
    using Disco.Web.Extensions;
    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.0.0")]
    [System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/Enrolment/Status.cshtml")]
    public class Status : System.Web.Mvc.WebViewPage<dynamic>
    {
        public Status()
        {
        }
        public override void Execute()
        {
            
            #line 1 "..\..\Areas\Config\Views\Enrolment\Status.cshtml"
  
    ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Enrolment", MVC.Config.Enrolment.Index(), "Status");
    Html.BundleDeferred("~/ClientScripts/Modules/Knockout");
    Html.BundleDeferred("~/ClientScripts/Modules/jQuery-SignalR");
    Html.BundleDeferred("~/ClientScripts/Modules/jQuery-Isotope");

            
            #line default
            #line hidden
WriteLiteral("\r\n<div");

WriteLiteral(" id=\"enrolStatus\"");

WriteLiteral(">\r\n    <div");

WriteLiteral(" id=\"noSessions\"");

WriteLiteral(" data-bind=\"visible: noSessions\"");

WriteLiteral(">\r\n        <h2>\r\n            No enrolment sessions today</h2>\r\n    </div>\r\n    <d" +
"iv");

WriteLiteral(" id=\"sessions\"");

WriteLiteral(" data-bind=\"visible: !noSessions(), foreach: {data: sessions, afterRender: sessio" +
"nRendered, afterAdd: sessionAdded}\"");

WriteLiteral("\r\n        style=\"display: none\"");

WriteLiteral(">\r\n        <div");

WriteLiteral(" class=\"session\"");

WriteLiteral(" data-bind=\"style: {backgroundImage: deviceModelImageUrl}, click: select\"");

WriteLiteral(">\r\n            <h3>\r\n                <span");

WriteLiteral(" data-bind=\"text: title\"");

WriteLiteral("></span><span");

WriteLiteral(" class=\"details\"");

WriteLiteral(" data-bind=\"text: \'(\' + deviceModelDescription() + \')\'\"");

WriteLiteral(">\r\n                </span>\r\n            </h3>\r\n            <p");

WriteLiteral(" class=\"sessionStart\"");

WriteLiteral(" data-bind=\"text: startTime\"");

WriteLiteral(">\r\n            </p>\r\n            <p");

WriteLiteral(" class=\"sessionStatus\"");

WriteLiteral(" data-bind=\"text: progressStatus\"");

WriteLiteral(">\r\n            </p>\r\n            <div");

WriteLiteral(" data-bind=\"visible: !sessionEnded(), progressValue: progressValue\"");

WriteLiteral(" class=\"sessionProgress\"");

WriteLiteral(">\r\n            </div>\r\n        </div>\r\n    </div>\r\n    <div");

WriteLiteral(" id=\"dialogSession\"");

WriteLiteral(" data-bind=\"with: currentSession\"");

WriteLiteral(">\r\n        <div");

WriteLiteral(" class=\"sessionHeader clearfix\"");

WriteLiteral(" data-bind=\"style: {backgroundImage: deviceModelImageUrl}\"");

WriteLiteral(">\r\n            <h2>\r\n                <a");

WriteLiteral(" href=\"\"");

WriteLiteral(" target=\"_blank\"");

WriteLiteral(" data-bind=\"text: title, attr: {href: deviceUrl}\"");

WriteLiteral("></a>\r\n            </h2>\r\n            <h3");

WriteLiteral(" data-bind=\"text: deviceModelDescription\"");

WriteLiteral(">\r\n            </h3>\r\n            <table");

WriteLiteral(" data-bind=\"if: sessionDeviceInfo\"");

WriteLiteral(">\r\n                <tr>\r\n                    <th");

WriteLiteral(" style=\"width: 128px\"");

WriteLiteral(">\r\n                        Computer Name:\r\n                    </th>\r\n           " +
"         <td");

WriteLiteral(" data-bind=\"text: sessionDeviceInfo().Arguments[3]\"");

WriteLiteral(">\r\n                    </td>\r\n                </tr>\r\n                <tr>\r\n      " +
"              <th");

WriteLiteral(" style=\"width: 128px\"");

WriteLiteral(">\r\n                        UUID:\r\n                    </th>\r\n                    " +
"<td");

WriteLiteral(" data-bind=\"text: sessionDeviceInfo().Arguments[2]\"");

WriteLiteral(">\r\n                    </td>\r\n                </tr>\r\n                <tr>\r\n      " +
"              <th");

WriteLiteral(" style=\"width: 128px\"");

WriteLiteral(">\r\n                        LAN Mac Address:\r\n                    </th>\r\n         " +
"           <td");

WriteLiteral(" data-bind=\"text: sessionDeviceInfo().Arguments[4]\"");

WriteLiteral(">\r\n                    </td>\r\n                </tr>\r\n                <tr>\r\n      " +
"              <th");

WriteLiteral(" style=\"width: 128px\"");

WriteLiteral(">\r\n                        WLAN Mac Address:\r\n                    </th>\r\n        " +
"            <td");

WriteLiteral(" data-bind=\"text: sessionDeviceInfo().Arguments[5]\"");

WriteLiteral(">\r\n                    </td>\r\n                </tr>\r\n                <tr>\r\n      " +
"              <th");

WriteLiteral(" style=\"width: 128px\"");

WriteLiteral(">\r\n                        Manufacturer/Model:\r\n                    </th>\r\n      " +
"              <td");

WriteLiteral(" data-bind=\"text: sessionDeviceInfo().Arguments[6] + \' \' + sessionDeviceInfo().Ar" +
"guments[7]\"");

WriteLiteral(">\r\n                    </td>\r\n                </tr>\r\n            </table>\r\n      " +
"  </div>\r\n        <div");

WriteLiteral(" class=\"sessionProgress clearfix\"");

WriteLiteral(">\r\n            <p");

WriteLiteral(" class=\"sessionStart\"");

WriteLiteral(" data-bind=\"text: startTime\"");

WriteLiteral(">\r\n            </p>\r\n            <p");

WriteLiteral(" class=\"sessionStatus\"");

WriteLiteral(" data-bind=\"text: progressStatus\"");

WriteLiteral(">\r\n            </p>\r\n            <div");

WriteLiteral(" data-bind=\"visible: !sessionEnded(), progressValue: progressValue\"");

WriteLiteral(">\r\n            </div>\r\n        </div>\r\n        <div");

WriteLiteral(" class=\"sessionInfoContainer clearfix\"");

WriteLiteral(">\r\n            <div");

WriteLiteral(" class=\"sessionInfoMessages\"");

WriteLiteral(">\r\n                <table");

WriteLiteral(" class=\"logEventsViewport\"");

WriteLiteral(">\r\n                    <thead>\r\n                        <tr>\r\n                   " +
"         <th");

WriteLiteral(" class=\"icon\"");

WriteLiteral(">\r\n                                &nbsp;\r\n                            </th>\r\n   " +
"                         <th");

WriteLiteral(" class=\"message\"");

WriteLiteral(">\r\n                                Message\r\n                            </th>\r\n  " +
"                      </tr>\r\n                    </thead>\r\n                </tab" +
"le>\r\n                <div");

WriteLiteral(" class=\"logEventsViewportContainer\"");

WriteLiteral(">\r\n                    <div");

WriteLiteral(" class=\"logEventsViewportNoLogs\"");

WriteLiteral(" data-bind=\"visible: messages().length == 0\"");

WriteLiteral("\r\n                        style=\"display: none\"");

WriteLiteral(">\r\n                        No logs\r\n                    </div>\r\n                 " +
"   <table");

WriteLiteral(" class=\"logEventsViewport\"");

WriteLiteral(" data-bind=\"visible: messages().length > 0\"");

WriteLiteral(" style=\"display: none\"");

WriteLiteral(">\r\n                        <tbody");

WriteLiteral(" data-bind=\"foreach: messages\"");

WriteLiteral(">\r\n                            <tr>\r\n                                <td");

WriteLiteral(" class=\"icon\"");

WriteLiteral(" data-bind=\"attr: {title: FormattedTimestamp}, css: {information: EventTypeSeveri" +
"ty == 0, warning: EventTypeSeverity == 1, error: EventTypeSeverity == 2}\"");

WriteLiteral(">\r\n                                    &nbsp;\r\n                                </" +
"td>\r\n                                <td");

WriteLiteral(" class=\"message\"");

WriteLiteral(" data-bind=\"text: FormattedMessage, attr: {title: EventTypeName}\"");

WriteLiteral(">\r\n                                </td>\r\n                            </tr>\r\n    " +
"                    </tbody>\r\n                    </table>\r\n                </di" +
"v>\r\n            </div>\r\n            <div");

WriteLiteral(" class=\"sessionInfoConsole\"");

WriteLiteral(" data-bind=\"foreach: console\"");

WriteLiteral(">\r\n                <span");

WriteLiteral(" data-bind=\"text: Arguments[1]\"");

WriteLiteral("></span>\r\n            </div>\r\n        </div>\r\n    </div>\r\n</div>\r\n<script");

WriteLiteral(" type=\"text/javascript\"");

WriteLiteral(@">
    ko.bindingHandlers.progressValue = {
        update: function (element, valueAccessor, allBindingsAccessor, viewModel) {
            var v = ko.utils.unwrapObservable(valueAccessor());
            var vInt = parseInt(v);
            if (vInt >= 0) {
                $element = $(element);
                if (!$element.is('.ui-progressbar'))
                    $element.progressbar();
                $(element).progressbar('option', 'value', vInt);
            }
        }
    };
</script>
<script");

WriteLiteral(" type=\"text/javascript\"");

WriteLiteral(@">
    $(function () {
        var vm;
        var host = $('#enrolStatus');
        var hostSessions = $('#sessions');
        var hostDialogSessions = $('#dialogSession');
        //var hostDialogSessionsProgress = $('#dialogSession').find('.sessionProgress');
        var deviceModels = {};
        var liveConnection;
        var deviceBaseUrl = '");

            
            #line 141 "..\..\Areas\Config\Views\Enrolment\Status.cshtml"
                         Write(Url.Action(MVC.Device.Show()));

            
            #line default
            #line hidden
WriteLiteral("/\'\r\n        var deviceModelImageUrl = \'");

            
            #line 142 "..\..\Areas\Config\Views\Enrolment\Status.cshtml"
                               Write(Url.Action(MVC.API.DeviceModel.Image()));

            
            #line default
            #line hidden
WriteLiteral("/\'\r\n        var iconWarningUrl = \'url(");

            
            #line 143 "..\..\Areas\Config\Views\Enrolment\Status.cshtml"
                              Write(Links.ClientSource.Style.Images.Status.warning32_png);

            
            #line default
            #line hidden
WriteLiteral(")\';\r\n        var iconErrorUrl = \'url(");

            
            #line 144 "..\..\Areas\Config\Views\Enrolment\Status.cshtml"
                            Write(Links.ClientSource.Style.Images.Status.fail32_png);

            
            #line default
            #line hidden
WriteLiteral(")\';\r\n\r\n        function pageViewModel() {\r\n            var self = this;\r\n\r\n      " +
"      self.noSessions = ko.observable(true);\r\n            self.sessions = ko.obs" +
"ervableArray();\r\n            self.sessionIndex = {};\r\n\r\n            self.isotope" +
"Inited = false;\r\n\r\n            self.currentSession = ko.observable();\r\n\r\n       " +
"     self.sessionRendered = function (e, d) {\r\n                if (!d.sessionEnd" +
"ed()) {\r\n                    d.progressbar = $(e).find(\'.sessionProgress\').progr" +
"essbar();\r\n                }\r\n            };\r\n            self.sessionAdded = fu" +
"nction (e, d) {\r\n                if (self.isotopeInited) {\r\n                    " +
"hostSessions.isotope(\'reloadItems\').isotope({ sortBy: \'original-order\' });\r\n    " +
"            }\r\n            };\r\n        }\r\n        function sessionViewModel(id) " +
"{\r\n            var self = this;\r\n\r\n            self.title = ko.observable(id);\r\n" +
"            self.messages = ko.observableArray();\r\n            self.console = ko" +
".observableArray();\r\n            self.serialNumber = ko.observable();\r\n         " +
"   self.sessionDeviceInfo = ko.observable();\r\n            self.progressStatus = " +
"ko.observable();\r\n            self.progressValue = ko.observable();\r\n           " +
" self.startTime = ko.observable();\r\n            self.sessionEnded = ko.observabl" +
"e(false);\r\n            self.progressbar = null;\r\n            self.hasError = ko." +
"observable(false);\r\n            self.hasWarning = ko.observable(false);\r\n       " +
"     self.deviceModelId = ko.observable();\r\n            self.deviceModelDescript" +
"ion = ko.computed(function () {\r\n                var deviceModelId = self.device" +
"ModelId();\r\n                var sessionDeviceInfo = self.sessionDeviceInfo();\r\n " +
"               if (deviceModelId) {\r\n                    var dm = deviceModels[d" +
"eviceModelId];\r\n                    if (dm) {\r\n                        if (dm.De" +
"scription)\r\n                            return dm.Description;\r\n                " +
"        else\r\n                            return dm.Manufacturer + \' \' + dm.Mode" +
"l;\r\n                    }\r\n                }\r\n                if (sessionDeviceI" +
"nfo) {\r\n                    return sessionDeviceInfo.Arguments[6] + \' \' + sessio" +
"nDeviceInfo.Arguments[7];\r\n                }\r\n            });\r\n            self." +
"deviceUrl = ko.computed(function () {\r\n                var serialNumber = self.s" +
"erialNumber();\r\n                if (serialNumber)\r\n                    return de" +
"viceBaseUrl + serialNumber;\r\n                else\r\n                    return nu" +
"ll;\r\n            });\r\n            self.deviceModelImageUrl = ko.computed(functio" +
"n () {\r\n                var deviceModelImage;\r\n                if (self.deviceMo" +
"delId())\r\n                    deviceModelImage = \'url(\' + deviceModelImageUrl + " +
"self.deviceModelId() + \')\';\r\n                else\r\n                    deviceMod" +
"elImage = \'url(\' + deviceModelImageUrl + \')\';\r\n                if (self.hasError" +
"())\r\n                    return iconErrorUrl + \', \' + deviceModelImage;\r\n       " +
"         else\r\n                    if (self.hasWarning())\r\n                     " +
"   return iconWarningUrl + \', \' + deviceModelImage;\r\n                    else\r\n " +
"                       return \'none, \' + deviceModelImage;\r\n            });\r\n   " +
"         self.select = function (e, d) {\r\n                vm.currentSession(self" +
");\r\n                hostDialogSessions.dialog(\'open\');\r\n                hostDial" +
"ogSessions.dialog(\'option\', \'title\', \'Device Enrolment: \' + self.title());\r\n    " +
"        }\r\n        }\r\n\r\n        function parseLog(log) {\r\n            if (log.Mo" +
"duleId === 50 && log.Arguments && log.Arguments.length > 0) {\r\n                /" +
"/ find session\r\n                var sessionId = log.Arguments[0];\r\n             " +
"   var session = vm.sessionIndex[sessionId];\r\n                if (!session && lo" +
"g.EventTypeId === 10) { // Starting Session (Ignore \'partial\' sessions)\r\n       " +
"             session = new sessionViewModel(sessionId);\r\n                    vm." +
"sessionIndex[sessionId] = session;\r\n                    vm.sessions.unshift(sess" +
"ion);\r\n                    vm.noSessions(false);\r\n                }\r\n           " +
"     if (session) {\r\n                    switch (log.EventTypeId) {\r\n           " +
"             case 10: // SessionStarting\r\n                            session.ti" +
"tle(log.Arguments[1]);\r\n                            session.startTime(log.Format" +
"tedTimestamp.substring(log.FormattedTimestamp.indexOf(\' \') + 1));\r\n             " +
"               session.messages.unshift(log);\r\n                            break" +
";\r\n                        case 11: // SessionProgress\r\n                        " +
"    //session.progressbar.progressbar(\'option\', \'value\', log.Arguments[1]);\r\n   " +
"                         session.progressValue(log.Arguments[1]);\r\n             " +
"               session.progressStatus(log.Arguments[2]);\r\n                      " +
"      break;\r\n                        case 12: // SessionDevice\r\n               " +
"             session.title(log.Arguments[1]);\r\n                            sessi" +
"on.serialNumber(log.Arguments[1]);\r\n                            if (log.Argument" +
"s.length >= 3 && log.Arguments[2])\r\n                                session.devi" +
"ceModelId(log.Arguments[2]);\r\n                            break;\r\n              " +
"              break;\r\n                        case 13: // SessionDeviceInfo\r\n   " +
"                         session.title(log.Arguments[1]);\r\n                     " +
"       session.serialNumber(log.Arguments[1]);\r\n                            sess" +
"ion.sessionDeviceInfo(log);\r\n                            if (log.Arguments.lengt" +
"h >= 10 && log.Arguments[9])\r\n                                session.deviceMode" +
"lId(log.Arguments[9]);\r\n                            break;\r\n                    " +
"    case 20: // SessionFinished\r\n                            session.sessionEnde" +
"d(true);\r\n                            if (session.hasError())\r\n                 " +
"               session.progressStatus(\'Enrolment Finished with an Error\');\r\n    " +
"                        else\r\n                                if (session.hasWar" +
"ning())\r\n                                    session.progressStatus(\'Enrolment F" +
"inished with a Warning\');\r\n                                else\r\n               " +
"                     session.progressStatus(\'Enrolment Finished Successfully\');\r" +
"\n                            session.messages.unshift(log);\r\n                   " +
"         break;\r\n                        case 21: // SessionDiagnosticInformatio" +
"n\r\n                            session.console.push(log);\r\n                     " +
"       break;\r\n                        case 22: // SessionWarning\r\n             " +
"               session.hasWarning(true);\r\n                            session.me" +
"ssages.unshift(log);\r\n                            break;\r\n                      " +
"  case 23: // SessionError\r\n                        case 24: // SessionErrorWith" +
"Inner\r\n                        case 25: // SessionClientError\r\n                 " +
"           session.hasError(true);\r\n                            session.messages" +
".unshift(log);\r\n                            break;\r\n                        defa" +
"ult:\r\n                            session.messages.unshift(log);\r\n              " +
"      }\r\n                }\r\n            }\r\n        }\r\n        function init() {\r" +
"\n            hostDialogSessions.dialog({\r\n                modal: true,\r\n        " +
"        height: 664,\r\n                width: 900,\r\n                resizable: fa" +
"lse,\r\n                autoOpen: false,\r\n                buttons: { \'Close\': func" +
"tion () { $(this).dialog(\'close\'); } }\r\n            });\r\n            //hostDialo" +
"gSessionsProgress.progressbar();\r\n\r\n            // Create View Model\r\n          " +
"  vm = new pageViewModel();\r\n            $.ajax({\r\n                url: \'");

            
            #line 309 "..\..\Areas\Config\Views\Enrolment\Status.cshtml"
                  Write(Url.Action(MVC.API.DeviceModel.Index()));

            
            #line default
            #line hidden
WriteLiteral(@"',
                dataType: 'json',
                type: 'POST',
                success: init_loadedDeviceModels,
                error: function (jqXHR, textStatus, errorThrown) {
                    alert('Unable to retrieve device models: ' + errorThrown);
                }
            });
        }
        function init_loadedDeviceModels(models) {
            for (var i = 0; i < models.length; i++) {
                var m = models[i];
                deviceModels[m.Id] = m;
            }

            // Load Logs
            var d = new Date();
            var loadData = {
                Format: ""json"",
                Start: d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate(),
                End: null,
                ModuleId: 50,
                Take: 2000
            };
            $.ajax({
                url: '");

            
            #line 334 "..\..\Areas\Config\Views\Enrolment\Status.cshtml"
                  Write(Url.Action(MVC.API.Logging.RetrieveEvents()));

            
            #line default
            #line hidden
WriteLiteral(@"',
                dataType: 'json',
                type: 'POST',
                traditional: true,
                data: loadData,
                success: init_loadedLogs,
                error: function (jqXHR, textStatus, errorThrown) {
                    alert('Unable to retrieve logs: ' + errorThrown);
                }
            });
        }
        function init_loadedLogs(logs) {
            logs.reverse();
            for (var i = 0; i < logs.length; i++) {
                parseLog(logs[i]);
            }
            // Bind
            ko.applyBindings(vm);

            // Isotope
            hostSessions.isotope({
                itemSelector: '.session',
                layoutMode: 'fitRows'
            });
            vm.isotopeInited = true;

            // Init Persistent Connection
            liveConnection = $.connection('");

            
            #line 361 "..\..\Areas\Config\Views\Enrolment\Status.cshtml"
                                       Write(Url.Content("~/API/Logging/Notifications"));

            
            #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(function () {
                liveConnection.send('/addToGroups:");

            
            #line 365 "..\..\Areas\Config\Views\Enrolment\Status.cshtml"
                                              Write(Disco.BI.DeviceBI.EnrolmentLog.Current.LiveLogGroupName);

            
            #line default
            #line hidden
WriteLiteral("\');\r\n            });\r\n        }\r\n        init();\r\n    });\r\n</script>\r\n");

        }
    }
}
#pragma warning restore 1591
