diff --git a/Disco.Models/Services/Jobs/Noticeboards/IHeldDeviceItem.cs b/Disco.Models/Services/Jobs/Noticeboards/IHeldDeviceItem.cs index a329371a..f26c922a 100644 --- a/Disco.Models/Services/Jobs/Noticeboards/IHeldDeviceItem.cs +++ b/Disco.Models/Services/Jobs/Noticeboards/IHeldDeviceItem.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace Disco.Models.Services.Jobs.Noticeboards { @@ -9,6 +10,7 @@ namespace Disco.Models.Services.Jobs.Noticeboards string DeviceSerialNumber { get; } string DeviceComputerNameFriendly { get; } string DeviceComputerName { get; } + string DeviceName { get; } string DeviceLocation { get; } string DeviceDescription { get; } @@ -16,6 +18,7 @@ namespace Disco.Models.Services.Jobs.Noticeboards int DeviceProfileId { get; } int? DeviceAddressId { get; } string DeviceAddressShortName { get; } + IEnumerable JobQueueIds { get; } string UserId { get; } string UserIdFriendly { get; } diff --git a/Disco.Services/Jobs/Noticeboards/HeldDeviceItem.cs b/Disco.Services/Jobs/Noticeboards/HeldDeviceItem.cs index 4cc2e22d..1c67f881 100644 --- a/Disco.Services/Jobs/Noticeboards/HeldDeviceItem.cs +++ b/Disco.Services/Jobs/Noticeboards/HeldDeviceItem.cs @@ -16,20 +16,22 @@ namespace Disco.Services.Jobs.Noticeboards public string DeviceSerialNumber { get; set; } public string DeviceComputerNameFriendly { - get - { - return DeviceComputerName == null ? null : ActiveDirectory.FriendlyAccountId(DeviceComputerName); - } + get => DeviceComputerName == null ? null : ActiveDirectory.FriendlyAccountId(DeviceComputerName); set { } // for XML Serialization } public string DeviceComputerName { get; set; } + public string DeviceName + { + get => DeviceComputerNameFriendly ?? DeviceSerialNumber; + set { } + } public string DeviceLocation { get; set; } public string DeviceDescription { get { - StringBuilder sb = new StringBuilder(DeviceComputerNameFriendly); + StringBuilder sb = new StringBuilder(DeviceName); if (UserId != null) sb.Append(" - ").Append(UserDisplayName).Append(" (").Append(UserIdFriendly).Append(")"); @@ -60,6 +62,7 @@ namespace Disco.Services.Jobs.Noticeboards } set { } // for XML Serialization } + public IEnumerable JobQueueIds { get; set; } public string UserId { get; set; } public string UserIdFriendly @@ -130,6 +133,7 @@ namespace Disco.Services.Jobs.Noticeboards DeviceLocation = j.Device.Location, DeviceProfileId = j.Device.DeviceProfileId, DeviceAddressId = j.Device.DeviceProfile.DefaultOrganisationAddress, + JobQueueIds = j.JobQueues.Where(q => q.RemovedDate == null).Select(q => q.JobQueueId), UserId = j.Device.AssignedUserId, UserDisplayName = j.Device.AssignedUser.DisplayName, WaitingForUserAction = j.WaitingForUserAction.HasValue || ((j.JobMetaNonWarranty.AccountingChargeRequiredDate.HasValue || j.JobMetaNonWarranty.AccountingChargeAddedDate.HasValue) && !j.JobMetaNonWarranty.AccountingChargePaidDate.HasValue), diff --git a/Disco.Services/Jobs/Noticeboards/HeldDevices.cs b/Disco.Services/Jobs/Noticeboards/HeldDevices.cs index 27d92f3e..44a512e1 100644 --- a/Disco.Services/Jobs/Noticeboards/HeldDevices.cs +++ b/Disco.Services/Jobs/Noticeboards/HeldDevices.cs @@ -15,7 +15,7 @@ namespace Disco.Services.Jobs.Noticeboards { public const string Name = "HeldDevices"; - private readonly static List MonitorJobProperties = new List() { + private static readonly List MonitorJobProperties = new List() { "DeviceSerialNumber", "UserId", "ExpectedClosedDate", @@ -25,25 +25,25 @@ namespace Disco.Services.Jobs.Noticeboards "DeviceReadyForReturn", "DeviceReturnedDate" }; - private readonly static List MonitorJobMetaNonWarrantyProperties = new List(){ + private static readonly List MonitorJobMetaNonWarrantyProperties = new List(){ "AccountingChargeRequiredDate", "AccountingChargeAddedDate", "AccountingChargePaidDate" }; - private readonly static List MonitorDeviceProperties = new List(){ + private static readonly List MonitorDeviceProperties = new List(){ "Location", "DeviceProfileId", "DeviceDomainId", "AssignedUserId", }; - private readonly static List MonitorDeviceProfileProperties = new List(){ + private static readonly List MonitorDeviceProfileProperties = new List(){ "DefaultOrganisationAddress" }; - private readonly static List MonitorUserProperties = new List(){ + private static readonly List MonitorUserProperties = new List(){ "DisplayName" }; - private static Subject, List>> BufferedUpdateStream; + private static readonly Subject, List>> BufferedUpdateStream; static HeldDevices() { @@ -74,7 +74,9 @@ namespace Disco.Services.Jobs.Noticeboards ) || (e.EntityType == typeof(User) && (e.EventType == RepositoryMonitorEventType.Modified && e.ModifiedProperties.Any(p => MonitorUserProperties.Contains(p))) - ) + ) || + (e.EntityType == typeof(JobQueueJob) && + (e.EventType == RepositoryMonitorEventType.Added || e.EventType == RepositoryMonitorEventType.Modified)) ) .Subscribe(RepositoryEvent); } @@ -147,6 +149,15 @@ namespace Disco.Services.Jobs.Noticeboards .Select(j => j.DeviceSerialNumber) ); } + else if (i.EntityType == typeof(JobQueueJob)) + { + var jqj = (JobQueueJob)i.Entity; + var j = i.Database.Jobs.Find(jqj.JobId); + if (j != null && j.DeviceSerialNumber != null) + { + deviceSerialNumbers.Add(j.DeviceSerialNumber); + } + } if (deviceSerialNumbers.Count > 0 || userIds.Count > 0) { diff --git a/Disco.Web/Areas/Config/Controllers/JobPreferencesController.cs b/Disco.Web/Areas/Config/Controllers/JobPreferencesController.cs index 1cb9880f..4acf114e 100644 --- a/Disco.Web/Areas/Config/Controllers/JobPreferencesController.cs +++ b/Disco.Web/Areas/Config/Controllers/JobPreferencesController.cs @@ -1,7 +1,9 @@ using Disco.Models.UI.Config.JobPreferences; using Disco.Services.Authorization; +using Disco.Services.Jobs.JobQueues; using Disco.Services.Plugins.Features.UIExtension; using Disco.Services.Web; +using System.Linq; using System.Web.Mvc; namespace Disco.Web.Areas.Config.Controllers @@ -23,6 +25,9 @@ namespace Disco.Web.Areas.Config.Controllers OnCreateExpression = Database.DiscoConfiguration.JobPreferences.OnCreateExpression, OnDeviceReadyForReturnExpression = Database.DiscoConfiguration.JobPreferences.OnDeviceReadyForReturnExpression, OnCloseExpression = Database.DiscoConfiguration.JobPreferences.OnCloseExpression, + DeviceProfiles = Database.DeviceProfiles.OrderBy(dp => dp.Name).ToList(), + OrganisationAddresses = Database.DiscoConfiguration.OrganisationAddresses.Addresses.OrderBy(a => a.Name).ToList(), + JobQueues = JobQueueService.GetQueues().Select(q => q.JobQueue).OrderBy(q => q.Name).ToList(), }; // UI Extensions diff --git a/Disco.Web/Areas/Config/Models/JobPreferences/IndexModel.cs b/Disco.Web/Areas/Config/Models/JobPreferences/IndexModel.cs index d03b3fd1..63cd1640 100644 --- a/Disco.Web/Areas/Config/Models/JobPreferences/IndexModel.cs +++ b/Disco.Web/Areas/Config/Models/JobPreferences/IndexModel.cs @@ -1,5 +1,4 @@ -using Disco.Data.Repository; -using Disco.Models.Services.Jobs; +using Disco.Models.Services.Jobs; using Disco.Models.UI.Config.JobPreferences; using Disco.Services.Extensions; using System; @@ -32,21 +31,9 @@ namespace Disco.Web.Areas.Config.Models.JobPreferences return UIHelpers.NoticeboardThemes.ToList(); } - public Lazy> DeviceProfiles = new Lazy>(() => - { - using (var database = new DiscoDataContext()) - { - return database.DeviceProfiles.OrderBy(a => a.Description).ToList(); - } - }); - - public Lazy> OrganisationAddresses = new Lazy>(() => - { - using (var database = new DiscoDataContext()) - { - return database.DiscoConfiguration.OrganisationAddresses.Addresses.OrderBy(a => a.Name).ToList(); - } - }); + public List DeviceProfiles { get; set; } + public List OrganisationAddresses { get; set; } + public List JobQueues { get; set; } public List> LongRunningJobDaysThresholdOptions() { diff --git a/Disco.Web/Areas/Config/Views/JobPreferences/Parts/Reports.cshtml b/Disco.Web/Areas/Config/Views/JobPreferences/Parts/Reports.cshtml index 56f77a04..46dd88b7 100644 --- a/Disco.Web/Areas/Config/Views/JobPreferences/Parts/Reports.cshtml +++ b/Disco.Web/Areas/Config/Views/JobPreferences/Parts/Reports.cshtml @@ -93,8 +93,18 @@

Filter

@@ -103,17 +113,17 @@
    - @foreach (var deviceProfile in Model.DeviceProfiles.Value) + @foreach (var deviceProfile in Model.DeviceProfiles) {
  • - +
  • }
    - @foreach (var address in Model.OrganisationAddresses.Value) + @foreach (var address in Model.OrganisationAddresses) {
  • @@ -121,6 +131,16 @@ }
+
+
    + @foreach (var queue in Model.JobQueues) + { +
  • + +
  • + } +
+
diff --git a/Disco.Web/Areas/Config/Views/JobPreferences/Parts/Reports.generated.cs b/Disco.Web/Areas/Config/Views/JobPreferences/Parts/Reports.generated.cs index 495448b3..1bba0b4c 100644 --- a/Disco.Web/Areas/Config/Views/JobPreferences/Parts/Reports.generated.cs +++ b/Disco.Web/Areas/Config/Views/JobPreferences/Parts/Reports.generated.cs @@ -436,16 +436,82 @@ WriteLiteral(">\r\n <None>\r\n <None>\r\n"); + + + #line 96 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + + + #line default + #line hidden + + #line 96 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + if (Model.DeviceProfiles.Any()) + { + + + #line default + #line hidden +WriteLiteral(" Device Profile\r\n Device Profile\r\n"); + + + #line 99 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + } + + + #line default + #line hidden +WriteLiteral(" "); + + + #line 100 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + if (Model.OrganisationAddresses.Any()) + { + + + #line default + #line hidden +WriteLiteral(" Device Profile Address\r\n \r\n " + -" Device Profile Address\r\n"); + + + #line 103 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + } + + + #line default + #line hidden +WriteLiteral(" "); + + + #line 104 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + if (Model.JobQueues.Any()) + { + + + #line default + #line hidden +WriteLiteral(" Job Queue\r\n"); + + + #line 107 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + } + + + #line default + #line hidden +WriteLiteral(" \r\n \r\n"); - #line 106 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + #line 116 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" #line default #line hidden - #line 106 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" - foreach (var deviceProfile in Model.DeviceProfiles.Value) + #line 116 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + foreach (var deviceProfile in Model.DeviceProfiles) { @@ -511,47 +577,47 @@ WriteLiteral(">\r\n"); WriteLiteral("
  • \r\n " + " (deviceProfile.Id + #line 119 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + , Tuple.Create(Tuple.Create("", 7841), Tuple.Create(deviceProfile.Id #line default #line hidden -, 7348), false) +, 7841), false) ); WriteLiteral(" type=\"checkbox\""); -WriteAttribute("value", Tuple.Create(" value=\"", 7384), Tuple.Create("\"", 7409) +WriteAttribute("value", Tuple.Create(" value=\"", 7877), Tuple.Create("\"", 7902) - #line 109 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" - , Tuple.Create(Tuple.Create("", 7392), Tuple.Create(deviceProfile.Id + #line 119 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + , Tuple.Create(Tuple.Create("", 7885), Tuple.Create(deviceProfile.Id #line default #line hidden -, 7392), false) +, 7885), false) ); WriteLiteral(" />(deviceProfile.Id + #line 119 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + , Tuple.Create(Tuple.Create("", 7948), Tuple.Create(deviceProfile.Id #line default #line hidden -, 7455), false) +, 7948), false) ); WriteLiteral(">"); - #line 109 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" - Write(deviceProfile.Description); + #line 119 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + Write(deviceProfile.Name); #line default @@ -559,7 +625,7 @@ WriteLiteral(">"); WriteLiteral("\r\n
  • \r\n"); - #line 111 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + #line 121 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" } @@ -577,14 +643,14 @@ WriteLiteral(" class=\"none\""); WriteLiteral(">\r\n"); - #line 116 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + #line 126 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" #line default #line hidden - #line 116 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" - foreach (var address in Model.OrganisationAddresses.Value) + #line 126 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + foreach (var address in Model.OrganisationAddresses) { @@ -593,46 +659,46 @@ WriteLiteral(">\r\n"); WriteLiteral("
  • \r\n " + " (address.Id + #line 129 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + , Tuple.Create(Tuple.Create("", 8589), Tuple.Create(address.Id #line default #line hidden -, 8109), false) +, 8589), false) ); WriteLiteral(" type=\"checkbox\""); -WriteAttribute("value", Tuple.Create(" value=\"", 8139), Tuple.Create("\"", 8165) +WriteAttribute("value", Tuple.Create(" value=\"", 8619), Tuple.Create("\"", 8645) - #line 119 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" - , Tuple.Create(Tuple.Create("", 8147), Tuple.Create(address.ShortName + #line 129 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + , Tuple.Create(Tuple.Create("", 8627), Tuple.Create(address.ShortName #line default #line hidden -, 8147), false) +, 8627), false) ); WriteLiteral(" />(address.Id + #line 129 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + , Tuple.Create(Tuple.Create("", 8691), Tuple.Create(address.Id #line default #line hidden -, 8211), false) +, 8691), false) ); WriteLiteral(">"); - #line 119 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + #line 129 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" Write(address.Name); @@ -641,7 +707,7 @@ WriteLiteral(">"); WriteLiteral(" ("); - #line 119 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + #line 129 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" Write(address.ShortName); @@ -650,7 +716,111 @@ WriteLiteral(" ("); WriteLiteral(")\r\n
  • \r\n"); - #line 121 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + #line 131 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + } + + + #line default + #line hidden +WriteLiteral(" \r\n " + +"\r\n \r\n \r\n"); + + + #line 136 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + + + #line default + #line hidden + + #line 136 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + foreach (var queue in Model.JobQueues) + { + + + #line default + #line hidden +WriteLiteral("
  • \r\n " + +" (queue.Id + + #line default + #line hidden +, 9322), false) +); + +WriteLiteral(" type=\"checkbox\""); + +WriteAttribute("value", Tuple.Create(" value=\"", 9350), Tuple.Create("\"", 9367) + + #line 139 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + , Tuple.Create(Tuple.Create("", 9358), Tuple.Create(queue.Id + + #line default + #line hidden +, 9358), false) +); + +WriteLiteral(" />(queue.Id + + #line default + #line hidden +, 9413), false) +); + +WriteLiteral(">(queue.Icon + + #line default + #line hidden +, 9442), false) +, Tuple.Create(Tuple.Create(" ", 9455), Tuple.Create("d-", 9456), true) + + #line 139 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + , Tuple.Create(Tuple.Create("", 9458), Tuple.Create(queue.IconColour + + #line default + #line hidden +, 9458), false) +); + +WriteLiteral("> "); + + + #line 139 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" + Write(queue.Name); + + + #line default + #line hidden +WriteLiteral("\r\n
  • \r\n"); + + + #line 141 "..\..\Areas\Config\Views\JobPreferences\Parts\Reports.cshtml" } diff --git a/Disco.Web/Areas/Public/Controllers/HeldDevicesController.cs b/Disco.Web/Areas/Public/Controllers/HeldDevicesController.cs index a1733668..aaa7d4b4 100644 --- a/Disco.Web/Areas/Public/Controllers/HeldDevicesController.cs +++ b/Disco.Web/Areas/Public/Controllers/HeldDevicesController.cs @@ -1,8 +1,8 @@ -using Disco.Models.Repository; +using Disco.Data.Repository; +using Disco.Models.Repository; using Disco.Services.Jobs.Noticeboards; using Disco.Services.Web; using Disco.Web.Areas.Public.Models.UserHeldDevices; -using System.Collections.Generic; using System.Linq; using System.Web.Mvc; @@ -10,30 +10,53 @@ namespace Disco.Web.Areas.Public.Controllers { public partial class HeldDevicesController : DatabaseController { - public virtual ActionResult Index(List DeviceProfileInclude, List DeviceProfileExclude, List DeviceAddressInclude, List DeviceAddressExclude) + public virtual ActionResult Index(string DeviceProfileInclude, string DeviceProfileExclude, string DeviceAddressInclude, string DeviceAddressExclude, string JobQueueInclude, string JobQueueExclude) { - IQueryable query = Database.Jobs; - - if (DeviceProfileInclude != null) - query = query.Where(j => DeviceProfileInclude.Contains(j.Device.DeviceProfileId)); - if (DeviceProfileExclude != null) - query = query.Where(j => !DeviceProfileExclude.Contains(j.Device.DeviceProfileId)); - if (DeviceAddressInclude != null && DeviceAddressInclude.Count > 0) - { - var addressIds = Database.DiscoConfiguration.OrganisationAddresses.Addresses.Where(a => DeviceAddressInclude.Contains(a.ShortName)).Select(a => a.Id).ToList(); - query = query.Where(j => addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress)); - } - if (DeviceAddressExclude != null && DeviceAddressExclude.Count > 0) - { - var addressIds = Database.DiscoConfiguration.OrganisationAddresses.Addresses.Where(a => DeviceAddressExclude.Contains(a.ShortName)).Select(a => (int?)a.Id).ToList(); - query = query.Where(j => j.Device.DeviceProfile.DefaultOrganisationAddress == null || !addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress)); - } + var query = FilterJobs(Database.Jobs, Database, DeviceProfileInclude, DeviceProfileExclude, DeviceAddressInclude, DeviceAddressExclude, JobQueueInclude, JobQueueExclude); var m = Disco.Services.Jobs.Noticeboards.HeldDevices.GetHeldDevices(query); return View(m); } + internal static IQueryable FilterJobs(IQueryable query, DiscoDataContext database, string deviceProfileInclude, string deviceProfileExclude, string deviceAddressInclude, string deviceAddressExclude, string jobQueueInclude, string jobQueueExclude) + { + if (!string.IsNullOrWhiteSpace(deviceProfileInclude)) + { + var include = deviceProfileInclude.Split(',').Select(int.Parse).ToList(); + query = query.Where(j => include.Contains(j.Device.DeviceProfileId)); + } + if (!string.IsNullOrWhiteSpace(deviceProfileExclude)) + { + var exclude = deviceProfileExclude.Split(',').Select(int.Parse).ToList(); + query = query.Where(j => !exclude.Contains(j.Device.DeviceProfileId)); + } + if (!string.IsNullOrWhiteSpace(deviceAddressInclude)) + { + var include = deviceAddressInclude.Split(','); + var addressIds = database.DiscoConfiguration.OrganisationAddresses.Addresses.Where(a => include.Contains(a.ShortName)).Select(a => a.Id).ToList(); + query = query.Where(j => addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress)); + } + if (!string.IsNullOrWhiteSpace(deviceAddressExclude)) + { + var exclude = deviceAddressExclude.Split(','); + var addressIds = database.DiscoConfiguration.OrganisationAddresses.Addresses.Where(a => exclude.Contains(a.ShortName)).Select(a => (int?)a.Id).ToList(); + query = query.Where(j => j.Device.DeviceProfile.DefaultOrganisationAddress == null || !addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress)); + } + if (jobQueueInclude != null) + { + var include = jobQueueInclude.Split(',').Select(int.Parse).ToList(); + query = query.Where(j => j.JobQueues.Any(q => q.RemovedDate == null && include.Contains(q.JobQueueId))); + } + if (jobQueueExclude != null) + { + var exclude = jobQueueExclude.Split(',').Select(int.Parse).ToList(); + query = query.Where(j => !j.JobQueues.Any(q => q.RemovedDate == null && exclude.Contains(q.JobQueueId))); + } + + return query; + } + public virtual ActionResult ReadyForReturnXml() { var readyForReturn = Disco.Services.Jobs.Noticeboards.HeldDevices.GetHeldDevices(Database) diff --git a/Disco.Web/Areas/Public/Controllers/UserHeldDevicesController.cs b/Disco.Web/Areas/Public/Controllers/UserHeldDevicesController.cs index 0b457128..7329ab06 100644 --- a/Disco.Web/Areas/Public/Controllers/UserHeldDevicesController.cs +++ b/Disco.Web/Areas/Public/Controllers/UserHeldDevicesController.cs @@ -1,8 +1,6 @@ -using Disco.Models.Repository; -using Disco.Services.Jobs.Noticeboards; +using Disco.Services.Jobs.Noticeboards; using Disco.Services.Web; using Disco.Web.Areas.Public.Models.UserHeldDevices; -using System.Collections.Generic; using System.Linq; using System.Web.Mvc; @@ -10,24 +8,9 @@ namespace Disco.Web.Areas.Public.Controllers { public partial class UserHeldDevicesController : DatabaseController { - public virtual ActionResult Index(List DeviceProfileInclude, List DeviceProfileExclude, List DeviceAddressInclude, List DeviceAddressExclude) + public virtual ActionResult Index(string DeviceProfileInclude, string DeviceProfileExclude, string DeviceAddressInclude, string DeviceAddressExclude, string JobQueueInclude, string JobQueueExclude) { - IQueryable query = Database.Jobs; - - if (DeviceProfileInclude != null) - query = query.Where(j => DeviceProfileInclude.Contains(j.Device.DeviceProfileId)); - if (DeviceProfileExclude != null) - query = query.Where(j => !DeviceProfileExclude.Contains(j.Device.DeviceProfileId)); - if (DeviceAddressInclude != null && DeviceAddressInclude.Count > 0) - { - var addressIds = Database.DiscoConfiguration.OrganisationAddresses.Addresses.Where(a => DeviceAddressInclude.Contains(a.ShortName)).Select(a => a.Id).ToList(); - query = query.Where(j => addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress)); - } - if (DeviceAddressExclude != null && DeviceAddressExclude.Count > 0) - { - var addressIds = Database.DiscoConfiguration.OrganisationAddresses.Addresses.Where(a => DeviceAddressExclude.Contains(a.ShortName)).Select(a => (int?)a.Id).ToList(); - query = query.Where(j => j.Device.DeviceProfile.DefaultOrganisationAddress == null || !addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress)); - } + var query = HeldDevicesController.FilterJobs(Database.Jobs, Database, DeviceProfileInclude, DeviceProfileExclude, DeviceAddressInclude, DeviceAddressExclude, JobQueueInclude, JobQueueExclude); var m = HeldDevicesForUsers.GetHeldDevicesForUsers(query); diff --git a/Disco.Web/Areas/Public/Views/HeldDevices/Index.cshtml b/Disco.Web/Areas/Public/Views/HeldDevices/Index.cshtml index 1df5823d..fb63d658 100644 --- a/Disco.Web/Areas/Public/Views/HeldDevices/Index.cshtml +++ b/Disco.Web/Areas/Public/Views/HeldDevices/Index.cshtml @@ -14,7 +14,7 @@ { - @item.DeviceComputerNameFriendly + @item.DeviceName @if (item.UserId != null) diff --git a/Disco.Web/Areas/Public/Views/HeldDevices/Index.generated.cs b/Disco.Web/Areas/Public/Views/HeldDevices/Index.generated.cs index 421737aa..e63cf0ad 100644 --- a/Disco.Web/Areas/Public/Views/HeldDevices/Index.generated.cs +++ b/Disco.Web/Areas/Public/Views/HeldDevices/Index.generated.cs @@ -114,7 +114,7 @@ WriteLiteral(" "); #line 17 "..\..\Areas\Public\Views\HeldDevices\Index.cshtml" - Write(item.DeviceComputerNameFriendly); + Write(item.DeviceName); #line default @@ -448,15 +448,15 @@ WriteLiteral("\r\n"); #line hidden WriteLiteral(" \r\n (item.IsAlert ? " Alert" : string.Empty +, Tuple.Create(Tuple.Create("", 3398), Tuple.Create(item.IsAlert ? " Alert" : string.Empty #line default #line hidden -, 3414), false) +, 3398), false) ); WriteLiteral(">Since "); @@ -650,15 +650,15 @@ WriteLiteral("\r\n"); #line hidden WriteLiteral(" \r\n (item.IsAlert ? " Alert" : string.Empty +, Tuple.Create(Tuple.Create("", 5023), Tuple.Create(item.IsAlert ? " Alert" : string.Empty #line default #line hidden -, 5039), false) +, 5023), false) ); WriteLiteral(">Ready "); diff --git a/Disco.Web/Areas/Public/Views/HeldDevices/Noticeboard.cshtml b/Disco.Web/Areas/Public/Views/HeldDevices/Noticeboard.cshtml index a91710ff..6863199c 100644 --- a/Disco.Web/Areas/Public/Views/HeldDevices/Noticeboard.cshtml +++ b/Disco.Web/Areas/Public/Views/HeldDevices/Noticeboard.cshtml @@ -353,6 +353,42 @@ }); } break; + case 'jobqueueinclude': // FILTER: Job Queue Include + var jobQueues = value.split(",").map(function (v) { return parseInt(v); }); + if (jobQueues.length > 0) { + filters.push(function (heldDeviceItem) { + // true if any JobQueueId is included + if (!heldDeviceItem.JobQueueIds) + return false; // not in any queues + var include = false; + $.each(jobQueues, function (i, v) { + if ($.inArray(v, heldDeviceItem.JobQueueIds) >= 0) { + include = true; + return false; // break + } + }); + return include; + }); + } + break; + case 'jobqueueexclude': // FILTER: Job Queue Exclude + var jobQueues = value.split(",").map(function (v) { return parseInt(v); }); + if (jobQueues.length > 0) { + filters.push(function (heldDeviceItem) { + // true if any JobQueueId is excluded + if (!heldDeviceItem.JobQueueIds) + return true; // not in any queues + var exclude = false; + $.each(jobQueues, function (i, v) { + if ($.inArray(v, heldDeviceItem.JobQueueIds) >= 0) { + exclude = true; + return false; // break + } + }); + return !exclude; + }); + } + break; } }); diff --git a/Disco.Web/Areas/Public/Views/HeldDevices/Noticeboard.generated.cs b/Disco.Web/Areas/Public/Views/HeldDevices/Noticeboard.generated.cs index 433e38ae..f543500a 100644 --- a/Disco.Web/Areas/Public/Views/HeldDevices/Noticeboard.generated.cs +++ b/Disco.Web/Areas/Public/Views/HeldDevices/Noticeboard.generated.cs @@ -409,58 +409,88 @@ WriteLiteral(">\r\n
  • \r\n "luded\r\n return $.inArray(heldDeviceItem.D" + "eviceProfileId, deviceProfiles) < 0;\r\n });\r\n " + " }\r\n break;\r\n " + -" }\r\n });\r\n\r\n if (filters." + -"length > 0)\r\n itemFilters = filters;\r\n " + -" else\r\n itemFilters = null;\r\n }\r\n " + -" }\r\n\r\n function connectionError() {\r\n try {\r\n " + -" $(\'body\').addClass(\'status-error\');\r\n } catch (e) {\r" + -"\n // Ignore\r\n }\r\n\r\n window.setT" + -"imeout(function () {\r\n window.location.reload(true);\r\n " + -" }, 10000);\r\n }\r\n\r\n // Helpers\r\n functi" + -"on rotateArray(koArray, element) {\r\n var items = koArray();\r\n\r\n " + -" if (items.length <= 1)\r\n return 0;\r\n\r\n " + -" if (element.height() < (element.parent().height() - 30)) {\r\n\r\n " + -" if (findUnsortedArrayTopIndex(items) !== 0)\r\n ko" + -"Array.sort(sortFunction);\r\n\r\n // Don\'t rotate if small & sort" + -"ed correctly\r\n return;\r\n }\r\n\r\n " + -"// Move Last Item to Top\r\n var item = koArray.pop();\r\n " + -" koArray.unshift(item);\r\n }\r\n function removeItemFromA" + -"rray(koArray, deviceSerialNumber) {\r\n var items = koArray();\r\n " + -" for (var i = 0; i < items.length; i++) {\r\n if (i" + -"tems[i].DeviceSerialNumber == deviceSerialNumber) {\r\n koA" + -"rray.splice(i, 1);\r\n items = koArray();\r\n " + -" i--;\r\n }\r\n }\r\n }\r\n " + -" function findUnsortedArrayTopIndex(items) {\r\n // Only one Item" + +" case \'jobqueueinclude\': // FILTER: Job Queue Include\r\n " + +" var jobQueues = value.split(\",\").map(function (v) { " + +"return parseInt(v); });\r\n if (jobQueues.length > " + +"0) {\r\n filters.push(function (heldDeviceItem)" + +" {\r\n // true if any JobQueueId is include" + +"d\r\n if (!heldDeviceItem.JobQueueIds)\r\n " + +" return false; // not in any queues\r\n " + +" var include = false;\r\n " + +" $.each(jobQueues, function (i, v) {\r\n " + +" if ($.inArray(v, heldDeviceItem.JobQueueIds) >= 0) {\r\n " + +" include = true;\r\n " + +" return false; // break\r\n " + +" }\r\n });\r\n " + +" return include;\r\n });\r" + +"\n }\r\n break;\r\n " + +" case \'jobqueueexclude\': // FILTER: Job Queue Exclude\r\n " + +" var jobQueues = value.split(\",\").map(function (v) " + +"{ return parseInt(v); });\r\n if (jobQueues.length " + +"> 0) {\r\n filters.push(function (heldDeviceIte" + +"m) {\r\n // true if any JobQueueId is exclu" + +"ded\r\n if (!heldDeviceItem.JobQueueIds)\r\n " + +" return true; // not in any queues\r\n " + +" var exclude = false;\r\n " + +" $.each(jobQueues, function (i, v) {\r\n " + +" if ($.inArray(v, heldDeviceItem.JobQueueIds) >= 0) {\r\n " + +" exclude = true;\r\n " + +" return false; // break\r\n " + +" }\r\n });\r\n " + +" return !exclude;\r\n })" + +";\r\n }\r\n break;\r\n " + +" }\r\n });\r\n\r\n if (filt" + +"ers.length > 0)\r\n itemFilters = filters;\r\n " + +" else\r\n itemFilters = null;\r\n }\r\n " + +" }\r\n\r\n function connectionError() {\r\n try {\r\n " + +" $(\'body\').addClass(\'status-error\');\r\n } catch (e" + +") {\r\n // Ignore\r\n }\r\n\r\n window." + +"setTimeout(function () {\r\n window.location.reload(true);\r\n " + +" }, 10000);\r\n }\r\n\r\n // Helpers\r\n fu" + +"nction rotateArray(koArray, element) {\r\n var items = koArray();\r\n" + "\r\n if (items.length <= 1)\r\n return 0;\r\n\r\n " + -" for (var i = 1; i < items.length; i++) {\r\n var s =" + -" sortFunction(items[i - 1], items[i]);\r\n if (s > 0)\r\n " + -" return i;\r\n }\r\n\r\n return 0;\r\n " + -" }\r\n function findSortedInsertIndex(koArray, heldDeviceItem) {\r" + -"\n var items = koArray();\r\n var startIndex = findUn" + -"sortedArrayTopIndex(items);\r\n for (var i = startIndex; i < items." + -"length; i++) {\r\n var s = sortFunction(heldDeviceItem, items[i" + -"]);\r\n if (s <= 0)\r\n return i;\r\n " + -" }\r\n if (startIndex !== 0) {\r\n for (va" + -"r i = 0; i < startIndex; i++) {\r\n var s = sortFunction(he" + -"ldDeviceItem, items[i]);\r\n if (s <= 0)\r\n " + -" return i;\r\n }\r\n return startInd" + -"ex;\r\n } else {\r\n return -1;\r\n }" + -"\r\n }\r\n function sortFunction(l, r) {\r\n retu" + -"rn l.DeviceDescription.toLowerCase() == r.DeviceDescription.toLowerCase() ? 0 : " + -"(l.DeviceDescription.toLowerCase() < r.DeviceDescription.toLowerCase() ? -1 : 1)" + -"\r\n }\r\n function isInProcess(i) {\r\n return !" + -"i.ReadyForReturn && !i.WaitingForUserAction;\r\n }\r\n functio" + -"n isReadyForReturn(i) {\r\n return i.ReadyForReturn && !i.WaitingFo" + -"rUserAction;\r\n }\r\n function isWaitingForUserAction(i) {\r\n " + -" return i.WaitingForUserAction;\r\n }\r\n functi" + -"on getQueryStringParameters() {\r\n\r\n if (window.location.search.le" + -"ngth === 0)\r\n return null;\r\n\r\n var params = {}" + -";\r\n window.location.search.substr(1).split(\"&\").forEach(function " + -"(pair) {\r\n if (pair === \"\") return;\r\n var " + -"parts = pair.split(\"=\");\r\n params[parts[0]] = parts[1] && dec" + -"odeURIComponent(parts[1].replace(/\\+/g, \" \"));\r\n });\r\n " + -" return params;\r\n }\r\n\r\n init();\r\n });\r\n \r\n\r\n\r\n"); +" if (element.height() < (element.parent().height() - 30)) {\r\n\r\n " + +" if (findUnsortedArrayTopIndex(items) !== 0)\r\n " + +" koArray.sort(sortFunction);\r\n\r\n // Don\'t rotate if small & " + +"sorted correctly\r\n return;\r\n }\r\n\r\n " + +" // Move Last Item to Top\r\n var item = koArray.pop();\r\n " + +" koArray.unshift(item);\r\n }\r\n function removeItemF" + +"romArray(koArray, deviceSerialNumber) {\r\n var items = koArray();\r" + +"\n for (var i = 0; i < items.length; i++) {\r\n i" + +"f (items[i].DeviceSerialNumber == deviceSerialNumber) {\r\n " + +" koArray.splice(i, 1);\r\n items = koArray();\r\n " + +" i--;\r\n }\r\n }\r\n }\r\n " + +" function findUnsortedArrayTopIndex(items) {\r\n // Only one " + +"Item\r\n if (items.length <= 1)\r\n return 0;\r\n\r\n " + +" for (var i = 1; i < items.length; i++) {\r\n var" + +" s = sortFunction(items[i - 1], items[i]);\r\n if (s > 0)\r\n " + +" return i;\r\n }\r\n\r\n return 0;\r\n " + +" }\r\n function findSortedInsertIndex(koArray, heldDeviceItem" + +") {\r\n var items = koArray();\r\n var startIndex = fi" + +"ndUnsortedArrayTopIndex(items);\r\n for (var i = startIndex; i < it" + +"ems.length; i++) {\r\n var s = sortFunction(heldDeviceItem, ite" + +"ms[i]);\r\n if (s <= 0)\r\n return i;\r\n " + +" }\r\n if (startIndex !== 0) {\r\n for" + +" (var i = 0; i < startIndex; i++) {\r\n var s = sortFunctio" + +"n(heldDeviceItem, items[i]);\r\n if (s <= 0)\r\n " + +" return i;\r\n }\r\n return star" + +"tIndex;\r\n } else {\r\n return -1;\r\n " + +" }\r\n }\r\n function sortFunction(l, r) {\r\n " + +"return l.DeviceDescription.toLowerCase() == r.DeviceDescription.toLowerCase() ? " + +"0 : (l.DeviceDescription.toLowerCase() < r.DeviceDescription.toLowerCase() ? -1 " + +": 1)\r\n }\r\n function isInProcess(i) {\r\n retu" + +"rn !i.ReadyForReturn && !i.WaitingForUserAction;\r\n }\r\n fun" + +"ction isReadyForReturn(i) {\r\n return i.ReadyForReturn && !i.Waiti" + +"ngForUserAction;\r\n }\r\n function isWaitingForUserAction(i) " + +"{\r\n return i.WaitingForUserAction;\r\n }\r\n fu" + +"nction getQueryStringParameters() {\r\n\r\n if (window.location.searc" + +"h.length === 0)\r\n return null;\r\n\r\n var params " + +"= {};\r\n window.location.search.substr(1).split(\"&\").forEach(funct" + +"ion (pair) {\r\n if (pair === \"\") return;\r\n " + +"var parts = pair.split(\"=\");\r\n params[parts[0]] = parts[1] &&" + +" decodeURIComponent(parts[1].replace(/\\+/g, \" \"));\r\n });\r\n " + +" return params;\r\n }\r\n\r\n init();\r\n });\r\n " + +"\r\n\r\n\r\n"); } } diff --git a/Disco.Web/Areas/Public/Views/UserHeldDevices/Noticeboard.cshtml b/Disco.Web/Areas/Public/Views/UserHeldDevices/Noticeboard.cshtml index f6365214..a4fae47d 100644 --- a/Disco.Web/Areas/Public/Views/UserHeldDevices/Noticeboard.cshtml +++ b/Disco.Web/Areas/Public/Views/UserHeldDevices/Noticeboard.cshtml @@ -353,6 +353,42 @@ }); } break; + case 'jobqueueinclude': // FILTER: Job Queue Include + var jobQueues = value.split(",").map(function (v) { return parseInt(v); }); + if (jobQueues.length > 0) { + filters.push(function (heldDeviceItem) { + // true if any JobQueueId is included + if (!heldDeviceItem.JobQueueIds) + return false; // not in any queues + var include = false; + $.each(jobQueues, function (i, v) { + if ($.inArray(v, heldDeviceItem.JobQueueIds) >= 0) { + include = true; + return false; // break + } + }); + return include; + }); + } + break; + case 'jobqueueexclude': // FILTER: Job Queue Exclude + var jobQueues = value.split(",").map(function (v) { return parseInt(v); }); + if (jobQueues.length > 0) { + filters.push(function (heldDeviceItem) { + // true if any JobQueueId is excluded + if (!heldDeviceItem.JobQueueIds) + return true; // not in any queues + var exclude = false; + $.each(jobQueues, function (i, v) { + if ($.inArray(v, heldDeviceItem.JobQueueIds) >= 0) { + exclude = true; + return false; // break + } + }); + return !exclude; + }); + } + break; } }); diff --git a/Disco.Web/Areas/Public/Views/UserHeldDevices/Noticeboard.generated.cs b/Disco.Web/Areas/Public/Views/UserHeldDevices/Noticeboard.generated.cs index c5751593..99ca5a44 100644 --- a/Disco.Web/Areas/Public/Views/UserHeldDevices/Noticeboard.generated.cs +++ b/Disco.Web/Areas/Public/Views/UserHeldDevices/Noticeboard.generated.cs @@ -408,58 +408,88 @@ WriteLiteral(">\r\n
  • \r\n " // true if DeviceProfileId is excluded\r\n " + " return $.inArray(heldDeviceItem.DeviceProfileId, deviceProfiles) < 0;\r\n " + " });\r\n }\r\n " + -" break;\r\n }\r\n }" + -");\r\n\r\n if (filters.length > 0)\r\n itemF" + -"ilters = filters;\r\n else\r\n itemFilters" + -" = null;\r\n }\r\n }\r\n\r\n function connectionErr" + -"or() {\r\n try {\r\n $(\'body\').addClass(\'status-er" + -"ror\');\r\n } catch (e) {\r\n // Ignore\r\n " + -" }\r\n\r\n window.setTimeout(function () {\r\n " + -"window.location.reload(true);\r\n }, 10000);\r\n }\r\n\r\n " + -" // Helpers\r\n function rotateArray(koArray, element) {\r\n " + -" var items = koArray();\r\n\r\n if (items.length <= 1)\r\n " + -" return 0;\r\n\r\n if (element.height() < (element.par" + -"ent().height() - 30)) {\r\n\r\n if (findUnsortedArrayTopIndex(ite" + -"ms) !== 0)\r\n koArray.sort(sortFunction);\r\n\r\n " + -" // Don\'t rotate if small & sorted correctly\r\n return;\r" + -"\n }\r\n\r\n // Move Last Item to Top\r\n " + -"var item = koArray.pop();\r\n koArray.unshift(item);\r\n }" + -"\r\n function removeItemFromArray(koArray, UserId) {\r\n v" + -"ar items = koArray();\r\n for (var i = 0; i < items.length; i++) {\r" + -"\n if (items[i].UserId == UserId) {\r\n k" + -"oArray.splice(i, 1);\r\n items = koArray();\r\n " + -" i--;\r\n }\r\n }\r\n }\r\n " + -" function findUnsortedArrayTopIndex(items) {\r\n // Only one It" + -"em\r\n if (items.length <= 1)\r\n return 0;\r\n\r\n " + -" for (var i = 1; i < items.length; i++) {\r\n var s" + -" = sortFunction(items[i - 1], items[i]);\r\n if (s > 0)\r\n " + -" return i;\r\n }\r\n\r\n return 0;\r\n " + -" }\r\n function findSortedInsertIndex(koArray, heldDeviceItem) " + -"{\r\n var items = koArray();\r\n var startIndex = find" + -"UnsortedArrayTopIndex(items);\r\n for (var i = startIndex; i < item" + -"s.length; i++) {\r\n var s = sortFunction(heldDeviceItem, items" + -"[i]);\r\n if (s <= 0)\r\n return i;\r\n " + -" }\r\n if (startIndex !== 0) {\r\n for (" + -"var i = 0; i < startIndex; i++) {\r\n var s = sortFunction(" + -"heldDeviceItem, items[i]);\r\n if (s <= 0)\r\n " + -" return i;\r\n }\r\n return startI" + -"ndex;\r\n } else {\r\n return -1;\r\n " + -" }\r\n }\r\n function sortFunction(l, r) {\r\n re" + -"turn l.UserIdFriendly.toLowerCase() == r.UserIdFriendly.toLowerCase() ? 0 : (l.U" + -"serIdFriendly.toLowerCase() < r.UserIdFriendly.toLowerCase() ? -1 : 1)\r\n " + -" }\r\n function isInProcess(i) {\r\n return !i.ReadyFor" + -"Return && !i.WaitingForUserAction;\r\n }\r\n function isReadyF" + -"orReturn(i) {\r\n return i.ReadyForReturn && !i.WaitingForUserActio" + -"n;\r\n }\r\n function isWaitingForUserAction(i) {\r\n " + -" return i.WaitingForUserAction;\r\n }\r\n function getQuer" + -"yStringParameters() {\r\n\r\n if (window.location.search.length === 0" + -")\r\n return null;\r\n\r\n var params = {};\r\n " + -" window.location.search.substr(1).split(\"&\").forEach(function (pair) {\r\n" + -" if (pair === \"\") return;\r\n var parts = pa" + -"ir.split(\"=\");\r\n params[parts[0]] = parts[1] && decodeURIComp" + -"onent(parts[1].replace(/\\+/g, \" \"));\r\n });\r\n retur" + -"n params;\r\n }\r\n\r\n init();\r\n });\r\n \r\n\r\n\r\n"); +" break;\r\n case \'jobqueueinclud" + +"e\': // FILTER: Job Queue Include\r\n var jobQueues " + +"= value.split(\",\").map(function (v) { return parseInt(v); });\r\n " + +" if (jobQueues.length > 0) {\r\n " + +"filters.push(function (heldDeviceItem) {\r\n " + +" // true if any JobQueueId is included\r\n " + +" if (!heldDeviceItem.JobQueueIds)\r\n r" + +"eturn false; // not in any queues\r\n var i" + +"nclude = false;\r\n $.each(jobQueues, funct" + +"ion (i, v) {\r\n if ($.inArray(v, heldD" + +"eviceItem.JobQueueIds) >= 0) {\r\n " + +"include = true;\r\n return false; /" + +"/ break\r\n }\r\n " + +" });\r\n return include;\r\n " + +" });\r\n }\r\n " + +" break;\r\n case \'jobqueueexcl" + +"ude\': // FILTER: Job Queue Exclude\r\n var jobQueue" + +"s = value.split(\",\").map(function (v) { return parseInt(v); });\r\n " + +" if (jobQueues.length > 0) {\r\n " + +" filters.push(function (heldDeviceItem) {\r\n " + +" // true if any JobQueueId is excluded\r\n " + +" if (!heldDeviceItem.JobQueueIds)\r\n " + +" return true; // not in any queues\r\n var " + +"exclude = false;\r\n $.each(jobQueues, func" + +"tion (i, v) {\r\n if ($.inArray(v, held" + +"DeviceItem.JobQueueIds) >= 0) {\r\n " + +" exclude = true;\r\n return false; " + +"// break\r\n }\r\n " + +" });\r\n return !exclude;\r\n" + +" });\r\n }\r\n " + +" break;\r\n }\r\n " + +" });\r\n\r\n if (filters.length > 0)\r\n i" + +"temFilters = filters;\r\n else\r\n itemFil" + +"ters = null;\r\n }\r\n }\r\n\r\n function connectio" + +"nError() {\r\n try {\r\n $(\'body\').addClass(\'statu" + +"s-error\');\r\n } catch (e) {\r\n // Ignore\r\n " + +" }\r\n\r\n window.setTimeout(function () {\r\n " + +" window.location.reload(true);\r\n }, 10000);\r\n }\r\n\r\n" + +" // Helpers\r\n function rotateArray(koArray, element) {\r\n " + +" var items = koArray();\r\n\r\n if (items.length <= 1)\r\n" + +" return 0;\r\n\r\n if (element.height() < (element" + +".parent().height() - 30)) {\r\n\r\n if (findUnsortedArrayTopIndex" + +"(items) !== 0)\r\n koArray.sort(sortFunction);\r\n\r\n " + +" // Don\'t rotate if small & sorted correctly\r\n retu" + +"rn;\r\n }\r\n\r\n // Move Last Item to Top\r\n " + +" var item = koArray.pop();\r\n koArray.unshift(item);\r\n " + +" }\r\n function removeItemFromArray(koArray, UserId) {\r\n " + +" var items = koArray();\r\n for (var i = 0; i < items.length; i++" + +") {\r\n if (items[i].UserId == UserId) {\r\n " + +" koArray.splice(i, 1);\r\n items = koArray();\r\n " + +" i--;\r\n }\r\n }\r\n }\r\n " + +" function findUnsortedArrayTopIndex(items) {\r\n // Only on" + +"e Item\r\n if (items.length <= 1)\r\n return 0;\r\n\r" + +"\n for (var i = 1; i < items.length; i++) {\r\n v" + +"ar s = sortFunction(items[i - 1], items[i]);\r\n if (s > 0)\r\n " + +" return i;\r\n }\r\n\r\n return 0;\r" + +"\n }\r\n function findSortedInsertIndex(koArray, heldDeviceIt" + +"em) {\r\n var items = koArray();\r\n var startIndex = " + +"findUnsortedArrayTopIndex(items);\r\n for (var i = startIndex; i < " + +"items.length; i++) {\r\n var s = sortFunction(heldDeviceItem, i" + +"tems[i]);\r\n if (s <= 0)\r\n return i;\r\n " + +" }\r\n if (startIndex !== 0) {\r\n f" + +"or (var i = 0; i < startIndex; i++) {\r\n var s = sortFunct" + +"ion(heldDeviceItem, items[i]);\r\n if (s <= 0)\r\n " + +" return i;\r\n }\r\n return st" + +"artIndex;\r\n } else {\r\n return -1;\r\n " + +" }\r\n }\r\n function sortFunction(l, r) {\r\n " + +" return l.UserIdFriendly.toLowerCase() == r.UserIdFriendly.toLowerCase() ? 0 : " + +"(l.UserIdFriendly.toLowerCase() < r.UserIdFriendly.toLowerCase() ? -1 : 1)\r\n " + +" }\r\n function isInProcess(i) {\r\n return !i.Read" + +"yForReturn && !i.WaitingForUserAction;\r\n }\r\n function isRe" + +"adyForReturn(i) {\r\n return i.ReadyForReturn && !i.WaitingForUserA" + +"ction;\r\n }\r\n function isWaitingForUserAction(i) {\r\n " + +" return i.WaitingForUserAction;\r\n }\r\n function get" + +"QueryStringParameters() {\r\n\r\n if (window.location.search.length =" + +"== 0)\r\n return null;\r\n\r\n var params = {};\r\n " + +" window.location.search.substr(1).split(\"&\").forEach(function (pair)" + +" {\r\n if (pair === \"\") return;\r\n var parts " + +"= pair.split(\"=\");\r\n params[parts[0]] = parts[1] && decodeURI" + +"Component(parts[1].replace(/\\+/g, \" \"));\r\n });\r\n r" + +"eturn params;\r\n }\r\n\r\n init();\r\n });\r\n \r" + +"\n\r\n\r\n"); } } diff --git a/Disco.Web/Extensions/T4MVC/Public.HeldDevicesController.generated.cs b/Disco.Web/Extensions/T4MVC/Public.HeldDevicesController.generated.cs index 37851145..16343b8b 100644 --- a/Disco.Web/Extensions/T4MVC/Public.HeldDevicesController.generated.cs +++ b/Disco.Web/Extensions/T4MVC/Public.HeldDevicesController.generated.cs @@ -119,6 +119,8 @@ namespace Disco.Web.Areas.Public.Controllers public readonly string DeviceProfileExclude = "DeviceProfileExclude"; public readonly string DeviceAddressInclude = "DeviceAddressInclude"; public readonly string DeviceAddressExclude = "DeviceAddressExclude"; + public readonly string JobQueueInclude = "JobQueueInclude"; + public readonly string JobQueueExclude = "JobQueueExclude"; } static readonly ActionParamsClass_HeldDevice s_params_HeldDevice = new ActionParamsClass_HeldDevice(); [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] @@ -152,17 +154,19 @@ namespace Disco.Web.Areas.Public.Controllers public T4MVC_HeldDevicesController() : base(Dummy.Instance) { } [NonAction] - partial void IndexOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, System.Collections.Generic.List DeviceProfileInclude, System.Collections.Generic.List DeviceProfileExclude, System.Collections.Generic.List DeviceAddressInclude, System.Collections.Generic.List DeviceAddressExclude); + partial void IndexOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string DeviceProfileInclude, string DeviceProfileExclude, string DeviceAddressInclude, string DeviceAddressExclude, string JobQueueInclude, string JobQueueExclude); [NonAction] - public override System.Web.Mvc.ActionResult Index(System.Collections.Generic.List DeviceProfileInclude, System.Collections.Generic.List DeviceProfileExclude, System.Collections.Generic.List DeviceAddressInclude, System.Collections.Generic.List DeviceAddressExclude) + public override System.Web.Mvc.ActionResult Index(string DeviceProfileInclude, string DeviceProfileExclude, string DeviceAddressInclude, string DeviceAddressExclude, string JobQueueInclude, string JobQueueExclude) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Index); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "DeviceProfileInclude", DeviceProfileInclude); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "DeviceProfileExclude", DeviceProfileExclude); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "DeviceAddressInclude", DeviceAddressInclude); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "DeviceAddressExclude", DeviceAddressExclude); - IndexOverride(callInfo, DeviceProfileInclude, DeviceProfileExclude, DeviceAddressInclude, DeviceAddressExclude); + ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "JobQueueInclude", JobQueueInclude); + ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "JobQueueExclude", JobQueueExclude); + IndexOverride(callInfo, DeviceProfileInclude, DeviceProfileExclude, DeviceAddressInclude, DeviceAddressExclude, JobQueueInclude, JobQueueExclude); return callInfo; } diff --git a/Disco.Web/Extensions/T4MVC/Public.UserHeldDevicesController.generated.cs b/Disco.Web/Extensions/T4MVC/Public.UserHeldDevicesController.generated.cs index 4ac4ede3..01685b92 100644 --- a/Disco.Web/Extensions/T4MVC/Public.UserHeldDevicesController.generated.cs +++ b/Disco.Web/Extensions/T4MVC/Public.UserHeldDevicesController.generated.cs @@ -119,6 +119,8 @@ namespace Disco.Web.Areas.Public.Controllers public readonly string DeviceProfileExclude = "DeviceProfileExclude"; public readonly string DeviceAddressInclude = "DeviceAddressInclude"; public readonly string DeviceAddressExclude = "DeviceAddressExclude"; + public readonly string JobQueueInclude = "JobQueueInclude"; + public readonly string JobQueueExclude = "JobQueueExclude"; } static readonly ActionParamsClass_UserHeldDevice s_params_UserHeldDevice = new ActionParamsClass_UserHeldDevice(); [GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode] @@ -152,17 +154,19 @@ namespace Disco.Web.Areas.Public.Controllers public T4MVC_UserHeldDevicesController() : base(Dummy.Instance) { } [NonAction] - partial void IndexOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, System.Collections.Generic.List DeviceProfileInclude, System.Collections.Generic.List DeviceProfileExclude, System.Collections.Generic.List DeviceAddressInclude, System.Collections.Generic.List DeviceAddressExclude); + partial void IndexOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string DeviceProfileInclude, string DeviceProfileExclude, string DeviceAddressInclude, string DeviceAddressExclude, string JobQueueInclude, string JobQueueExclude); [NonAction] - public override System.Web.Mvc.ActionResult Index(System.Collections.Generic.List DeviceProfileInclude, System.Collections.Generic.List DeviceProfileExclude, System.Collections.Generic.List DeviceAddressInclude, System.Collections.Generic.List DeviceAddressExclude) + public override System.Web.Mvc.ActionResult Index(string DeviceProfileInclude, string DeviceProfileExclude, string DeviceAddressInclude, string DeviceAddressExclude, string JobQueueInclude, string JobQueueExclude) { var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Index); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "DeviceProfileInclude", DeviceProfileInclude); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "DeviceProfileExclude", DeviceProfileExclude); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "DeviceAddressInclude", DeviceAddressInclude); ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "DeviceAddressExclude", DeviceAddressExclude); - IndexOverride(callInfo, DeviceProfileInclude, DeviceProfileExclude, DeviceAddressInclude, DeviceAddressExclude); + ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "JobQueueInclude", JobQueueInclude); + ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "JobQueueExclude", JobQueueExclude); + IndexOverride(callInfo, DeviceProfileInclude, DeviceProfileExclude, DeviceAddressInclude, DeviceAddressExclude, JobQueueInclude, JobQueueExclude); return callInfo; }