diff --git a/Disco.BI/Properties/AssemblyInfo.cs b/Disco.BI/Properties/AssemblyInfo.cs index 48b1adeb..fc85f20b 100644 --- a/Disco.BI/Properties/AssemblyInfo.cs +++ b/Disco.BI/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0221.1820")] -[assembly: AssemblyFileVersion("1.2.0221.1820")] +[assembly: AssemblyVersion("1.2.0225.1951")] +[assembly: AssemblyFileVersion("1.2.0225.1951")] diff --git a/Disco.Client/Package Creation/PreparationClient.zip b/Disco.Client/Package Creation/PreparationClient.zip deleted file mode 100644 index e9a6e11b..00000000 Binary files a/Disco.Client/Package Creation/PreparationClient.zip and /dev/null differ diff --git a/Disco.Client/Properties/AssemblyInfo.cs b/Disco.Client/Properties/AssemblyInfo.cs index 5cc2cfe5..82542bec 100644 --- a/Disco.Client/Properties/AssemblyInfo.cs +++ b/Disco.Client/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0221.1820")] -[assembly: AssemblyFileVersion("1.2.0221.1820")] +[assembly: AssemblyVersion("1.2.0225.1950")] +[assembly: AssemblyFileVersion("1.2.0225.1950")] diff --git a/Disco.ClientBootstrapper/Properties/AssemblyInfo.cs b/Disco.ClientBootstrapper/Properties/AssemblyInfo.cs index 5240b2ea..82c1d757 100644 --- a/Disco.ClientBootstrapper/Properties/AssemblyInfo.cs +++ b/Disco.ClientBootstrapper/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0221.1820")] -[assembly: AssemblyFileVersion("1.2.0221.1820")] +[assembly: AssemblyVersion("1.2.0225.1950")] +[assembly: AssemblyFileVersion("1.2.0225.1950")] diff --git a/Disco.Data/Properties/AssemblyInfo.cs b/Disco.Data/Properties/AssemblyInfo.cs index 45de1187..3492143e 100644 --- a/Disco.Data/Properties/AssemblyInfo.cs +++ b/Disco.Data/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0221.1820")] -[assembly: AssemblyFileVersion("1.2.0221.1820")] +[assembly: AssemblyVersion("1.2.0225.1951")] +[assembly: AssemblyFileVersion("1.2.0225.1951")] diff --git a/Disco.Models/Disco.Models.csproj b/Disco.Models/Disco.Models.csproj index 87e5fde4..cdfa8943 100644 --- a/Disco.Models/Disco.Models.csproj +++ b/Disco.Models/Disco.Models.csproj @@ -97,7 +97,14 @@ + + + + + + + @@ -105,7 +112,7 @@ - + diff --git a/Disco.Models/Properties/AssemblyInfo.cs b/Disco.Models/Properties/AssemblyInfo.cs index 79b7e186..0f82186d 100644 --- a/Disco.Models/Properties/AssemblyInfo.cs +++ b/Disco.Models/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0221.1820")] -[assembly: AssemblyFileVersion("1.2.0221.1820")] +[assembly: AssemblyVersion("1.2.0225.1951")] +[assembly: AssemblyFileVersion("1.2.0225.1951")] diff --git a/Disco.Models/UI/Device/DeviceIndexModel.cs b/Disco.Models/UI/Device/DeviceIndexModel.cs new file mode 100644 index 00000000..4277e555 --- /dev/null +++ b/Disco.Models/UI/Device/DeviceIndexModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Disco.Models.UI.Device +{ + public interface DeviceIndexModel : BaseUIModel + { + + + + } +} diff --git a/Disco.Models/UI/Device/DeviceShowModel.cs b/Disco.Models/UI/Device/DeviceShowModel.cs new file mode 100644 index 00000000..d50e9021 --- /dev/null +++ b/Disco.Models/UI/Device/DeviceShowModel.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Disco.Models.UI.Device +{ + public interface DeviceShowModel : BaseUIModel + { + Disco.Models.Repository.Device Device { get; set; } + + List DeviceProfiles { get; set; } + List DeviceBatches { get; set; } + + Disco.Models.BI.Job.JobTableModel Jobs { get; set; } + + List Certificates { get; set; } + + List DocumentTemplates { get; set; } + } +} diff --git a/Disco.Models/UI/Job/JobCreateModel.cs b/Disco.Models/UI/Job/JobCreateModel.cs new file mode 100644 index 00000000..4302d2f1 --- /dev/null +++ b/Disco.Models/UI/Job/JobCreateModel.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Disco.Models.UI.Job +{ + public interface JobCreateModel : BaseUIModel + { + string DeviceSerialNumber { get; set; } + string UserId { get; set; } + + string Type { get; set; } + List SubTypes { get; set; } + + string Comments { get; set; } + + bool? DeviceHeld { get; set; } + + string QuickLogDestinationUrl { get; set; } + + bool? QuickLog { get; set; } + int? QuickLogTaskTimeMinutes { get; set; } + int? QuickLogTaskTimeMinutesOther { get; set; } + + Disco.Models.Repository.Device Device { get; set; } + Disco.Models.Repository.User User { get; set; } + List JobTypes { get; set; } + List JobSubTypes { get; set; } + } +} diff --git a/Disco.Models/UI/Job/JobIndexModel.cs b/Disco.Models/UI/Job/JobIndexModel.cs new file mode 100644 index 00000000..02d558b2 --- /dev/null +++ b/Disco.Models/UI/Job/JobIndexModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Disco.Models.BI.Job; + +namespace Disco.Models.UI.Job +{ + public interface JobIndexModel : BaseUIModel + { + JobTableModel OpenJobs { get; set; } + JobTableModel LongRunningJobs { get; set; } + } +} diff --git a/Disco.Models/UI/Job/JobListModel.cs b/Disco.Models/UI/Job/JobListModel.cs new file mode 100644 index 00000000..09e56d18 --- /dev/null +++ b/Disco.Models/UI/Job/JobListModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Disco.Models.UI.Job +{ + public interface JobListModel : BaseUIModel + { + string Title { get; set; } + Disco.Models.BI.Job.JobTableModel JobTable { get; set; } + } +} diff --git a/Disco.Models/UI/User/UserIndexModel.cs b/Disco.Models/UI/User/UserIndexModel.cs new file mode 100644 index 00000000..ae2f0733 --- /dev/null +++ b/Disco.Models/UI/User/UserIndexModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Disco.Models.UI.User +{ + public interface UserIndexModel : BaseUIModel + { + } +} diff --git a/Disco.Models/UI/User/UserShowModel.cs b/Disco.Models/UI/User/UserShowModel.cs new file mode 100644 index 00000000..8c54743b --- /dev/null +++ b/Disco.Models/UI/User/UserShowModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Disco.Models.UI.User +{ + public interface UserShowModel : BaseUIModel + { + Disco.Models.Repository.User User { get; set; } + Disco.Models.BI.Job.JobTableModel Jobs { get; set; } + List DocumentTemplates { get; set; } + } +} diff --git a/Disco.Services/Disco.Services.csproj b/Disco.Services/Disco.Services.csproj index cda7edc9..bf1a68d4 100644 --- a/Disco.Services/Disco.Services.csproj +++ b/Disco.Services/Disco.Services.csproj @@ -102,7 +102,10 @@ + + + @@ -137,7 +140,7 @@ - + diff --git a/Disco.Services/Plugins/Features/UIExtension/Results/LiteralResult.cs b/Disco.Services/Plugins/Features/UIExtension/Results/LiteralResult.cs index c75b89bf..624794cf 100644 --- a/Disco.Services/Plugins/Features/UIExtension/Results/LiteralResult.cs +++ b/Disco.Services/Plugins/Features/UIExtension/Results/LiteralResult.cs @@ -12,14 +12,16 @@ namespace Disco.Services.Plugins.Features.UIExtension.Results { private string _content; - public LiteralResult(PluginFeatureManifest Source, string Content) : base(Source) + public LiteralResult(PluginFeatureManifest Source, string Content) + : base(Source) { this._content = Content; } public override void ExecuteResult(WebViewPage page) { - page.Write(new HtmlString(_content)); + if (!string.IsNullOrEmpty(_content)) + page.Write(new HtmlString(_content)); } } } diff --git a/Disco.Services/Plugins/Features/UIExtension/Results/MultipleResult.cs b/Disco.Services/Plugins/Features/UIExtension/Results/MultipleResult.cs new file mode 100644 index 00000000..87f90bdd --- /dev/null +++ b/Disco.Services/Plugins/Features/UIExtension/Results/MultipleResult.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Disco.Services.Plugins.Features.UIExtension.Results +{ + public class MultipleResult : UIExtensionResult + { + private IEnumerable results; + + public MultipleResult(PluginFeatureManifest Source, params UIExtensionResult[] Results) : base(Source) + { + if (Results == null || Results.Length == 0) + throw new ArgumentException("At least one result is required", "Results"); + + this.results = Results; + } + + public override void ExecuteResult(System.Web.Mvc.WebViewPage page) + { + foreach (var result in this.results) + { + result.ExecuteResult(page); + page.WriteLiteral("\n"); + } + } + } +} diff --git a/Disco.Services/Plugins/Features/UIExtension/Results/PluginResourceCssResult.cs b/Disco.Services/Plugins/Features/UIExtension/Results/PluginResourceCssResult.cs new file mode 100644 index 00000000..875ffa75 --- /dev/null +++ b/Disco.Services/Plugins/Features/UIExtension/Results/PluginResourceCssResult.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Web; + +namespace Disco.Services.Plugins.Features.UIExtension.Results +{ + public class PluginResourceCssResult : UIExtensionResult + { + private string _resource; + private HtmlString _resourceUrl; + + public PluginResourceCssResult(PluginFeatureManifest Source, string Resource) + : base(Source) + { + this._resource = Resource; + this._resourceUrl = HttpContext.Current.Request.RequestContext.DiscoPluginResourceUrl(Resource, false, Source.PluginManifest); + + var deferredBundles = HttpContext.Current.Items["Bundles.UIExtensionCss"] as List; + if (deferredBundles == null) + { + deferredBundles = new List(); + HttpContext.Current.Items["Bundles.UIExtensionCss"] = deferredBundles; + } + if (!deferredBundles.Contains(this._resourceUrl)) + deferredBundles.Add(this._resourceUrl); + } + + public override void ExecuteResult(System.Web.Mvc.WebViewPage page) + { + // Nothing Done + } + } +} diff --git a/Disco.Services/Plugins/Features/UIExtension/Results/PluginResourceScriptResult.cs b/Disco.Services/Plugins/Features/UIExtension/Results/PluginResourceScriptResult.cs index 70eb75a3..14a67c52 100644 --- a/Disco.Services/Plugins/Features/UIExtension/Results/PluginResourceScriptResult.cs +++ b/Disco.Services/Plugins/Features/UIExtension/Results/PluginResourceScriptResult.cs @@ -3,23 +3,44 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Web; namespace Disco.Services.Plugins.Features.UIExtension.Results { public class PluginResourceScriptResult : UIExtensionResult { private string _resource; + private HtmlString _resourceUrl; + private bool _placeInPageHead; - public PluginResourceScriptResult(PluginFeatureManifest Source, string Resource) : base(Source) + public PluginResourceScriptResult(PluginFeatureManifest Source, string Resource, bool PlaceInPageHead) + : base(Source) { this._resource = Resource; + this._resourceUrl = HttpContext.Current.Request.RequestContext.DiscoPluginResourceUrl(Resource, false, Source.PluginManifest); + this._placeInPageHead = PlaceInPageHead; + + if (this._placeInPageHead) + { + var deferredBundles = HttpContext.Current.Items["Bundles.UIExtensionScripts"] as List; + if (deferredBundles == null) + { + deferredBundles = new List(); + HttpContext.Current.Items["Bundles.UIExtensionScripts"] = deferredBundles; + } + if (!deferredBundles.Contains(this._resourceUrl)) + deferredBundles.Add(this._resourceUrl); + } } public override void ExecuteResult(System.Web.Mvc.WebViewPage page) { - page.WriteLiteral(""); + if (!this._placeInPageHead) + { + page.WriteLiteral(""); + } } } } diff --git a/Disco.Services/Plugins/Features/UIExtension/Results/PrecompiledPartialViewResult.cs b/Disco.Services/Plugins/Features/UIExtension/Results/PrecompiledPartialViewResult.cs new file mode 100644 index 00000000..a045721f --- /dev/null +++ b/Disco.Services/Plugins/Features/UIExtension/Results/PrecompiledPartialViewResult.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Web; +using System.Web.Mvc; +using System.Web.WebPages; + +namespace Disco.Services.Plugins.Features.UIExtension.Results +{ + public class PrecompiledPartialViewResult : UIExtensionResult + { + private Type viewType; + private object model; + + public PrecompiledPartialViewResult(PluginFeatureManifest Source, Type ViewType, object Model = null) + : base(Source) + { + if (!typeof(WebViewPage).IsAssignableFrom(ViewType)) + throw new ArgumentException("The View Type must inherit from WebViewPage", "ViewType"); + + this.viewType = ViewType; + this.model = Model; + } + + public override void ExecuteResult(System.Web.Mvc.WebViewPage page) + { + WebViewPage partialView = Activator.CreateInstance(viewType) as WebViewPage; + if (partialView == null) + throw new InvalidOperationException("Invalid View Type"); + partialView.ViewContext = page.ViewContext; + partialView.ViewData = new ViewDataDictionary(this.model); + partialView.InitHelpers(); + partialView.ExecutePageHierarchy(new WebPageContext(page.ViewContext.HttpContext, null, model), page.ViewContext.Writer, null); + } + } +} diff --git a/Disco.Services/Plugins/Features/UIExtension/UIExtensionFeature.cs b/Disco.Services/Plugins/Features/UIExtension/UIExtensionFeature.cs index f56b05e0..753902f3 100644 --- a/Disco.Services/Plugins/Features/UIExtension/UIExtensionFeature.cs +++ b/Disco.Services/Plugins/Features/UIExtension/UIExtensionFeature.cs @@ -20,9 +20,25 @@ namespace Disco.Services.Plugins.Features.UIExtension { return new LiteralResult(this.Manifest, Content); } - protected PluginResourceScriptResult ScriptResource(string Resource) + protected LiteralResult Nothing() { - return new PluginResourceScriptResult(this.Manifest, Resource); + return new LiteralResult(this.Manifest, null); + } + protected PluginResourceScriptResult ScriptResource(string Resource, bool PlaceInPageHead) + { + return new PluginResourceScriptResult(this.Manifest, Resource, PlaceInPageHead); + } + protected PluginResourceCssResult CssResource(string Resource) + { + return new PluginResourceCssResult(this.Manifest, Resource); + } + protected MultipleResult Multiple(params UIExtensionResult[] Results) + { + return new MultipleResult(this.Manifest, Results); + } + protected PrecompiledPartialViewResult Partial(Type PartialViewType, object Model = null) + { + return new PrecompiledPartialViewResult(this.Manifest, PartialViewType, Model); } #endregion @@ -30,17 +46,17 @@ namespace Disco.Services.Plugins.Features.UIExtension #region Registration public bool Register() { - return UIExtensions.UIExtensions.RegisterExtension(this); + return UIExtensions.RegisterExtension(this); } public bool Unregister() { - return UIExtensions.UIExtensions.UnregisterExtension(this); + return UIExtensions.UnregisterExtension(this); } public bool IsRegistered { get { - return UIExtensions.UIExtensions.ExtensionRegistered(this); + return UIExtensions.ExtensionRegistered(this); } } #endregion diff --git a/Disco.Services/UIExtensions/UIExtensions.cs b/Disco.Services/Plugins/Features/UIExtension/UIExtensions.cs similarity index 98% rename from Disco.Services/UIExtensions/UIExtensions.cs rename to Disco.Services/Plugins/Features/UIExtension/UIExtensions.cs index dd5cad8f..6b16bb62 100644 --- a/Disco.Services/UIExtensions/UIExtensions.cs +++ b/Disco.Services/Plugins/Features/UIExtension/UIExtensions.cs @@ -11,7 +11,7 @@ using Disco.Models.UI; using Disco.Services.Plugins; using Disco.Services.Plugins.Features.UIExtension; -namespace Disco.Services.UIExtensions +namespace Disco.Services.Plugins.Features.UIExtension { public static class UIExtensions { diff --git a/Disco.Services/Plugins/PluginExtensions.cs b/Disco.Services/Plugins/PluginExtensions.cs index 81066ef4..d56268e9 100644 --- a/Disco.Services/Plugins/PluginExtensions.cs +++ b/Disco.Services/Plugins/PluginExtensions.cs @@ -96,11 +96,15 @@ namespace Disco.Services.Plugins return ViewPage.DiscoPluginResourceUrl(Resource, false, manifest); } public static HtmlString DiscoPluginResourceUrl(this WebViewPage ViewPage, string Resource, bool Download, PluginManifest manifest) + { + return ViewPage.ViewContext.RequestContext.DiscoPluginResourceUrl(Resource, Download, manifest); + } + public static HtmlString DiscoPluginResourceUrl(this RequestContext RequestContext, string Resource, bool Download, PluginManifest manifest) { var resourcePath = manifest.WebResourcePath(Resource); var routeValues = new RouteValueDictionary(new { PluginId = manifest.Id, res = Resource }); - string pluginActionUrl = UrlHelper.GenerateUrl("Plugin_Resources", null, null, routeValues, RouteTable.Routes, ViewPage.ViewContext.RequestContext, false); + string pluginActionUrl = UrlHelper.GenerateUrl("Plugin_Resources", null, null, routeValues, RouteTable.Routes, RequestContext, false); pluginActionUrl += string.Format("?v={0}", resourcePath.Item2); @@ -122,9 +126,13 @@ namespace Disco.Services.Plugins return ViewPage.DiscoPluginActionUrl(PluginAction, manifest); } public static HtmlString DiscoPluginActionUrl(this WebViewPage ViewPage, string PluginAction, PluginManifest manifest) + { + return ViewPage.ViewContext.RequestContext.DiscoPluginActionUrl(PluginAction, manifest); + } + public static HtmlString DiscoPluginActionUrl(this RequestContext RequestContext, string PluginAction, PluginManifest manifest) { var routeValues = new RouteValueDictionary(new { PluginId = manifest.Id, PluginAction = PluginAction }); - string pluginActionUrl = UrlHelper.GenerateUrl("Plugin", null, null, routeValues, RouteTable.Routes, ViewPage.ViewContext.RequestContext, false); + string pluginActionUrl = UrlHelper.GenerateUrl("Plugin", null, null, routeValues, RouteTable.Routes, RequestContext, false); return new HtmlString(pluginActionUrl); } public static HtmlString DiscoPluginConfigureUrl(this WebViewPage ViewPage) diff --git a/Disco.Services/Properties/AssemblyInfo.cs b/Disco.Services/Properties/AssemblyInfo.cs index 3dff3609..2f41c342 100644 --- a/Disco.Services/Properties/AssemblyInfo.cs +++ b/Disco.Services/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0221.1820")] -[assembly: AssemblyFileVersion("1.2.0221.1820")] +[assembly: AssemblyVersion("1.2.0225.1951")] +[assembly: AssemblyFileVersion("1.2.0225.1951")] diff --git a/Disco.Web.Extensions/MvcExtensions/Bundles/BundleExtensions.cs b/Disco.Web.Extensions/MvcExtensions/Bundles/BundleExtensions.cs index b8ecb197..14a1aa61 100644 --- a/Disco.Web.Extensions/MvcExtensions/Bundles/BundleExtensions.cs +++ b/Disco.Web.Extensions/MvcExtensions/Bundles/BundleExtensions.cs @@ -1,49 +1,65 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Web; -using System.Web.Mvc; -using Disco.Web.Extensions.MvcExtensions.Bundles; - -namespace Disco.Web.Extensions -{ - public static class BundleExtensions - { - public static void BundleDeferred(this HtmlHelper htmlHelper, string BundleUrl) - { - // Ensure 'App-Relative' Url: - BundleUrl = BundleUrl.StartsWith("~/") ? BundleUrl : (BundleUrl.StartsWith("/") ? string.Concat("~", BundleUrl) : string.Concat("~/", BundleUrl)); - - var deferredBundles = default(List); - deferredBundles = htmlHelper.ViewContext.HttpContext.Items["Bundles.Deferred"] as List; - if (deferredBundles == null) - { - deferredBundles = new List(); - htmlHelper.ViewContext.HttpContext.Items["Bundles.Deferred"] = deferredBundles; - } - if (!deferredBundles.Contains(BundleUrl)) - deferredBundles.Add(BundleUrl); - } - public static HtmlString BundleRenderDeferred(this HtmlHelper htmlHelper) - { - var deferredBundles = default(List); - deferredBundles = htmlHelper.ViewContext.HttpContext.Items["Bundles.Deferred"] as List; - - if (deferredBundles != null) - { - StringBuilder bundleUrls = new StringBuilder(); - deferredBundles.Reverse(); - foreach (string bundleUrl in deferredBundles) - { - bundleUrls.AppendLine(BundleTable.ResolveBundleHtmlElement(bundleUrl)); - } - return new HtmlString(bundleUrls.ToString()); - } - else - { - return new HtmlString(string.Empty); - } - } - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Web; +using System.Web.Mvc; +using Disco.Web.Extensions.MvcExtensions.Bundles; + +namespace Disco.Web.Extensions +{ + public static class BundleExtensions + { + public static void BundleDeferred(this HtmlHelper htmlHelper, string BundleUrl) + { + // Ensure 'App-Relative' Url: + BundleUrl = BundleUrl.StartsWith("~/") ? BundleUrl : (BundleUrl.StartsWith("/") ? string.Concat("~", BundleUrl) : string.Concat("~/", BundleUrl)); + + var deferredBundles = htmlHelper.ViewContext.HttpContext.Items["Bundles.Deferred"] as List; + if (deferredBundles == null) + { + deferredBundles = new List(); + htmlHelper.ViewContext.HttpContext.Items["Bundles.Deferred"] = deferredBundles; + } + if (!deferredBundles.Contains(BundleUrl)) + deferredBundles.Add(BundleUrl); + } + public static HtmlString BundleRenderDeferred(this HtmlHelper htmlHelper) + { + var deferredBundles = htmlHelper.ViewContext.HttpContext.Items["Bundles.Deferred"] as List; + + var uiExtensionScripts = htmlHelper.ViewContext.HttpContext.Items["Bundles.UIExtensionScripts"] as List; + var uiExtensionCss = htmlHelper.ViewContext.HttpContext.Items["Bundles.UIExtensionCss"] as List; + + if (deferredBundles != null || uiExtensionScripts != null || uiExtensionCss != null) + { + StringBuilder bundleUrls = new StringBuilder(); + + if (deferredBundles != null) + { + deferredBundles.Reverse(); + foreach (string bundleUrl in deferredBundles) + { + bundleUrls.AppendLine(BundleTable.ResolveBundleHtmlElement(bundleUrl)); + } + } + if (uiExtensionCss != null) + { + foreach (HtmlString extensionUrl in uiExtensionCss) + bundleUrls.Append(""); + } + if (uiExtensionScripts != null) + { + foreach (HtmlString extensionUrl in uiExtensionScripts) + bundleUrls.Append(""); + } + + return new HtmlString(bundleUrls.ToString()); + } + else + { + return new HtmlString(string.Empty); + } + } + } +} diff --git a/Disco.Web.Extensions/Properties/AssemblyInfo.cs b/Disco.Web.Extensions/Properties/AssemblyInfo.cs index 4357d297..5f2c14a3 100644 --- a/Disco.Web.Extensions/Properties/AssemblyInfo.cs +++ b/Disco.Web.Extensions/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0221.1820")] -[assembly: AssemblyFileVersion("1.2.0221.1820")] +[assembly: AssemblyVersion("1.2.0225.1951")] +[assembly: AssemblyFileVersion("1.2.0225.1951")] diff --git a/Disco.Web/Controllers/DeviceController.cs b/Disco.Web/Controllers/DeviceController.cs index 698c1a52..4bb4047a 100644 --- a/Disco.Web/Controllers/DeviceController.cs +++ b/Disco.Web/Controllers/DeviceController.cs @@ -1,114 +1,124 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; -using Disco.BI; -using Disco.BI.Extensions; -using Disco.Data.Repository; -using Disco.Models.Repository; -using System.Data.Objects.SqlClient; -using Disco.Web.Extensions; - - -namespace Disco.Web.Controllers -{ - public partial class DeviceController : dbAdminController - { - #region Index - public virtual ActionResult Index() - { - return View(); - } - #endregion - - #region Add Offline - public virtual ActionResult AddOffline() - { - var m = new Models.Device.AddOfflineModel() - { - DefaultDeviceProfileId = dbContext.DiscoConfiguration.DeviceProfiles.DefaultAddDeviceOfflineDeviceProfileId - }; - m.DeviceBatches = dbContext.DeviceBatches.ToSelectListItems(); - m.DeviceProfiles = dbContext.DeviceProfiles.ToList(); - if (m.DefaultDeviceProfileId == 0) - { - m.DeviceProfiles.Insert(0, new DeviceProfile() { Id = 0, Name = "Select a Device Profile" }); - } - - return View(m); - } - [HttpPost] - public virtual ActionResult AddOffline(Models.Device.AddOfflineModel m) - { - // Trim Serial Number & Error Check - m.Device.SerialNumber = m.Device.SerialNumber.Trim(); - if (string.IsNullOrEmpty(m.Device.SerialNumber)) - { - ModelState.AddModelError("Device.SerialNumber", "The Serial Number is Required"); - } - else - { - // Ensure Existing Device Doesn't Exist - if (!string.IsNullOrEmpty(m.Device.SerialNumber) && dbContext.Devices.Count(d => d.SerialNumber == m.Device.SerialNumber) > 0) - ModelState.AddModelError("Device.SerialNumber", "A Device what this Serial Number already exists"); - } - - - if (ModelState.IsValid) - { - var d = m.Device.AddOffline(dbContext); - dbContext.SaveChanges(); - return RedirectToAction(MVC.Device.Show(d.SerialNumber)); - } - return AddOffline(); - } - #endregion - - #region Show - public virtual ActionResult Show(string id) - { - var m = new Models.Device.ShowModel(); - - dbContext.Configuration.LazyLoadingEnabled = true; - - m.Device = dbContext.Devices - .Where(d => d.SerialNumber == id) - .FirstOrDefault(); - - if (m.Device == null) - throw new ArgumentException(string.Format("Unknown Device: [{0}]", id), "id"); - - // Removed 2012-07-03 G# - // Deferred to Ajax call - improve load performance - // Update Device LastNetworkLogonDate - //if (m.Device.UpdateLastNetworkLogonDate()) - // dbContext.SaveChanges(); - - // No Necessary - Yet... - //if (!string.IsNullOrWhiteSpace(m.Device.ComputerName)) - //{ - // var adMachineAccount = BI.Interop.ActiveDirectory.ActiveDirectory.GetMachineAccount(m.Device.ComputerName); - // if (adMachineAccount != null) - // { - // m.OrganisationUnit = adMachineAccount.ParentDistinguishedName; - // } - //} - - m.DeviceProfiles = dbContext.DeviceProfiles.ToList(); - - m.DeviceBatches = dbContext.DeviceBatches.ToSelectListItems(m.Device.DeviceBatchId); - - m.Jobs = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true, ShowDevice = false, IsSmallTable = true, HideClosedJobs = true }; - m.Jobs.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.DeviceSerialNumber == m.Device.SerialNumber)); - - m.Certificates = dbContext.DeviceCertificates.Where(c => c.DeviceSerialNumber == m.Device.SerialNumber).ToList(); - - //m.AttachmentTypes = dbContext.AttachmentTypes.Where(at => at.Scope == AttachmentType.AttachmentTypeScopes.Device).ToList(); - m.DocumentTemplates = m.Device.AvailableDocumentTemplates(dbContext, DiscoApplication.CurrentUser, DateTime.Now); - - return View(m); - } - #endregion - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using Disco.BI; +using Disco.BI.Extensions; +using Disco.Data.Repository; +using Disco.Models.Repository; +using System.Data.Objects.SqlClient; +using Disco.Web.Extensions; +using Disco.Services.Plugins.Features.UIExtension; +using Disco.Models.UI.Device; + + +namespace Disco.Web.Controllers +{ + public partial class DeviceController : dbAdminController + { + #region Index + public virtual ActionResult Index() + { + Models.Device.IndexModel m = new Models.Device.IndexModel(); + + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + + return View(); + } + #endregion + + #region Add Offline + public virtual ActionResult AddOffline() + { + var m = new Models.Device.AddOfflineModel() + { + DefaultDeviceProfileId = dbContext.DiscoConfiguration.DeviceProfiles.DefaultAddDeviceOfflineDeviceProfileId + }; + m.DeviceBatches = dbContext.DeviceBatches.ToSelectListItems(); + m.DeviceProfiles = dbContext.DeviceProfiles.ToList(); + if (m.DefaultDeviceProfileId == 0) + { + m.DeviceProfiles.Insert(0, new DeviceProfile() { Id = 0, Name = "Select a Device Profile" }); + } + + return View(m); + } + [HttpPost] + public virtual ActionResult AddOffline(Models.Device.AddOfflineModel m) + { + // Trim Serial Number & Error Check + m.Device.SerialNumber = m.Device.SerialNumber.Trim(); + if (string.IsNullOrEmpty(m.Device.SerialNumber)) + { + ModelState.AddModelError("Device.SerialNumber", "The Serial Number is Required"); + } + else + { + // Ensure Existing Device Doesn't Exist + if (!string.IsNullOrEmpty(m.Device.SerialNumber) && dbContext.Devices.Count(d => d.SerialNumber == m.Device.SerialNumber) > 0) + ModelState.AddModelError("Device.SerialNumber", "A Device what this Serial Number already exists"); + } + + + if (ModelState.IsValid) + { + var d = m.Device.AddOffline(dbContext); + dbContext.SaveChanges(); + return RedirectToAction(MVC.Device.Show(d.SerialNumber)); + } + return AddOffline(); + } + #endregion + + #region Show + public virtual ActionResult Show(string id) + { + var m = new Models.Device.ShowModel(); + + dbContext.Configuration.LazyLoadingEnabled = true; + + m.Device = dbContext.Devices + .Where(d => d.SerialNumber == id) + .FirstOrDefault(); + + if (m.Device == null) + throw new ArgumentException(string.Format("Unknown Device: [{0}]", id), "id"); + + // Removed 2012-07-03 G# + // Deferred to Ajax call - improve load performance + // Update Device LastNetworkLogonDate + //if (m.Device.UpdateLastNetworkLogonDate()) + // dbContext.SaveChanges(); + + // No Necessary - Yet... + //if (!string.IsNullOrWhiteSpace(m.Device.ComputerName)) + //{ + // var adMachineAccount = BI.Interop.ActiveDirectory.ActiveDirectory.GetMachineAccount(m.Device.ComputerName); + // if (adMachineAccount != null) + // { + // m.OrganisationUnit = adMachineAccount.ParentDistinguishedName; + // } + //} + + m.DeviceProfiles = dbContext.DeviceProfiles.ToList(); + + m.DeviceBatches = dbContext.DeviceBatches.ToList(); + + m.Jobs = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true, ShowDevice = false, IsSmallTable = true, HideClosedJobs = true }; + m.Jobs.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.DeviceSerialNumber == m.Device.SerialNumber)); + + m.Certificates = dbContext.DeviceCertificates.Where(c => c.DeviceSerialNumber == m.Device.SerialNumber).ToList(); + + //m.AttachmentTypes = dbContext.AttachmentTypes.Where(at => at.Scope == AttachmentType.AttachmentTypeScopes.Device).ToList(); + m.DocumentTemplates = m.Device.AvailableDocumentTemplates(dbContext, DiscoApplication.CurrentUser, DateTime.Now); + + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + + return View(m); + } + #endregion + } +} diff --git a/Disco.Web/Controllers/JobController.cs b/Disco.Web/Controllers/JobController.cs index ac4a5e98..30345767 100644 --- a/Disco.Web/Controllers/JobController.cs +++ b/Disco.Web/Controllers/JobController.cs @@ -10,8 +10,8 @@ using Disco.Models.Repository; using System.Web.Script.Serialization; using Disco.Services.Plugins.Features.WarrantyProvider; using Disco.Services.Plugins; -using Disco.Services.UIExtensions; using Disco.Models.UI.Job; +using Disco.Services.Plugins.Features.UIExtension; namespace Disco.Web.Controllers { @@ -64,6 +64,10 @@ namespace Disco.Web.Controllers // closedThreshold = closedThreshold.AddDays(-1); //m.RecentlyClosedJobs = new Disco.Models.BI.Job.JobTableModel(); //m.RecentlyClosedJobs.Fill(BI.JobTableModelBI.BuildQuery(dbContext).Where(j => j.ClosedDate > closedThreshold)); + + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + return View(m); } #endregion @@ -75,6 +79,10 @@ namespace Disco.Web.Controllers var m = new Models.Job.ListModel() { Title = "All Open Jobs" }; m.JobTable = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true }; m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.ClosedDate == null).OrderBy(j => j.Id)); + + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + return View(Views.List, m); } public virtual ActionResult DevicesReadyForReturn() @@ -86,6 +94,10 @@ namespace Disco.Web.Controllers && j.DeviceHeld != null && j.DeviceReturnedDate == null && j.DeviceReadyForReturn != null && ((!j.JobMetaNonWarranty.AccountingChargeRequiredDate.HasValue && !j.JobMetaNonWarranty.AccountingChargeAddedDate.HasValue) || j.JobMetaNonWarranty.AccountingChargePaidDate.HasValue) && j.ClosedDate == null).OrderBy(j => j.Id)); + + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + return View(Views.List, m); } public virtual ActionResult DevicesAwaitingRepair() @@ -98,6 +110,10 @@ namespace Disco.Web.Controllers (j.JobMetaNonWarranty.RepairerLoggedDate != null && j.JobMetaNonWarranty.RepairerCompletedDate == null) || (j.JobMetaWarranty.ExternalLoggedDate != null && j.JobMetaWarranty.ExternalCompletedDate == null) )).OrderBy(j => j.Id)); + + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + return View(Views.List, m); } @@ -114,6 +130,10 @@ namespace Disco.Web.Controllers (j.JobTypeId == JobType.JobTypeIds.HNWar && (!j.JobMetaNonWarranty.AccountingChargeAddedDate.HasValue || !j.JobMetaNonWarranty.AccountingChargePaidDate.HasValue)) || (j.JobTypeId == JobType.JobTypeIds.UMgmt && (long)Job.UserManagementFlags.Infringement_BreachFinancialAgreement == (j.Flags & (long)Job.UserManagementFlags.Infringement_BreachFinancialAgreement)) ))); + + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + return View(Views.List, m); } @@ -126,6 +146,9 @@ namespace Disco.Web.Controllers (j.JobTypeId == JobType.JobTypeIds.HNWar && (j.JobMetaNonWarranty.AccountingChargeRequiredDate.HasValue && (!j.JobMetaNonWarranty.AccountingChargeAddedDate.HasValue && !j.JobMetaNonWarranty.AccountingChargePaidDate.HasValue))) ).OrderBy(j => j.Id)); + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + return View(Views.List, m); } public virtual ActionResult AwaitingFinancePayment() @@ -136,6 +159,10 @@ namespace Disco.Web.Controllers m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.ClosedDate == null && (j.JobTypeId == JobType.JobTypeIds.HNWar && (!j.JobMetaNonWarranty.AccountingChargeAddedDate.HasValue || !j.JobMetaNonWarranty.AccountingChargePaidDate.HasValue)) ).OrderBy(j => j.Id)); + + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + return View(Views.List, m); } public virtual ActionResult AwaitingFinanceInsuranceProcessing() @@ -146,6 +173,10 @@ namespace Disco.Web.Controllers m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.ClosedDate == null && (j.JobTypeId == JobType.JobTypeIds.HNWar && (j.JobMetaNonWarranty.IsInsuranceClaim && !j.JobMetaInsurance.ClaimFormSentDate.HasValue)) ).OrderBy(j => j.Id)); + + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + return View(Views.List, m); } public virtual ActionResult AwaitingFinanceAgreementBreach() @@ -156,6 +187,10 @@ namespace Disco.Web.Controllers m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.ClosedDate == null && (j.JobTypeId == JobType.JobTypeIds.UMgmt && (long)Job.UserManagementFlags.Infringement_BreachFinancialAgreement == (j.Flags & (long)Job.UserManagementFlags.Infringement_BreachFinancialAgreement)) ).OrderBy(j => j.Id)); + + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + return View(Views.List, m); } @@ -168,6 +203,10 @@ namespace Disco.Web.Controllers m.JobTable = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true }; m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => (j.WaitingForUserAction.HasValue || (j.JobMetaNonWarranty.AccountingChargeAddedDate != null && j.JobMetaNonWarranty.AccountingChargePaidDate == null)) && j.ClosedDate == null).OrderBy(j => j.Id)); + + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + return View(Views.List, m); } public virtual ActionResult RecentlyClosed() @@ -183,6 +222,10 @@ namespace Disco.Web.Controllers if (dateTimeNow.DayOfWeek == DayOfWeek.Tuesday) closedThreshold = closedThreshold.AddDays(-1); m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.ClosedDate > closedThreshold).OrderBy(j => j.Id)); + + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + return View(Views.List, m); } public virtual ActionResult Locations() @@ -191,6 +234,10 @@ namespace Disco.Web.Controllers var m = new Models.Job.ListModel() { Title = "Held Device Locations" }; m.JobTable = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true, ShowLocation = true, ShowTechnician = false, ShowType = false }; m.JobTable.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.ClosedDate == null && j.DeviceHeld.HasValue && !j.DeviceReturnedDate.HasValue).OrderBy(j => j.DeviceHeldLocation)); + + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + return View(Views.List, m); } @@ -232,6 +279,9 @@ namespace Disco.Web.Controllers }; m.UpdateModel(dbContext); + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + return View(m); } [HttpPost] @@ -241,6 +291,9 @@ namespace Disco.Web.Controllers if (!ModelState.IsValid) { + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + return View(m); } else diff --git a/Disco.Web/Controllers/UserController.cs b/Disco.Web/Controllers/UserController.cs index 8bdb8d86..fd46291a 100644 --- a/Disco.Web/Controllers/UserController.cs +++ b/Disco.Web/Controllers/UserController.cs @@ -1,51 +1,61 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; -using Disco.Models.Repository; -using Disco.BI.Extensions; - -namespace Disco.Web.Controllers -{ - public partial class UserController : dbAdminController - { - #region Index - public virtual ActionResult Index() - { - return View(); - } - #endregion - - #region Show - public virtual ActionResult Show(string id) - { - var m = new Models.User.ShowModel(); - - dbContext.Configuration.LazyLoadingEnabled = true; - - // Update User Cache - // Do this first so the Database is updated if necessary - try - { - Disco.BI.UserBI.UserCache.GetUser(id, dbContext, true); - } - catch (ArgumentException) - { - // Ignore if User not in Active Directory anymore - } - - - m.User = dbContext.Users.Where(um => um.Id == id).FirstOrDefault(); - - m.Jobs = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true, ShowDevice = true, ShowUser = false, IsSmallTable = true, HideClosedJobs = true }; - m.Jobs.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.UserId == id)); - - m.DocumentTemplates = m.User.AvailableDocumentTemplates(dbContext, DiscoApplication.CurrentUser, DateTime.Now); - - return View(m); - } - #endregion - - } -} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using Disco.Models.Repository; +using Disco.BI.Extensions; +using Disco.Services.Plugins.Features.UIExtension; +using Disco.Models.UI.User; + +namespace Disco.Web.Controllers +{ + public partial class UserController : dbAdminController + { + #region Index + public virtual ActionResult Index() + { + var m = new Models.User.IndexModel(); + + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + + return View(); + } + #endregion + + #region Show + public virtual ActionResult Show(string id) + { + var m = new Models.User.ShowModel(); + + dbContext.Configuration.LazyLoadingEnabled = true; + + // Update User Cache + // Do this first so the Database is updated if necessary + try + { + Disco.BI.UserBI.UserCache.GetUser(id, dbContext, true); + } + catch (ArgumentException) + { + // Ignore if User not in Active Directory anymore + } + + + m.User = dbContext.Users.Where(um => um.Id == id).FirstOrDefault(); + + m.Jobs = new Disco.Models.BI.Job.JobTableModel() { ShowStatus = true, ShowDevice = true, ShowUser = false, IsSmallTable = true, HideClosedJobs = true }; + m.Jobs.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.UserId == id)); + + m.DocumentTemplates = m.User.AvailableDocumentTemplates(dbContext, DiscoApplication.CurrentUser, DateTime.Now); + + // UI Extensions + UIExtensions.ExecuteExtensions(this.ControllerContext, m); + + return View(m); + } + #endregion + + } +} diff --git a/Disco.Web/Disco.Web.csproj b/Disco.Web/Disco.Web.csproj index 75bc4a9b..a50e863a 100644 --- a/Disco.Web/Disco.Web.csproj +++ b/Disco.Web/Disco.Web.csproj @@ -466,6 +466,7 @@ Global.asax + @@ -480,6 +481,7 @@ + @@ -1835,7 +1837,7 @@ False - + diff --git a/Disco.Web/Models/Device/IndexModel.cs b/Disco.Web/Models/Device/IndexModel.cs new file mode 100644 index 00000000..50692114 --- /dev/null +++ b/Disco.Web/Models/Device/IndexModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Disco.Models.UI.Device; + +namespace Disco.Web.Models.Device +{ + public class IndexModel : DeviceIndexModel + { + } +} \ No newline at end of file diff --git a/Disco.Web/Models/Device/ShowModel.cs b/Disco.Web/Models/Device/ShowModel.cs index 9472730a..411be4a2 100644 --- a/Disco.Web/Models/Device/ShowModel.cs +++ b/Disco.Web/Models/Device/ShowModel.cs @@ -1,37 +1,37 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; -using Disco.BI; -using Disco.BI.Extensions; -using Disco.Web.Extensions; - -namespace Disco.Web.Models.Device -{ - public class ShowModel - { - public Disco.Models.Repository.Device Device { get; set; } - - - public List DeviceProfiles { get; set; } - public List DeviceBatches { get; set; } - public Disco.Models.BI.Job.JobTableModel Jobs { get; set; } - public List Certificates { get; set; } - - public string OrganisationUnit { get; set; } - - public List DocumentTemplates { get; set; } - - public List DocumentTemplatesSelectListItems - { - get - { - var list = new List(); - list.Add(new SelectListItem() { Selected = true, Value = string.Empty, Text = "Select a Document to Generate" }); - list.AddRange(this.DocumentTemplates.ToSelectListItems()); - return list; - } - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using Disco.BI; +using Disco.BI.Extensions; +using Disco.Models.UI.Device; +using Disco.Web.Extensions; + +namespace Disco.Web.Models.Device +{ + public class ShowModel : DeviceShowModel + { + public Disco.Models.Repository.Device Device { get; set; } + + public List DeviceProfiles { get; set; } + public List DeviceBatches { get; set; } + public Disco.Models.BI.Job.JobTableModel Jobs { get; set; } + public List Certificates { get; set; } + + public string OrganisationUnit { get; set; } + + public List DocumentTemplates { get; set; } + + public List DocumentTemplatesSelectListItems + { + get + { + var list = new List(); + list.Add(new SelectListItem() { Selected = true, Value = string.Empty, Text = "Select a Document to Generate" }); + list.AddRange(this.DocumentTemplates.ToSelectListItems()); + return list; + } + } + } } \ No newline at end of file diff --git a/Disco.Web/Models/Job/CreateModel.cs b/Disco.Web/Models/Job/CreateModel.cs index 3b1e192a..89a5554f 100644 --- a/Disco.Web/Models/Job/CreateModel.cs +++ b/Disco.Web/Models/Job/CreateModel.cs @@ -1,184 +1,182 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Web; -using Disco.Data.Repository; - -namespace Disco.Web.Models.Job -{ - [CustomValidation(typeof(CreateModel), "ValidateCreateModel")] - public class CreateModel - { - public string DeviceSerialNumber { get; set; } - public string UserId { get; set; } - - [Required] - public string Type { get; set; } - [Required] - public List SubTypes { get; set; } - - [DataType(System.ComponentModel.DataAnnotations.DataType.MultilineText)] - public string Comments { get; set; } - - //public string AssignedUserId { get; set; } - //public DateTime? AssignedUserTargetCompletionDate { get; set; } - - [Required(ErrorMessage = "Please specify whether the device is held or not")] - public bool? DeviceHeld { get; set; } - - public string QuickLogDestinationUrl { get; set; } - - [Display(Description = "Automatically close this job")] - public bool? QuickLog { get; set; } - public int? QuickLogTaskTimeMinutes { get; set; } - public int? QuickLogTaskTimeMinutesOther { get; set; } - - #region Helpers & Model Logic - // View Required Data - public Disco.Models.Repository.Device Device { get; set; } - public Disco.Models.Repository.User User { get; set; } - public List JobTypes { get; set; } - public List JobSubTypes { get; set; } - public void UpdateModel(DiscoDataContext dbContext) - { - if (this.JobTypes == null) - JobTypes = dbContext.JobTypes.ToList(); - if (this.JobSubTypes == null) - JobSubTypes = dbContext.JobSubTypes.ToList(); - - if (!string.IsNullOrEmpty(DeviceSerialNumber)) - { - this.Device = dbContext.Devices.Include("DeviceModel").Where(d => d.SerialNumber == DeviceSerialNumber).FirstOrDefault(); - if (this.Device == null) - { - throw new ArgumentException("Invalid Device Serial Number Specified", "DeviceSerialNumber"); - } - if (string.IsNullOrEmpty(this.UserId) && !string.IsNullOrEmpty(this.Device.AssignedUserId)) - { - this.UserId = this.Device.AssignedUserId; - } - if (string.IsNullOrEmpty(this.Type)) - this.Type = this.JobTypes.First(jt => jt.Id == Disco.Models.Repository.JobType.JobTypeIds.HWar).Id; - - if (string.IsNullOrEmpty(this.UserId)) - { - // No User - Remove User Types - foreach (var jobType in JobTypes.ToArray()) - { - switch (jobType.Id) - { - case Disco.Models.Repository.JobType.JobTypeIds.UMgmt: - JobTypes.Remove(jobType); - JobSubTypes.RemoveAll(jst => jst.JobType == jobType); - break; - default: - break; - } - } - } - } - else - { - // No Device - Remove Hardware Types - foreach (var jobType in JobTypes.ToArray()) - { - switch (jobType.Id) - { - case Disco.Models.Repository.JobType.JobTypeIds.HMisc: - case Disco.Models.Repository.JobType.JobTypeIds.HNWar: - case Disco.Models.Repository.JobType.JobTypeIds.HWar: - case Disco.Models.Repository.JobType.JobTypeIds.SImg: - JobTypes.Remove(jobType); - JobSubTypes.RemoveAll(jst => jst.JobType == jobType); - break; - default: - break; - } - } - - // Set Default Job Type for Users - if (string.IsNullOrEmpty(this.Type)) - this.Type = this.JobTypes.First(jt => jt.Id == Disco.Models.Repository.JobType.JobTypeIds.SApp).Id; - } - if (!string.IsNullOrEmpty(UserId)) - { - this.User = dbContext.Users.Find(UserId); - if (this.User == null) - { - throw new ArgumentException("Invalid User Id Specified", "UserId"); - } - if (string.IsNullOrEmpty(this.Type)) - this.Type = Disco.Models.Repository.JobType.JobTypeIds.SApp; - } - if (this.User == null && this.Device == null) - { - throw new InvalidOperationException("A Job must reference a Device and/or a User"); - } - } - - // Job Type Helpers - public Disco.Models.Repository.JobType GetJobType - { - get - { - if (!string.IsNullOrEmpty(this.Type)) - { - return this.JobTypes.FirstOrDefault(m => m.Id == this.Type); - } - return null; - } - } - public List GetJobSubTypes - { - get - { - if (SubTypes != null) - { - var subTypes = this.SubTypes; - return this.JobSubTypes.Where(m => subTypes.Contains(String.Format("{0}_{1}", m.JobTypeId, m.Id))).ToList(); - } - return null; - } - } - - public static ValidationResult ValidateCreateModel(CreateModel model) - { - // Device && User both can't be null - if (string.IsNullOrEmpty(model.DeviceSerialNumber) && string.IsNullOrEmpty(model.UserId)) - return new ValidationResult("A Job must reference a Device and/or a User"); - - if (!string.IsNullOrEmpty(model.Type) && model.SubTypes != null) - { - var typeId = string.Format("{0}_", model.Type); - model.SubTypes = model.SubTypes.Where(m => m.StartsWith(typeId)).ToList(); - if (model.SubTypes.Count == 0) - { - model.SubTypes = null; - return new ValidationResult("At least one Sub Type is required", new string[] { "SubTypes" }); - } - } - - // Enforce Behaviour - if (model.DeviceHeld.HasValue && model.DeviceHeld.Value) - { - model.QuickLog = false; - } - else - { - if (model.QuickLog.HasValue && model.QuickLog.Value) - { - if (!model.QuickLogTaskTimeMinutes.HasValue || model.QuickLogTaskTimeMinutes.Value <= 0) - if (model.QuickLogTaskTimeMinutesOther.HasValue && model.QuickLogTaskTimeMinutesOther.Value > 0) - model.QuickLogTaskTimeMinutes = model.QuickLogTaskTimeMinutesOther.Value; - else - model.QuickLogTaskTimeMinutes = 10; // Default to 10 Minutes - } - } - - return ValidationResult.Success; - } - #endregion - - } +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Web; +using Disco.Data.Repository; +using Disco.Models.UI.Job; + +namespace Disco.Web.Models.Job +{ + [CustomValidation(typeof(CreateModel), "ValidateCreateModel")] + public class CreateModel : JobCreateModel + { + public string DeviceSerialNumber { get; set; } + public string UserId { get; set; } + + [Required] + public string Type { get; set; } + [Required] + public List SubTypes { get; set; } + + [DataType(System.ComponentModel.DataAnnotations.DataType.MultilineText)] + public string Comments { get; set; } + + [Required(ErrorMessage = "Please specify whether the device is held or not")] + public bool? DeviceHeld { get; set; } + + public string QuickLogDestinationUrl { get; set; } + + [Display(Description = "Automatically close this job")] + public bool? QuickLog { get; set; } + public int? QuickLogTaskTimeMinutes { get; set; } + public int? QuickLogTaskTimeMinutesOther { get; set; } + + #region Helpers & Model Logic + // View Required Data + public Disco.Models.Repository.Device Device { get; set; } + public Disco.Models.Repository.User User { get; set; } + public List JobTypes { get; set; } + public List JobSubTypes { get; set; } + public void UpdateModel(DiscoDataContext dbContext) + { + if (this.JobTypes == null) + JobTypes = dbContext.JobTypes.ToList(); + if (this.JobSubTypes == null) + JobSubTypes = dbContext.JobSubTypes.ToList(); + + if (!string.IsNullOrEmpty(DeviceSerialNumber)) + { + this.Device = dbContext.Devices.Include("DeviceModel").Where(d => d.SerialNumber == DeviceSerialNumber).FirstOrDefault(); + if (this.Device == null) + { + throw new ArgumentException("Invalid Device Serial Number Specified", "DeviceSerialNumber"); + } + if (string.IsNullOrEmpty(this.UserId) && !string.IsNullOrEmpty(this.Device.AssignedUserId)) + { + this.UserId = this.Device.AssignedUserId; + } + if (string.IsNullOrEmpty(this.Type)) + this.Type = this.JobTypes.First(jt => jt.Id == Disco.Models.Repository.JobType.JobTypeIds.HWar).Id; + + if (string.IsNullOrEmpty(this.UserId)) + { + // No User - Remove User Types + foreach (var jobType in JobTypes.ToArray()) + { + switch (jobType.Id) + { + case Disco.Models.Repository.JobType.JobTypeIds.UMgmt: + JobTypes.Remove(jobType); + JobSubTypes.RemoveAll(jst => jst.JobType == jobType); + break; + default: + break; + } + } + } + } + else + { + // No Device - Remove Hardware Types + foreach (var jobType in JobTypes.ToArray()) + { + switch (jobType.Id) + { + case Disco.Models.Repository.JobType.JobTypeIds.HMisc: + case Disco.Models.Repository.JobType.JobTypeIds.HNWar: + case Disco.Models.Repository.JobType.JobTypeIds.HWar: + case Disco.Models.Repository.JobType.JobTypeIds.SImg: + JobTypes.Remove(jobType); + JobSubTypes.RemoveAll(jst => jst.JobType == jobType); + break; + default: + break; + } + } + + // Set Default Job Type for Users + if (string.IsNullOrEmpty(this.Type)) + this.Type = this.JobTypes.First(jt => jt.Id == Disco.Models.Repository.JobType.JobTypeIds.SApp).Id; + } + if (!string.IsNullOrEmpty(UserId)) + { + this.User = dbContext.Users.Find(UserId); + if (this.User == null) + { + throw new ArgumentException("Invalid User Id Specified", "UserId"); + } + if (string.IsNullOrEmpty(this.Type)) + this.Type = Disco.Models.Repository.JobType.JobTypeIds.SApp; + } + if (this.User == null && this.Device == null) + { + throw new InvalidOperationException("A Job must reference a Device and/or a User"); + } + } + + // Job Type Helpers + public Disco.Models.Repository.JobType GetJobType + { + get + { + if (!string.IsNullOrEmpty(this.Type)) + { + return this.JobTypes.FirstOrDefault(m => m.Id == this.Type); + } + return null; + } + } + public List GetJobSubTypes + { + get + { + if (SubTypes != null) + { + var subTypes = this.SubTypes; + return this.JobSubTypes.Where(m => subTypes.Contains(String.Format("{0}_{1}", m.JobTypeId, m.Id))).ToList(); + } + return null; + } + } + + public static ValidationResult ValidateCreateModel(CreateModel model) + { + // Device && User both can't be null + if (string.IsNullOrEmpty(model.DeviceSerialNumber) && string.IsNullOrEmpty(model.UserId)) + return new ValidationResult("A Job must reference a Device and/or a User"); + + if (!string.IsNullOrEmpty(model.Type) && model.SubTypes != null) + { + var typeId = string.Format("{0}_", model.Type); + model.SubTypes = model.SubTypes.Where(m => m.StartsWith(typeId)).ToList(); + if (model.SubTypes.Count == 0) + { + model.SubTypes = null; + return new ValidationResult("At least one Sub Type is required", new string[] { "SubTypes" }); + } + } + + // Enforce Behaviour + if (model.DeviceHeld.HasValue && model.DeviceHeld.Value) + { + model.QuickLog = false; + } + else + { + if (model.QuickLog.HasValue && model.QuickLog.Value) + { + if (!model.QuickLogTaskTimeMinutes.HasValue || model.QuickLogTaskTimeMinutes.Value <= 0) + if (model.QuickLogTaskTimeMinutesOther.HasValue && model.QuickLogTaskTimeMinutesOther.Value > 0) + model.QuickLogTaskTimeMinutes = model.QuickLogTaskTimeMinutesOther.Value; + else + model.QuickLogTaskTimeMinutes = 10; // Default to 10 Minutes + } + } + + return ValidationResult.Success; + } + #endregion + + } } \ No newline at end of file diff --git a/Disco.Web/Models/Job/IndexModel.cs b/Disco.Web/Models/Job/IndexModel.cs index 7b6b6650..cf8615ed 100644 --- a/Disco.Web/Models/Job/IndexModel.cs +++ b/Disco.Web/Models/Job/IndexModel.cs @@ -1,16 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; - -namespace Disco.Web.Models.Job -{ - public class IndexModel - { - public Disco.Models.BI.Job.JobTableModel OpenJobs { get; set; } - public Disco.Models.BI.Job.JobTableModel LongRunningJobs { get; set; } - //public Disco.Models.BI.Job.JobTableModel WaitingForUserActionJobs { get; set; } - //public Disco.Models.BI.Job.JobTableModel ReadyForReturnJobs { get; set; } - //public Disco.Models.BI.Job.JobTableModel RecentlyClosedJobs { get; set; } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Disco.Models.UI.Job; + +namespace Disco.Web.Models.Job +{ + public class IndexModel : JobIndexModel + { + public Disco.Models.BI.Job.JobTableModel OpenJobs { get; set; } + public Disco.Models.BI.Job.JobTableModel LongRunningJobs { get; set; } + //public Disco.Models.BI.Job.JobTableModel WaitingForUserActionJobs { get; set; } + //public Disco.Models.BI.Job.JobTableModel ReadyForReturnJobs { get; set; } + //public Disco.Models.BI.Job.JobTableModel RecentlyClosedJobs { get; set; } + } } \ No newline at end of file diff --git a/Disco.Web/Models/Job/ListModel.cs b/Disco.Web/Models/Job/ListModel.cs index c2f1d9b1..231af5c9 100644 --- a/Disco.Web/Models/Job/ListModel.cs +++ b/Disco.Web/Models/Job/ListModel.cs @@ -1,21 +1,22 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; - -namespace Disco.Web.Models.Job -{ - public class ListModel - { - public string Title { get; set; } - public Disco.Models.BI.Job.JobTableModel JobTable { get; set; } - - public string PageTitle - { - get - { - return string.Format("{0} ({1})", Title, JobTable.Items.Count); - } - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Disco.Models.UI.Job; + +namespace Disco.Web.Models.Job +{ + public class ListModel : JobListModel + { + public string Title { get; set; } + public Disco.Models.BI.Job.JobTableModel JobTable { get; set; } + + public string PageTitle + { + get + { + return string.Format("{0} ({1})", Title, JobTable.Items.Count); + } + } + } } \ No newline at end of file diff --git a/Disco.Web/Models/User/IndexModel.cs b/Disco.Web/Models/User/IndexModel.cs new file mode 100644 index 00000000..0b878158 --- /dev/null +++ b/Disco.Web/Models/User/IndexModel.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Disco.Models.UI.User; + +namespace Disco.Web.Models.User +{ + public class IndexModel : UserIndexModel + { + } +} \ No newline at end of file diff --git a/Disco.Web/Models/User/ShowModel.cs b/Disco.Web/Models/User/ShowModel.cs index b68e36b7..3a7da101 100644 --- a/Disco.Web/Models/User/ShowModel.cs +++ b/Disco.Web/Models/User/ShowModel.cs @@ -1,46 +1,47 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; -using System.Web.Mvc; -using Disco.BI; -using Disco.BI.Extensions; -using Disco.Models.Interop.ActiveDirectory; -using Disco.Web.Extensions; - -namespace Disco.Web.Models.User -{ - public class ShowModel - { - public Disco.Models.Repository.User User { get; set; } - public Disco.Models.BI.Job.JobTableModel Jobs { get; set; } - public List DocumentTemplates { get; set; } - - public List DocumentTemplatesSelectListItems - { - get - { - var list = new List(); - list.Add(new SelectListItem() { Selected = true, Value = string.Empty, Text = "Select a Document to Generate" }); - list.AddRange(this.DocumentTemplates.ToSelectListItems()); - return list; - } - } - - public string PrimaryDeviceSerialNumber - { - get - { - var assignedDevice = User.DeviceUserAssignments.Where(d => !d.UnassignedDate.HasValue).FirstOrDefault(); - if (assignedDevice == null) - { - return null; - } - else - { - return assignedDevice.DeviceSerialNumber; - } - } - } - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using System.Web.Mvc; +using Disco.BI; +using Disco.BI.Extensions; +using Disco.Models.Interop.ActiveDirectory; +using Disco.Models.UI.User; +using Disco.Web.Extensions; + +namespace Disco.Web.Models.User +{ + public class ShowModel : UserShowModel + { + public Disco.Models.Repository.User User { get; set; } + public Disco.Models.BI.Job.JobTableModel Jobs { get; set; } + public List DocumentTemplates { get; set; } + + public List DocumentTemplatesSelectListItems + { + get + { + var list = new List(); + list.Add(new SelectListItem() { Selected = true, Value = string.Empty, Text = "Select a Document to Generate" }); + list.AddRange(this.DocumentTemplates.ToSelectListItems()); + return list; + } + } + + public string PrimaryDeviceSerialNumber + { + get + { + var assignedDevice = User.DeviceUserAssignments.Where(d => !d.UnassignedDate.HasValue).FirstOrDefault(); + if (assignedDevice == null) + { + return null; + } + else + { + return assignedDevice.DeviceSerialNumber; + } + } + } + } } \ No newline at end of file diff --git a/Disco.Web/Properties/AssemblyInfo.cs b/Disco.Web/Properties/AssemblyInfo.cs index 82ba877b..92e81e65 100644 --- a/Disco.Web/Properties/AssemblyInfo.cs +++ b/Disco.Web/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.2.0221.1820")] -[assembly: AssemblyFileVersion("1.2.0221.1820")] +[assembly: AssemblyVersion("1.2.0225.1951")] +[assembly: AssemblyFileVersion("1.2.0225.1951")] diff --git a/Disco.Web/Views/Device/Show.cshtml b/Disco.Web/Views/Device/Show.cshtml index 9ef07d2b..0506066b 100644 --- a/Disco.Web/Views/Device/Show.cshtml +++ b/Disco.Web/Views/Device/Show.cshtml @@ -103,7 +103,7 @@ Batch: - @Html.DropDownListFor(m => m.Device.DeviceBatchId, Model.DeviceBatches) + @Html.DropDownListFor(m => m.Device.DeviceBatchId, Model.DeviceBatches.ToSelectListItems(Model.Device.DeviceBatchId)) @AjaxHelpers.AjaxLoader()