diff --git a/Disco.BI/BI/Extensions/JobTableExtensions.cs b/Disco.BI/BI/Extensions/JobTableExtensions.cs index 2721d8b0..f7981f63 100644 --- a/Disco.BI/BI/Extensions/JobTableExtensions.cs +++ b/Disco.BI/BI/Extensions/JobTableExtensions.cs @@ -21,13 +21,15 @@ namespace Disco.BI.Extensions var jobItems = Jobs.Select(j => new JobTableModel.JobTableItemModelIncludeStatus() { Id = j.Id, - DeviceAddressId = j.Device.DeviceProfile.DefaultOrganisationAddress, OpenedDate = j.OpenedDate, ClosedDate = j.ClosedDate, TypeId = j.JobTypeId, TypeDescription = j.JobType.Description, DeviceSerialNumber = j.Device.SerialNumber, + DeviceProfileId = j.Device.DeviceProfileId, + DeviceModelId = j.Device.DeviceModelId, DeviceModelDescription = j.Device.DeviceModel.Description, + DeviceAddressId = j.Device.DeviceProfile.DefaultOrganisationAddress, UserId = j.UserId, UserDisplayName = j.User.DisplayName, OpenedTechUserId = j.OpenedTechUserId, @@ -66,13 +68,15 @@ namespace Disco.BI.Extensions items = Jobs.Select(j => new JobTableModel.JobTableItemModel() { Id = j.Id, - DeviceAddressId = j.Device.DeviceProfile.DefaultOrganisationAddress, OpenedDate = j.OpenedDate, ClosedDate = j.ClosedDate, TypeId = j.JobTypeId, TypeDescription = j.JobType.Description, DeviceSerialNumber = j.Device.SerialNumber, + DeviceProfileId = j.Device.DeviceProfileId, + DeviceModelId = j.Device.DeviceModelId, DeviceModelDescription = j.Device.DeviceModel.Description, + DeviceAddressId = j.Device.DeviceProfile.DefaultOrganisationAddress, UserId = j.UserId, UserDisplayName = j.User.DisplayName, OpenedTechUserId = j.OpenedTechUserId, @@ -84,16 +88,13 @@ namespace Disco.BI.Extensions if (!model.ShowDeviceAddress.HasValue) model.ShowDeviceAddress = dbContext.DiscoConfiguration.MultiSiteMode; - if (model.ShowDeviceAddress.Value) - { - foreach (var j in items) - if (j.DeviceAddressId.HasValue) - j.DeviceAddress = dbContext.DiscoConfiguration.OrganisationAddresses.GetAddress(j.DeviceAddressId.Value).Name; - } + foreach (var j in items) + if (j.DeviceAddressId.HasValue) + j.DeviceAddress = dbContext.DiscoConfiguration.OrganisationAddresses.GetAddress(j.DeviceAddressId.Value).Name; return items; } - + public static void Fill(this JobTableModel model, DiscoDataContext dbContext, IQueryable Jobs) { model.Items = model.DetermineItems(dbContext, Jobs); diff --git a/Disco.Models/BI/Job/JobTableModel.cs b/Disco.Models/BI/Job/JobTableModel.cs index d7cc989d..61e3c09f 100644 --- a/Disco.Models/BI/Job/JobTableModel.cs +++ b/Disco.Models/BI/Job/JobTableModel.cs @@ -30,17 +30,61 @@ namespace Disco.Models.BI.Job ShowTechnician = true; } + private JobTableModel CloneEmptyModel() + { + return new JobTableModel() + { + ShowId = this.ShowId, + ShowDeviceAddress = this.ShowDeviceAddress, + ShowDates = this.ShowDates, + ShowType = this.ShowType, + ShowDevice = this.ShowDevice, + ShowUser = this.ShowUser, + ShowTechnician = this.ShowTechnician, + ShowLocation = this.ShowLocation, + ShowStatus = this.ShowStatus, + IsSmallTable = this.IsSmallTable, + HideClosedJobs = this.HideClosedJobs + }; + } + + public IDictionary MultiCampusModels + { + get + { + var items = this.Items; + if (items == null || items.Count > 0) + { + return items.OrderBy(i => i.DeviceAddress).GroupBy(i => i.DeviceAddress).ToDictionary( + ig => ig.Key ?? string.Empty, + ig => + { + var jtm = this.CloneEmptyModel(); + jtm.Items = ig.ToList(); + return jtm; + } + ); + } + else + { + return null; + } + } + } + public class JobTableItemModel { public int Id { get; set; } - public int? DeviceAddressId { get; set; } - public string DeviceAddress { get; set; } public DateTime OpenedDate { get; set; } public DateTime? ClosedDate { get; set; } public string TypeId { get; set; } public string TypeDescription { get; set; } public string DeviceSerialNumber { get; set; } + public int? DeviceModelId { get; set; } public string DeviceModelDescription { get; set; } + public int? DeviceProfileId { get; set; } + public int? DeviceAddressId { get; set; } + public string DeviceAddress { get; set; } public string UserId { get; set; } public string UserDisplayName { get; set; } public string OpenedTechUserId { get; set; } diff --git a/Disco.Web/Views/Shared/_JobTable.cshtml b/Disco.Web/Views/Shared/_JobTable.cshtml index 7bc77ad7..da361d55 100644 --- a/Disco.Web/Views/Shared/_JobTable.cshtml +++ b/Disco.Web/Views/Shared/_JobTable.cshtml @@ -7,17 +7,15 @@ } else { - var modelItems = Model.Items; - var modelItemsGrouped = modelItems.OrderBy(i => i.DeviceAddress).GroupBy(i => i.DeviceAddress); - foreach (var modelItemsGroup in modelItemsGrouped) + var multiSiteModels = Model.MultiCampusModels; + + foreach (var multiSiteModel in multiSiteModels) { - Model.Items = modelItemsGroup.ToList(); - if (modelItemsGroup.Key != null) - { -

- @modelItemsGroup.Key

+ if (!string.IsNullOrEmpty(multiSiteModel.Key)) + { +

@multiSiteModel.Key

} - @Html.Partial(MVC.Shared.Views._JobTableRender, Model, new ViewDataDictionary()) + @Html.Partial(MVC.Shared.Views._JobTableRender, multiSiteModel.Value, new ViewDataDictionary()) } } } diff --git a/Disco.Web/Views/Shared/_JobTable.generated.cs b/Disco.Web/Views/Shared/_JobTable.generated.cs index 8b480067..2f376acf 100644 --- a/Disco.Web/Views/Shared/_JobTable.generated.cs +++ b/Disco.Web/Views/Shared/_JobTable.generated.cs @@ -2,7 +2,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.17929 +// Runtime Version:4.0.30319.18033 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -31,9 +31,9 @@ namespace Disco.Web.Views.Shared using Disco.Web; using Disco.Web.Extensions; - [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.0.0")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.4.0")] [System.Web.WebPages.PageVirtualPathAttribute("~/Views/Shared/_JobTable.cshtml")] - public class JobTable : System.Web.Mvc.WebViewPage + public partial class JobTable : System.Web.Mvc.WebViewPage { public JobTable() { @@ -61,24 +61,21 @@ WriteLiteral(">No Jobs Found\r\n"); } else { - var modelItems = Model.Items; - var modelItemsGrouped = modelItems.OrderBy(i => i.DeviceAddress).GroupBy(i => i.DeviceAddress); - foreach (var modelItemsGroup in modelItemsGrouped) + var multiSiteModels = Model.MultiCampusModels; + + foreach (var multiSiteModel in multiSiteModels) { - Model.Items = modelItemsGroup.ToList(); - if (modelItemsGroup.Key != null) - { + if (!string.IsNullOrEmpty(multiSiteModel.Key)) + { #line default #line hidden -WriteLiteral("

\r\n"); - -WriteLiteral(" "); +WriteLiteral("

"); - #line 18 "..\..\Views\Shared\_JobTable.cshtml" - Write(modelItemsGroup.Key); + #line 16 "..\..\Views\Shared\_JobTable.cshtml" + Write(multiSiteModel.Key); #line default @@ -86,22 +83,22 @@ WriteLiteral(" "); WriteLiteral("

\r\n"); - #line 19 "..\..\Views\Shared\_JobTable.cshtml" + #line 17 "..\..\Views\Shared\_JobTable.cshtml" } #line default #line hidden - #line 20 "..\..\Views\Shared\_JobTable.cshtml" -Write(Html.Partial(MVC.Shared.Views._JobTableRender, Model, new ViewDataDictionary())); + #line 18 "..\..\Views\Shared\_JobTable.cshtml" +Write(Html.Partial(MVC.Shared.Views._JobTableRender, multiSiteModel.Value, new ViewDataDictionary())); #line default #line hidden - #line 20 "..\..\Views\Shared\_JobTable.cshtml" - + #line 18 "..\..\Views\Shared\_JobTable.cshtml" + } } } @@ -112,14 +109,14 @@ else #line default #line hidden - #line 26 "..\..\Views\Shared\_JobTable.cshtml" + #line 24 "..\..\Views\Shared\_JobTable.cshtml" Write(Html.Partial(MVC.Shared.Views._JobTableRender, Model, new ViewDataDictionary())); #line default #line hidden - #line 26 "..\..\Views\Shared\_JobTable.cshtml" + #line 24 "..\..\Views\Shared\_JobTable.cshtml" }