initial source commit
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
@* Generator: WebPagesHelper *@
|
||||
@using Disco.BI.Extensions;
|
||||
@using Disco.Web;
|
||||
@using Disco.Web.Extensions;
|
||||
@helper AjaxLoader(string id = null)
|
||||
{
|
||||
Html.GetPageHelper().BundleDeferred("~/ClientScripts/Modules/Disco-AjaxHelperIcons");
|
||||
<span @(id!=null ? new HtmlString(string.Format("id=\"{0}_loading\"", id)) : new HtmlString(string.Empty)) class="ajaxHelperIcon ajaxLoading" title="Loading..."></span><span @(id != null ? new HtmlString(string.Format("id=\"{0}_ok\"", id)) : new HtmlString(string.Empty)) class="ajaxHelperIcon ajaxOk"
|
||||
title="Ok"></span>
|
||||
}
|
||||
@helper AjaxSave()
|
||||
{
|
||||
Html.GetPageHelper().BundleDeferred("~/ClientScripts/Modules/Disco-AjaxHelperIcons");
|
||||
<span class="ajaxHelperIcon ajaxSave" title="Save Changes"></span>
|
||||
}
|
||||
@helper AjaxRemove()
|
||||
{
|
||||
Html.GetPageHelper().BundleDeferred("~/ClientScripts/Modules/Disco-AjaxHelperIcons");
|
||||
<span class="ajaxHelperIcon ajaxRemove" title="Remove"></span>
|
||||
}
|
||||
@helper JsonDate(DateTime? date)
|
||||
{
|
||||
if (date.HasValue)
|
||||
{
|
||||
var d = date.Value;
|
||||
@(new HtmlString(string.Format("new Date({0}, {1}, {2}, {3}, {4}, {5})", d.Year, d.Month - 1, d.Day, d.Hour, d.Minute, d.Second)))
|
||||
}
|
||||
else
|
||||
{
|
||||
@(new HtmlString("null"))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
#pragma warning disable 1591
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17929
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Disco.Web
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Helpers;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.WebPages;
|
||||
using System.Web.WebPages.Html;
|
||||
|
||||
#line 2 "..\..\App_Code\AjaxHelpers.cshtml"
|
||||
using Disco.BI.Extensions;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 3 "..\..\App_Code\AjaxHelpers.cshtml"
|
||||
using Disco.Web;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 4 "..\..\App_Code\AjaxHelpers.cshtml"
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.0.0")]
|
||||
public class AjaxHelpers : System.Web.WebPages.HelperPage
|
||||
{
|
||||
|
||||
public static System.Web.WebPages.HelperResult AjaxLoader(string id = null)
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 6 "..\..\App_Code\AjaxHelpers.cshtml"
|
||||
|
||||
Html.GetPageHelper().BundleDeferred("~/ClientScripts/Modules/Disco-AjaxHelperIcons");
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " <span ");
|
||||
|
||||
|
||||
|
||||
#line 8 "..\..\App_Code\AjaxHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, id!=null ? new HtmlString(string.Format("id=\"{0}_loading\"", id)) : new HtmlString(string.Empty));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " class=\"ajaxHelperIcon ajaxLoading\" title=\"Loading...\"></span>");
|
||||
|
||||
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "<span ");
|
||||
|
||||
|
||||
|
||||
#line 8 "..\..\App_Code\AjaxHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, id != null ? new HtmlString(string.Format("id=\"{0}_ok\"", id)) : new HtmlString(string.Empty));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " class=\"ajaxHelperIcon ajaxOk\"\r\n title=\"Ok\"></span>\r\n");
|
||||
|
||||
|
||||
|
||||
#line 10 "..\..\App_Code\AjaxHelpers.cshtml"
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static System.Web.WebPages.HelperResult AjaxSave()
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 12 "..\..\App_Code\AjaxHelpers.cshtml"
|
||||
|
||||
Html.GetPageHelper().BundleDeferred("~/ClientScripts/Modules/Disco-AjaxHelperIcons");
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " <span class=\"ajaxHelperIcon ajaxSave\" title=\"Save Changes\"></span>\r\n");
|
||||
|
||||
|
||||
|
||||
#line 15 "..\..\App_Code\AjaxHelpers.cshtml"
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static System.Web.WebPages.HelperResult AjaxRemove()
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 17 "..\..\App_Code\AjaxHelpers.cshtml"
|
||||
|
||||
Html.GetPageHelper().BundleDeferred("~/ClientScripts/Modules/Disco-AjaxHelperIcons");
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " <span class=\"ajaxHelperIcon ajaxRemove\" title=\"Remove\"></span>\r\n");
|
||||
|
||||
|
||||
|
||||
#line 20 "..\..\App_Code\AjaxHelpers.cshtml"
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static System.Web.WebPages.HelperResult JsonDate(DateTime? date)
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 22 "..\..\App_Code\AjaxHelpers.cshtml"
|
||||
|
||||
if (date.HasValue)
|
||||
{
|
||||
var d = date.Value;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 26 "..\..\App_Code\AjaxHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, new HtmlString(string.Format("new Date({0}, {1}, {2}, {3}, {4}, {5})", d.Year, d.Month - 1, d.Day, d.Hour, d.Minute, d.Second)));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 26 "..\..\App_Code\AjaxHelpers.cshtml"
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 30 "..\..\App_Code\AjaxHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, new HtmlString("null"));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 30 "..\..\App_Code\AjaxHelpers.cshtml"
|
||||
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public AjaxHelpers()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
@@ -0,0 +1,132 @@
|
||||
@* Generator: WebPagesHelper *@
|
||||
@using Disco.BI.Extensions;
|
||||
@using Disco.Models.Repository;
|
||||
@using Disco.Web;
|
||||
@using System.Web.Mvc
|
||||
@using System.Web.Mvc.Html;
|
||||
@using Disco.Web.Extensions;
|
||||
@helper FriendlyDate(DateTime d)
|
||||
{
|
||||
<span title="@d.ToFullDateTime()" data-discodatetime="@d.ToSortableDateTime()" class="date nowrap">@d.ToFuzzy()</span>
|
||||
}
|
||||
@helper FriendlyDate(DateTime? d, string NullValue = "N/A")
|
||||
{
|
||||
<span title="@d.ToFullDateTime(NullValue)" data-discodatetime="@d.ToSortableDateTime()" class="date nowrap">@d.ToFuzzy(NullValue)</span>
|
||||
}
|
||||
@helper RadioButtonList(string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1)
|
||||
{
|
||||
@ItemList("radio", id, items, columns)
|
||||
}
|
||||
@helper CheckBoxList(string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1, bool alignEven = true, int? forceUniqueIds = null)
|
||||
{
|
||||
@ItemList("checkbox", id, items, columns, alignEven, forceUniqueIds)
|
||||
}
|
||||
@helper ItemList(string inputType, string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1, bool alignEven = true, int? forceUniqueIds = null)
|
||||
{
|
||||
int itemsPerColumn = items.Count / columns;
|
||||
int columnWidth = (100 / columns);
|
||||
var itemNextId = 0;
|
||||
<table class="none">
|
||||
<tr>
|
||||
@for (int i = 0; i < columns; i++)
|
||||
{
|
||||
<td@(alignEven ? new HtmlString(string.Format(" style=\"width: {0}%\"", columnWidth)) : new HtmlString(string.Empty))>
|
||||
<ul class="none">
|
||||
@{
|
||||
int itemsForThisColumn = itemsPerColumn + (items.Count % columns > i ? 1 : 0);
|
||||
for (int i2 = 0; i2 < itemsForThisColumn && itemNextId < items.Count; i2++)
|
||||
{
|
||||
var item = items[itemNextId];
|
||||
itemNextId++;
|
||||
var itemId = forceUniqueIds.HasValue ? string.Format("{0}_{1}_{2}", id, item.Value, forceUniqueIds++) : string.Format("{0}_{1}", id, item.Value);
|
||||
<li>
|
||||
<input id="@itemId" name="@id" value="@item.Value" type="@inputType" @(item.Selected ? "checked=\"checked\" " : " ")/><label for="@itemId">@item.Text</label></li>
|
||||
}
|
||||
}
|
||||
</ul>
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
</table>
|
||||
}
|
||||
@helper FriendlyDateAndUser(DateTime? d, User u, string DateNullValue = "N/A")
|
||||
{
|
||||
@FriendlyDate(d, DateNullValue);
|
||||
@FriendlyUser(u, null, "by");
|
||||
}
|
||||
@helper FriendlyDateAndUser(DateTime d, User u)
|
||||
{
|
||||
@FriendlyDate(d);
|
||||
@FriendlyUser(u, null, "by");
|
||||
}
|
||||
@helper FriendlyDateAndTitleUser(DateTime? d, User u, string DateNullValue = "N/A")
|
||||
{
|
||||
<span title="@d.ToFullDateTime(DateNullValue) by @u" data-discodatetime="@d.ToSortableDateTime()" class="date nowrap">@d.ToFuzzy(DateNullValue)</span>
|
||||
}
|
||||
@helper FriendlyDateAndTitleUser(DateTime d, User u)
|
||||
{
|
||||
<span title="@d.ToFullDateTime() by @u" data-discodatetime="@d.ToSortableDateTime()" class="date nowrap">@d.ToFuzzy()</span>
|
||||
}
|
||||
@helper FriendlyUser(User u, string nullValue = null, string prepend = null)
|
||||
{
|
||||
if (u != null)
|
||||
{
|
||||
@prepend <span title="@u">@u.Id</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>@nullValue</span>
|
||||
}
|
||||
}
|
||||
@helper Breadcrumbs(List<Tuple<string, ActionResult>> BreadCrumbs)
|
||||
{
|
||||
for (int index = 0; index < BreadCrumbs.Count; index++)
|
||||
{
|
||||
var breadCrumb = BreadCrumbs[index];
|
||||
if (index != 0)
|
||||
{
|
||||
<span>></span>
|
||||
}
|
||||
if (breadCrumb.Item2 == null)
|
||||
{
|
||||
@breadCrumb.Item1
|
||||
}
|
||||
else
|
||||
{
|
||||
@Html.GetPageHelper().ActionLink(breadCrumb.Item1, breadCrumb.Item2)
|
||||
}
|
||||
}
|
||||
}
|
||||
@helper Breadcrumbs(string Title)
|
||||
{
|
||||
@Title
|
||||
}
|
||||
@helper BreadcrumbsTitle(List<Tuple<string, ActionResult>> BreadCrumbs)
|
||||
{
|
||||
for (int index = 0; index < BreadCrumbs.Count; index++)
|
||||
{
|
||||
var breadCrumb = BreadCrumbs[index];
|
||||
if (index != 0)
|
||||
{
|
||||
@(new HtmlString(" > "))
|
||||
}
|
||||
@breadCrumb.Item1
|
||||
}
|
||||
}
|
||||
@helper BreadcrumbsTitle(string Title)
|
||||
{
|
||||
@Title
|
||||
}
|
||||
@helper CheckboxBulkSelect(string BulkSelectContainerId, string ParentJQuerySelector = null)
|
||||
{Html.GetPageHelper().BundleDeferred("~/ClientScripts/Modules/Disco-jQueryExtensions");
|
||||
<span id="@BulkSelectContainerId" class="checkboxBulkSelectContainer">
|
||||
@if (string.IsNullOrWhiteSpace(ParentJQuerySelector))
|
||||
{
|
||||
<script type="text/javascript">$(function () { $('#@(BulkSelectContainerId)').checkboxBulkSelect(); });</script>
|
||||
}
|
||||
else
|
||||
{
|
||||
<script type="text/javascript">$(function () { $('#@(BulkSelectContainerId)').checkboxBulkSelect({ parentSelector: '@(ParentJQuerySelector)' }); });</script>
|
||||
}
|
||||
</span>
|
||||
}
|
||||
@@ -0,0 +1,984 @@
|
||||
#pragma warning disable 1591
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17929
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Disco.Web
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Helpers;
|
||||
|
||||
#line 5 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
using System.Web.Mvc;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 6 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
using System.Web.Mvc.Html;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.WebPages;
|
||||
using System.Web.WebPages.Html;
|
||||
|
||||
#line 2 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
using Disco.BI.Extensions;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 3 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
using Disco.Models.Repository;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 4 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
using Disco.Web;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 7 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.0.0")]
|
||||
public class CommonHelpers : System.Web.WebPages.HelperPage
|
||||
{
|
||||
|
||||
public static System.Web.WebPages.HelperResult FriendlyDate(DateTime d)
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 9 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " <span title=\"");
|
||||
|
||||
|
||||
|
||||
#line 10 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, d.ToFullDateTime());
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\" data-discodatetime=\"");
|
||||
|
||||
|
||||
|
||||
#line 10 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, d.ToSortableDateTime());
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\" class=\"date nowrap\">");
|
||||
|
||||
|
||||
|
||||
#line 10 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, d.ToFuzzy());
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "</span>\r\n");
|
||||
|
||||
|
||||
|
||||
#line 11 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static System.Web.WebPages.HelperResult FriendlyDate(DateTime? d, string NullValue = "N/A")
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 13 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " <span title=\"");
|
||||
|
||||
|
||||
|
||||
#line 14 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, d.ToFullDateTime(NullValue));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\" data-discodatetime=\"");
|
||||
|
||||
|
||||
|
||||
#line 14 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, d.ToSortableDateTime());
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\" class=\"date nowrap\">");
|
||||
|
||||
|
||||
|
||||
#line 14 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, d.ToFuzzy(NullValue));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "</span>\r\n");
|
||||
|
||||
|
||||
|
||||
#line 15 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static System.Web.WebPages.HelperResult RadioButtonList(string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1)
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 17 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 18 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, ItemList("radio", id, items, columns));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 18 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static System.Web.WebPages.HelperResult CheckBoxList(string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1, bool alignEven = true, int? forceUniqueIds = null)
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 21 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 22 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, ItemList("checkbox", id, items, columns, alignEven, forceUniqueIds));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 22 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static System.Web.WebPages.HelperResult ItemList(string inputType, string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1, bool alignEven = true, int? forceUniqueIds = null)
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 25 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
int itemsPerColumn = items.Count / columns;
|
||||
int columnWidth = (100 / columns);
|
||||
var itemNextId = 0;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " <table class=\"none\">\r\n <tr>\r\n");
|
||||
|
||||
|
||||
|
||||
#line 31 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
for (int i = 0; i < columns; i++)
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " <td");
|
||||
|
||||
|
||||
|
||||
#line 33 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, alignEven ? new HtmlString(string.Format(" style=\"width: {0}%\"", columnWidth)) : new HtmlString(string.Empty));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, ">\r\n <ul class=\"none\">\r\n");
|
||||
|
||||
|
||||
|
||||
#line 35 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
int itemsForThisColumn = itemsPerColumn + (items.Count % columns > i ? 1 : 0);
|
||||
for (int i2 = 0; i2 < itemsForThisColumn && itemNextId < items.Count; i2++)
|
||||
{
|
||||
var item = items[itemNextId];
|
||||
itemNextId++;
|
||||
var itemId = forceUniqueIds.HasValue ? string.Format("{0}_{1}_{2}", id, item.Value, forceUniqueIds++) : string.Format("{0}_{1}", id, item.Value);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " <li>\r\n <input id=\"");
|
||||
|
||||
|
||||
|
||||
#line 43 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, itemId);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\" name=\"");
|
||||
|
||||
|
||||
|
||||
#line 43 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, id);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\" value=\"");
|
||||
|
||||
|
||||
|
||||
#line 43 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, item.Value);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\" type=\"");
|
||||
|
||||
|
||||
|
||||
#line 43 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, inputType);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\" ");
|
||||
|
||||
|
||||
|
||||
#line 43 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, item.Selected ? "checked=\"checked\" " : " ");
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "/><label for=\"");
|
||||
|
||||
|
||||
|
||||
#line 43 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, itemId);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\">");
|
||||
|
||||
|
||||
|
||||
#line 43 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, item.Text);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "</label></li>\r\n");
|
||||
|
||||
|
||||
|
||||
#line 44 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " </ul>\r\n </td>\r\n");
|
||||
|
||||
|
||||
|
||||
#line 48 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " </tr>\r\n </table>\r\n");
|
||||
|
||||
|
||||
|
||||
#line 51 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static System.Web.WebPages.HelperResult FriendlyDateAndUser(DateTime? d, User u, string DateNullValue = "N/A")
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 53 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 54 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, FriendlyDate(d, DateNullValue));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 54 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 55 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, FriendlyUser(u, null, "by"));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 55 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static System.Web.WebPages.HelperResult FriendlyDateAndUser(DateTime d, User u)
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 58 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 59 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, FriendlyDate(d));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 59 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 60 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, FriendlyUser(u, null, "by"));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 60 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
;
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static System.Web.WebPages.HelperResult FriendlyDateAndTitleUser(DateTime? d, User u, string DateNullValue = "N/A")
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 63 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " <span title=\"");
|
||||
|
||||
|
||||
|
||||
#line 64 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, d.ToFullDateTime(DateNullValue));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " by ");
|
||||
|
||||
|
||||
|
||||
#line 64 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, u);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\" data-discodatetime=\"");
|
||||
|
||||
|
||||
|
||||
#line 64 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, d.ToSortableDateTime());
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\" class=\"date nowrap\">");
|
||||
|
||||
|
||||
|
||||
#line 64 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, d.ToFuzzy(DateNullValue));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "</span>\r\n");
|
||||
|
||||
|
||||
|
||||
#line 65 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static System.Web.WebPages.HelperResult FriendlyDateAndTitleUser(DateTime d, User u)
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 67 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " <span title=\"");
|
||||
|
||||
|
||||
|
||||
#line 68 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, d.ToFullDateTime());
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " by ");
|
||||
|
||||
|
||||
|
||||
#line 68 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, u);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\" data-discodatetime=\"");
|
||||
|
||||
|
||||
|
||||
#line 68 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, d.ToSortableDateTime());
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\" class=\"date nowrap\">");
|
||||
|
||||
|
||||
|
||||
#line 68 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, d.ToFuzzy());
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "</span>\r\n");
|
||||
|
||||
|
||||
|
||||
#line 69 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static System.Web.WebPages.HelperResult FriendlyUser(User u, string nullValue = null, string prepend = null)
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 71 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
if (u != null)
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 74 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, prepend);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " <span title=\"");
|
||||
|
||||
|
||||
|
||||
#line 74 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, u);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\">");
|
||||
|
||||
|
||||
|
||||
#line 74 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, u.Id);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "</span>\r\n");
|
||||
|
||||
|
||||
|
||||
#line 75 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " <span>");
|
||||
|
||||
|
||||
|
||||
#line 78 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, nullValue);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "</span>\r\n");
|
||||
|
||||
|
||||
|
||||
#line 79 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static System.Web.WebPages.HelperResult Breadcrumbs(List<Tuple<string, ActionResult>> BreadCrumbs)
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 82 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
for (int index = 0; index < BreadCrumbs.Count; index++)
|
||||
{
|
||||
var breadCrumb = BreadCrumbs[index];
|
||||
if (index != 0)
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " <span>></span>\r\n");
|
||||
|
||||
|
||||
|
||||
#line 89 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
}
|
||||
if (breadCrumb.Item2 == null)
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 92 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, breadCrumb.Item1);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 92 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 96 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, Html.GetPageHelper().ActionLink(breadCrumb.Item1, breadCrumb.Item2));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 96 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static System.Web.WebPages.HelperResult Breadcrumbs(string Title)
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 101 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 102 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, Title);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 102 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static System.Web.WebPages.HelperResult BreadcrumbsTitle(List<Tuple<string, ActionResult>> BreadCrumbs)
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 105 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
for (int index = 0; index < BreadCrumbs.Count; index++)
|
||||
{
|
||||
var breadCrumb = BreadCrumbs[index];
|
||||
if (index != 0)
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 111 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, new HtmlString(" > "));
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 111 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 113 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, breadCrumb.Item1);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 113 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static System.Web.WebPages.HelperResult BreadcrumbsTitle(string Title)
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 117 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 118 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, Title);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
|
||||
#line 118 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static System.Web.WebPages.HelperResult CheckboxBulkSelect(string BulkSelectContainerId, string ParentJQuerySelector = null)
|
||||
{
|
||||
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
|
||||
|
||||
|
||||
|
||||
#line 121 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
Html.GetPageHelper().BundleDeferred("~/ClientScripts/Modules/Disco-jQueryExtensions");
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " <span id=\"");
|
||||
|
||||
|
||||
|
||||
#line 122 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, BulkSelectContainerId);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\" class=\"checkboxBulkSelectContainer\">\r\n");
|
||||
|
||||
|
||||
|
||||
#line 123 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
if (string.IsNullOrWhiteSpace(ParentJQuerySelector))
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " <script type=\"text/javascript\">$(function () { $(\'#");
|
||||
|
||||
|
||||
|
||||
#line 125 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, BulkSelectContainerId);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\').checkboxBulkSelect(); });</script>\r\n");
|
||||
|
||||
|
||||
|
||||
#line 126 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " <script type=\"text/javascript\">$(function () { $(\'#");
|
||||
|
||||
|
||||
|
||||
#line 129 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, BulkSelectContainerId);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\').checkboxBulkSelect({ parentSelector: \'");
|
||||
|
||||
|
||||
|
||||
#line 129 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
WriteTo(@__razor_helper_writer, ParentJQuerySelector);
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, "\' }); });</script>\r\n");
|
||||
|
||||
|
||||
|
||||
#line 130 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
WriteLiteralTo(@__razor_helper_writer, " </span>\r\n");
|
||||
|
||||
|
||||
|
||||
#line 132 "..\..\App_Code\CommonHelpers.cshtml"
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public CommonHelpers()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.Data.Repository;
|
||||
|
||||
namespace Disco.Web
|
||||
{
|
||||
public static class AppConfig
|
||||
{
|
||||
public static bool InitializeDatabase()
|
||||
{
|
||||
// Modified Connection Factory
|
||||
System.Data.Entity.Database.DefaultConnectionFactory = new DiscoDatabaseConnectionFactory(System.Data.Entity.Database.DefaultConnectionFactory);
|
||||
|
||||
if (Disco.Data.Repository.DiscoDatabaseConnectionFactory.DiscoDataContextConnectionString == null)
|
||||
{
|
||||
// Database Connection String not configured - Trigger 'Install'
|
||||
return false;
|
||||
}
|
||||
|
||||
// Migrate Database
|
||||
Disco.Data.Migrations.DiscoDataMigrator.MigrateLatest(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void InitalizeEnvironment()
|
||||
{
|
||||
using (var dbContext = new DiscoDataContext())
|
||||
{
|
||||
// Initialize Logging
|
||||
Disco.Services.Logging.LogContext.Initalize(dbContext, DiscoApplication.SchedulerFactory);
|
||||
|
||||
// Load Organisation Name
|
||||
DiscoApplication.OrganisationName = dbContext.DiscoConfiguration.OrganisationName;
|
||||
DiscoApplication.MultiSiteMode = dbContext.DiscoConfiguration.MultiSiteMode;
|
||||
|
||||
// Setup Global Proxy
|
||||
DiscoApplication.SetGlobalProxy(dbContext.DiscoConfiguration.ProxyAddress,
|
||||
dbContext.DiscoConfiguration.ProxyPort,
|
||||
dbContext.DiscoConfiguration.ProxyUsername,
|
||||
dbContext.DiscoConfiguration.ProxyPassword);
|
||||
|
||||
// Initialize Expressions
|
||||
BI.Expressions.Expression.InitializeExpressions();
|
||||
|
||||
// Initialize Warranty Providers Plugins
|
||||
Disco.Services.Plugins.Plugins.InitalizePlugins(dbContext);
|
||||
|
||||
// Initialize Scheduled Tasks
|
||||
Disco.Services.Tasks.ScheduledTasks.InitalizeScheduledTasks(dbContext, DiscoApplication.SchedulerFactory);
|
||||
|
||||
// Schedule Immediate Check for Update (if a new version was installed, never updated, last updated over 2 days ago)
|
||||
var currentVersion = Disco.BI.Interop.Community.UpdateCheck.CurrentDiscoVersion();
|
||||
if (dbContext.DiscoConfiguration.InstalledDatabaseVersion == null ||
|
||||
dbContext.DiscoConfiguration.InstalledDatabaseVersion != currentVersion ||
|
||||
dbContext.DiscoConfiguration.UpdateLastCheck == null ||
|
||||
dbContext.DiscoConfiguration.UpdateLastCheck.ResponseTimestamp < DateTime.Now.AddDays(-2))
|
||||
{
|
||||
Disco.BI.Interop.Community.UpdateCheckTask.ScheduleNow();
|
||||
dbContext.DiscoConfiguration.InstalledDatabaseVersion = currentVersion;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
// Setup Attachment Monitor
|
||||
DiscoApplication.DocumentDropBoxMonitor = new BI.DocumentTemplateBI.Importer.DocumentDropBoxMonitor(dbContext, DiscoApplication.SchedulerFactory, HttpContext.Current.Cache);
|
||||
}
|
||||
DiscoApplication.DocumentDropBoxMonitor.StartWatching();
|
||||
DiscoApplication.DocumentDropBoxMonitor.ScheduleCurrentFiles(10);
|
||||
}
|
||||
|
||||
public static void DisposeEnvironment()
|
||||
{
|
||||
if (DiscoApplication.DocumentDropBoxMonitor != null)
|
||||
DiscoApplication.DocumentDropBoxMonitor.Dispose();
|
||||
|
||||
if (DiscoApplication.SchedulerFactory != null)
|
||||
{
|
||||
foreach (var item in DiscoApplication.SchedulerFactory.AllSchedulers.ToArray())
|
||||
{
|
||||
item.Shutdown(false);
|
||||
}
|
||||
}
|
||||
|
||||
Disco.Services.Logging.SystemLog.LogUninitialized();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Disco.Web.Extensions.MvcExtensions.Bundles;
|
||||
|
||||
namespace Disco.Web
|
||||
{
|
||||
public class BundleConfig
|
||||
{
|
||||
public static void RegisterBundles()
|
||||
{
|
||||
// Styles - Site Core
|
||||
BundleTable.Add(new Bundle("~/Style/Site", Links.ClientSource.Style.BundleSite_min_css));
|
||||
|
||||
// Styles - Targeted
|
||||
BundleTable.Add(new Bundle("~/Style/Config", Links.ClientSource.Style.Config_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/Device", Links.ClientSource.Style.Device_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/Dialog", Links.ClientSource.Style.Dialog_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/Job", Links.ClientSource.Style.Job_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/User", Links.ClientSource.Style.User_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/Credits", Links.ClientSource.Style.Credits_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/InitialConfig", Links.ClientSource.Style.InitialConfig_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/jQueryUI/dynatree", Links.ClientSource.Style.jQueryUI.dynatree.ui_dynatree_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/Shadowbox", Links.ClientSource.Style.Shadowbox_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/Timeline", Links.ClientSource.Style.Timeline_min_css));
|
||||
|
||||
// Styles - Public Targeted
|
||||
BundleTable.Add(new Bundle("~/Style/Public/UserHeldDevices", Links.ClientSource.Style.Public.UserHeldDevices_min_css));
|
||||
BundleTable.Add(new Bundle("~/Style/Public/UserHeldDevicesNoticeboard", Links.ClientSource.Style.Public.UserHeldDevicesNoticeboard_min_css));
|
||||
|
||||
|
||||
// Scripts - Core
|
||||
#if DEBUG
|
||||
BundleTable.Add(new Bundle("~/ClientScripts/Core", Links.ClientSource.Scripts.Core_js));
|
||||
#else
|
||||
BundleTable.Add(new Bundle("~/ClientScripts/Core", Links.ClientSource.Scripts.Core_min_js));
|
||||
#endif
|
||||
|
||||
// Scripts - Modules
|
||||
#if DEBUG
|
||||
foreach (FileInfo f in new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ClientSource/Scripts/Modules")).EnumerateFiles("*.js", SearchOption.TopDirectoryOnly))
|
||||
BundleTable.Add(new Bundle(string.Format("~/ClientScripts/Modules/{0}", f.Name.Substring(0, f.Name.Length - 3)), f.FullName));
|
||||
#else
|
||||
foreach (FileInfo f in new DirectoryInfo(HttpContext.Current.Server.MapPath("~/ClientSource/Scripts/Modules")).EnumerateFiles("*.min.js", SearchOption.TopDirectoryOnly))
|
||||
BundleTable.Add(new Bundle(string.Format("~/ClientScripts/Modules/{0}", f.Name.Substring(0, f.Name.Length - 7)), f.FullName));
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Disco.Web
|
||||
{
|
||||
public class FilterConfig
|
||||
{
|
||||
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
|
||||
{
|
||||
//filters.Add(new HandleErrorAttribute());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.WebPages;
|
||||
using RazorGenerator.Mvc;
|
||||
|
||||
[assembly: WebActivator.PostApplicationStartMethod(typeof(Disco.Web.App_Start.RazorGeneratorMvcStart), "Start")]
|
||||
|
||||
namespace Disco.Web.App_Start {
|
||||
public static class RazorGeneratorMvcStart {
|
||||
public static void Start() {
|
||||
var engine = new PrecompiledMvcEngine(typeof(RazorGeneratorMvcStart).Assembly) {
|
||||
#if DEBUG
|
||||
UsePhysicalViewsIfNewer = true
|
||||
#else
|
||||
UsePhysicalViewsIfNewer = false
|
||||
#endif
|
||||
};
|
||||
|
||||
ViewEngines.Engines.Insert(0, engine);
|
||||
|
||||
// StartPage lookups are done by WebPages.
|
||||
VirtualPathFactoryManager.RegisterVirtualPathFactory(engine);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
|
||||
namespace Disco.Web
|
||||
{
|
||||
public class RouteConfig
|
||||
{
|
||||
public static void RegisterInstallRoutes(RouteCollection routes)
|
||||
{
|
||||
// Install Route
|
||||
routes.MapRoute(
|
||||
name: "InitialConfig", // Route name
|
||||
url: "{controller}/{action}/{id}", // URL with parameters
|
||||
defaults: new { controller = "InitialConfig", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
|
||||
namespaces: new string[] { "Disco.Web.Controllers" } // Controllers Namespace Only
|
||||
);
|
||||
}
|
||||
|
||||
public static void RegisterRoutes(RouteCollection routes)
|
||||
{
|
||||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
|
||||
|
||||
// Device Route
|
||||
routes.MapRoute(
|
||||
name: "Device", // Route name
|
||||
url: "Device/{action}/{id}", // URL with parameters
|
||||
defaults: new { controller = "Device", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
|
||||
namespaces: new string[] { "Disco.Web.Controllers" } // Controllers Namespace Only
|
||||
);
|
||||
// Search Route
|
||||
routes.MapRoute(
|
||||
name: "SearchQuery",
|
||||
url: "Search/Query/{SearchQuery}",
|
||||
defaults: new { controller = "Search", action = "Query", SearchQuery = UrlParameter.Optional }
|
||||
);
|
||||
// User Route
|
||||
routes.MapRoute(
|
||||
name: "User", // Route name
|
||||
url: "User/{action}/{id}", // URL with parameters
|
||||
defaults: new { controller = "User", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
|
||||
namespaces: new string[] { "Disco.Web.Controllers" } // Controllers Namespace Only
|
||||
);
|
||||
|
||||
// Plugin Resources Route
|
||||
routes.MapRoute(
|
||||
name: "Plugin_Resources", // Route name
|
||||
url: "Plugin/{PluginId}/Resources/{*res}", // URL with parameters
|
||||
defaults: new { controller = "PluginWebHandler", action = "Resource" }, // Parameter defaults
|
||||
namespaces: new string[] { "Disco.Web.Controllers" } // Controllers Namespace Only
|
||||
);
|
||||
// Plugin Route
|
||||
routes.MapRoute(
|
||||
name: "Plugin", // Route name
|
||||
url: "Plugin/{PluginId}/{PluginAction}", // URL with parameters
|
||||
defaults: new { controller = "PluginWebHandler", action = "Index" }, // Parameter defaults
|
||||
namespaces: new string[] { "Disco.Web.Controllers" } // Controllers Namespace Only
|
||||
);
|
||||
|
||||
// Job Route
|
||||
routes.MapRoute(
|
||||
name: "Job", // Route name
|
||||
url: "{controller}/{action}/{id}", // URL with parameters
|
||||
defaults: new { controller = "Job", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
|
||||
namespaces: new string[] { "Disco.Web.Controllers" } // Controllers Namespace Only
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace Disco.Web
|
||||
{
|
||||
public static class WebApiConfig
|
||||
{
|
||||
public static void Register(HttpConfiguration config)
|
||||
{
|
||||
// Migrate to WebAPI Eventually...
|
||||
|
||||
|
||||
//config.Routes.MapHttpRoute(
|
||||
// name: "DefaultApi",
|
||||
// routeTemplate: "api/{controller}/{id}",
|
||||
// defaults: new { id = RouteParameter.Optional }
|
||||
//);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using SignalR;
|
||||
|
||||
namespace Disco.Web.Areas.API
|
||||
{
|
||||
public class APIAreaRegistration : AreaRegistration
|
||||
{
|
||||
public override string AreaName
|
||||
{
|
||||
get
|
||||
{
|
||||
return "API";
|
||||
}
|
||||
}
|
||||
|
||||
public override void RegisterArea(AreaRegistrationContext context)
|
||||
{
|
||||
context.Routes.MapConnection<Disco.Services.Logging.Targets.LogLiveContext>(
|
||||
"API_Logging_Notifications", "API/Logging/Notifications/{*operation}");
|
||||
|
||||
context.Routes.MapConnection<Disco.Services.Tasks.ScheduledTasksLiveStatusService>(
|
||||
"API_Logging_TaskStatusNotifications", "API/Logging/TaskStatusNotifications/{*operation}");
|
||||
|
||||
context.MapRoute(
|
||||
"API_Update",
|
||||
"API/{controller}/Update/{id}/{key}",
|
||||
new { action = "Update" }
|
||||
);
|
||||
|
||||
context.MapRoute(
|
||||
"API_default",
|
||||
"API/{controller}/{action}/{id}",
|
||||
new { id = UrlParameter.Optional }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Disco.BI.Extensions;
|
||||
|
||||
namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
public partial class BootstrapperController : dbAdminController
|
||||
{
|
||||
|
||||
public virtual ActionResult MacSshUsername(string MacSshUsername)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(MacSshUsername))
|
||||
{
|
||||
dbContext.DiscoConfiguration.Bootstrapper.MacSshUsername = MacSshUsername;
|
||||
dbContext.SaveChanges();
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("The Username cannot be null or empty");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
public virtual ActionResult MacSshPassword(string MacSshPassword)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(MacSshPassword))
|
||||
{
|
||||
dbContext.DiscoConfiguration.Bootstrapper.MacSshPassword = MacSshPassword;
|
||||
dbContext.SaveChanges();
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("The Password cannot be null or empty");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,469 @@
|
||||
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.Repository;
|
||||
using Disco.Web.Extensions;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
public partial class DeviceBatchController : dbAdminController
|
||||
{
|
||||
|
||||
const string pName = "name";
|
||||
const string pPurchaseDate = "purchasedate";
|
||||
const string pSupplier = "supplier";
|
||||
const string pPurchaseDetails = "purchasedetails";
|
||||
const string pUnitCost = "unitcost";
|
||||
const string pUnitQuantity = "unitquantity";
|
||||
const string pDefaultDeviceModelId = "defaultdevicemodelid";
|
||||
const string pWarrantyValidUntil = "warrantyvaliduntil";
|
||||
const string pWarrantyDetails = "warrantydetails";
|
||||
const string pInsuredDate = "insureddate";
|
||||
const string pInsuranceSupplier = "insurancesupplier";
|
||||
const string pInsuredUntil = "insureduntil";
|
||||
const string pInsuranceDetails = "insurancedetails";
|
||||
const string pComments = "comments";
|
||||
|
||||
public virtual ActionResult Update(int id, string key, string value = null, bool redirect = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id < 0)
|
||||
throw new ArgumentOutOfRangeException("id");
|
||||
if (string.IsNullOrEmpty(key))
|
||||
throw new ArgumentNullException("key");
|
||||
var deviceBatch = dbContext.DeviceBatches.Find(id);
|
||||
if (deviceBatch != null)
|
||||
{
|
||||
switch (key.ToLower())
|
||||
{
|
||||
case pName:
|
||||
UpdateName(deviceBatch, value);
|
||||
break;
|
||||
case pPurchaseDate:
|
||||
UpdatePurchaseDate(deviceBatch, value);
|
||||
break;
|
||||
case pSupplier:
|
||||
UpdateSupplier(deviceBatch, value);
|
||||
break;
|
||||
case pPurchaseDetails:
|
||||
UpdatePurchaseDetails(deviceBatch, value);
|
||||
break;
|
||||
case pUnitCost:
|
||||
UpdateUnitCost(deviceBatch, value);
|
||||
break;
|
||||
case pUnitQuantity:
|
||||
UpdateUnitQuantity(deviceBatch, value);
|
||||
break;
|
||||
case pDefaultDeviceModelId:
|
||||
UpdateDefaultDeviceModelId(deviceBatch, value);
|
||||
break;
|
||||
case pWarrantyValidUntil:
|
||||
UpdateWarrantyValidUntil(deviceBatch, value);
|
||||
break;
|
||||
case pWarrantyDetails:
|
||||
UpdateWarrantyDetails(deviceBatch, value);
|
||||
break;
|
||||
case pInsuredDate:
|
||||
UpdateInsuredDate(deviceBatch, value);
|
||||
break;
|
||||
case pInsuranceSupplier:
|
||||
UpdateInsuranceSupplier(deviceBatch, value);
|
||||
break;
|
||||
case pInsuredUntil:
|
||||
UpdateInsuredUntil(deviceBatch, value);
|
||||
break;
|
||||
case pInsuranceDetails:
|
||||
UpdateInsuranceDetails(deviceBatch, value);
|
||||
break;
|
||||
case pComments:
|
||||
UpdateComments(deviceBatch, value);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Invalid Update Key");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Json("Invalid Device Batch Id", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.DeviceBatch.Index(deviceBatch.Id));
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (redirect)
|
||||
throw;
|
||||
else
|
||||
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
|
||||
#region Update Shortcut Methods
|
||||
public virtual ActionResult UpdateName(int id, string BatchName = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pName, BatchName, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdatePurchaseDate(int id, string PurchaseDate = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pPurchaseDate, PurchaseDate, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateSupplier(int id, string Supplier = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pSupplier, Supplier, redirect);
|
||||
}
|
||||
[ValidateInput(false)]
|
||||
public virtual ActionResult UpdatePurchaseDetails(int id, string PurchaseDetails = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pPurchaseDetails, PurchaseDetails, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateUnitCost(int id, string UnitCost = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pUnitCost, UnitCost, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateUnitQuantity(int id, string UnitQuantity = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pUnitQuantity, UnitQuantity, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateDefaultDeviceModelId(int id, string DefaultDeviceModelId = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pDefaultDeviceModelId, DefaultDeviceModelId, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateWarrantyValidUntil(int id, string WarrantyValidUntil = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pWarrantyValidUntil, WarrantyValidUntil, redirect);
|
||||
}
|
||||
[ValidateInput(false)]
|
||||
public virtual ActionResult UpdateWarrantyDetails(int id, string WarrantyDetails = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pWarrantyDetails, WarrantyDetails, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateInsuredDate(int id, string InsuredDate = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pInsuredDate, InsuredDate, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateInsuranceSupplier(int id, string InsuranceSupplier = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pInsuranceSupplier, InsuranceSupplier, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateInsuredUntil(int id, string InsuredUntil = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pInsuredUntil, InsuredUntil, redirect);
|
||||
}
|
||||
[ValidateInput(false)]
|
||||
public virtual ActionResult UpdateInsuranceDetails(int id, string InsuranceDetails = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pInsuranceDetails, InsuranceDetails, redirect);
|
||||
}
|
||||
[ValidateInput(false)]
|
||||
public virtual ActionResult UpdateComments(int id, string Comments = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pComments, Comments, redirect);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Update Properties
|
||||
private void UpdateName(DeviceBatch deviceBatch, string Name)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Name))
|
||||
throw new ArgumentNullException("Name", "Device Batch Name is required");
|
||||
else
|
||||
{
|
||||
// Check for Duplicates
|
||||
var d = dbContext.DeviceBatches.Where(db => db.Id != deviceBatch.Id && db.Name == Name).Count();
|
||||
if (d > 0)
|
||||
{
|
||||
throw new Exception("A Device Batch with that name already exists");
|
||||
}
|
||||
deviceBatch.Name = Name;
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdatePurchaseDate(DeviceBatch deviceBatch, string PurchaseDate)
|
||||
{
|
||||
if (string.IsNullOrEmpty(PurchaseDate))
|
||||
throw new ArgumentNullException("PurchaseDate", "A Device Batch Purchase Date is required");
|
||||
else
|
||||
{
|
||||
DateTime ecd;
|
||||
if (DateTime.TryParse(PurchaseDate, out ecd))
|
||||
{
|
||||
deviceBatch.PurchaseDate = ecd.Date;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid Date Format");
|
||||
}
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateSupplier(DeviceBatch deviceBatch, string Supplier)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Supplier))
|
||||
deviceBatch.Supplier = null;
|
||||
else
|
||||
deviceBatch.Supplier = Supplier;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdatePurchaseDetails(DeviceBatch deviceBatch, string PurchaseDetails)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(PurchaseDetails))
|
||||
deviceBatch.PurchaseDetails = null;
|
||||
else
|
||||
deviceBatch.PurchaseDetails = PurchaseDetails;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateUnitCost(DeviceBatch deviceBatch, string UnitCost)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(UnitCost))
|
||||
deviceBatch.UnitCost = null;
|
||||
else
|
||||
{
|
||||
decimal unitCost;
|
||||
if (decimal.TryParse(UnitCost, out unitCost))
|
||||
{
|
||||
deviceBatch.UnitCost = unitCost;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid Currency Format");
|
||||
}
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateUnitQuantity(DeviceBatch deviceBatch, string UnitQuantity)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(UnitQuantity))
|
||||
deviceBatch.UnitQuantity = null;
|
||||
else
|
||||
{
|
||||
int unitQuantity;
|
||||
if (int.TryParse(UnitQuantity, out unitQuantity))
|
||||
{
|
||||
deviceBatch.UnitQuantity = unitQuantity;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid Number");
|
||||
}
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateDefaultDeviceModelId(DeviceBatch deviceBatch, string DefaultDeviceModelId)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(DefaultDeviceModelId))
|
||||
{
|
||||
int bId;
|
||||
if (int.TryParse(DefaultDeviceModelId, out bId))
|
||||
{
|
||||
var dm = dbContext.DeviceModels.Find(bId);
|
||||
if (dm != null)
|
||||
{
|
||||
deviceBatch.DefaultDeviceModelId = dm.Id;
|
||||
deviceBatch.DefaultDeviceModel = dm;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Null Id - No Batch
|
||||
deviceBatch.DefaultDeviceModelId = null;
|
||||
deviceBatch.DefaultDeviceModel = null;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
return;
|
||||
}
|
||||
throw new Exception("Invalid Device Model Id");
|
||||
}
|
||||
private void UpdateWarrantyValidUntil(DeviceBatch deviceBatch, string WarrantyValidUntil)
|
||||
{
|
||||
if (string.IsNullOrEmpty(WarrantyValidUntil))
|
||||
deviceBatch.WarrantyValidUntil = null;
|
||||
else
|
||||
{
|
||||
DateTime ecd;
|
||||
if (DateTime.TryParse(WarrantyValidUntil, out ecd))
|
||||
{
|
||||
deviceBatch.WarrantyValidUntil = ecd.Date;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid Date Format");
|
||||
}
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateWarrantyDetails(DeviceBatch deviceBatch, string WarrantyDetails)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(WarrantyDetails))
|
||||
deviceBatch.WarrantyDetails = null;
|
||||
else
|
||||
deviceBatch.WarrantyDetails = WarrantyDetails;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateInsuredDate(DeviceBatch deviceBatch, string InsuredDate)
|
||||
{
|
||||
if (string.IsNullOrEmpty(InsuredDate))
|
||||
deviceBatch.InsuredDate = null;
|
||||
else
|
||||
{
|
||||
DateTime ecd;
|
||||
if (DateTime.TryParse(InsuredDate, out ecd))
|
||||
{
|
||||
deviceBatch.InsuredDate = ecd.Date;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid Date Format");
|
||||
}
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateInsuranceSupplier(DeviceBatch deviceBatch, string InsuranceSupplier)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(InsuranceSupplier))
|
||||
deviceBatch.InsuranceSupplier = null;
|
||||
else
|
||||
deviceBatch.InsuranceSupplier = InsuranceSupplier;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateInsuredUntil(DeviceBatch deviceBatch, string InsuredUntil)
|
||||
{
|
||||
if (string.IsNullOrEmpty(InsuredUntil))
|
||||
deviceBatch.InsuredUntil = null;
|
||||
else
|
||||
{
|
||||
DateTime ecd;
|
||||
if (DateTime.TryParse(InsuredUntil, out ecd))
|
||||
{
|
||||
deviceBatch.InsuredUntil = ecd.Date;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid Date Format");
|
||||
}
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateInsuranceDetails(DeviceBatch deviceBatch, string InsuranceDetails)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(InsuranceDetails))
|
||||
deviceBatch.InsuranceDetails = null;
|
||||
else
|
||||
deviceBatch.InsuranceDetails = InsuranceDetails;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateComments(DeviceBatch deviceBatch, string Comments)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Comments))
|
||||
deviceBatch.Comments = null;
|
||||
else
|
||||
deviceBatch.Comments = Comments;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Actions
|
||||
|
||||
public virtual ActionResult Delete(int id, Nullable<bool> redirect = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var db = dbContext.DeviceBatches.Find(id);
|
||||
if (db != null)
|
||||
{
|
||||
db.Delete(dbContext);
|
||||
dbContext.SaveChanges();
|
||||
if (redirect.HasValue && redirect.Value)
|
||||
return RedirectToAction(MVC.Config.DeviceBatch.Index(null));
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
throw new Exception("Invalid Device Batch Number");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (redirect.HasValue && redirect.Value)
|
||||
throw;
|
||||
else
|
||||
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Index
|
||||
public virtual ActionResult Index(int? id)
|
||||
{
|
||||
if (id.HasValue)
|
||||
{
|
||||
dbContext.Configuration.ProxyCreationEnabled = false;
|
||||
DeviceBatch deviceBatch = dbContext.DeviceBatches.FirstOrDefault(db => db.Id == id);
|
||||
return Json(deviceBatch, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
else
|
||||
{
|
||||
var deviceBatches = dbContext.DeviceBatches.ToArray();
|
||||
return Json(deviceBatches, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Timeline
|
||||
public virtual ActionResult Timeline()
|
||||
{
|
||||
|
||||
var batchesInformation = dbContext.DeviceBatches.Select(db => new
|
||||
{
|
||||
Name = db.Name,
|
||||
Comments = db.Comments,
|
||||
PurchaseDate = db.PurchaseDate,
|
||||
WarrantyValidUntil = db.WarrantyValidUntil,
|
||||
DeviceCount = db.Devices.Count(),
|
||||
DefaultModelId = db.DefaultDeviceModelId,
|
||||
DefaultModelDescription = db.DefaultDeviceModel.Description
|
||||
}).ToArray();
|
||||
|
||||
Color warningColour = Color.FromArgb(225, 70, 0);
|
||||
Color normalColour = Color.FromArgb(88, 160, 220);
|
||||
Color highlightColour = Color.FromArgb(0, 140, 0);
|
||||
|
||||
double mostDevices = batchesInformation.Max(bi => bi.DeviceCount);
|
||||
var events = new List<Models.DeviceBatch.DeviceBatchTimelineEvent>();
|
||||
|
||||
foreach (var bi in batchesInformation)
|
||||
{
|
||||
var color = warningColour; // No Devices
|
||||
if (bi.DeviceCount > 0)
|
||||
color = normalColour.InterpolateColours(highlightColour, bi.DeviceCount / mostDevices);
|
||||
|
||||
events.Add(new Models.DeviceBatch.DeviceBatchTimelineEvent()
|
||||
{
|
||||
start = bi.PurchaseDate,
|
||||
end = bi.WarrantyValidUntil,
|
||||
caption = bi.DefaultModelDescription,
|
||||
title = string.Format("{0} [{1} x{2}]", bi.Name, bi.DefaultModelDescription, bi.DeviceCount),
|
||||
textColor = "#000",
|
||||
description = bi.Comments ?? string.Empty,
|
||||
color = ColorTranslator.ToHtml(color),
|
||||
image = Url.Action(MVC.API.DeviceModel.Image(bi.DefaultModelId)),
|
||||
link = Url.Action(MVC.Config.DeviceBatch.Index(bi.DefaultModelId))
|
||||
});
|
||||
}
|
||||
|
||||
return this.JsonNet(new Models.DeviceBatch.DeviceBatchTimelineEventSource() { events = events.ToArray() }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,468 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.BI;
|
||||
using Disco.BI.Interop.ActiveDirectory;
|
||||
using System.IO;
|
||||
|
||||
namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
public partial class DeviceController : dbAdminController
|
||||
{
|
||||
|
||||
const string pDeviceProfileId = "deviceprofileid";
|
||||
const string pDeviceBatchId = "devicebatchid";
|
||||
const string pAssetNumber = "assetnumber";
|
||||
const string pAssignedUserId = "assigneduserid";
|
||||
const string pLocation = "location";
|
||||
const string pAllowUnauthenticatedEnrol = "allowunauthenticatedenrol";
|
||||
|
||||
public virtual ActionResult Update(string id, string key, string value = null, bool redirect = false)
|
||||
{
|
||||
dbContext.Configuration.LazyLoadingEnabled = true;
|
||||
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
throw new ArgumentNullException("id");
|
||||
if (string.IsNullOrEmpty(key))
|
||||
throw new ArgumentNullException("key");
|
||||
var device = dbContext.Devices.Find(id);
|
||||
if (device != null)
|
||||
{
|
||||
switch (key.ToLower())
|
||||
{
|
||||
case pDeviceProfileId:
|
||||
UpdateDeviceProfileId(device, value);
|
||||
break;
|
||||
case pDeviceBatchId:
|
||||
UpdateDeviceBatchId(device, value);
|
||||
break;
|
||||
case pAssetNumber:
|
||||
UpdateAssetNumber(device, value);
|
||||
break;
|
||||
case pAssignedUserId:
|
||||
UpdateAssignedUserId(device, value);
|
||||
break;
|
||||
case pLocation:
|
||||
UpdateLocation(device, value);
|
||||
break;
|
||||
case pAllowUnauthenticatedEnrol:
|
||||
UpdateAllowUnauthenticatedEnrol(device, value);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Invalid Update Key");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid Serial Number or Device Profile Id");
|
||||
}
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Device.Show(device.SerialNumber));
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (redirect)
|
||||
throw;
|
||||
else
|
||||
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
|
||||
#region Update Shortcut Methods
|
||||
public virtual ActionResult UpdateDeviceProfileId(string id, string DeviceProfileId = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pDeviceProfileId, DeviceProfileId, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateDeviceBatchId(string id, string DeviceBatchId = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pDeviceBatchId, DeviceBatchId, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateAssetNumber(string id, string AssetNumber = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pAssetNumber, AssetNumber, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateLocation(string id, string Location = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pLocation, Location, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateAssignedUserId(string id, string AssignedUserId = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pAssignedUserId, AssignedUserId, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateAllowUnauthenticatedEnrol(string id, string AllowUnauthenticatedEnrol = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pAllowUnauthenticatedEnrol, AllowUnauthenticatedEnrol, redirect);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Update Properties
|
||||
private void UpdateDeviceProfileId(Disco.Models.Repository.Device device, string DeviceProfileId)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(DeviceProfileId))
|
||||
{
|
||||
int pId;
|
||||
if (int.TryParse(DeviceProfileId, out pId))
|
||||
{
|
||||
var p = dbContext.DeviceProfiles.Find(pId);
|
||||
if (p != null)
|
||||
{
|
||||
device.DeviceProfileId = p.Id;
|
||||
device.DeviceProfile = p;
|
||||
|
||||
// Update AD Account
|
||||
if (!string.IsNullOrEmpty(device.ComputerName) && device.ComputerName.Length <= 24)
|
||||
{
|
||||
var adMachineAccount = ActiveDirectory.GetMachineAccount(device.ComputerName);
|
||||
if (adMachineAccount != null)
|
||||
adMachineAccount.SetDescription(device);
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new Exception("Invalid Device Profile Id");
|
||||
}
|
||||
private void UpdateDeviceBatchId(Disco.Models.Repository.Device device, string DeviceBatchId)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(DeviceBatchId))
|
||||
{
|
||||
int bId;
|
||||
if (int.TryParse(DeviceBatchId, out bId))
|
||||
{
|
||||
var b = dbContext.DeviceBatches.Find(bId);
|
||||
if (b != null)
|
||||
{
|
||||
device.DeviceBatchId = b.Id;
|
||||
device.DeviceBatch = b;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Null Id - No Batch
|
||||
device.DeviceBatchId = null;
|
||||
device.DeviceBatch = null;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
return;
|
||||
}
|
||||
throw new Exception("Invalid Device Batch Id");
|
||||
}
|
||||
private void UpdateAssetNumber(Disco.Models.Repository.Device device, string AssetNumber)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(AssetNumber))
|
||||
device.AssetNumber = null;
|
||||
else
|
||||
device.AssetNumber = AssetNumber.Trim();
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateLocation(Disco.Models.Repository.Device device, string Location)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Location))
|
||||
device.Location = null;
|
||||
else
|
||||
device.Location = Location.Trim();
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateAssignedUserId(Disco.Models.Repository.Device device, string UserId)
|
||||
{
|
||||
var daus = dbContext.DeviceUserAssignments.Where(m => m.DeviceSerialNumber == device.SerialNumber && m.UnassignedDate == null);
|
||||
Disco.Models.Repository.User u = null;
|
||||
if (!string.IsNullOrEmpty(UserId))
|
||||
{
|
||||
// Changed 2012-12-13 G# - Stop error when assigning user - Force Refresh
|
||||
// http://www.discoict.com.au/forum/support/2012/11/error-when-assigning-multiple-devices-to-single-user.aspx
|
||||
//u = BI.UserBI.UserCache.GetUser(UserId, dbContext);
|
||||
u = BI.UserBI.UserCache.GetUser(UserId, dbContext, true);
|
||||
// End Changed 2012-12-13 G#
|
||||
if (u == null)
|
||||
{
|
||||
throw new Exception("Invalid Username");
|
||||
}
|
||||
}
|
||||
|
||||
device.AssignDevice(dbContext, u);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateAllowUnauthenticatedEnrol(Disco.Models.Repository.Device device, string AllowUnauthenticatedEnrol)
|
||||
{
|
||||
bool bAllowUnauthenticatedEnrol;
|
||||
if (string.IsNullOrEmpty(AllowUnauthenticatedEnrol) || !bool.TryParse(AllowUnauthenticatedEnrol, out bAllowUnauthenticatedEnrol))
|
||||
{
|
||||
throw new Exception("Invalid AllowUnauthenticatedEnrol Value");
|
||||
}
|
||||
|
||||
if (device.AllowUnauthenticatedEnrol != bAllowUnauthenticatedEnrol)
|
||||
{
|
||||
device.AllowUnauthenticatedEnrol = bAllowUnauthenticatedEnrol;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Device Actions
|
||||
public virtual ActionResult Decommission(string id, bool redirect)
|
||||
{
|
||||
var d = dbContext.Devices.Find(id);
|
||||
dbContext.Configuration.LazyLoadingEnabled = true;
|
||||
if (d != null)
|
||||
{
|
||||
if (d.CanDecommission())
|
||||
{
|
||||
d.OnDecommission();
|
||||
|
||||
dbContext.SaveChanges();
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Device.Show(id));
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Json("Device's state doesn't allow this action", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
return Json("Invalid Device Serial Number", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
public virtual ActionResult Recommission(string id, bool redirect)
|
||||
{
|
||||
var d = dbContext.Devices.Find(id);
|
||||
dbContext.Configuration.LazyLoadingEnabled = true;
|
||||
if (d != null)
|
||||
{
|
||||
if (d.CanRecommission())
|
||||
{
|
||||
d.OnRecommission();
|
||||
|
||||
dbContext.SaveChanges();
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Device.Show(id));
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Json("Device's state doesn't allow this action", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
return Json("Invalid Device Serial Number", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
public virtual ActionResult Delete(string id, bool redirect)
|
||||
{
|
||||
var j = dbContext.Devices.Find(id);
|
||||
dbContext.Configuration.LazyLoadingEnabled = true;
|
||||
if (j != null)
|
||||
{
|
||||
if (j.CanDelete())
|
||||
{
|
||||
j.OnDelete(dbContext);
|
||||
|
||||
dbContext.SaveChanges();
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Device.Index());
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Json("Job's state doesn't allow this action", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
return Json("Invalid Device Serial Number", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public virtual ActionResult GeneratePdf(string id, string DocumentTemplateId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
throw new ArgumentNullException("id");
|
||||
if (string.IsNullOrEmpty(DocumentTemplateId))
|
||||
throw new ArgumentNullException("AttachmentTypeId");
|
||||
var device = dbContext.Devices.Find(id);
|
||||
if (device != null)
|
||||
{
|
||||
var documentTemplate = dbContext.DocumentTemplates.Find(DocumentTemplateId);
|
||||
if (documentTemplate != null)
|
||||
{
|
||||
var timeStamp = DateTime.Now;
|
||||
Stream pdf;
|
||||
using (var generationState = Disco.Models.BI.DocumentTemplates.DocumentState.DefaultState()){
|
||||
pdf = documentTemplate.GeneratePdf(dbContext, device, DiscoApplication.CurrentUser, timeStamp, generationState);
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
return File(pdf, "application/pdf", string.Format("{0}_{1}_{2:yyyyMMdd-HHmmss}.pdf", documentTemplate.Id, device.SerialNumber, timeStamp));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Invalid Document Template Id", "id");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Invalid Serial Number", "id");
|
||||
}
|
||||
}
|
||||
|
||||
public virtual ActionResult LastNetworkLogonDate(string id)
|
||||
{
|
||||
var device = dbContext.Devices.Find(id);
|
||||
if (device == null)
|
||||
{
|
||||
return HttpNotFound("Invalid Device Serial Number");
|
||||
}
|
||||
|
||||
if (device.UpdateLastNetworkLogonDate())
|
||||
dbContext.SaveChanges();
|
||||
|
||||
var result = new
|
||||
{
|
||||
Timestamp = device.LastNetworkLogonDate,
|
||||
Friendly = device.LastNetworkLogonDate.ToFuzzy("Unknown"),
|
||||
Formatted = device.LastNetworkLogonDate.ToFullDateTime("Unknown")
|
||||
};
|
||||
|
||||
return Json(result, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
#region Device Attachements
|
||||
[OutputCache(Location = System.Web.UI.OutputCacheLocation.Client, Duration = 172800)]
|
||||
public virtual ActionResult AttachmentDownload(int id)
|
||||
{
|
||||
var da = dbContext.DeviceAttachments.Find(id);
|
||||
if (da != null)
|
||||
{
|
||||
var filePath = da.RepositoryFilename(dbContext);
|
||||
if (System.IO.File.Exists(filePath))
|
||||
{
|
||||
return File(filePath, da.MimeType, da.Filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
return HttpNotFound("Attachment reference exists, but file not found");
|
||||
}
|
||||
}
|
||||
return HttpNotFound("Invalid Attachment Number");
|
||||
}
|
||||
[OutputCache(Location = System.Web.UI.OutputCacheLocation.Client, Duration = 172800)]
|
||||
public virtual ActionResult AttachmentThumbnail(int id)
|
||||
{
|
||||
var da = dbContext.DeviceAttachments.Find(id);
|
||||
if (da != null)
|
||||
{
|
||||
var thumbPath = da.RepositoryThumbnailFilename(dbContext);
|
||||
if (System.IO.File.Exists(thumbPath))
|
||||
{
|
||||
if (thumbPath.EndsWith(".png", StringComparison.InvariantCultureIgnoreCase))
|
||||
return File(thumbPath, "image/png");
|
||||
else
|
||||
return File(thumbPath, "image/jpg");
|
||||
}
|
||||
else
|
||||
return File(ClientSource.Style.Images.AttachmentTypes.MimeTypeIcons.Icon(da.MimeType), "image/png");
|
||||
}
|
||||
return HttpNotFound("Invalid Attachment Number");
|
||||
}
|
||||
public virtual ActionResult AttachmentUpload(string id, string Comments)
|
||||
{
|
||||
var d = dbContext.Devices.Find(id);
|
||||
if (d != null)
|
||||
{
|
||||
if (Request.Files.Count > 0)
|
||||
{
|
||||
var file = Request.Files.Get(0);
|
||||
if (file.ContentLength > 0)
|
||||
{
|
||||
var contentType = file.ContentType;
|
||||
if (string.IsNullOrEmpty(contentType) || contentType.Equals("unknown/unknown", StringComparison.InvariantCultureIgnoreCase))
|
||||
contentType = BI.Interop.MimeTypes.ResolveMimeType(file.FileName);
|
||||
|
||||
var da = new Disco.Models.Repository.DeviceAttachment()
|
||||
{
|
||||
DeviceSerialNumber = d.SerialNumber,
|
||||
TechUserId = DiscoApplication.CurrentUser.Id,
|
||||
Filename = file.FileName,
|
||||
MimeType = contentType,
|
||||
Timestamp = DateTime.Now,
|
||||
Comments = Comments
|
||||
};
|
||||
dbContext.DeviceAttachments.Add(da);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
da.SaveAttachment(dbContext, file.InputStream);
|
||||
|
||||
da.GenerateThumbnail(dbContext);
|
||||
|
||||
return Json(da.Id, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
throw new Exception("No Attachment Uploaded");
|
||||
}
|
||||
throw new Exception("Invalid Device Serial Number");
|
||||
}
|
||||
public virtual ActionResult Attachment(int id)
|
||||
{
|
||||
var da = dbContext.DeviceAttachments.Include("TechUser").Where(m => m.Id == id).FirstOrDefault();
|
||||
if (da != null)
|
||||
{
|
||||
|
||||
var m = new Models.Attachment.AttachmentModel()
|
||||
{
|
||||
Attachment = Models.Attachment._AttachmentModel.FromAttachment(da),
|
||||
Result = "OK"
|
||||
};
|
||||
|
||||
return Json(m, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
return Json(new Models.Attachment.AttachmentModel() { Result = "Invalid Attachment Number" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
public virtual ActionResult Attachments(string id)
|
||||
{
|
||||
var d = dbContext.Devices.Include("DeviceAttachments.TechUser").Where(m => m.SerialNumber == id).FirstOrDefault();
|
||||
if (d != null)
|
||||
{
|
||||
var m = new Models.Attachment.AttachmentsModel()
|
||||
{
|
||||
Attachments = d.DeviceAttachments.Select(ua => Models.Attachment._AttachmentModel.FromAttachment(ua)).ToList(),
|
||||
Result = "OK"
|
||||
};
|
||||
|
||||
return Json(m, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
return Json(new Models.Attachment.AttachmentsModel() { Result = "Invalid Device Serial Number" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
public virtual ActionResult AttachmentRemove(int id)
|
||||
{
|
||||
var da = dbContext.DeviceAttachments.Include("TechUser").Where(m => m.Id == id).FirstOrDefault();
|
||||
if (da != null)
|
||||
{
|
||||
// 2012-02-17 G# Remove - 'Delete Own Comments' policy
|
||||
//if (da.TechUserId == DiscoApplication.CurrentUser.Id)
|
||||
//{
|
||||
da.OnDelete(dbContext);
|
||||
dbContext.SaveChanges();
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// return Json("You can only delete your own attachments.", JsonRequestBehavior.AllowGet);
|
||||
//}
|
||||
}
|
||||
return Json("Invalid Attachment Number", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,338 @@
|
||||
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.Repository;
|
||||
using Disco.Services.Plugins;
|
||||
using Disco.Services.Plugins.Features.WarrantyProvider;
|
||||
|
||||
namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
public partial class DeviceModelController : dbAdminController
|
||||
{
|
||||
|
||||
const string pDescription = "description";
|
||||
const string pDefaultPurchaseDate = "defaultpurchasedate";
|
||||
const string pDefaultWarrantyProvider = "defaultwarrantyprovider";
|
||||
|
||||
public virtual ActionResult Update(int id, string key, string value = null, bool redirect = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id < 0)
|
||||
throw new ArgumentOutOfRangeException("id");
|
||||
if (string.IsNullOrEmpty(key))
|
||||
throw new ArgumentNullException("key");
|
||||
var deviceModel = dbContext.DeviceModels.Find(id);
|
||||
if (deviceModel != null)
|
||||
{
|
||||
switch (key.ToLower())
|
||||
{
|
||||
case pDescription:
|
||||
UpdateDescription(deviceModel, value);
|
||||
break;
|
||||
case pDefaultPurchaseDate:
|
||||
UpdateDefaultPurchaseDate(deviceModel, value);
|
||||
break;
|
||||
case pDefaultWarrantyProvider:
|
||||
UpdateDefaultWarrantyProvider(deviceModel, value);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Invalid Update Key");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return Json("Invalid Device Model Number", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.DeviceModel.Index(deviceModel.Id));
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (redirect)
|
||||
throw;
|
||||
else
|
||||
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
|
||||
#region Update Shortcut Methods
|
||||
public virtual ActionResult UpdateDescription(int id, string Description = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pDescription, Description, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateDefaultPurchaseDate(int id, string DefaultPurchaseDate = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pDefaultPurchaseDate, DefaultPurchaseDate, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateDefaultWarrantyProvider(int id, string DefaultWarrantyProvider = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pDefaultWarrantyProvider, DefaultWarrantyProvider, redirect);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Update Properties
|
||||
private void UpdateDescription(Disco.Models.Repository.DeviceModel deviceModel, string Description)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Description))
|
||||
deviceModel.Description = null;
|
||||
else
|
||||
deviceModel.Description = Description;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateDefaultPurchaseDate(Disco.Models.Repository.DeviceModel deviceModel, string DefaultPurchaseDate)
|
||||
{
|
||||
if (string.IsNullOrEmpty(DefaultPurchaseDate))
|
||||
{
|
||||
deviceModel.DefaultPurchaseDate = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
DateTime d;
|
||||
if (DateTime.TryParse(DefaultPurchaseDate, out d))
|
||||
{
|
||||
deviceModel.DefaultPurchaseDate = d;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid Date Format");
|
||||
}
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateDefaultWarrantyProvider(Disco.Models.Repository.DeviceModel deviceModel, string DefaultWarrantyProvider)
|
||||
{
|
||||
if (string.IsNullOrEmpty(DefaultWarrantyProvider))
|
||||
{
|
||||
deviceModel.DefaultWarrantyProvider = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Validate
|
||||
var WarrantyProvider = Plugins.GetPluginFeature(DefaultWarrantyProvider, typeof(WarrantyProviderFeature));
|
||||
deviceModel.DefaultWarrantyProvider = WarrantyProvider.Id;
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region ModelImage
|
||||
[OutputCache(Duration = 31536000, Location = System.Web.UI.OutputCacheLocation.Any, VaryByParam = "*")]
|
||||
public virtual ActionResult Image(int? id, string v = null)
|
||||
{
|
||||
if (id.HasValue)
|
||||
{
|
||||
var m = dbContext.DeviceModels.Find(id.Value);
|
||||
if (m != null)
|
||||
{
|
||||
// Try From DataStore
|
||||
|
||||
var deviceModelImage = m.Image();
|
||||
if (deviceModelImage != null)
|
||||
return File(deviceModelImage, "image/png");
|
||||
//if ( m.Image != null)
|
||||
//{
|
||||
// return File(m.Image, "image/png");
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// DataStore Failed - Use Generic Images
|
||||
if (m.ModelType != null)
|
||||
{
|
||||
var modelTypePath = Server.MapPath(string.Format("~/Content/Images/DeviceTypes/{0}.png", m.ModelType));
|
||||
if (System.IO.File.Exists(modelTypePath))
|
||||
{
|
||||
return File(modelTypePath, "image/png");
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
return File(Links.ClientSource.Style.Images.DeviceTypes.Unknown_png, "image/png");
|
||||
}
|
||||
[HttpPost]
|
||||
public virtual ActionResult Image(int id, bool redirect, HttpPostedFileBase Image)
|
||||
{
|
||||
if (Image != null && Image.ContentLength > 0)
|
||||
{
|
||||
var dm = dbContext.DeviceModels.Find(id);
|
||||
if (dm != null)
|
||||
{
|
||||
if (dm.ImageImport(Image.InputStream))
|
||||
{
|
||||
dbContext.SaveChanges();
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.DeviceModel.Index(dm.Id));
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.DeviceModel.Index(dm.Id));
|
||||
else
|
||||
return Json("Invalid Image Format", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.DeviceModel.Index());
|
||||
else
|
||||
return Json("Invalid Device Model Number", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.DeviceModel.Index());
|
||||
else
|
||||
return Json("No Image Supplied", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Actions
|
||||
|
||||
public virtual ActionResult Delete(int id, Nullable<bool> redirect = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dm = dbContext.DeviceModels.Find(id);
|
||||
if (dm != null)
|
||||
{
|
||||
dm.Delete(dbContext);
|
||||
dbContext.SaveChanges();
|
||||
if (redirect.HasValue && redirect.Value)
|
||||
return RedirectToAction(MVC.Config.DeviceModel.Index(null));
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
throw new Exception("Invalid Device Model Number");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (redirect.HasValue && redirect.Value)
|
||||
throw;
|
||||
else
|
||||
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Device Model Components
|
||||
|
||||
public virtual ActionResult Component(int id)
|
||||
{
|
||||
var dc = dbContext.DeviceComponents.Include("JobSubTypes").Where(i => i.Id == id).FirstOrDefault();
|
||||
if (dc != null)
|
||||
{
|
||||
return Json(new Models.DeviceModel.ComponentModel { Result = "OK", Component = Models.DeviceModel._ComponentModel.FromDeviceComponent(dc) }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
return Json(new Models.DeviceModel.ComponentModel { Result = "Invalid Device Component Id" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
public virtual ActionResult ComponentAdd(int? id, string Description, string Cost)
|
||||
{
|
||||
DeviceModel dm = null;
|
||||
if (id.HasValue)
|
||||
{
|
||||
dm = dbContext.DeviceModels.Find(id.Value);
|
||||
if (dm == null)
|
||||
{
|
||||
return Json(new Models.DeviceModel.ComponentModel { Result = "Invalid Device Model Id" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
|
||||
decimal cost = 0;
|
||||
if (string.IsNullOrEmpty(Description))
|
||||
Description = "?";
|
||||
if (!string.IsNullOrEmpty(Cost) && Cost.Contains("$"))
|
||||
Cost = Cost.Substring(Cost.IndexOf("$") + 1);
|
||||
decimal.TryParse(Cost, out cost);
|
||||
|
||||
var dc = new Disco.Models.Repository.DeviceComponent()
|
||||
{
|
||||
Description = Description,
|
||||
Cost = cost
|
||||
};
|
||||
if (dm != null)
|
||||
{
|
||||
dc.DeviceModelId = dm.Id;
|
||||
}
|
||||
dc.JobSubTypes = new List<JobSubType>();
|
||||
|
||||
dbContext.DeviceComponents.Add(dc);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
return Json(new Models.DeviceModel.ComponentModel { Result = "OK", Component = Models.DeviceModel._ComponentModel.FromDeviceComponent(dc) }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
public virtual ActionResult ComponentUpdateJobSubTypes(int id, List<string> JobSubTypes)
|
||||
{
|
||||
var dc = dbContext.DeviceComponents.Include("JobSubTypes").Where(i => i.Id == id).FirstOrDefault();
|
||||
if (dc != null)
|
||||
{
|
||||
dc.JobSubTypes.Clear();
|
||||
|
||||
if (JobSubTypes != null)
|
||||
{
|
||||
var jsts = dbContext.JobSubTypes.Where(jst => JobSubTypes.Contains(jst.JobTypeId + "_" + jst.Id));
|
||||
foreach (var jst in jsts)
|
||||
{
|
||||
dc.JobSubTypes.Add(jst);
|
||||
}
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
return Json(new Models.DeviceModel.ComponentModel { Result = "OK", Component = Models.DeviceModel._ComponentModel.FromDeviceComponent(dc) }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
return Json(new Models.DeviceModel.ComponentModel { Result = "Invalid Device Component Id" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
public virtual ActionResult ComponentUpdate(int id, string Description, string Cost)
|
||||
{
|
||||
var dc = dbContext.DeviceComponents.Include("JobSubTypes").Where(i => i.Id == id).FirstOrDefault();
|
||||
if (dc != null)
|
||||
{
|
||||
decimal cost = 0;
|
||||
|
||||
if (string.IsNullOrEmpty(Description))
|
||||
Description = "?";
|
||||
if (!string.IsNullOrEmpty(Cost) && Cost.Contains("$"))
|
||||
Cost = Cost.Substring(Cost.IndexOf("$") + 1);
|
||||
decimal.TryParse(Cost, out cost);
|
||||
|
||||
dc.Description = Description;
|
||||
dc.Cost = cost;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
return Json(new Models.DeviceModel.ComponentModel { Result = "OK", Component = Models.DeviceModel._ComponentModel.FromDeviceComponent(dc) }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
return Json(new Models.DeviceModel.ComponentModel { Result = "Invalid Device Component Id" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
public virtual ActionResult ComponentRemove(int id)
|
||||
{
|
||||
var dc = dbContext.DeviceComponents.Include("JobSubTypes").Where(c => c.Id == id).FirstOrDefault();
|
||||
if (dc != null)
|
||||
{
|
||||
dc.JobSubTypes.Clear();
|
||||
dbContext.DeviceComponents.Remove(dc);
|
||||
dbContext.SaveChanges();
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
return Json("Invalid Device Component Id", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Index
|
||||
public virtual ActionResult Index()
|
||||
{
|
||||
var deviceModels = dbContext.DeviceModels.ToArray().Select(dm => Models.DeviceModel._DeviceModel.FromDeviceModel(dm)).ToArray();
|
||||
return Json(deviceModels, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,393 @@
|
||||
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.Configuration.Modules;
|
||||
|
||||
namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
public partial class DeviceProfileController : dbAdminController
|
||||
{
|
||||
|
||||
const string pDescription = "description";
|
||||
const string pName = "name";
|
||||
const string pShortName = "shortname";
|
||||
const string pDistributionType = "distributiontype";
|
||||
const string pCertificateProviderId = "certificateproviderid";
|
||||
const string pOrganisationalUnit = "organisationalunit";
|
||||
const string pDefaultOrganisationAddress = "defaultorganisationaddress";
|
||||
const string pComputerNameTemplate = "computernametemplate";
|
||||
const string pEnforceComputerNameConvention = "enforcecomputernameconvention";
|
||||
const string pEnforceOrganisationalUnit = "enforceorganisationalunit";
|
||||
const string pProvisionADAccount = "provisionadaccount";
|
||||
|
||||
public virtual ActionResult Update(int id, string key, string value = null, Nullable<bool> redirect = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (id < 0)
|
||||
throw new ArgumentOutOfRangeException("id");
|
||||
if (string.IsNullOrEmpty(key))
|
||||
throw new ArgumentNullException("key");
|
||||
var deviceProfile = dbContext.DeviceProfiles.Find(id);
|
||||
if (deviceProfile != null)
|
||||
{
|
||||
switch (key.ToLower())
|
||||
{
|
||||
case pDescription:
|
||||
UpdateDescription(deviceProfile, value);
|
||||
break;
|
||||
case pName:
|
||||
UpdateName(deviceProfile, value);
|
||||
break;
|
||||
case pShortName:
|
||||
UpdateShortName(deviceProfile, value);
|
||||
break;
|
||||
case pDistributionType:
|
||||
UpdateDistributionType(deviceProfile, value);
|
||||
break;
|
||||
case pCertificateProviderId:
|
||||
UpdateCertificateProviderId(deviceProfile, value);
|
||||
break;
|
||||
case pOrganisationalUnit:
|
||||
UpdateOrganisationalUnit(deviceProfile, value);
|
||||
break;
|
||||
case pDefaultOrganisationAddress:
|
||||
UpdateDefaultOrganisationAddress(deviceProfile, value);
|
||||
break;
|
||||
case pComputerNameTemplate:
|
||||
UpdateComputerNameTemplate(deviceProfile, value);
|
||||
break;
|
||||
case pEnforceComputerNameConvention:
|
||||
UpdateEnforceComputerNameConvention(deviceProfile, value);
|
||||
break;
|
||||
case pEnforceOrganisationalUnit:
|
||||
UpdateEnforceOrganisationalUnit(deviceProfile, value);
|
||||
break;
|
||||
case pProvisionADAccount:
|
||||
UpdateProvisionADAccount(deviceProfile, value);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Invalid Update Key");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid Device Profile Number");
|
||||
}
|
||||
if (redirect.HasValue && redirect.Value)
|
||||
return RedirectToAction(MVC.Config.DeviceModel.Index(deviceProfile.Id));
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (redirect.HasValue && redirect.Value)
|
||||
throw;
|
||||
else
|
||||
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
#region Update Shortcut Methods
|
||||
public virtual ActionResult UpdateDescription(int id, string Description = null, Nullable<bool> redirect = null)
|
||||
{
|
||||
return Update(id, pDescription, Description, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateName(int id, string ProfileName = null, Nullable<bool> redirect = null)
|
||||
{
|
||||
return Update(id, pName, ProfileName, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateShortName(int id, string ShortName = null, Nullable<bool> redirect = null)
|
||||
{
|
||||
return Update(id, pShortName, ShortName, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateDistributionType(int id, string DistributionType = null, Nullable<bool> redirect = null)
|
||||
{
|
||||
return Update(id, pDistributionType, DistributionType, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateCertificateProviderId(int id, string CertificateProviderId = null, Nullable<bool> redirect = null)
|
||||
{
|
||||
return Update(id, pCertificateProviderId, CertificateProviderId, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateOrganisationalUnit(int id, string OrganisationalUnit = null, Nullable<bool> redirect = null)
|
||||
{
|
||||
return Update(id, pOrganisationalUnit, OrganisationalUnit, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateDefaultOrganisationAddress(int id, string DefaultOrganisationAddress = null, Nullable<bool> redirect = null)
|
||||
{
|
||||
return Update(id, pDefaultOrganisationAddress, DefaultOrganisationAddress, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateComputerNameTemplate(int id, string ComputerNameTemplate = null, Nullable<bool> redirect = null)
|
||||
{
|
||||
return Update(id, pComputerNameTemplate, ComputerNameTemplate, redirect);
|
||||
}
|
||||
// Added 2012-06-14 G#
|
||||
public virtual ActionResult UpdateEnforceComputerNameConvention(int id, string EnforceComputerNameConvention = null, Nullable<bool> redirect = null)
|
||||
{
|
||||
return Update(id, pEnforceComputerNameConvention, EnforceComputerNameConvention, redirect);
|
||||
}
|
||||
// Added 2012-06-14 G#
|
||||
public virtual ActionResult UpdateEnforceOrganisationalUnit(int id, string EnforceOrganisationalUnit = null, Nullable<bool> redirect = null)
|
||||
{
|
||||
return Update(id, pEnforceOrganisationalUnit, EnforceOrganisationalUnit, redirect);
|
||||
}
|
||||
// Added 2012-06-28 G#
|
||||
public virtual ActionResult UpdateProvisionADAccount(int id, string ProvisionADAccount = null, Nullable<bool> redirect = null)
|
||||
{
|
||||
return Update(id, pProvisionADAccount, ProvisionADAccount, redirect);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Update Properties
|
||||
private void UpdateDescription(Disco.Models.Repository.DeviceProfile deviceProfile, string Description)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Description))
|
||||
deviceProfile.Description = null;
|
||||
else
|
||||
deviceProfile.Description = Description;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
private void UpdateName(Disco.Models.Repository.DeviceProfile deviceProfile, string Name)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Name))
|
||||
throw new Exception("Profile name cannot be empty");
|
||||
else
|
||||
deviceProfile.Name = Name;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
private void UpdateShortName(Disco.Models.Repository.DeviceProfile deviceProfile, string ShortName)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(ShortName))
|
||||
throw new Exception("Profile short name cannot be empty");
|
||||
else
|
||||
deviceProfile.ShortName = ShortName;
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
private void UpdateDistributionType(Disco.Models.Repository.DeviceProfile deviceProfile, string DistributionType)
|
||||
{
|
||||
int iDt;
|
||||
if (int.TryParse(DistributionType, out iDt))
|
||||
{
|
||||
// Removed 2012-06-14 G# - Properties moved to DeviceProfile model & DB Migrated in DBv3.
|
||||
//deviceProfile.Configuration(dbContext).DistributionType = (DeviceProfileConfiguration.DeviceProfileDistributionTypes)iDt;
|
||||
deviceProfile.DistributionType = (Disco.Models.Repository.DeviceProfile.DistributionTypes)iDt;
|
||||
dbContext.SaveChanges();
|
||||
return;
|
||||
}
|
||||
throw new Exception("Invalid Distribution Type Number");
|
||||
}
|
||||
|
||||
private void UpdateCertificateProviderId(Disco.Models.Repository.DeviceProfile deviceProfile, string CertificateProviderId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(CertificateProviderId))
|
||||
{
|
||||
deviceProfile.CertificateProviderId = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Validate
|
||||
var featureManifest = Disco.Services.Plugins.Plugins.GetPluginFeature(CertificateProviderId, typeof(Disco.Services.Plugins.Features.CertificateProvider.CertificateProviderFeature));
|
||||
if (featureManifest == null)
|
||||
throw new Exception(string.Format("Invalid Certificate Provider Plugin Id: [{0}]", CertificateProviderId));
|
||||
else
|
||||
deviceProfile.CertificateProviderId = featureManifest.Id;
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
private void UpdateOrganisationalUnit(Disco.Models.Repository.DeviceProfile deviceProfile, string OrganisationalUnit)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(OrganisationalUnit))
|
||||
OrganisationalUnit = null;
|
||||
// Removed 2012-06-14 G# - Properties moved to DeviceProfile model & DB Migrated in DBv3.
|
||||
//deviceProfile.Configuration(dbContext).OrganisationalUnit = OrganisationalUnit;
|
||||
deviceProfile.OrganisationalUnit = OrganisationalUnit;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateComputerNameTemplate(Disco.Models.Repository.DeviceProfile deviceProfile, string ComputerNameTemplate)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(ComputerNameTemplate))
|
||||
throw new Exception("ComputerNameTemplate is Required");
|
||||
// Removed 2012-06-14 G# - Properties moved to DeviceProfile model & DB Migrated in DBv3.
|
||||
//deviceProfile.Configuration(dbContext).ComputerNameTemplate = ComputerNameTemplate;
|
||||
deviceProfile.ComputerNameTemplate = ComputerNameTemplate;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
private void UpdateDefaultOrganisationAddress(Disco.Models.Repository.DeviceProfile deviceProfile, string DefaultOrganisationAddress)
|
||||
{
|
||||
if (string.IsNullOrEmpty(DefaultOrganisationAddress))
|
||||
{
|
||||
deviceProfile.DefaultOrganisationAddress = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Validate
|
||||
int daoId;
|
||||
if (int.TryParse(DefaultOrganisationAddress, out daoId))
|
||||
{
|
||||
var oa = dbContext.DiscoConfiguration.OrganisationAddresses.GetAddress(daoId);
|
||||
if (oa != null)
|
||||
{
|
||||
deviceProfile.DefaultOrganisationAddress = oa.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid Default Organisation Address Id (No such Id)");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid Default Organisation Address Id (Not Integer)");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
// Added 2012-06-14 G#
|
||||
private void UpdateEnforceComputerNameConvention(Disco.Models.Repository.DeviceProfile deviceProfile, string EnforceComputerNameConvention)
|
||||
{
|
||||
bool bValue;
|
||||
if (bool.TryParse(EnforceComputerNameConvention, out bValue))
|
||||
{
|
||||
deviceProfile.EnforceComputerNameConvention = bValue;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
return;
|
||||
}
|
||||
throw new Exception("Invalid Boolean Value");
|
||||
}
|
||||
// Added 2012-06-14 G#
|
||||
private void UpdateEnforceOrganisationalUnit(Disco.Models.Repository.DeviceProfile deviceProfile, string EnforceOrganisationalUnit)
|
||||
{
|
||||
bool bValue;
|
||||
if (bool.TryParse(EnforceOrganisationalUnit, out bValue))
|
||||
{
|
||||
deviceProfile.EnforceOrganisationalUnit = bValue;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
return;
|
||||
}
|
||||
throw new Exception("Invalid Boolean Value");
|
||||
}
|
||||
// Added 2012-06-28 G#
|
||||
private void UpdateProvisionADAccount(Disco.Models.Repository.DeviceProfile deviceProfile, string ProvisionADAccount)
|
||||
{
|
||||
bool bValue;
|
||||
if (bool.TryParse(ProvisionADAccount, out bValue))
|
||||
{
|
||||
deviceProfile.ProvisionADAccount = bValue;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
return;
|
||||
}
|
||||
throw new Exception("Invalid Boolean Value");
|
||||
}
|
||||
#endregion
|
||||
|
||||
public virtual ActionResult OrganisationalUnits()
|
||||
{
|
||||
var OUs = BI.Interop.ActiveDirectory.ActiveDirectory.GetOrganisationalUnitStructure();
|
||||
return Json(OUs, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
#region Actions
|
||||
|
||||
public virtual ActionResult Delete(int id, Nullable<bool> redirect = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dp = dbContext.DeviceProfiles.Find(id);
|
||||
if (dp != null)
|
||||
{
|
||||
dp.Delete(dbContext);
|
||||
dbContext.SaveChanges();
|
||||
if (redirect.HasValue && redirect.Value)
|
||||
return RedirectToAction(MVC.Config.DeviceProfile.Index(null));
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
throw new Exception("Invalid Device Profile Number");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (redirect.HasValue && redirect.Value)
|
||||
throw;
|
||||
else
|
||||
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Defaults
|
||||
public virtual ActionResult Default(int id, Nullable<bool> redirect = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dp = dbContext.DeviceProfiles.Find(id);
|
||||
if (dp != null)
|
||||
{
|
||||
dbContext.DiscoConfiguration.DeviceProfiles.DefaultDeviceProfileId = dp.Id;
|
||||
dbContext.SaveChanges();
|
||||
if (redirect.HasValue && redirect.Value)
|
||||
return RedirectToAction(MVC.Config.DeviceProfile.Index(id));
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
throw new Exception("Invalid Device Profile Number");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (redirect.HasValue && redirect.Value)
|
||||
throw;
|
||||
else
|
||||
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
public virtual ActionResult DefaultAddDeviceOffline(int id, Nullable<bool> redirect = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
int defaultValue = 0;
|
||||
if (id > 0)
|
||||
{
|
||||
var dp = dbContext.DeviceProfiles.Find(id);
|
||||
if (dp != null)
|
||||
{
|
||||
defaultValue = dp.Id;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid Device Profile Number");
|
||||
}
|
||||
}
|
||||
dbContext.DiscoConfiguration.DeviceProfiles.DefaultAddDeviceOfflineDeviceProfileId = defaultValue;
|
||||
dbContext.SaveChanges();
|
||||
if (redirect.HasValue && redirect.Value)
|
||||
return RedirectToAction(MVC.Config.DeviceProfile.Index(id));
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (redirect.HasValue && redirect.Value)
|
||||
throw;
|
||||
else
|
||||
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,469 @@
|
||||
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.Repository;
|
||||
|
||||
namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
public partial class DocumentTemplateController : dbAdminController
|
||||
{
|
||||
|
||||
const string pDescription = "description";
|
||||
const string pScope = "scope";
|
||||
const string pFilterExpression = "filterexpression";
|
||||
const string pFlattenForm = "flattenform";
|
||||
|
||||
public virtual ActionResult Update(string id, string key, string value = null, bool redirect = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
throw new ArgumentNullException("id");
|
||||
if (string.IsNullOrEmpty(key))
|
||||
throw new ArgumentNullException("key");
|
||||
var documentTemplate = dbContext.DocumentTemplates.Find(id);
|
||||
if (documentTemplate != null)
|
||||
{
|
||||
switch (key.ToLower())
|
||||
{
|
||||
case pDescription:
|
||||
UpdateDescription(documentTemplate, value);
|
||||
break;
|
||||
case pScope:
|
||||
UpdateScope(documentTemplate, value);
|
||||
break;
|
||||
case pFilterExpression:
|
||||
UpdateFilterExpression(documentTemplate, value);
|
||||
break;
|
||||
case pFlattenForm:
|
||||
UpdateFlattenForm(documentTemplate, value);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Invalid Update Key");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Invalid Document Template Id");
|
||||
}
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.DocumentTemplate.Index(documentTemplate.Id));
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (redirect)
|
||||
throw;
|
||||
else
|
||||
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public virtual ActionResult Template(string id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
throw new ArgumentNullException("id");
|
||||
var documentTemplate = dbContext.DocumentTemplates.Find(id);
|
||||
if (documentTemplate == null)
|
||||
throw new ArgumentException("Invalid Document Template Id", "id");
|
||||
|
||||
var filename = documentTemplate.RepositoryFilename(dbContext);
|
||||
if (System.IO.File.Exists(filename))
|
||||
{
|
||||
return File(filename, DocumentTemplate.PdfMimeType, string.Format("{0}.pdf", documentTemplate.Id));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidOperationException("Template not found");
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public virtual ActionResult Template(string id, bool redirect, HttpPostedFileBase Template)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
throw new ArgumentNullException("id");
|
||||
var documentTemplate = dbContext.DocumentTemplates.Find(id);
|
||||
if (documentTemplate == null)
|
||||
throw new ArgumentException("Invalid Document Template Id", "id");
|
||||
|
||||
documentTemplate.SavePdfTemplate(dbContext, Template.InputStream);
|
||||
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.DocumentTemplate.Index(documentTemplate.Id));
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (redirect)
|
||||
throw;
|
||||
else
|
||||
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
|
||||
#region Update Shortcut Methods
|
||||
public virtual ActionResult UpdateDescription(string id, string Description = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pDescription, Description, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateFilterExpression(string id, string FilterExpression = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pFilterExpression, FilterExpression, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateFlattenForm(string id, string FlattenForm = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pFlattenForm, FlattenForm, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateScope(string id, string Scope = null, bool redirect = false)
|
||||
{
|
||||
return Update(id, pScope, Scope, redirect);
|
||||
}
|
||||
public virtual ActionResult UpdateSubTypes(string id, List<string> SubTypes = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
throw new ArgumentNullException("id");
|
||||
var documentTemplate = dbContext.DocumentTemplates.Find(id);
|
||||
|
||||
UpdateSubTypes(documentTemplate, SubTypes);
|
||||
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Update Properties
|
||||
private void UpdateDescription(Disco.Models.Repository.DocumentTemplate documentTemplate, string Description)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(Description))
|
||||
{
|
||||
documentTemplate.Description = Description.Trim();
|
||||
dbContext.SaveChanges();
|
||||
return;
|
||||
}
|
||||
throw new Exception("Invalid Description");
|
||||
}
|
||||
private void UpdateScope(Disco.Models.Repository.DocumentTemplate documentTemplate, string Scope)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(Scope))
|
||||
{
|
||||
if (Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.ToList().Contains(Scope))
|
||||
{
|
||||
dbContext.Configuration.LazyLoadingEnabled = true;
|
||||
|
||||
documentTemplate.Scope = Scope;
|
||||
|
||||
if (documentTemplate.Scope != Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.Job &&
|
||||
documentTemplate.JobSubTypes != null)
|
||||
{
|
||||
foreach (var st in documentTemplate.JobSubTypes.ToArray())
|
||||
documentTemplate.JobSubTypes.Remove(st);
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new Exception("Invalid Scope");
|
||||
}
|
||||
private void UpdateFilterExpression(Disco.Models.Repository.DocumentTemplate documentTemplate, string FilterExpression)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(FilterExpression))
|
||||
{
|
||||
documentTemplate.FilterExpression = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
documentTemplate.FilterExpression = FilterExpression.Trim();
|
||||
}
|
||||
// Invalidate Cache
|
||||
documentTemplate.FilterExpressionInvalidateCache();
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateFlattenForm(Disco.Models.Repository.DocumentTemplate documentTemplate, string FlattenForm)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(FlattenForm))
|
||||
{
|
||||
documentTemplate.FlattenForm = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool ff = default(bool);
|
||||
if (bool.TryParse(FlattenForm, out ff))
|
||||
documentTemplate.FlattenForm = ff;
|
||||
else
|
||||
throw new Exception("Invalid Boolean Format");
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
private void UpdateSubTypes(Disco.Models.Repository.DocumentTemplate documentTemplate, List<string> SubTypes)
|
||||
{
|
||||
dbContext.Configuration.LazyLoadingEnabled = true;
|
||||
|
||||
// Remove All Existing
|
||||
if (documentTemplate.JobSubTypes != null)
|
||||
{
|
||||
foreach (var st in documentTemplate.JobSubTypes.ToArray())
|
||||
documentTemplate.JobSubTypes.Remove(st);
|
||||
}
|
||||
|
||||
// Add New
|
||||
if (SubTypes != null && SubTypes.Count > 0)
|
||||
{
|
||||
var subTypes = new List<Disco.Models.Repository.JobSubType>();
|
||||
foreach (var stId in SubTypes)
|
||||
{
|
||||
var typeId = stId.Substring(0, stId.IndexOf("_"));
|
||||
var subTypeId = stId.Substring(stId.IndexOf("_") + 1);
|
||||
var subType = dbContext.JobSubTypes.FirstOrDefault(jst => jst.JobTypeId == typeId && jst.Id == subTypeId);
|
||||
subTypes.Add(subType);
|
||||
}
|
||||
documentTemplate.JobSubTypes = subTypes;
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region Actions
|
||||
|
||||
[OutputCache(NoStore = true, Duration = 0)]
|
||||
public virtual ActionResult ImporterThumbnail(string SessionId, int PageNumber)
|
||||
{
|
||||
// Load from Cache
|
||||
//var cacheKey = string.Format("Disco.BI.DocumentImporter-{0}-{1}", SessionId, PageNumber);
|
||||
//var cacheValue = HttpContext.Cache.Get(cacheKey);
|
||||
//if (cacheValue != null)
|
||||
//{
|
||||
// var cacheFile = cacheValue as byte[];
|
||||
// if (cacheFile != null)
|
||||
// {
|
||||
// return File(cacheFile, "image/png");
|
||||
// }
|
||||
//}
|
||||
|
||||
var dataStoreSessionPagesCacheLocation = DataStore.CreateLocation(dbContext, "Cache\\DocumentDropBox_SessionPages");
|
||||
var filename = System.IO.Path.Combine(dataStoreSessionPagesCacheLocation, string.Format("{0}-{1}", SessionId, PageNumber));
|
||||
if (System.IO.File.Exists(filename))
|
||||
return File(filename, "image/png");
|
||||
else
|
||||
return File("~/Content/Images/Status/fileBroken256.png", "image/png");
|
||||
}
|
||||
|
||||
public virtual ActionResult ImporterUndetectedFiles()
|
||||
{
|
||||
var undetectedLocation = DataStore.CreateLocation(dbContext, "DocumentDropBox_Unassigned");
|
||||
var undetectedDirectory = new System.IO.DirectoryInfo(undetectedLocation);
|
||||
var m = undetectedDirectory.GetFiles("*.pdf").Select(f => new Models.DocumentTemplate.ImporterUndetectedFilesModel()
|
||||
{
|
||||
Id = System.IO.Path.GetFileNameWithoutExtension(f.Name),
|
||||
Timestamp = f.CreationTime.ToString(),
|
||||
TimestampFuzzy = f.CreationTime.ToFuzzy()
|
||||
}).ToArray();
|
||||
|
||||
return Json(m);
|
||||
}
|
||||
public virtual ActionResult ImporterUndetectedDataIdLookup(string id, string term, int limitCount = 20)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(id) && !string.IsNullOrWhiteSpace(term))
|
||||
{
|
||||
string searchScope;
|
||||
if (id.StartsWith("--"))
|
||||
{
|
||||
switch (id.ToUpper())
|
||||
{
|
||||
case "--DEVICE":
|
||||
searchScope = DocumentTemplate.DocumentTemplateScopes.Device;
|
||||
break;
|
||||
case "--JOB":
|
||||
searchScope = DocumentTemplate.DocumentTemplateScopes.Job;
|
||||
break;
|
||||
case "--USER":
|
||||
searchScope = DocumentTemplate.DocumentTemplateScopes.User;
|
||||
break;
|
||||
default:
|
||||
searchScope = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var documentTemplate = dbContext.DocumentTemplates.Find(id);
|
||||
if (documentTemplate != null)
|
||||
searchScope = documentTemplate.Scope;
|
||||
else
|
||||
searchScope = null;
|
||||
}
|
||||
if (searchScope != null)
|
||||
{
|
||||
Models.DocumentTemplate.ImporterUndetectedDataIdLookupModel[] results;
|
||||
switch (searchScope)
|
||||
{
|
||||
case DocumentTemplate.DocumentTemplateScopes.Device:
|
||||
results = BI.DeviceBI.Searching.Search(dbContext, term, limitCount).Select(sr => Models.DocumentTemplate.ImporterUndetectedDataIdLookupModel.FromSearchResultItem(sr)).ToArray();
|
||||
break;
|
||||
case DocumentTemplate.DocumentTemplateScopes.Job:
|
||||
results = BI.JobBI.Searching.Search(dbContext, term, limitCount, false).Items.Select(sr => Models.DocumentTemplate.ImporterUndetectedDataIdLookupModel.FromSearchResultItem(sr)).ToArray();
|
||||
break;
|
||||
case DocumentTemplate.DocumentTemplateScopes.User:
|
||||
results = BI.UserBI.Searching.Search(dbContext, term, limitCount).Select(sr => Models.DocumentTemplate.ImporterUndetectedDataIdLookupModel.FromSearchResultItem(sr)).ToArray();
|
||||
break;
|
||||
default:
|
||||
results = null;
|
||||
break;
|
||||
}
|
||||
if (results != null)
|
||||
return Json(results, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
}
|
||||
return Json(null, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
public virtual ActionResult ImporterUndetectedFile(string id, Nullable<bool> Source, Nullable<bool> Thumbnail)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(id))
|
||||
{
|
||||
var undetectedLocation = DataStore.CreateLocation(dbContext, "DocumentDropBox_Unassigned");
|
||||
if (Source.HasValue && Source.Value)
|
||||
{
|
||||
var filename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, ".pdf"));
|
||||
if (System.IO.File.Exists(filename))
|
||||
return File(filename, DocumentTemplate.PdfMimeType);
|
||||
else
|
||||
return HttpNotFound();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Thumbnail.HasValue && Thumbnail.Value)
|
||||
{
|
||||
var filename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, "_thumbnail.png"));
|
||||
if (System.IO.File.Exists(filename))
|
||||
return File(filename, "image/png");
|
||||
else
|
||||
return File(Links.ClientSource.Style.Images.Status.fileBroken256_png, "image/png");
|
||||
}
|
||||
else
|
||||
{
|
||||
var filename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, ".jpg"));
|
||||
if (System.IO.File.Exists(filename))
|
||||
return File(filename, "image/jpeg");
|
||||
else
|
||||
return File(Links.ClientSource.Style.Images.Status.fileBroken256_png, "image/png");
|
||||
}
|
||||
}
|
||||
}
|
||||
return HttpNotFound();
|
||||
}
|
||||
public virtual ActionResult ImporterUndetectedAssign(string id, string DocumentTemplateId, string DataId)
|
||||
{
|
||||
var undetectedLocation = DataStore.CreateLocation(dbContext, "DocumentDropBox_Unassigned");
|
||||
var filename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, ".pdf"));
|
||||
if (BI.Interop.Pdf.PdfImporter.ProcessPdfAttachment(filename, dbContext, DocumentTemplateId, DataId, DiscoApplication.CurrentUser.Id, DateTime.Now))
|
||||
{
|
||||
// Delete File
|
||||
System.IO.File.Delete(filename);
|
||||
|
||||
// Delete Thumbnail/Preview
|
||||
var thumbnailFilename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, "_thumbnail.png"));
|
||||
if (System.IO.File.Exists(thumbnailFilename))
|
||||
System.IO.File.Delete(thumbnailFilename);
|
||||
var previewFilename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, ".jpg"));
|
||||
if (System.IO.File.Exists(previewFilename))
|
||||
System.IO.File.Delete(previewFilename);
|
||||
|
||||
return Json("OK");
|
||||
}
|
||||
else
|
||||
{
|
||||
return Json("Unable to Import File with the supplied parameters");
|
||||
}
|
||||
}
|
||||
public virtual ActionResult ImporterUndetectedDelete(string id)
|
||||
{
|
||||
var undetectedLocation = DataStore.CreateLocation(dbContext, "DocumentDropBox_Unassigned");
|
||||
var filename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, ".pdf"));
|
||||
if (System.IO.File.Exists(filename))
|
||||
{
|
||||
// Delete File
|
||||
System.IO.File.Delete(filename);
|
||||
|
||||
// Delete Thumbnail/Preview
|
||||
var thumbnailFilename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, "_thumbnail.png"));
|
||||
if (System.IO.File.Exists(thumbnailFilename))
|
||||
System.IO.File.Delete(thumbnailFilename);
|
||||
var previewFilename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, ".jpg"));
|
||||
if (System.IO.File.Exists(previewFilename))
|
||||
System.IO.File.Delete(previewFilename);
|
||||
|
||||
return Json("OK");
|
||||
}
|
||||
else
|
||||
{
|
||||
return Json("File Not Found");
|
||||
}
|
||||
}
|
||||
|
||||
public virtual ActionResult BulkGenerate(string id, string DataIds = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
throw new ArgumentNullException("id");
|
||||
if (string.IsNullOrEmpty(DataIds))
|
||||
throw new ArgumentNullException("DataIds");
|
||||
var documentTemplate = dbContext.DocumentTemplates.Find(id);
|
||||
if (documentTemplate == null)
|
||||
throw new ArgumentException("Invalid Document Template Id", "id");
|
||||
|
||||
var dataIds = DataIds.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
|
||||
var timeStamp = DateTime.Now;
|
||||
var pdf = documentTemplate.GeneratePdfBulk(dbContext, DiscoApplication.CurrentUser, timeStamp, dataIds);
|
||||
|
||||
return File(pdf, "application/pdf", string.Format("{0}_Bulk_{1:yyyyMMdd-HHmmss}.pdf", documentTemplate.Id, timeStamp));
|
||||
}
|
||||
|
||||
public virtual ActionResult Delete(string id, Nullable<bool> redirect = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
var at = dbContext.DocumentTemplates.Include("JobSubTypes").FirstOrDefault(a => a.Id == id);
|
||||
if (at != null)
|
||||
{
|
||||
at.Delete(dbContext);
|
||||
dbContext.SaveChanges();
|
||||
if (redirect.HasValue && redirect.Value)
|
||||
return RedirectToAction(MVC.Config.DocumentTemplate.Index(null));
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
throw new Exception("Invalid Document Template Id");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (redirect.HasValue && redirect.Value)
|
||||
throw;
|
||||
else
|
||||
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
public partial class ExpressionsController : dbAdminController
|
||||
{
|
||||
public virtual ActionResult ValidateExpression(string Expression)
|
||||
{
|
||||
var part = new BI.Expressions.EvaluateExpressionPart(Expression);
|
||||
return Json(Models.Expressions.ValidateExpressionModel.FromEvaluateExpressionPart(part), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Services.Logging;
|
||||
using Disco.Services.Tasks;
|
||||
|
||||
namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
public partial class LoggingController : dbAdminController
|
||||
{
|
||||
public virtual ActionResult Modules()
|
||||
{
|
||||
var m = LogContext.LogModules.Values.Select(lm => Models.Logs.LogModuleModel.FromLogModule(lm)).ToList();
|
||||
|
||||
return Json(m, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
public virtual ActionResult RetrieveEvents(string Format, DateTime? Start = null, DateTime? End = null, int? ModuleId = null, List<int> EventTypeIds = null, int? Take = null)
|
||||
{
|
||||
var logRetriever = new ReadLogContext()
|
||||
{
|
||||
Start = Start,
|
||||
End = End,
|
||||
Module = ModuleId,
|
||||
EventTypes = EventTypeIds,
|
||||
Take = Take
|
||||
};
|
||||
var results = logRetriever.Query(dbContext);
|
||||
|
||||
switch (Format.ToLower())
|
||||
{
|
||||
case "json":
|
||||
{
|
||||
return Json(results, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
case "csv":
|
||||
{
|
||||
return File(results.ToCsv(), "text/csv", "DiscoLogs.csv");
|
||||
}
|
||||
default:
|
||||
{
|
||||
throw new ArgumentException("Unknown Format", "Format");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public virtual ActionResult ScheduledTaskStatus(string id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
throw new ArgumentNullException("id");
|
||||
|
||||
var status = ScheduledTasks.GetTaskStatus(id);
|
||||
|
||||
if (status == null)
|
||||
throw new ArgumentException("Invalid ScheduledTask SessionId", "id");
|
||||
|
||||
return Json(ScheduledTaskStatusLive.FromScheduledTaskStatus(status, null), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Disco.BI;
|
||||
using Disco.BI.Extensions;
|
||||
using System.IO;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using Disco.Services.Tasks;
|
||||
using Disco.BI.Interop.ActiveDirectory;
|
||||
using Disco.Models.Repository;
|
||||
|
||||
namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
public partial class SystemController : dbAdminController
|
||||
{
|
||||
|
||||
public virtual ActionResult UpdateLastNetworkLogonDates()
|
||||
{
|
||||
//ActiveDirectoryUpdateLastNetworkLogonDateJob updateJob = new ActiveDirectoryUpdateLastNetworkLogonDateJob();
|
||||
|
||||
ActiveDirectoryUpdateLastNetworkLogonDateJob.UpdateLastNetworkLogonDates(dbContext);
|
||||
|
||||
var resultCount = dbContext.SaveChanges();
|
||||
|
||||
var model = new Models.System.UpdateLastNetworkLogonDatesModel()
|
||||
{
|
||||
Result = "OK",
|
||||
UpdateCount = resultCount
|
||||
};
|
||||
|
||||
return Json(model, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
public virtual ActionResult UpdateAttachmentThumbnails()
|
||||
{
|
||||
// Device Attachments
|
||||
var das = dbContext.DeviceAttachments.Where(da => da.MimeType == "application/pdf");
|
||||
foreach (var da in das)
|
||||
{
|
||||
var fileName = da.RepositoryThumbnailFilename(dbContext);
|
||||
if (!System.IO.File.Exists(fileName))
|
||||
{
|
||||
da.GenerateThumbnail(dbContext);
|
||||
}
|
||||
}
|
||||
|
||||
// User Attachments
|
||||
var uas = dbContext.UserAttachments.Where(ua => ua.MimeType == "application/pdf");
|
||||
foreach (var ua in uas)
|
||||
{
|
||||
var fileName = ua.RepositoryThumbnailFilename(dbContext);
|
||||
if (!System.IO.File.Exists(fileName))
|
||||
{
|
||||
ua.GenerateThumbnail(dbContext);
|
||||
}
|
||||
}
|
||||
|
||||
// Job Attachments
|
||||
var jas = dbContext.JobAttachments.Where(ja => ja.MimeType == "application/pdf");
|
||||
foreach (var ja in jas)
|
||||
{
|
||||
var fileName = ja.RepositoryThumbnailFilename(dbContext);
|
||||
if (!System.IO.File.Exists(fileName))
|
||||
{
|
||||
ja.GenerateThumbnail(dbContext);
|
||||
}
|
||||
}
|
||||
|
||||
return Content("Done", "text/text");
|
||||
}
|
||||
|
||||
public virtual ActionResult UpdateCheck()
|
||||
{
|
||||
var ts = Disco.BI.Interop.Community.UpdateCheckTask.ScheduleNow();
|
||||
ts.SetFinishedUrl(Url.Action(MVC.Config.SystemConfig.Index()));
|
||||
return RedirectToAction(MVC.Config.Logging.TaskStatus(ts.SessionId));
|
||||
}
|
||||
|
||||
#region Organisation
|
||||
|
||||
#region Organisation Name
|
||||
public virtual ActionResult UpdateOrganisationName(string OrganisationName, bool redirect = false)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(OrganisationName))
|
||||
dbContext.DiscoConfiguration.OrganisationName = null;
|
||||
else
|
||||
dbContext.DiscoConfiguration.OrganisationName = OrganisationName;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
DiscoApplication.OrganisationName = dbContext.DiscoConfiguration.OrganisationName;
|
||||
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.Organisation.Index());
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Organisation Logo
|
||||
[OutputCache(Duration = 31536000, Location = System.Web.UI.OutputCacheLocation.Any, VaryByParam = "*")]
|
||||
public virtual ActionResult OrganisationLogo(int Width = 256, int Height = 256, string v = null)
|
||||
{
|
||||
if (Width < 1)
|
||||
throw new ArgumentOutOfRangeException("Width");
|
||||
if (Height < 1)
|
||||
throw new ArgumentOutOfRangeException("Height");
|
||||
|
||||
using (Stream logoStream = dbContext.DiscoConfiguration.OrganisationLogo)
|
||||
{
|
||||
using (Image logoBitmap = Bitmap.FromStream(logoStream))
|
||||
{
|
||||
return File(logoBitmap.ResizeImage(Width, Height).SavePng(), "image/png");
|
||||
}
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public virtual ActionResult OrganisationLogo(bool redirect, HttpPostedFileBase Image, bool? ResetLogo = null)
|
||||
{
|
||||
if (ResetLogo.HasValue && ResetLogo.Value)
|
||||
{
|
||||
dbContext.DiscoConfiguration.OrganisationLogo = null;
|
||||
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.Organisation.Index());
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
if (Image != null && Image.ContentLength > 0)
|
||||
{
|
||||
if (Image.ContentType.StartsWith("image/", StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
dbContext.DiscoConfiguration.OrganisationLogo = Image.InputStream;
|
||||
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.Organisation.Index());
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.Organisation.Index());
|
||||
else
|
||||
return Json("Invalid Content Type", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.Organisation.Index());
|
||||
else
|
||||
return Json("No Image Supplied", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Organisation Addresses
|
||||
|
||||
public virtual ActionResult UpdateOrganisationAddress(Disco.Models.BI.Config.OrganisationAddress organisationAddress, bool redirect = false)
|
||||
{
|
||||
if (organisationAddress == null)
|
||||
{
|
||||
ModelState.AddModelError("Address", "No address was supplied");
|
||||
}
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
dbContext.DiscoConfiguration.OrganisationAddresses.SetAddress(organisationAddress);
|
||||
dbContext.SaveChanges();
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.Organisation.Index());
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Build Error Message
|
||||
var em = new StringBuilder();
|
||||
em.AppendLine("Error:");
|
||||
foreach (var item in ModelState)
|
||||
{
|
||||
foreach (var errorItem in item.Value.Errors)
|
||||
{
|
||||
em.Append(item.Key);
|
||||
em.Append(": ");
|
||||
em.AppendLine(errorItem.ErrorMessage);
|
||||
}
|
||||
}
|
||||
if (redirect)
|
||||
throw new InvalidOperationException(em.ToString());
|
||||
else
|
||||
return Json(em.ToString(), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
public virtual ActionResult DeleteOrganisationAddress(int Id, bool redirect = false)
|
||||
{
|
||||
dbContext.DiscoConfiguration.OrganisationAddresses.RemoveAddress(Id);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.Organisation.Index());
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MultiSiteMode
|
||||
|
||||
public virtual ActionResult UpdateMultiSiteMode(bool MultiSiteMode, bool redirect = false)
|
||||
{
|
||||
dbContext.DiscoConfiguration.MultiSiteMode = MultiSiteMode;
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
DiscoApplication.MultiSiteMode = dbContext.DiscoConfiguration.MultiSiteMode;
|
||||
|
||||
if (redirect)
|
||||
return RedirectToAction(MVC.Config.Organisation.Index());
|
||||
else
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Disco.BI;
|
||||
using Disco.BI.Extensions;
|
||||
using System.IO;
|
||||
|
||||
namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
public partial class UserController : dbAdminController
|
||||
{
|
||||
public virtual ActionResult UpstreamUsers(string term)
|
||||
{
|
||||
return Json(BI.UserBI.Searching.SearchUpstream(term), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
#region User Attachements
|
||||
[OutputCache(Location = System.Web.UI.OutputCacheLocation.Client, Duration = 172800)]
|
||||
public virtual ActionResult AttachmentDownload(int id)
|
||||
{
|
||||
var ua = dbContext.UserAttachments.Find(id);
|
||||
if (ua != null)
|
||||
{
|
||||
var filePath = ua.RepositoryFilename(dbContext);
|
||||
if (System.IO.File.Exists(filePath))
|
||||
{
|
||||
return File(filePath, ua.MimeType, ua.Filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
return HttpNotFound("Attachment reference exists, but file not found");
|
||||
}
|
||||
}
|
||||
return HttpNotFound("Invalid Attachment Number");
|
||||
}
|
||||
[OutputCache(Location = System.Web.UI.OutputCacheLocation.Client, Duration = 172800)]
|
||||
public virtual ActionResult AttachmentThumbnail(int id)
|
||||
{
|
||||
var ua = dbContext.UserAttachments.Find(id);
|
||||
if (ua != null)
|
||||
{
|
||||
var thumbPath = ua.RepositoryThumbnailFilename(dbContext);
|
||||
if (System.IO.File.Exists(thumbPath))
|
||||
{
|
||||
if (thumbPath.EndsWith(".png", StringComparison.InvariantCultureIgnoreCase))
|
||||
return File(thumbPath, "image/png");
|
||||
else
|
||||
return File(thumbPath, "image/jpg");
|
||||
}
|
||||
else
|
||||
return File(ClientSource.Style.Images.AttachmentTypes.MimeTypeIcons.Icon(ua.MimeType), "image/png");
|
||||
}
|
||||
return HttpNotFound("Invalid Attachment Number");
|
||||
}
|
||||
public virtual ActionResult AttachmentUpload(string id, string Comments)
|
||||
{
|
||||
var u = dbContext.Users.Find(id);
|
||||
if (u != null)
|
||||
{
|
||||
if (Request.Files.Count > 0)
|
||||
{
|
||||
var file = Request.Files.Get(0);
|
||||
if (file.ContentLength > 0)
|
||||
{
|
||||
var contentType = file.ContentType;
|
||||
if (string.IsNullOrEmpty(contentType) || contentType.Equals("unknown/unknown", StringComparison.InvariantCultureIgnoreCase))
|
||||
contentType = BI.Interop.MimeTypes.ResolveMimeType(file.FileName);
|
||||
|
||||
var ua = new Disco.Models.Repository.UserAttachment()
|
||||
{
|
||||
UserId = u.Id,
|
||||
TechUserId = DiscoApplication.CurrentUser.Id,
|
||||
Filename = file.FileName,
|
||||
MimeType = contentType,
|
||||
Timestamp = DateTime.Now,
|
||||
Comments = Comments
|
||||
};
|
||||
dbContext.UserAttachments.Add(ua);
|
||||
dbContext.SaveChanges();
|
||||
|
||||
ua.SaveAttachment(dbContext, file.InputStream);
|
||||
|
||||
ua.GenerateThumbnail(dbContext);
|
||||
|
||||
return Json(ua.Id, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
throw new Exception("No Attachment Uploaded");
|
||||
}
|
||||
throw new Exception("Invalid User Id");
|
||||
}
|
||||
public virtual ActionResult Attachment(int id)
|
||||
{
|
||||
var ua = dbContext.UserAttachments.Include("TechUser").Where(m => m.Id == id).FirstOrDefault();
|
||||
if (ua != null)
|
||||
{
|
||||
|
||||
var m = new Models.Attachment.AttachmentModel()
|
||||
{
|
||||
Attachment = Models.Attachment._AttachmentModel.FromAttachment(ua),
|
||||
Result = "OK"
|
||||
};
|
||||
|
||||
return Json(m, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
return Json(new Models.Attachment.AttachmentModel() { Result = "Invalid Attachment Number" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
public virtual ActionResult Attachments(string id)
|
||||
{
|
||||
var u = dbContext.Users.Include("UserAttachments.TechUser").Where(m => m.Id == id).FirstOrDefault();
|
||||
if (u != null)
|
||||
{
|
||||
var m = new Models.Attachment.AttachmentsModel()
|
||||
{
|
||||
Attachments = u.UserAttachments.Select(ua => Models.Attachment._AttachmentModel.FromAttachment(ua)).ToList(),
|
||||
Result = "OK"
|
||||
};
|
||||
|
||||
return Json(m, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
return Json(new Models.Attachment.AttachmentsModel() { Result = "Invalid User Id" }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
public virtual ActionResult AttachmentRemove(int id)
|
||||
{
|
||||
var ua = dbContext.UserAttachments.Include("TechUser").Where(m => m.Id == id).FirstOrDefault();
|
||||
if (ua != null)
|
||||
{
|
||||
// 2012-02-17 G# Remove - 'Delete Own Comments' policy
|
||||
//if (ua.TechUserId == DiscoApplication.CurrentUser.Id)
|
||||
//{
|
||||
ua.OnDelete(dbContext);
|
||||
dbContext.SaveChanges();
|
||||
return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// return Json("You can only delete your own attachments.", JsonRequestBehavior.AllowGet);
|
||||
//}
|
||||
}
|
||||
return Json("Invalid Attachment Number", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public virtual ActionResult GeneratePdf(string id, string DocumentTemplateId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
throw new ArgumentNullException("id");
|
||||
if (string.IsNullOrEmpty(DocumentTemplateId))
|
||||
throw new ArgumentNullException("AttachmentTypeId");
|
||||
var user = dbContext.Users.Find(id);
|
||||
if (user != null)
|
||||
{
|
||||
var documentTemplate = dbContext.DocumentTemplates.Find(DocumentTemplateId);
|
||||
if (documentTemplate != null)
|
||||
{
|
||||
var timeStamp = DateTime.Now;
|
||||
Stream pdf;
|
||||
using (var generationState = Disco.Models.BI.DocumentTemplates.DocumentState.DefaultState())
|
||||
{
|
||||
pdf = documentTemplate.GeneratePdf(dbContext, user, DiscoApplication.CurrentUser, timeStamp, generationState);
|
||||
}
|
||||
dbContext.SaveChanges();
|
||||
return File(pdf, "application/pdf", string.Format("{0}_{1}_{2:yyyyMMdd-HHmmss}.pdf", documentTemplate.Id, user.Id, timeStamp));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Invalid Document Template Id", "id");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Invalid User Id", "id");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
public partial class WirelessCertificateController : dbAdminController
|
||||
{
|
||||
|
||||
public virtual ActionResult Download(int id)
|
||||
{
|
||||
var wc = dbContext.DeviceCertificates.Find(id);
|
||||
if (wc == null)
|
||||
{
|
||||
throw new Exception("Invalid Wireless Certificate Number");
|
||||
}
|
||||
return File(wc.Content, "application/x-pkcs12", string.Format("{0}.pfx", wc.Name));
|
||||
}
|
||||
|
||||
//public virtual ActionResult DownloadLog()
|
||||
//{
|
||||
// //var path = BI.Wireless.BaseWirelessProvider.LoggingPath;
|
||||
// //if (path != null && System.IO.File.Exists(path))
|
||||
// //{
|
||||
// // System.IO.MemoryStream ms = new System.IO.MemoryStream();
|
||||
// // using (var s = new System.IO.FileStream(path, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.ReadWrite))
|
||||
// // {
|
||||
// // s.CopyTo(ms);
|
||||
// // }
|
||||
// // ms.Position = 0;
|
||||
// // return File(ms, "text/plain", "WirelessCertificateLog.txt");
|
||||
// //}
|
||||
// //return HttpNotFound();
|
||||
//}
|
||||
|
||||
public virtual ActionResult FillBuffer(int Value, Nullable<bool> redirect = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
//try
|
||||
//{
|
||||
// if (Value >= 0)
|
||||
// {
|
||||
// if (!WirelessCertificatesLog.IsCertificateRetrievalProcessing)
|
||||
// {
|
||||
// BaseWirelessProvider.GetProvider(dbContext).FillCertificateBuffer(Value);
|
||||
// if (redirect.HasValue && redirect.Value)
|
||||
// return RedirectToAction(MVC.Config.WirelessCertificate.Index());
|
||||
// else
|
||||
// return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw new Exception("Buffer is already processing");
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw new Exception("The value must be >= 0");
|
||||
// }
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// if (redirect.HasValue && redirect.Value)
|
||||
// throw;
|
||||
// else
|
||||
// return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
//}
|
||||
}
|
||||
|
||||
//#region Auto Buffer
|
||||
|
||||
//public virtual ActionResult AutoBufferMax(int Value, Nullable<bool> redirect = null)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// if (Value >= 0)
|
||||
// {
|
||||
// dbContext.DiscoConfiguration.Wireless.CertificateAutoBufferMax = Value;
|
||||
// dbContext.SaveChanges();
|
||||
// if (redirect.HasValue && redirect.Value)
|
||||
// return RedirectToAction(MVC.Config.WirelessCertificate.Index());
|
||||
// else
|
||||
// return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw new Exception("The value must be >= 0");
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// if (redirect.HasValue && redirect.Value)
|
||||
// throw;
|
||||
// else
|
||||
// return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
// }
|
||||
//}
|
||||
//public virtual ActionResult AutoBufferLow(int Value, Nullable<bool> redirect = null)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// if (Value >= 0)
|
||||
// {
|
||||
// dbContext.DiscoConfiguration.Wireless.CertificateAutoBufferLow = Value;
|
||||
// dbContext.SaveChanges();
|
||||
// if (redirect.HasValue && redirect.Value)
|
||||
// return RedirectToAction(MVC.Config.WirelessCertificate.Index());
|
||||
// else
|
||||
// return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw new Exception("The value must be >= 0");
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// if (redirect.HasValue && redirect.Value)
|
||||
// throw;
|
||||
// else
|
||||
// return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
// }
|
||||
//}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region eduSTAR Credentials
|
||||
|
||||
//public virtual ActionResult eduSTAR_SchoolId(string SchoolId)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// if (!string.IsNullOrWhiteSpace(SchoolId))
|
||||
// {
|
||||
// dbContext.DiscoConfiguration.Wireless.eduSTAR_ServiceAccountSchoolId = SchoolId;
|
||||
// dbContext.SaveChanges();
|
||||
// return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw new Exception("The SchoolId cannot be null or empty");
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
// }
|
||||
//}
|
||||
//public virtual ActionResult eduSTAR_Username(string Username)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// if (!string.IsNullOrWhiteSpace(Username))
|
||||
// {
|
||||
// dbContext.DiscoConfiguration.Wireless.eduSTAR_ServiceAccountUsername = Username;
|
||||
// dbContext.SaveChanges();
|
||||
// return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw new Exception("The Username cannot be null or empty");
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
// }
|
||||
//}
|
||||
//public virtual ActionResult eduSTAR_Password(string Password)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// if (!string.IsNullOrWhiteSpace(Password))
|
||||
// {
|
||||
// dbContext.DiscoConfiguration.Wireless.eduSTAR_ServiceAccountPassword = Password;
|
||||
// dbContext.SaveChanges();
|
||||
// return Json("OK", JsonRequestBehavior.AllowGet);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw new Exception("The Password cannot be null or empty");
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
|
||||
// }
|
||||
//}
|
||||
|
||||
//#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.Attachment
|
||||
{
|
||||
public class AttachmentModel
|
||||
{
|
||||
public _AttachmentModel Attachment { get; set; }
|
||||
public string Result { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.Attachment
|
||||
{
|
||||
public class AttachmentsModel
|
||||
{
|
||||
public List<_AttachmentModel> Attachments { get; set; }
|
||||
public string Result { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.BI;
|
||||
using Disco.BI.Extensions;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.Attachment
|
||||
{
|
||||
public class _AttachmentModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Author { get; set; }
|
||||
public DateTime Timestamp { get; set; }
|
||||
public string Comments { get; set; }
|
||||
public string Filename { get; set; }
|
||||
public string MimeType { get; set; }
|
||||
public string TimestampFuzzy
|
||||
{
|
||||
get
|
||||
{
|
||||
return Timestamp.ToFuzzy();
|
||||
}
|
||||
set
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
public string TimestampFull
|
||||
{
|
||||
get
|
||||
{
|
||||
return Timestamp.ToFullDateTime();
|
||||
}
|
||||
set
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
public static _AttachmentModel FromAttachment(Disco.Models.Repository.UserAttachment ua)
|
||||
{
|
||||
return new _AttachmentModel
|
||||
{
|
||||
Id = ua.Id,
|
||||
Author = ua.TechUser.ToString(),
|
||||
Timestamp = ua.Timestamp,
|
||||
Comments = ua.Comments,
|
||||
Filename = ua.Filename,
|
||||
MimeType = ua.MimeType
|
||||
};
|
||||
}
|
||||
public static _AttachmentModel FromAttachment(Disco.Models.Repository.JobAttachment ja)
|
||||
{
|
||||
return new _AttachmentModel
|
||||
{
|
||||
Id = ja.Id,
|
||||
Author = ja.TechUser.ToString(),
|
||||
Timestamp = ja.Timestamp,
|
||||
Comments = ja.Comments,
|
||||
Filename = ja.Filename,
|
||||
MimeType = ja.MimeType
|
||||
};
|
||||
}
|
||||
public static _AttachmentModel FromAttachment(Disco.Models.Repository.DeviceAttachment da)
|
||||
{
|
||||
return new _AttachmentModel
|
||||
{
|
||||
Id = da.Id,
|
||||
Author = da.TechUser.ToString(),
|
||||
Timestamp = da.Timestamp,
|
||||
Comments = da.Comments,
|
||||
Filename = da.Filename,
|
||||
MimeType = da.MimeType
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.DeviceBatch
|
||||
{
|
||||
public class DeviceBatchTimelineEvent
|
||||
{
|
||||
public string id { get; set; }
|
||||
public DateTime start { get; set; }
|
||||
public DateTime? end { get; set; }
|
||||
public DateTime? latestStart { get; set; }
|
||||
public DateTime? earliestEnd { get; set; }
|
||||
public bool instant { get; set; }
|
||||
public string title { get; set; }
|
||||
public string description { get; set; }
|
||||
public string image { get; set; }
|
||||
public string link { get; set; }
|
||||
public string icon { get; set; }
|
||||
public string color { get; set; }
|
||||
public string textColor { get; set; }
|
||||
public string hoverText { get; set; }
|
||||
public string classname { get; set; }
|
||||
public string tapeImage { get; set; }
|
||||
public bool tapeRepeat { get; set; }
|
||||
public string caption { get; set; }
|
||||
public string eventID { get; set; }
|
||||
public string trackNum { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.DeviceBatch
|
||||
{
|
||||
public class DeviceBatchTimelineEventSource
|
||||
{
|
||||
public string wikiURL { get; set; }
|
||||
public string wikiSection { get; set; }
|
||||
public string dateTimeFormat { get { return "iso8601"; } }
|
||||
public DeviceBatchTimelineEvent[] events { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.DeviceModel
|
||||
{
|
||||
public class ComponentModel
|
||||
{
|
||||
public _ComponentModel Component { get; set; }
|
||||
public string Result { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.DeviceModel
|
||||
{
|
||||
public class _ComponentModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Cost { get; set; }
|
||||
public List<string> JobSubTypes { get; set; }
|
||||
|
||||
public static _ComponentModel FromDeviceComponent(Disco.Models.Repository.DeviceComponent dc)
|
||||
{
|
||||
return new _ComponentModel
|
||||
{
|
||||
Id = dc.Id,
|
||||
Description = dc.Description,
|
||||
Cost = dc.Cost.ToString("C"),
|
||||
JobSubTypes = dc.JobSubTypes.Select(j => string.Format("{0}_{1}", j.JobTypeId, j.Id)).ToList()
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.DeviceModel
|
||||
{
|
||||
public class _DeviceModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Manufacturer { get; set; }
|
||||
public string Model { get; set; }
|
||||
public string ModelType { get; set; }
|
||||
|
||||
public static _DeviceModel FromDeviceModel(Disco.Models.Repository.DeviceModel dm)
|
||||
{
|
||||
return new _DeviceModel()
|
||||
{
|
||||
Id = dm.Id,
|
||||
Description = dm.Description,
|
||||
Manufacturer = dm.Manufacturer,
|
||||
Model = dm.Model,
|
||||
ModelType = dm.ModelType
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.DocumentTemplate
|
||||
{
|
||||
public class ImporterUndetectedDataIdLookupModel
|
||||
{
|
||||
public string value { get; set; }
|
||||
public string label { get; set; }
|
||||
|
||||
public static ImporterUndetectedDataIdLookupModel FromSearchResultItem(Disco.Models.BI.Search.DeviceSearchResultItem item)
|
||||
{
|
||||
return new ImporterUndetectedDataIdLookupModel
|
||||
{
|
||||
value = item.SerialNumber,
|
||||
label = string.Format("{0} - {1} - {2}", item.SerialNumber, item.ComputerName, item.DeviceModelDescription)
|
||||
};
|
||||
}
|
||||
public static ImporterUndetectedDataIdLookupModel FromSearchResultItem(Disco.Models.BI.Job.JobTableModel.JobTableItemModel item)
|
||||
{
|
||||
return new ImporterUndetectedDataIdLookupModel
|
||||
{
|
||||
value = item.Id.ToString(),
|
||||
label = string.Format("{0} ({1}; {2})", item.Id, item.DeviceSerialNumber, item.UserDisplayName)
|
||||
};
|
||||
}
|
||||
public static ImporterUndetectedDataIdLookupModel FromSearchResultItem(Disco.Models.BI.Search.UserSearchResultItem item)
|
||||
{
|
||||
return new ImporterUndetectedDataIdLookupModel
|
||||
{
|
||||
value = item.Id,
|
||||
label = string.Format("{0} - {1}", item.Id, item.DisplayName)
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.DocumentTemplate
|
||||
{
|
||||
public class ImporterUndetectedFilesModel
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Timestamp { get; set; }
|
||||
public string TimestampFuzzy { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.BI.Expressions;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.Expressions
|
||||
{
|
||||
public class ValidateExpressionModel
|
||||
{
|
||||
public string Expression { get; set; }
|
||||
public bool ExpressionValid { get; set; }
|
||||
public int PositionRow { get; set; }
|
||||
public int PositionColumn { get; set; }
|
||||
public string Message { get; set; }
|
||||
public string MessageHtmlEncoded { get; set; }
|
||||
|
||||
public static ValidateExpressionModel FromEvaluateExpressionPart(EvaluateExpressionPart part)
|
||||
{
|
||||
var parseException = part.ParseException;
|
||||
if (parseException != null)
|
||||
{
|
||||
return new ValidateExpressionModel()
|
||||
{
|
||||
Expression = part.Source,
|
||||
ExpressionValid = false,
|
||||
Message = parseException.Message,
|
||||
MessageHtmlEncoded = HttpUtility.HtmlEncode(parseException.Message),
|
||||
PositionRow = parseException.PositionRow,
|
||||
PositionColumn = parseException.PositionColumn
|
||||
};
|
||||
}
|
||||
else
|
||||
return new ValidateExpressionModel() { Expression = part.Source, ExpressionValid = true };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.Job
|
||||
{
|
||||
public class CommentPostModel
|
||||
{
|
||||
public string Result { get; set; }
|
||||
public _CommentModel Comment { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.Job
|
||||
{
|
||||
public class CommentsModel
|
||||
{
|
||||
public string Result { get; set; }
|
||||
public List<_CommentModel> Comments { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.Job
|
||||
{
|
||||
public class ComponentModel
|
||||
{
|
||||
public _ComponentModel Component { get; set; }
|
||||
public string Result { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.BI;
|
||||
using Disco.BI.Extensions;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.Job
|
||||
{
|
||||
public class _CommentModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Author { get; set; }
|
||||
public DateTime Timestamp { get; set; }
|
||||
public string Comments { get; set; }
|
||||
public string TimestampFuzzy
|
||||
{
|
||||
get
|
||||
{
|
||||
return Timestamp.ToFuzzy();
|
||||
}
|
||||
set
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
public string TimestampFull
|
||||
{
|
||||
get
|
||||
{
|
||||
return Timestamp.ToFullDateTime();
|
||||
}
|
||||
set
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
|
||||
public static _CommentModel FromJobLog(Disco.Models.Repository.JobLog jl)
|
||||
{
|
||||
return new _CommentModel
|
||||
{
|
||||
Id = jl.Id,
|
||||
Author = jl.TechUser.ToString(),
|
||||
Timestamp = jl.Timestamp,
|
||||
Comments = jl.Comments
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.Job
|
||||
{
|
||||
public class _ComponentModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Cost { get; set; }
|
||||
|
||||
public static _ComponentModel FromJobComponent(Disco.Models.Repository.JobComponent jc)
|
||||
{
|
||||
return new _ComponentModel
|
||||
{
|
||||
Id = jc.Id,
|
||||
Description = jc.Description,
|
||||
Cost = jc.Cost.ToString("C")
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.Job
|
||||
{
|
||||
public class _DateChangeModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Result { get; set; }
|
||||
public string UserDescription { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.Services.Logging.Models;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.Logs
|
||||
{
|
||||
public class LogEventTypeModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public int Severity { get; set; }
|
||||
|
||||
public static LogEventTypeModel FromLogEventType(LogEventType EventType)
|
||||
{
|
||||
return new LogEventTypeModel()
|
||||
{
|
||||
Id = EventType.Id,
|
||||
Name = EventType.Name,
|
||||
Severity = EventType.Severity
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.Services.Logging;
|
||||
using System.Web.WebPages.Html;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.Logs
|
||||
{
|
||||
public class LogModuleModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
|
||||
public List<LogEventTypeModel> EventTypes { get; set; }
|
||||
|
||||
public static LogModuleModel FromLogModule(LogBase LogModule)
|
||||
{
|
||||
return new LogModuleModel()
|
||||
{
|
||||
Id = LogModule.ModuleId,
|
||||
Name = LogModule.ModuleName,
|
||||
Description = LogModule.ModuleDescription,
|
||||
EventTypes = LogModule.EventTypes.Values.Select(et => LogEventTypeModel.FromLogEventType(et)).ToList()
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.API.Models.System
|
||||
{
|
||||
public class UpdateLastNetworkLogonDatesModel
|
||||
{
|
||||
public string Result { get; set; }
|
||||
public int UpdateCount { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Disco.Web.Areas.Config
|
||||
{
|
||||
public class ConfigAreaRegistration : AreaRegistration
|
||||
{
|
||||
public override string AreaName
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Config";
|
||||
}
|
||||
}
|
||||
|
||||
public override void RegisterArea(AreaRegistrationContext context)
|
||||
{
|
||||
context.MapRoute(
|
||||
"Config_DeviceModel_GenericComponents",
|
||||
"Config/DeviceModel/GenericComponents",
|
||||
new { controller = "DeviceModel", action = "GenericComponents" }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_DeviceModel",
|
||||
"Config/DeviceModel/{id}",
|
||||
new { controller = "DeviceModel", action = "Index", id = UrlParameter.Optional }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_DeviceBatch_Create",
|
||||
"Config/DeviceBatch/Create",
|
||||
new { controller = "DeviceBatch", action = "Create", id = UrlParameter.Optional }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_DeviceBatch_Timeline",
|
||||
"Config/DeviceBatch/Timeline",
|
||||
new { controller = "DeviceBatch", action = "Timeline" }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_DeviceBatch",
|
||||
"Config/DeviceBatch/{id}",
|
||||
new { controller = "DeviceBatch", action = "Index", id = UrlParameter.Optional }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_DeviceProfile_Create",
|
||||
"Config/DeviceProfile/Create",
|
||||
new { controller = "DeviceProfile", action = "Create" }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_DeviceProfile_Defaults",
|
||||
"Config/DeviceProfile/Defaults",
|
||||
new { controller = "DeviceProfile", action = "Defaults" }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_DeviceProfile",
|
||||
"Config/DeviceProfile/{id}",
|
||||
new { controller = "DeviceProfile", action = "Index", id = UrlParameter.Optional }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_AttachmentType_Create",
|
||||
"Config/AttachmentType/Create",
|
||||
new { controller = "AttachmentType", action = "Create" }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_AttachmentType_ExpressionBrowser_Type",
|
||||
"Config/AttachmentType/ExpressionBrowser/{type}",
|
||||
new { controller = "AttachmentType", action = "ExpressionBrowser", type = UrlParameter.Optional }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_AttachmentType",
|
||||
"Config/AttachmentType/{id}",
|
||||
new { controller = "AttachmentType", action = "Index", id = UrlParameter.Optional }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_DocumentTemplate_Create",
|
||||
"Config/DocumentTemplate/Create",
|
||||
new { controller = "DocumentTemplate", action = "Create", id = UrlParameter.Optional }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_DocumentTemplate_ImportStatus",
|
||||
"Config/DocumentTemplate/ImportStatus",
|
||||
new { controller = "DocumentTemplate", action = "ImportStatus", id = UrlParameter.Optional }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_DocumentTemplate_UndetectedPages",
|
||||
"Config/DocumentTemplate/UndetectedPages",
|
||||
new { controller = "DocumentTemplate", action = "UndetectedPages", id = UrlParameter.Optional }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_DocumentTemplate_ExpressionBrowser",
|
||||
"Config/DocumentTemplate/ExpressionBrowser",
|
||||
new { controller = "DocumentTemplate", action = "ExpressionBrowser", id = UrlParameter.Optional }
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_DocumentTemplate",
|
||||
"Config/DocumentTemplate/{id}",
|
||||
new { controller = "DocumentTemplate", action = "Index", id = UrlParameter.Optional }
|
||||
);
|
||||
|
||||
context.MapRoute(
|
||||
"Config_Warranty",
|
||||
"Config/Warranty/{id}",
|
||||
new { controller = "Warranty", action = "Index", id = UrlParameter.Optional }
|
||||
);
|
||||
|
||||
context.MapRoute(
|
||||
"Config_Plugins",
|
||||
"Config/Plugins",
|
||||
new { controller = "Plugins", action = "Index"}
|
||||
);
|
||||
context.MapRoute(
|
||||
"Config_Plugins_Configure",
|
||||
"Config/Plugins/{PluginId}",
|
||||
new { controller = "Plugins", action = "Configure" }
|
||||
);
|
||||
|
||||
context.MapRoute(
|
||||
"Config_default",
|
||||
"Config/{controller}/{action}/{id}",
|
||||
new { controller = "Config", action = "Index", id = UrlParameter.Optional }
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Controllers
|
||||
{
|
||||
public partial class ConfigController : dbAdminController
|
||||
{
|
||||
//
|
||||
// GET: /Config/Config/
|
||||
|
||||
public virtual ActionResult Index()
|
||||
{
|
||||
|
||||
var m = new Models.Config.IndexModel()
|
||||
{
|
||||
UpdateResponse = dbContext.DiscoConfiguration.UpdateLastCheck
|
||||
};
|
||||
|
||||
return View(m);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
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.Areas.Config.Controllers
|
||||
{
|
||||
public partial class DeviceBatchController : dbAdminController
|
||||
{
|
||||
|
||||
public virtual ActionResult Index(int? id)
|
||||
{
|
||||
dbContext.Configuration.LazyLoadingEnabled = true;
|
||||
|
||||
if (id.HasValue)
|
||||
{
|
||||
var m = new Models.DeviceBatch.ShowModel()
|
||||
{
|
||||
DeviceBatch = dbContext.DeviceBatches.Find(id)
|
||||
};
|
||||
if (m.DeviceBatch == null)
|
||||
{
|
||||
return RedirectToAction(MVC.Config.DeviceBatch.Index(null));
|
||||
}
|
||||
m.CanDelete = m.DeviceBatch.CanDelete(dbContext);
|
||||
|
||||
m.DeviceCount = m.DeviceBatch.Devices.Count();
|
||||
m.DeviceDecommissionedCount = m.DeviceBatch.Devices.Count(d => d.DecommissionedDate.HasValue);
|
||||
|
||||
m.DeviceModels = dbContext.DeviceModels.ToSelectListItems();
|
||||
|
||||
return View(MVC.Config.DeviceBatch.Views.Show, m);
|
||||
}
|
||||
else
|
||||
{
|
||||
return View(Models.DeviceBatch.IndexModel.Build(dbContext));
|
||||
}
|
||||
}
|
||||
|
||||
public virtual ActionResult Create()
|
||||
{
|
||||
// Default Batch
|
||||
var m = BI.DeviceBI.BatchUtilities.DefaultNewDeviceBatch(dbContext);
|
||||
return View(m);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public virtual ActionResult Create(Disco.Models.Repository.DeviceBatch model)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
// Check for Existing
|
||||
var existing = dbContext.DeviceBatches.Where(m => m.Name == model.Name).FirstOrDefault();
|
||||
if (existing == null)
|
||||
{
|
||||
dbContext.DeviceBatches.Add(model);
|
||||
dbContext.SaveChanges();
|
||||
return RedirectToAction(MVC.Config.DeviceBatch.Index(model.Id));
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelState.AddModelError("Name", "A Device Batch with this name already exists.");
|
||||
}
|
||||
}
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
public virtual ActionResult Timeline()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Disco.Services.Plugins.Features.WarrantyProvider;
|
||||
using Disco.Services.Plugins;
|
||||
using Disco.BI.Extensions;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Controllers
|
||||
{
|
||||
public partial class DeviceModelController : dbAdminController
|
||||
{
|
||||
public virtual ActionResult Index(int? id)
|
||||
{
|
||||
if (id.HasValue)
|
||||
{
|
||||
var m = new Models.DeviceModel.ShowModel()
|
||||
{
|
||||
DeviceModel = dbContext.DeviceModels.Include("DeviceComponents.JobSubTypes").Where(dm => dm.Id == id.Value).FirstOrDefault(),
|
||||
WarrantyProviders = Plugins.GetPluginFeatures(typeof(WarrantyProviderFeature))
|
||||
};
|
||||
|
||||
m.DeviceComponentsModel = new Models.DeviceModel.DeviceComponentsModel()
|
||||
{
|
||||
DeviceModelId = m.DeviceModel.Id,
|
||||
DeviceComponents = m.DeviceModel.DeviceComponents.ToList(),
|
||||
JobSubTypes = dbContext.JobSubTypes.Where(jst => jst.JobTypeId == Disco.Models.Repository.JobType.JobTypeIds.HNWar).ToList()
|
||||
};
|
||||
|
||||
m.CanDelete = m.DeviceModel.CanDelete(dbContext);
|
||||
|
||||
//m.Devices = BI.DeviceBI.SelectDeviceSearchResultItem(dbContext.Devices.Where(d => d.DeviceModelId == m.DeviceModel.Id));
|
||||
|
||||
//m.Devices = dbContext.Devices.Include("DeviceModel").Include("DeviceProfile").Include("AssignedUser")
|
||||
// .Where(d => d.DeviceModelId == m.DeviceModel.Id).ToList();
|
||||
|
||||
return View(MVC.Config.DeviceModel.Views.Show, m);
|
||||
}
|
||||
else
|
||||
{
|
||||
return View(Models.DeviceModel.IndexModel.Build(dbContext));
|
||||
}
|
||||
}
|
||||
|
||||
public virtual ActionResult GenericComponents()
|
||||
{
|
||||
var m = new Models.DeviceModel.DeviceComponentsModel()
|
||||
{
|
||||
DeviceComponents = dbContext.DeviceComponents.Include("JobSubTypes").Where(dc => !dc.DeviceModelId.HasValue).ToList(),
|
||||
JobSubTypes = dbContext.JobSubTypes.Where(jst => jst.JobTypeId == Disco.Models.Repository.JobType.JobTypeIds.HNWar).ToList()
|
||||
};
|
||||
|
||||
return View(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Disco.Data.Configuration;
|
||||
using Disco.BI;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Services.Plugins.Features.CertificateProvider;
|
||||
using Disco.Services.Plugins;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Controllers
|
||||
{
|
||||
public partial class DeviceProfileController : dbAdminController
|
||||
{
|
||||
public virtual ActionResult Index(int? id)
|
||||
{
|
||||
if (id.HasValue)
|
||||
{
|
||||
var m = new Models.DeviceProfile.ShowModel()
|
||||
{
|
||||
DeviceProfile = dbContext.DeviceProfiles.Find(id.Value),
|
||||
OrganisationAddresses = dbContext.DiscoConfiguration.OrganisationAddresses.Addresses,
|
||||
CertificateProviders = Plugins.GetPluginFeatures(typeof(CertificateProviderFeature))
|
||||
};
|
||||
|
||||
//m.Devices = BI.DeviceBI.SelectDeviceSearchResultItem(dbContext.Devices.Where(d => d.DeviceProfileId == m.DeviceProfile.Id));
|
||||
|
||||
var DistributionValues = Enum.GetValues(typeof(Disco.Models.Repository.DeviceProfile.DistributionTypes));
|
||||
m.DeviceProfileDistributionTypes = new List<SelectListItem>();
|
||||
foreach (int value in DistributionValues)
|
||||
{
|
||||
m.DeviceProfileDistributionTypes.Add(new SelectListItem()
|
||||
{
|
||||
Value = value.ToString(),
|
||||
Text = Enum.GetName(typeof(Disco.Models.Repository.DeviceProfile.DistributionTypes), value),
|
||||
Selected = ((int)m.DeviceProfile.DistributionType == value)
|
||||
});
|
||||
}
|
||||
m.CanDelete = m.DeviceProfile.CanDelete(dbContext);
|
||||
|
||||
// Removed 2012-06-14 G# - Properties moved to DeviceProfile model & DB Migrated in DBv3.
|
||||
//var config = m.DeviceProfile.Configuration(dbContext);
|
||||
//m.AllocateWirelessCertificate = m.DeviceProfile.AllocateWirelessCertificate;
|
||||
//m.OrganisationalUnit = m.DeviceProfile.OrganisationalUnit;
|
||||
//m.ComputerNameTemplate = m.DeviceProfile.ComputerNameTemplate;
|
||||
|
||||
return View(MVC.Config.DeviceProfile.Views.Show, m);
|
||||
}
|
||||
else
|
||||
{
|
||||
return View(Models.DeviceProfile.IndexModel.Build(dbContext));
|
||||
}
|
||||
}
|
||||
|
||||
public virtual ActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public virtual ActionResult Create(Disco.Models.Repository.DeviceProfile model)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
// Check for Existing
|
||||
var existing = dbContext.DeviceProfiles.Where(m => m.Name == model.Name).FirstOrDefault();
|
||||
if (existing == null)
|
||||
{
|
||||
model.ProvisionADAccount = true;
|
||||
|
||||
dbContext.DeviceProfiles.Add(model);
|
||||
dbContext.SaveChanges();
|
||||
return RedirectToAction(MVC.Config.DeviceProfile.Index(model.Id));
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelState.AddModelError("Name", "A Device Profile with this name already exists.");
|
||||
}
|
||||
}
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
public virtual ActionResult Defaults()
|
||||
{
|
||||
var m = new Models.DeviceProfile.DefaultsModel()
|
||||
{
|
||||
DeviceProfiles = dbContext.DeviceProfiles.ToList(),
|
||||
Default = dbContext.DiscoConfiguration.DeviceProfiles.DefaultDeviceProfileId,
|
||||
DefaultAddDeviceOffline = dbContext.DiscoConfiguration.DeviceProfiles.DefaultAddDeviceOfflineDeviceProfileId
|
||||
};
|
||||
m.DeviceProfilesAndNone = m.DeviceProfiles.ToList();
|
||||
m.DeviceProfilesAndNone.Insert(0, new Disco.Models.Repository.DeviceProfile() { Id = 0, Name = "<No Default>" });
|
||||
|
||||
return View(m);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Disco.BI;
|
||||
using Disco.BI.Extensions;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Controllers
|
||||
{
|
||||
public partial class DocumentTemplateController : dbAdminController
|
||||
{
|
||||
|
||||
public virtual ActionResult Index(string id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
{
|
||||
var m = new Models.DocumentTemplate.IndexModel() { DocumentTemplates = dbContext.DocumentTemplates.ToList() };
|
||||
return View(m);
|
||||
}
|
||||
else
|
||||
{
|
||||
var m = new Models.DocumentTemplate.ShowModel()
|
||||
{
|
||||
DocumentTemplate = dbContext.DocumentTemplates.Include("JobSubTypes").Where(at => at.Id == id).FirstOrDefault()
|
||||
};
|
||||
m.TemplateExpressions = m.DocumentTemplate.ExtractPdfExpressions(dbContext);
|
||||
m.UpdateModel(dbContext);
|
||||
return View(MVC.Config.DocumentTemplate.Views.Show, m);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual ActionResult ImportStatus()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
public virtual ActionResult UndetectedPages()
|
||||
{
|
||||
var m = new Models.DocumentTemplate.UndetectedPagesModel()
|
||||
{
|
||||
DocumentTemplates = dbContext.DocumentTemplates.ToList()
|
||||
};
|
||||
|
||||
return View(m);
|
||||
}
|
||||
|
||||
public virtual ActionResult Create()
|
||||
{
|
||||
var m = new Models.DocumentTemplate.CreateModel();
|
||||
m.UpdateModel(dbContext);
|
||||
|
||||
return View(m);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public virtual ActionResult Create(Models.DocumentTemplate.CreateModel model)
|
||||
{
|
||||
model.UpdateModel(dbContext);
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
// Check for Existing
|
||||
var existing = dbContext.DocumentTemplates.Where(m => m.Id == model.DocumentTemplate.Id).FirstOrDefault();
|
||||
if (existing == null)
|
||||
{
|
||||
|
||||
dbContext.DocumentTemplates.Add(model.DocumentTemplate);
|
||||
|
||||
if (model.DocumentTemplate.Scope == Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.Job)
|
||||
{
|
||||
var jobSubTypes = new List<Disco.Models.Repository.JobSubType>();
|
||||
jobSubTypes.AddRange(model.GetJobSubTypes);
|
||||
model.DocumentTemplate.JobSubTypes = jobSubTypes;
|
||||
//foreach (var jobSubType in model.GetJobSubTypes)
|
||||
// model.AttachmentType.JobSubTypes.Add(jobSubType);
|
||||
}
|
||||
|
||||
dbContext.SaveChanges();
|
||||
|
||||
// Save Template
|
||||
model.DocumentTemplate.SavePdfTemplate(dbContext, model.Template.InputStream);
|
||||
|
||||
return RedirectToAction(MVC.Config.DocumentTemplate.Index(model.DocumentTemplate.Id));
|
||||
}
|
||||
else
|
||||
{
|
||||
ModelState.AddModelError("Name", "A Document Template with this Name already exists.");
|
||||
}
|
||||
}
|
||||
return View(model);
|
||||
}
|
||||
|
||||
public virtual ActionResult ExpressionBrowser(string type, bool StaticDeclaredMembersOnly = false)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(type))
|
||||
{
|
||||
var m = new Models.DocumentTemplate.ExpressionBrowserModel()
|
||||
{
|
||||
DeviceType = typeof(Disco.Models.Repository.Device).AssemblyQualifiedName,
|
||||
JobType = typeof(Disco.Models.Repository.Job).AssemblyQualifiedName,
|
||||
UserType = typeof(Disco.Models.Repository.User).AssemblyQualifiedName,
|
||||
Variables = BI.Expressions.Expression.StandardVariableTypes(),
|
||||
ExtensionLibraries = BI.Expressions.Expression.ExtensionLibraryTypes()
|
||||
};
|
||||
|
||||
return View(m);
|
||||
}
|
||||
else
|
||||
{
|
||||
var t = Type.GetType(type);
|
||||
if (t != null)
|
||||
{
|
||||
return Json(BI.Expressions.ExpressionTypeDescriptor.Build(t, StaticDeclaredMembersOnly), JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Json("Invalid Type Specified", JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Controllers
|
||||
{
|
||||
public partial class EnrolmentController : dbAdminController
|
||||
{
|
||||
//
|
||||
// GET: /Config/Bootstrapper/
|
||||
|
||||
public virtual ActionResult Index()
|
||||
{
|
||||
var m = new Models.Enrolment.IndexModel()
|
||||
{
|
||||
MacSshUsername = dbContext.DiscoConfiguration.Bootstrapper.MacSshUsername
|
||||
};
|
||||
|
||||
return View(m);
|
||||
}
|
||||
public virtual ActionResult Status()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Controllers
|
||||
{
|
||||
public partial class ExpressionsController : Controller
|
||||
{
|
||||
//
|
||||
// GET: /Config/Expressions/
|
||||
|
||||
public virtual ActionResult Index()
|
||||
{
|
||||
return View(Views.Editor, new Models.Expressions.EditorModel()
|
||||
{
|
||||
Expression = @"JobComponentsTotalCost() < 100 ? JobComponentsTotalCost().ToString('c') : '$100.00'"
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Disco.Services.Logging;
|
||||
using Disco.Services.Logging.Models;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Controllers
|
||||
{
|
||||
public partial class LoggingController : dbAdminController
|
||||
{
|
||||
//
|
||||
// GET: /Config/Logs/
|
||||
|
||||
public virtual ActionResult Index()
|
||||
{
|
||||
var m = new Models.Logging.IndexModel()
|
||||
{
|
||||
LogModules = new Dictionary<LogBase, List<LogEventType>>()
|
||||
};
|
||||
foreach (var logModule in LogContext.LogModules.Values)
|
||||
{
|
||||
m.LogModules.Add(logModule, logModule.EventTypes.Values.Where(et => et.UsePersist).ToList());
|
||||
}
|
||||
|
||||
return View(m);
|
||||
}
|
||||
|
||||
public virtual ActionResult TaskStatus(string id)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(id))
|
||||
{
|
||||
string sessionId;
|
||||
do
|
||||
{
|
||||
System.Threading.Thread.Sleep(100);
|
||||
sessionId = Disco.Services.Tasks.ScheduledTasks.GetTaskStatuses(typeof(Disco.BI.Interop.ActiveDirectory.ActiveDirectoryUpdateLastNetworkLogonDateJob)).Select(t => t.SessionId).FirstOrDefault();
|
||||
} while (sessionId == null);
|
||||
|
||||
return View(new Models.Logging.TaskStatusModel() { SessionId = sessionId });
|
||||
}
|
||||
else
|
||||
{
|
||||
var taskStatus = Disco.Services.Tasks.ScheduledTasks.GetTaskStatus(id);
|
||||
return View(new Models.Logging.TaskStatusModel() { SessionId = taskStatus.SessionId });
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Controllers
|
||||
{
|
||||
public partial class OrganisationController : dbAdminController
|
||||
{
|
||||
//
|
||||
// GET: /Config/Organisation/
|
||||
|
||||
public virtual ActionResult Index()
|
||||
{
|
||||
var viewModel = new Models.Organisation.IndexModel();
|
||||
|
||||
viewModel.OrganisationName = dbContext.DiscoConfiguration.OrganisationName;
|
||||
viewModel.MultiSiteMode = dbContext.DiscoConfiguration.MultiSiteMode;
|
||||
viewModel.OrganisationAddresses = dbContext.DiscoConfiguration.OrganisationAddresses.Addresses;
|
||||
|
||||
return View(viewModel);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Disco.Services.Plugins;
|
||||
using Disco.Web.Areas.Config.Models.Plugins;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Controllers
|
||||
{
|
||||
public partial class PluginsController : dbAdminController
|
||||
{
|
||||
[HttpGet]
|
||||
public virtual ActionResult Index()
|
||||
{
|
||||
Models.Plugins.IndexViewModel vm = new Models.Plugins.IndexViewModel()
|
||||
{
|
||||
PluginManifests = Plugins.GetPlugins()
|
||||
};
|
||||
return View(vm);
|
||||
}
|
||||
|
||||
#region Plugin Configuration
|
||||
[HttpPost]
|
||||
public virtual ActionResult Configure(string PluginId, FormCollection form)
|
||||
{
|
||||
if (string.IsNullOrEmpty(PluginId))
|
||||
return RedirectToAction(MVC.Config.Plugins.Index());
|
||||
|
||||
PluginManifest manifest = Plugins.GetPlugin(PluginId);
|
||||
|
||||
using (PluginConfigurationHandler configHandler = manifest.CreateConfigurationHandler())
|
||||
{
|
||||
if (configHandler.Post(dbContext, form, this))
|
||||
{
|
||||
dbContext.SaveChanges();
|
||||
|
||||
PluginsLog.LogPluginConfigurationSaved(manifest.Id, DiscoApplication.CurrentUser.Id);
|
||||
|
||||
return RedirectToAction(MVC.Config.Plugins.Index());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Config Errors
|
||||
PluginConfigurationViewModel vm = new PluginConfigurationViewModel(configHandler.Get(dbContext, this));
|
||||
return View(Views.Configure, vm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public virtual ActionResult Configure(string PluginId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(PluginId))
|
||||
return RedirectToAction(MVC.Config.Plugins.Index());
|
||||
|
||||
PluginManifest manifest = Plugins.GetPlugin(PluginId);
|
||||
|
||||
using (PluginConfigurationHandler configHandler = manifest.CreateConfigurationHandler())
|
||||
{
|
||||
PluginConfigurationViewModel vm = new PluginConfigurationViewModel(configHandler.Get(dbContext, this));
|
||||
PluginsLog.LogPluginConfigurationLoaded(manifest.Id, DiscoApplication.CurrentUser.Id);
|
||||
return View(Views.Configure, vm);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
//public virtual ActionResult PluginAction(string PluginId, string PluginAction)
|
||||
//{
|
||||
// if (string.IsNullOrEmpty(PluginId))
|
||||
// return HttpNotFound("PluginId is Required");
|
||||
// if (string.IsNullOrEmpty(PluginAction))
|
||||
// return HttpNotFound("PluginAction is Required");
|
||||
|
||||
// PluginManifest def = Plugins.GetPlugin(PluginId);
|
||||
|
||||
// using (Plugin instance = def.CreateInstance())
|
||||
// {
|
||||
// IPluginWebController instanceController = instance as IPluginWebController;
|
||||
|
||||
// if (instanceController == null)
|
||||
// return HttpNotFound("Plugin is not a Web Controller");
|
||||
|
||||
// PluginsLog.LogPluginWebControllerAccessed(instance.Id, PluginAction, DiscoApplication.CurrentUser.Id);
|
||||
|
||||
// try
|
||||
// {
|
||||
// return instanceController.ExecuteAction(PluginAction, this);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// PluginsLog.LogPluginException("Disco Plugin Web Controller Action", new PluginWebControllerException(instance.Id, PluginAction, ex));
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Controllers
|
||||
{
|
||||
public partial class SystemConfigController : dbAdminController
|
||||
{
|
||||
[HttpGet]
|
||||
public virtual ActionResult Index()
|
||||
{
|
||||
var m = Models.SystemConfig.IndexModel.FromConfiguration(dbContext.DiscoConfiguration);
|
||||
return View(m);
|
||||
}
|
||||
[HttpPost]
|
||||
public virtual ActionResult Index(Models.SystemConfig.IndexModel config)
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
config.ToConfiguration(dbContext);
|
||||
return RedirectToAction(MVC.Config.Config.Index());
|
||||
}
|
||||
else
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.Models.BI.Interop.Community;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.Config
|
||||
{
|
||||
public class IndexModel
|
||||
{
|
||||
public bool UpdateAvailable
|
||||
{
|
||||
get
|
||||
{
|
||||
if (UpdateResponse != null)
|
||||
{
|
||||
var updateVersion = Version.Parse(UpdateResponse.Version);
|
||||
return (updateVersion > typeof(DiscoApplication).Assembly.GetName().Version);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public UpdateResponse UpdateResponse { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.Data.Repository;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.DeviceBatch
|
||||
{
|
||||
public class IndexModel
|
||||
{
|
||||
public List<_IndexModelDeviceBatch> DeviceBatches { get; set; }
|
||||
|
||||
public static IndexModel Build(DiscoDataContext dbContext)
|
||||
{
|
||||
var m = new IndexModel();
|
||||
m.DeviceBatches = dbContext.DeviceBatches.OrderBy(db => db.Name).Select(db => new _IndexModelDeviceBatch()
|
||||
{
|
||||
Id = db.Id,
|
||||
Name = db.Name,
|
||||
PurchaseDate = db.PurchaseDate,
|
||||
PurchaseUnitQuantity = db.UnitQuantity,
|
||||
DeviceCount = db.Devices.Count,
|
||||
DeviceDecommissionedCount = db.Devices.Count(d=> d.DecommissionedDate.HasValue),
|
||||
DefaultDeviceModel = db.DefaultDeviceModel.Description,
|
||||
WarrantyExpires = db.WarrantyValidUntil,
|
||||
InsuranceSupplier = db.InsuranceSupplier,
|
||||
InsuredUntil = db.InsuredUntil
|
||||
}).ToList();
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.DeviceBatch
|
||||
{
|
||||
public class ShowModel
|
||||
{
|
||||
public Disco.Models.Repository.DeviceBatch DeviceBatch { get; set; }
|
||||
public List<SelectListItem> DeviceModels { get; set; }
|
||||
public int DeviceCount { get; set; }
|
||||
public int DeviceDecommissionedCount { get; set; }
|
||||
public bool CanDelete { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.DeviceBatch
|
||||
{
|
||||
public class _IndexModelDeviceBatch
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
[Required(), DisplayFormat(ApplyFormatInEditMode = true, ConvertEmptyStringToNull = true, DataFormatString = "{0:yyyy/MM/dd}", HtmlEncode = false)]
|
||||
public DateTime PurchaseDate { get; set; }
|
||||
public int DeviceCount { get; set; }
|
||||
public int DeviceDecommissionedCount { get; set; }
|
||||
public int? PurchaseUnitQuantity { get; set; }
|
||||
public string DefaultDeviceModel { get; set; }
|
||||
public DateTime? WarrantyExpires { get; set; }
|
||||
public DateTime? InsuredUntil { get; set; }
|
||||
public string InsuranceSupplier { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.DeviceModel
|
||||
{
|
||||
public class DeviceComponentsModel
|
||||
{
|
||||
public int? DeviceModelId { get; set; }
|
||||
public List<Disco.Models.Repository.DeviceComponent> DeviceComponents { get; set; }
|
||||
|
||||
public List<Disco.Models.Repository.JobSubType> JobSubTypes { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.Data.Repository;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.DeviceModel
|
||||
{
|
||||
public class IndexModel
|
||||
{
|
||||
public List<_IndexModelDeviceModel> DeviceModels { get; set; }
|
||||
|
||||
public static IndexModel Build(DiscoDataContext dbContext)
|
||||
{
|
||||
var m = new IndexModel();
|
||||
m.DeviceModels = dbContext.DeviceModels.OrderBy(dm => dm.Description).Select(dm => new _IndexModelDeviceModel()
|
||||
{
|
||||
Id = dm.Id,
|
||||
Name = dm.Description,
|
||||
Manufacturer = dm.Manufacturer,
|
||||
Model = dm.Model,
|
||||
ModelType = dm.ModelType,
|
||||
DeviceCount = dm.Devices.Count
|
||||
}).ToList();
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.Services.Plugins;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.DeviceModel
|
||||
{
|
||||
public class ShowModel
|
||||
{
|
||||
public Disco.Models.Repository.DeviceModel DeviceModel { get; set; }
|
||||
|
||||
public Models.DeviceModel.DeviceComponentsModel DeviceComponentsModel { get; set; }
|
||||
|
||||
public List<PluginFeatureManifest> WarrantyProviders { get; set; }
|
||||
|
||||
public bool CanDelete { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.DeviceModel
|
||||
{
|
||||
public class _IndexModelDeviceModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Manufacturer { get; set; }
|
||||
public string Model { get; set; }
|
||||
public string ModelType { get; set; }
|
||||
public int DeviceCount { get; set; }
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Name))
|
||||
return string.Format("{0} {1}", Manufacturer, Model);
|
||||
else
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.DeviceProfile
|
||||
{
|
||||
public class DefaultsModel
|
||||
{
|
||||
public List<Disco.Models.Repository.DeviceProfile> DeviceProfiles { get; set; }
|
||||
public List<Disco.Models.Repository.DeviceProfile> DeviceProfilesAndNone { get; set; }
|
||||
public int Default { get; set; }
|
||||
public int DefaultAddDeviceOffline { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.Data.Repository;
|
||||
using Disco.BI.Extensions;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.DeviceProfile
|
||||
{
|
||||
public class IndexModel
|
||||
{
|
||||
public List<_IndexModelDeviceProfile> DeviceProfiles { get; set; }
|
||||
|
||||
public static IndexModel Build(DiscoDataContext dbContext)
|
||||
{
|
||||
var m = new IndexModel();
|
||||
m.DeviceProfiles = dbContext.DeviceProfiles.OrderBy(dp => dp.Name).Select(dp => new _IndexModelDeviceProfile()
|
||||
{
|
||||
Id = dp.Id,
|
||||
Name = dp.Name,
|
||||
ShortName = dp.ShortName,
|
||||
Address = dp.DefaultOrganisationAddress,
|
||||
Description = dp.Description,
|
||||
DistributionTypeId = dp.DistributionTypeDb,
|
||||
DeviceCount = dp.Devices.Count,
|
||||
DeviceDecommissionedCount = dp.Devices.Count(d => d.DecommissionedDate.HasValue)
|
||||
}).ToList();
|
||||
|
||||
if (DiscoApplication.MultiSiteMode)
|
||||
{
|
||||
foreach (var dp in m.DeviceProfiles)
|
||||
if (dp.Address.HasValue)
|
||||
dp.AddressName = dbContext.DiscoConfiguration.OrganisationAddresses.GetAddress(dp.Address.Value).Name;
|
||||
}
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Disco.Services.Plugins;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.DeviceProfile
|
||||
{
|
||||
public class ShowModel
|
||||
{
|
||||
public Disco.Models.Repository.DeviceProfile DeviceProfile { get; set; }
|
||||
public List<SelectListItem> DeviceProfileDistributionTypes { get; set; }
|
||||
public List<Disco.Models.BI.Config.OrganisationAddress> OrganisationAddresses { get; set; }
|
||||
|
||||
public List<PluginFeatureManifest> CertificateProviders { get; set; }
|
||||
|
||||
public bool CanDelete { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.DeviceProfile
|
||||
{
|
||||
public class _IndexModelDeviceProfile
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string ShortName { get; set; }
|
||||
public int? Address { get; set; }
|
||||
//public string AddressShortName { get; set; }
|
||||
public string AddressName { get; set; }
|
||||
public string Description { get; set; }
|
||||
public int DistributionTypeId { get; set; }
|
||||
|
||||
public string DistributionType
|
||||
{
|
||||
get
|
||||
{
|
||||
return Enum.GetName(typeof(Disco.Models.Repository.DeviceProfile.DistributionTypes), this.DistributionTypeId);
|
||||
}
|
||||
}
|
||||
|
||||
public int DeviceCount { get; set; }
|
||||
public int DeviceDecommissionedCount { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Disco.Data.Repository;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.DocumentTemplate
|
||||
{
|
||||
[CustomValidation(typeof(CreateModelValidation), "ValidateCreateModel")]
|
||||
public class CreateModel
|
||||
{
|
||||
public Disco.Models.Repository.DocumentTemplate DocumentTemplate { get; set; }
|
||||
|
||||
[Required]
|
||||
public HttpPostedFileBase Template { get; set; }
|
||||
|
||||
public List<string> Types { get; set; }
|
||||
public List<string> SubTypes { get; set; }
|
||||
|
||||
public List<Disco.Models.Repository.JobType> JobTypes { get; set; }
|
||||
public List<Disco.Models.Repository.JobSubType> JobSubTypes { get; set; }
|
||||
|
||||
public List<string> Scopes
|
||||
{
|
||||
get
|
||||
{
|
||||
return Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public List<Disco.Models.Repository.JobType> GetJobTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Types != null)
|
||||
{
|
||||
var types = this.Types;
|
||||
return this.JobTypes.Where(m => types.Contains(m.Id)).ToList();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public List<Disco.Models.Repository.JobSubType> 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 void UpdateModel(DiscoDataContext dbContext)
|
||||
{
|
||||
if (this.JobTypes == null)
|
||||
JobTypes = dbContext.JobTypes.ToList();
|
||||
if (this.JobSubTypes == null)
|
||||
JobSubTypes = dbContext.JobSubTypes.ToList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class CreateModelValidation
|
||||
{
|
||||
|
||||
public static ValidationResult ValidateCreateModel(CreateModel model)
|
||||
{
|
||||
|
||||
if (model.DocumentTemplate != null && model.DocumentTemplate.Scope == Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.Job)
|
||||
{
|
||||
if (model.Types != null && model.SubTypes != null)
|
||||
{
|
||||
var typeId = string.Format("{0}_", model.Types);
|
||||
model.SubTypes = model.SubTypes.Where(m => model.Types.Contains(m.Substring(0, m.IndexOf("_")))).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
return ValidationResult.Success;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.DocumentTemplate
|
||||
{
|
||||
public class ExpressionBrowserModel
|
||||
{
|
||||
public string DeviceType { get; set; }
|
||||
public string UserType { get; set; }
|
||||
public string JobType { get; set; }
|
||||
|
||||
//public string DataExtType { get; set; }
|
||||
//public string DeviceExtType { get; set; }
|
||||
//public string UserExtType { get; set; }
|
||||
|
||||
public Dictionary<string, string> Variables { get; set; }
|
||||
public Dictionary<string, string> ExtensionLibraries { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.DocumentTemplate
|
||||
{
|
||||
public class IndexModel
|
||||
{
|
||||
public List<Disco.Models.Repository.DocumentTemplate> DocumentTemplates { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.Data.Repository;
|
||||
using Disco.Models.Repository;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.DocumentTemplate
|
||||
{
|
||||
public class ShowModel
|
||||
{
|
||||
public Disco.Models.Repository.DocumentTemplate DocumentTemplate { get; set; }
|
||||
|
||||
public int StoredInstanceCount { get; set; }
|
||||
|
||||
public List<Disco.BI.Expressions.Expression> TemplateExpressions { get; set; }
|
||||
|
||||
public List<string> Types { get; set; }
|
||||
public List<string> SubTypes { get; set; }
|
||||
|
||||
public List<Disco.Models.Repository.JobType> JobTypes { get; set; }
|
||||
public List<Disco.Models.Repository.JobSubType> JobSubTypes { get; set; }
|
||||
|
||||
public ShowModel()
|
||||
{
|
||||
this.Types = new List<string>();
|
||||
this.SubTypes = new List<string>();
|
||||
}
|
||||
|
||||
public List<string> Scopes
|
||||
{
|
||||
get
|
||||
{
|
||||
return Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateModel(DiscoDataContext dbContext)
|
||||
{
|
||||
|
||||
switch (this.DocumentTemplate.Scope)
|
||||
{
|
||||
case Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.Device:
|
||||
this.StoredInstanceCount = dbContext.DeviceAttachments.Count(a => a.DocumentTemplateId == this.DocumentTemplate.Id);
|
||||
break;
|
||||
case Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.Job:
|
||||
this.StoredInstanceCount = dbContext.JobAttachments.Count(a => a.DocumentTemplateId == this.DocumentTemplate.Id);
|
||||
break;
|
||||
case Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.User:
|
||||
this.StoredInstanceCount = dbContext.UserAttachments.Count(a => a.DocumentTemplateId == this.DocumentTemplate.Id);
|
||||
break;
|
||||
}
|
||||
|
||||
if (this.JobTypes == null)
|
||||
JobTypes = dbContext.JobTypes.ToList();
|
||||
if (this.JobSubTypes == null)
|
||||
JobSubTypes = dbContext.JobSubTypes.ToList();
|
||||
|
||||
if (DocumentTemplate != null)
|
||||
{
|
||||
if (DocumentTemplate.JobSubTypes != null)
|
||||
{
|
||||
foreach (var jst in DocumentTemplate.JobSubTypes)
|
||||
{
|
||||
if (!Types.Contains(jst.JobTypeId))
|
||||
Types.Add(jst.JobTypeId);
|
||||
SubTypes.Add(string.Format("{0}_{1}", jst.JobTypeId, jst.Id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
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.Areas.Config.Models.DocumentTemplate
|
||||
{
|
||||
public class UndetectedPagesModel
|
||||
{
|
||||
|
||||
public List<Disco.Models.Repository.DocumentTemplate> DocumentTemplates { get; set; }
|
||||
|
||||
public List<SelectListItem> DocumentTemplatesSelectListItems
|
||||
{
|
||||
get
|
||||
{
|
||||
var list = new List<SelectListItem>();
|
||||
list.Add(new SelectListItem() { Selected = false, Value = "--DEVICE", Text = "<Generic Device Document>" });
|
||||
list.Add(new SelectListItem() { Selected = true, Value = "--JOB", Text = "<Generic Job Document>" });
|
||||
list.Add(new SelectListItem() { Selected = false, Value = "--USER", Text = "<Generic User Document>" });
|
||||
list.AddRange(this.DocumentTemplates.ToSelectListItems());
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.Enrolment
|
||||
{
|
||||
public class IndexModel
|
||||
{
|
||||
public string MacSshUsername { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.Expressions
|
||||
{
|
||||
public class EditorModel
|
||||
{
|
||||
public string Expression { get; set; }
|
||||
public Disco.Web.Areas.API.Models.Expressions.ValidateExpressionModel ExpressionException { get; set; }
|
||||
public string TestScope { get; set; }
|
||||
public string TestScopeDataType { get; set; }
|
||||
public string TestScopeDataId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.Services.Logging;
|
||||
using Disco.Services.Logging.Models;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.Logging
|
||||
{
|
||||
public class IndexModel
|
||||
{
|
||||
public Dictionary<LogBase, List<LogEventType>> LogModules { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.Logging
|
||||
{
|
||||
public class TaskStatusModel
|
||||
{
|
||||
public string SessionId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.Models.BI.Config;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.Organisation
|
||||
{
|
||||
public class IndexModel
|
||||
{
|
||||
public string OrganisationName { get; set; }
|
||||
[Display(Name="Enabled")]
|
||||
public bool MultiSiteMode { get; set; }
|
||||
public List<OrganisationAddress> OrganisationAddresses { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.Services.Plugins;
|
||||
using Disco.Services.Plugins.Features.Other;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.Plugins
|
||||
{
|
||||
public class IndexViewModel
|
||||
{
|
||||
public List<PluginManifest> PluginManifests { get; set; }
|
||||
|
||||
public List<Tuple<Type, List<PluginManifest>>> PluginManifestsByType
|
||||
{
|
||||
get
|
||||
{
|
||||
if (PluginManifests.Count == 0)
|
||||
return new List<Tuple<Type, List<PluginManifest>>>();
|
||||
|
||||
var categorisedManifests = PluginManifests.SelectMany(pm => pm.Features)
|
||||
.GroupBy(fm => fm.CategoryType)
|
||||
.Select(g => new Tuple<Type, List<PluginManifest>>(g.Key, g.Select(fm => fm.PluginManifest).Distinct().OrderBy(fm => fm.Name).ToList())).ToList();
|
||||
|
||||
// Ensure all plugins are represented
|
||||
var allCategorisedManifests = categorisedManifests.SelectMany(g => g.Item2).ToList();
|
||||
|
||||
var unrepresentedPlugins = PluginManifests.Where(m => !allCategorisedManifests.Contains(m)).ToList();
|
||||
if (unrepresentedPlugins.Count > 0)
|
||||
{
|
||||
Tuple<Type, List<PluginManifest>> otherCategory = null;
|
||||
foreach (var category in categorisedManifests)
|
||||
{
|
||||
if (category.Item1 == typeof(OtherFeature))
|
||||
{
|
||||
otherCategory = category;
|
||||
}
|
||||
}
|
||||
if (otherCategory == null)
|
||||
{
|
||||
otherCategory = new Tuple<Type, List<PluginManifest>>(typeof(OtherFeature), new List<PluginManifest>());
|
||||
categorisedManifests.Add(otherCategory);
|
||||
}
|
||||
foreach (var pluginManifest in unrepresentedPlugins)
|
||||
otherCategory.Item2.Add(pluginManifest);
|
||||
}
|
||||
|
||||
return categorisedManifests;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.Services.Plugins;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.Plugins
|
||||
{
|
||||
public class PluginConfigurationViewModel
|
||||
{
|
||||
public PluginManifest Manifest { get; set; }
|
||||
public Type PluginViewType { get; set; }
|
||||
public object PluginViewModel { get; set; }
|
||||
|
||||
public PluginConfigurationViewModel(PluginConfigurationHandler.PluginConfigurationHandlerGetResponse response)
|
||||
{
|
||||
this.Manifest = response.Manifest;
|
||||
|
||||
this.PluginViewType = response.ViewType;
|
||||
this.PluginViewModel = response.ViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.Shared
|
||||
{
|
||||
public class LogEventsModel
|
||||
{
|
||||
public bool IsLive { get; set; }
|
||||
public Disco.Services.Logging.LogBase ModuleFilter { get; set; }
|
||||
public IEnumerable<Disco.Services.Logging.Models.LogEventType> EventTypesFilter { get; set; }
|
||||
public int? TakeFilter { get; set; }
|
||||
public DateTime? StartFilter { get; set; }
|
||||
public DateTime? EndFilter { get; set; }
|
||||
public int? ViewPortHeight { get; set; }
|
||||
public int? ViewPortWidth { get; set; }
|
||||
public string JavascriptLiveEventFunctionName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Disco.Data.Configuration;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Data.SqlClient;
|
||||
using Disco.Data.Repository;
|
||||
using Disco.Models.BI.Interop.Community;
|
||||
using Disco.Services.Tasks;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.SystemConfig
|
||||
{
|
||||
public class IndexModel
|
||||
{
|
||||
public Version DiscoVersion { get; set; }
|
||||
public DateTime? DiscoVersionBuilt
|
||||
{
|
||||
get
|
||||
{
|
||||
var v = DiscoVersion;
|
||||
if (v != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new DateTime(v.Minor + 2011, v.Build / 100, v.Build % 100, v.Revision / 100, v.Revision % 100, 0);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public string DataStoreLocation { get; set; }
|
||||
|
||||
#region Database Connection
|
||||
private Lazy<SqlConnectionStringBuilder> DatabaseConnectionString = new Lazy<SqlConnectionStringBuilder>(() =>
|
||||
{
|
||||
return new SqlConnectionStringBuilder(Disco.Data.Repository.DiscoDatabaseConnectionFactory.DiscoDataContextConnectionString);
|
||||
});
|
||||
public string DatabaseServer
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.DatabaseConnectionString.Value.DataSource;
|
||||
}
|
||||
}
|
||||
public string DatabaseName
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.DatabaseConnectionString.Value.InitialCatalog;
|
||||
}
|
||||
}
|
||||
public string DatabaseAuthentication
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.DatabaseConnectionString.Value.IntegratedSecurity ? "Integrated Authentication" : "SQL Authentication";
|
||||
}
|
||||
}
|
||||
public string DatabaseSqlAuthUsername
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.DatabaseConnectionString.Value.IntegratedSecurity ? null : this.DatabaseConnectionString.Value.UserID;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Proxy
|
||||
public string ProxyAddress { get; set; }
|
||||
public int ProxyPort { get; set; }
|
||||
public string ProxyUsername { get; set; }
|
||||
[DataType(DataType.Password)]
|
||||
public string ProxyPassword { get; set; }
|
||||
#endregion
|
||||
|
||||
public ScheduledTaskStatus UpdateRunningStatus { get; set; }
|
||||
public DateTime? UpdateNextScheduled { get; set; }
|
||||
public UpdateResponse UpdateLatestResponse { get; set; }
|
||||
public bool UpdateBetaDeployment { get; set; }
|
||||
|
||||
public static IndexModel FromConfiguration(ConfigurationContext config)
|
||||
{
|
||||
return new IndexModel()
|
||||
{
|
||||
DiscoVersion = typeof(DiscoApplication).Assembly.GetName().Version,
|
||||
DataStoreLocation = config.DataStoreLocation,
|
||||
ProxyAddress = config.ProxyAddress,
|
||||
ProxyPort = config.ProxyPort,
|
||||
ProxyUsername = config.ProxyUsername,
|
||||
ProxyPassword = config.ProxyPassword,
|
||||
UpdateLatestResponse = config.UpdateLastCheck,
|
||||
UpdateRunningStatus = Disco.BI.Interop.Community.UpdateCheckTask.RunningStatus,
|
||||
UpdateNextScheduled = Disco.BI.Interop.Community.UpdateCheckTask.NextScheduled,
|
||||
UpdateBetaDeployment = config.UpdateBetaDeployment
|
||||
};
|
||||
}
|
||||
|
||||
public void ToConfiguration(DiscoDataContext db)
|
||||
{
|
||||
ConfigurationContext config = db.DiscoConfiguration;
|
||||
//config.DataStoreLocation = DataStoreLocation;
|
||||
config.ProxyAddress = ProxyAddress;
|
||||
config.ProxyPort = ProxyPort;
|
||||
config.ProxyUsername = ProxyUsername;
|
||||
config.ProxyPassword = ProxyPassword;
|
||||
DiscoApplication.SetGlobalProxy(ProxyAddress, ProxyPort, ProxyUsername, ProxyPassword);
|
||||
|
||||
db.SaveChanges();
|
||||
|
||||
// Try and check for updates if needed - After Proxy Changed
|
||||
if (db.DiscoConfiguration.UpdateLastCheck == null
|
||||
|| db.DiscoConfiguration.UpdateLastCheck.ResponseTimestamp < DateTime.Now.AddDays(-1))
|
||||
{
|
||||
Disco.BI.Interop.Community.UpdateCheckTask.ScheduleNow();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Areas.Config.Models.WirelessCertificate
|
||||
{
|
||||
public class IndexModel
|
||||
{
|
||||
public int Total { get; set; }
|
||||
public int Unallocated { get; set; }
|
||||
public int Allocated { get; set; }
|
||||
public string Provider { get; set; }
|
||||
public int AutoBufferMax { get; set; }
|
||||
public int AutoBufferLow { get; set; }
|
||||
public bool Processing { get; set; }
|
||||
|
||||
public string eduSTAR_SchoolId { get; set; }
|
||||
public string eduSTAR_Username { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
@model Disco.Web.Areas.Config.Models.Config.IndexModel
|
||||
@{
|
||||
ViewBag.Title = "Configuration";
|
||||
}
|
||||
<table id="pageMenu">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="pageMenuArea">
|
||||
<h2>Hosting</h2>
|
||||
@Html.ActionLinkClass("System", MVC.Config.SystemConfig.Index(), "config")
|
||||
<div class="pageMenuBlurb">
|
||||
Update system configuration, such as the Data Storage Location and Proxy settings.
|
||||
</div>
|
||||
@Html.ActionLinkClass("Organisation Details", MVC.Config.Organisation.Index(), "config")
|
||||
<div class="pageMenuBlurb">
|
||||
Update the Organisation Name, Logo and Addresses associated with this organisation.
|
||||
</div>
|
||||
@Html.ActionLinkClass("Logging", MVC.Config.Logging.Index(), "config")
|
||||
<div class="pageMenuBlurb">
|
||||
Export Log files from various Disco Modules and view Live Logging.
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="pageMenuArea">
|
||||
<h2>Devices</h2>
|
||||
@Html.ActionLinkClass("Models", MVC.Config.DeviceModel.Index(), "config")
|
||||
<div class="pageMenuBlurb">
|
||||
Configure Components, Product Images and default settings for Device Models.
|
||||
</div>
|
||||
@Html.ActionLinkClass("Batches", MVC.Config.DeviceBatch.Index(), "config")
|
||||
<div class="pageMenuBlurb">
|
||||
Create and Configure Device Batches.
|
||||
</div>
|
||||
@Html.ActionLinkClass("Profiles", MVC.Config.DeviceProfile.Index(), "config")
|
||||
<div class="pageMenuBlurb">
|
||||
Configure Device Profiles including computer name generation, distribution and Active
|
||||
Directory OU layout.
|
||||
</div>
|
||||
@Html.ActionLinkClass("Enrolment", MVC.Config.Enrolment.Index(), "config")
|
||||
<div class="pageMenuBlurb">
|
||||
Configure Enrolment settings including secure credentials.
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="pageMenuArea">
|
||||
<h2>Features</h2>
|
||||
@Html.ActionLinkClass("Document Templates", MVC.Config.DocumentTemplate.Index(), "config")
|
||||
<div class="pageMenuBlurb">
|
||||
Create, Update and Bulk Generate documents based on PDF Templates for Jobs, Devices
|
||||
and Users.
|
||||
</div>
|
||||
@Html.ActionLinkClass("Plugins", MVC.Config.Plugins.Index(), "config")
|
||||
<div class="pageMenuBlurb">
|
||||
Manage extensions to the Disco platform.
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@{
|
||||
if (Model.UpdateAvailable)
|
||||
{
|
||||
<div id="updateAvailableContainer">
|
||||
<div>An updated version of Disco is available</div>
|
||||
<a href="@Model.UpdateResponse.UrlLink" target="_blank">Download Disco v@(Model.UpdateResponse.Version)</a>
|
||||
</div>
|
||||
<script>
|
||||
(function () {
|
||||
$(function () {
|
||||
var layout_PageHeading = $('#layout_PageHeading').height(80);
|
||||
var updateAvailableContainer = $('#updateAvailableContainer');
|
||||
updateAvailableContainer.appendTo(layout_PageHeading);
|
||||
@{
|
||||
if (Model.UpdateResponse.VersionReleasedTimestamp < DateTime.Now.AddDays(-7))
|
||||
{
|
||||
<text>
|
||||
updateAvailableContainer.effect("shake", { times: 3 }, 100);
|
||||
</text>
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,304 @@
|
||||
#pragma warning disable 1591
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17929
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Disco.Web.Areas.Config.Views.Config
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Helpers;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Ajax;
|
||||
using System.Web.Mvc.Html;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.WebPages;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/Config/Index.cshtml")]
|
||||
public class Index : System.Web.Mvc.WebViewPage<Disco.Web.Areas.Config.Models.Config.IndexModel>
|
||||
{
|
||||
public Index()
|
||||
{
|
||||
}
|
||||
public override void Execute()
|
||||
{
|
||||
|
||||
#line 2 "..\..\Areas\Config\Views\Config\Index.cshtml"
|
||||
|
||||
ViewBag.Title = "Configuration";
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n<table");
|
||||
|
||||
WriteLiteral(" id=\"pageMenu\"");
|
||||
|
||||
WriteLiteral(">\r\n <tr>\r\n <td>\r\n <div");
|
||||
|
||||
WriteLiteral(" class=\"pageMenuArea\"");
|
||||
|
||||
WriteLiteral(">\r\n <h2>Hosting</h2>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 10 "..\..\Areas\Config\Views\Config\Index.cshtml"
|
||||
Write(Html.ActionLinkClass("System", MVC.Config.SystemConfig.Index(), "config"));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n <div");
|
||||
|
||||
WriteLiteral(" class=\"pageMenuBlurb\"");
|
||||
|
||||
WriteLiteral(">\r\n Update system configuration, such as the Data Storage Loca" +
|
||||
"tion and Proxy settings.\r\n </div>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 14 "..\..\Areas\Config\Views\Config\Index.cshtml"
|
||||
Write(Html.ActionLinkClass("Organisation Details", MVC.Config.Organisation.Index(), "config"));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n <div");
|
||||
|
||||
WriteLiteral(" class=\"pageMenuBlurb\"");
|
||||
|
||||
WriteLiteral(">\r\n Update the Organisation Name, Logo and Addresses associate" +
|
||||
"d with this organisation.\r\n </div>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 18 "..\..\Areas\Config\Views\Config\Index.cshtml"
|
||||
Write(Html.ActionLinkClass("Logging", MVC.Config.Logging.Index(), "config"));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n <div");
|
||||
|
||||
WriteLiteral(" class=\"pageMenuBlurb\"");
|
||||
|
||||
WriteLiteral(">\r\n Export Log files from various Disco Modules and view Live " +
|
||||
"Logging.\r\n </div>\r\n </div>\r\n </td>\r\n <td" +
|
||||
">\r\n <div");
|
||||
|
||||
WriteLiteral(" class=\"pageMenuArea\"");
|
||||
|
||||
WriteLiteral(">\r\n <h2>Devices</h2>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 27 "..\..\Areas\Config\Views\Config\Index.cshtml"
|
||||
Write(Html.ActionLinkClass("Models", MVC.Config.DeviceModel.Index(), "config"));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n <div");
|
||||
|
||||
WriteLiteral(" class=\"pageMenuBlurb\"");
|
||||
|
||||
WriteLiteral(">\r\n Configure Components, Product Images and default settings " +
|
||||
"for Device Models.\r\n </div>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 31 "..\..\Areas\Config\Views\Config\Index.cshtml"
|
||||
Write(Html.ActionLinkClass("Batches", MVC.Config.DeviceBatch.Index(), "config"));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n <div");
|
||||
|
||||
WriteLiteral(" class=\"pageMenuBlurb\"");
|
||||
|
||||
WriteLiteral(">\r\n Create and Configure Device Batches.\r\n </di" +
|
||||
"v>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 35 "..\..\Areas\Config\Views\Config\Index.cshtml"
|
||||
Write(Html.ActionLinkClass("Profiles", MVC.Config.DeviceProfile.Index(), "config"));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n <div");
|
||||
|
||||
WriteLiteral(" class=\"pageMenuBlurb\"");
|
||||
|
||||
WriteLiteral(">\r\n Configure Device Profiles including computer name generati" +
|
||||
"on, distribution and Active\r\n Directory OU layout.\r\n " +
|
||||
" </div>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 40 "..\..\Areas\Config\Views\Config\Index.cshtml"
|
||||
Write(Html.ActionLinkClass("Enrolment", MVC.Config.Enrolment.Index(), "config"));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n <div");
|
||||
|
||||
WriteLiteral(" class=\"pageMenuBlurb\"");
|
||||
|
||||
WriteLiteral(">\r\n Configure Enrolment settings including secure credentials." +
|
||||
"\r\n </div>\r\n </div>\r\n </td>\r\n <td>\r\n " +
|
||||
" <div");
|
||||
|
||||
WriteLiteral(" class=\"pageMenuArea\"");
|
||||
|
||||
WriteLiteral(">\r\n <h2>Features</h2>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 49 "..\..\Areas\Config\Views\Config\Index.cshtml"
|
||||
Write(Html.ActionLinkClass("Document Templates", MVC.Config.DocumentTemplate.Index(), "config"));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n <div");
|
||||
|
||||
WriteLiteral(" class=\"pageMenuBlurb\"");
|
||||
|
||||
WriteLiteral(">\r\n Create, Update and Bulk Generate documents based on PDF Te" +
|
||||
"mplates for Jobs, Devices\r\n and Users.\r\n </div" +
|
||||
">\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 54 "..\..\Areas\Config\Views\Config\Index.cshtml"
|
||||
Write(Html.ActionLinkClass("Plugins", MVC.Config.Plugins.Index(), "config"));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n <div");
|
||||
|
||||
WriteLiteral(" class=\"pageMenuBlurb\"");
|
||||
|
||||
WriteLiteral(">\r\n Manage extensions to the Disco platform.\r\n " +
|
||||
"</div>\r\n </div>\r\n </td>\r\n </tr>\r\n</table>\r\n");
|
||||
|
||||
|
||||
#line 62 "..\..\Areas\Config\Views\Config\Index.cshtml"
|
||||
|
||||
if (Model.UpdateAvailable)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" id=\"updateAvailableContainer\"");
|
||||
|
||||
WriteLiteral(">\r\n <div>An updated version of Disco is available</div>\r\n <a");
|
||||
|
||||
WriteAttribute("href", Tuple.Create(" href=\"", 3034), Tuple.Create("\"", 3070)
|
||||
|
||||
#line 67 "..\..\Areas\Config\Views\Config\Index.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 3041), Tuple.Create<System.Object, System.Int32>(Model.UpdateResponse.UrlLink
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 3041), false)
|
||||
);
|
||||
|
||||
WriteLiteral(" target=\"_blank\"");
|
||||
|
||||
WriteLiteral(">Download Disco v");
|
||||
|
||||
|
||||
#line 67 "..\..\Areas\Config\Views\Config\Index.cshtml"
|
||||
Write(Model.UpdateResponse.Version);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</a>\r\n </div>\r\n");
|
||||
|
||||
WriteLiteral(@" <script>
|
||||
(function () {
|
||||
$(function () {
|
||||
var layout_PageHeading = $('#layout_PageHeading').height(80);
|
||||
var updateAvailableContainer = $('#updateAvailableContainer');
|
||||
updateAvailableContainer.appendTo(layout_PageHeading);
|
||||
");
|
||||
|
||||
|
||||
#line 75 "..\..\Areas\Config\Views\Config\Index.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 75 "..\..\Areas\Config\Views\Config\Index.cshtml"
|
||||
|
||||
if (Model.UpdateResponse.VersionReleasedTimestamp < DateTime.Now.AddDays(-7))
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" ");
|
||||
|
||||
WriteLiteral("\r\n updateAvailableContainer.effect(\"shake\", { times: 3 }, 100);\r\n " +
|
||||
" ");
|
||||
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
|
||||
#line 81 "..\..\Areas\Config\Views\Config\Index.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n });\r\n })();\r\n </script>\r\n");
|
||||
|
||||
|
||||
#line 86 "..\..\Areas\Config\Views\Config\Index.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
@@ -0,0 +1,39 @@
|
||||
@model Disco.Models.Repository.DeviceBatch
|
||||
@{
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Batches", MVC.Config.DeviceBatch.Index(null), "Create");
|
||||
}
|
||||
@using (Html.BeginForm())
|
||||
{
|
||||
<div class="form" style="width: 450px">
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
Name:
|
||||
</th>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.Name)<br />@Html.ValidationMessageFor(model => model.Name)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Purchase Date:
|
||||
</th>
|
||||
<td>@Html.EditorFor(model => model.PurchaseDate)<br />@Html.ValidationMessageFor(model => model.PurchaseDate)
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="actions">
|
||||
<input type="submit" class="button" value="Create" />
|
||||
</p>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$('#Name').focus().select();
|
||||
$('#PurchaseDate').datepicker({
|
||||
changeYear: true,
|
||||
changeMonth: true,
|
||||
dateFormat: 'yy/mm/dd'
|
||||
})
|
||||
});
|
||||
</script>
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
#pragma warning disable 1591
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17929
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Disco.Web.Areas.Config.Views.DeviceBatch
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Helpers;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Ajax;
|
||||
using System.Web.Mvc.Html;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.WebPages;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/DeviceBatch/Create.cshtml")]
|
||||
public class Create : System.Web.Mvc.WebViewPage<Disco.Models.Repository.DeviceBatch>
|
||||
{
|
||||
public Create()
|
||||
{
|
||||
}
|
||||
public override void Execute()
|
||||
{
|
||||
|
||||
#line 2 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Batches", MVC.Config.DeviceBatch.Index(null), "Create");
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
|
||||
#line 5 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
using (Html.BeginForm())
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" class=\"form\"");
|
||||
|
||||
WriteLiteral(" style=\"width: 450px\"");
|
||||
|
||||
WriteLiteral(">\r\n <table>\r\n <tr>\r\n <th>\r\n N" +
|
||||
"ame:\r\n </th>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 14 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
Write(Html.EditorFor(model => model.Name));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("<br />");
|
||||
|
||||
|
||||
#line 14 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
Write(Html.ValidationMessageFor(model => model.Name));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n </tr>\r\n <tr>\r\n <th" +
|
||||
">\r\n Purchase Date:\r\n </th>\r\n <t" +
|
||||
"d>");
|
||||
|
||||
|
||||
#line 21 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
Write(Html.EditorFor(model => model.PurchaseDate));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("<br />");
|
||||
|
||||
|
||||
#line 21 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
Write(Html.ValidationMessageFor(model => model.PurchaseDate));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n </tr>\r\n </table>\r\n <p");
|
||||
|
||||
WriteLiteral(" class=\"actions\"");
|
||||
|
||||
WriteLiteral(">\r\n <input");
|
||||
|
||||
WriteLiteral(" type=\"submit\"");
|
||||
|
||||
WriteLiteral(" class=\"button\"");
|
||||
|
||||
WriteLiteral(" value=\"Create\"");
|
||||
|
||||
WriteLiteral(" />\r\n </p>\r\n </div>\r\n");
|
||||
|
||||
WriteLiteral(" <script");
|
||||
|
||||
WriteLiteral(" type=\"text/javascript\"");
|
||||
|
||||
WriteLiteral(@">
|
||||
$(function () {
|
||||
$('#Name').focus().select();
|
||||
$('#PurchaseDate').datepicker({
|
||||
changeYear: true,
|
||||
changeMonth: true,
|
||||
dateFormat: 'yy/mm/dd'
|
||||
})
|
||||
});
|
||||
</script>
|
||||
");
|
||||
|
||||
|
||||
#line 39 "..\..\Areas\Config\Views\DeviceBatch\Create.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
@@ -0,0 +1,69 @@
|
||||
@model Disco.Web.Areas.Config.Models.DeviceBatch.IndexModel
|
||||
@{
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Batches");
|
||||
}
|
||||
<table class="tableData">
|
||||
<tr>
|
||||
<th>
|
||||
Name
|
||||
</th>
|
||||
<th>
|
||||
Default Model
|
||||
</th>
|
||||
<th>
|
||||
Purchase Date
|
||||
</th>
|
||||
<th>
|
||||
Warranty Expires
|
||||
</th>
|
||||
<th>
|
||||
Insurance Expires
|
||||
</th>
|
||||
<th>
|
||||
Device Count
|
||||
</th>
|
||||
</tr>
|
||||
@foreach (var item in Model.DeviceBatches)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.ActionLink(item.Name, MVC.Config.DeviceBatch.Index(item.Id))
|
||||
</td>
|
||||
<td>
|
||||
@item.DefaultDeviceModel
|
||||
</td>
|
||||
<td>
|
||||
@CommonHelpers.FriendlyDate(item.PurchaseDate)
|
||||
</td>
|
||||
<td>
|
||||
@CommonHelpers.FriendlyDate(item.WarrantyExpires, "Unknown")
|
||||
</td>
|
||||
<td>
|
||||
@CommonHelpers.FriendlyDate(item.InsuredUntil, item.InsuranceSupplier == null ? "N/A" : "Unknown")
|
||||
@(item.InsuranceSupplier == null ? string.Empty : string.Format("[{0}]", item.InsuranceSupplier))
|
||||
</td>
|
||||
<td>
|
||||
@if (item.PurchaseUnitQuantity.HasValue)
|
||||
{
|
||||
<span>@item.DeviceCount.ToString("n0")/@(item.PurchaseUnitQuantity.Value.ToString("n0"))</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
@item.DeviceCount.ToString("n0")
|
||||
}
|
||||
@if (item.DeviceDecommissionedCount > 0)
|
||||
{
|
||||
<span class="smallMessage" title="@(item.DeviceDecommissionedCount) Decommissioned">
|
||||
(@(item.DeviceDecommissionedCount))</span>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
<div class="actionBar">
|
||||
@if (Model.DeviceBatches.Count > 0)
|
||||
{
|
||||
@Html.ActionLinkButton("Timeline", MVC.Config.DeviceBatch.Timeline())
|
||||
}
|
||||
@Html.ActionLinkButton("Create Device Batch", MVC.Config.DeviceBatch.Create())
|
||||
</div>
|
||||
@@ -0,0 +1,319 @@
|
||||
#pragma warning disable 1591
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17929
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Disco.Web.Areas.Config.Views.DeviceBatch
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Helpers;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Ajax;
|
||||
using System.Web.Mvc.Html;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.WebPages;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/DeviceBatch/Index.cshtml")]
|
||||
public class Index : System.Web.Mvc.WebViewPage<Disco.Web.Areas.Config.Models.DeviceBatch.IndexModel>
|
||||
{
|
||||
public Index()
|
||||
{
|
||||
}
|
||||
public override void Execute()
|
||||
{
|
||||
|
||||
#line 2 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Batches");
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n<table");
|
||||
|
||||
WriteLiteral(" class=\"tableData\"");
|
||||
|
||||
WriteLiteral(@">
|
||||
<tr>
|
||||
<th>
|
||||
Name
|
||||
</th>
|
||||
<th>
|
||||
Default Model
|
||||
</th>
|
||||
<th>
|
||||
Purchase Date
|
||||
</th>
|
||||
<th>
|
||||
Warranty Expires
|
||||
</th>
|
||||
<th>
|
||||
Insurance Expires
|
||||
</th>
|
||||
<th>
|
||||
Device Count
|
||||
</th>
|
||||
</tr>
|
||||
");
|
||||
|
||||
|
||||
#line 26 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 26 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
foreach (var item in Model.DeviceBatches)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <tr>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 30 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
Write(Html.ActionLink(item.Name, MVC.Config.DeviceBatch.Index(item.Id)));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 33 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
Write(item.DefaultDeviceModel);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 36 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
Write(CommonHelpers.FriendlyDate(item.PurchaseDate));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 39 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
Write(CommonHelpers.FriendlyDate(item.WarrantyExpires, "Unknown"));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 42 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
Write(CommonHelpers.FriendlyDate(item.InsuredUntil, item.InsuranceSupplier == null ? "N/A" : "Unknown"));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 43 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
Write(item.InsuranceSupplier == null ? string.Empty : string.Format("[{0}]", item.InsuranceSupplier));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n <td>\r\n");
|
||||
|
||||
|
||||
#line 46 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 46 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
if (item.PurchaseUnitQuantity.HasValue)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <span>");
|
||||
|
||||
|
||||
#line 48 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
Write(item.DeviceCount.ToString("n0"));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("/");
|
||||
|
||||
|
||||
#line 48 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
Write(item.PurchaseUnitQuantity.Value.ToString("n0"));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</span>\r\n");
|
||||
|
||||
|
||||
#line 49 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 52 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
Write(item.DeviceCount.ToString("n0"));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 52 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 54 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
if (item.DeviceDecommissionedCount > 0)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <span");
|
||||
|
||||
WriteLiteral(" class=\"smallMessage\"");
|
||||
|
||||
WriteAttribute("title", Tuple.Create(" title=\"", 1775), Tuple.Create("\"", 1831)
|
||||
|
||||
#line 56 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 1783), Tuple.Create<System.Object, System.Int32>(item.DeviceDecommissionedCount
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 1783), false)
|
||||
, Tuple.Create(Tuple.Create(" ", 1816), Tuple.Create("Decommissioned", 1817), true)
|
||||
);
|
||||
|
||||
WriteLiteral(">\r\n (");
|
||||
|
||||
|
||||
#line 57 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
Write(item.DeviceDecommissionedCount);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(")</span>\r\n");
|
||||
|
||||
|
||||
#line 58 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </td>\r\n </tr>\r\n");
|
||||
|
||||
|
||||
#line 61 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</table>\r\n<div");
|
||||
|
||||
WriteLiteral(" class=\"actionBar\"");
|
||||
|
||||
WriteLiteral(">\r\n");
|
||||
|
||||
|
||||
#line 64 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 64 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
if (Model.DeviceBatches.Count > 0)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 66 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
Write(Html.ActionLinkButton("Timeline", MVC.Config.DeviceBatch.Timeline()));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 66 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 68 "..\..\Areas\Config\Views\DeviceBatch\Index.cshtml"
|
||||
Write(Html.ActionLinkButton("Create Device Batch", MVC.Config.DeviceBatch.Create()));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n</div>\r\n");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
@@ -0,0 +1,504 @@
|
||||
@model Disco.Web.Areas.Config.Models.DeviceBatch.ShowModel
|
||||
@{
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Batches", MVC.Config.DeviceBatch.Index(null), Model.DeviceBatch.ToString());
|
||||
Html.BundleDeferred("~/ClientScripts/Modules/Disco-PropertyChangeHelpers");
|
||||
Html.BundleDeferred("~/ClientScripts/Modules/Disco-AjaxHelperIcons");
|
||||
Html.BundleDeferred("~/ClientScripts/Modules/tinymce");
|
||||
}
|
||||
<div class="form deviceBatches" style="width: 730px">
|
||||
<table>
|
||||
<tr>
|
||||
<th style="width: 150px">
|
||||
Id:
|
||||
</th>
|
||||
<td>
|
||||
@Html.DisplayFor(model => model.DeviceBatch.Id)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Name:
|
||||
</th>
|
||||
<td>@Html.EditorFor(model => model.DeviceBatch.Name)
|
||||
@AjaxHelpers.AjaxSave()
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
document.DiscoFunctions.PropertyChangeHelper(
|
||||
$('#DeviceBatch_Name'),
|
||||
'Invalid Name',
|
||||
'@(Url.Action(MVC.API.DeviceBatch.UpdateName(Model.DeviceBatch.Id)))',
|
||||
'BatchName'
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Device Count:
|
||||
</th>
|
||||
<td>
|
||||
@if (Model.DeviceBatch.UnitQuantity.HasValue)
|
||||
{
|
||||
<span>@Model.DeviceCount of @(Model.DeviceBatch.UnitQuantity.Value)</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
@Model.DeviceCount
|
||||
}
|
||||
managed by Disco
|
||||
@if (Model.DeviceDecommissionedCount > 0)
|
||||
{
|
||||
<span class="smallMessage">(@(Model.DeviceDecommissionedCount)
|
||||
Decommissioned)</span>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Purchase:
|
||||
</th>
|
||||
<td class="details">
|
||||
<table class="sub">
|
||||
<tr>
|
||||
<th class="name" style="width: 100px">
|
||||
Purchase Date:
|
||||
</th>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.DeviceBatch.PurchaseDate)
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script>
|
||||
$(function () {
|
||||
var dateField = $('#DeviceBatch_PurchaseDate');
|
||||
document.DiscoFunctions.DateChangeHelper(
|
||||
dateField,
|
||||
'Invalid Date',
|
||||
'@(Url.Action(MVC.API.DeviceBatch.UpdatePurchaseDate(Model.DeviceBatch.Id)))',
|
||||
'PurchaseDate',
|
||||
null,
|
||||
true
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Supplier:
|
||||
</th>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.DeviceBatch.Supplier)
|
||||
@AjaxHelpers.AjaxSave()
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
document.DiscoFunctions.PropertyChangeHelper(
|
||||
$('#DeviceBatch_Supplier'),
|
||||
'Batch Supplier',
|
||||
'@(Url.Action(MVC.API.DeviceBatch.UpdateSupplier(Model.DeviceBatch.Id)))',
|
||||
'Supplier'
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Unit Cost:
|
||||
</th>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.DeviceBatch.UnitCost)
|
||||
@AjaxHelpers.AjaxSave()
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
document.DiscoFunctions.PropertyChangeHelper(
|
||||
$('#DeviceBatch_UnitCost'),
|
||||
'Unit Cost',
|
||||
'@(Url.Action(MVC.API.DeviceBatch.UpdateUnitCost(Model.DeviceBatch.Id)))',
|
||||
'UnitCost'
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Quantity:
|
||||
</th>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.DeviceBatch.UnitQuantity)
|
||||
@AjaxHelpers.AjaxSave()
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
document.DiscoFunctions.PropertyChangeHelper(
|
||||
$('#DeviceBatch_UnitQuantity'),
|
||||
'Quantity',
|
||||
'@(Url.Action(MVC.API.DeviceBatch.UpdateUnitQuantity(Model.DeviceBatch.Id)))',
|
||||
'UnitQuantity'
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="DeviceBatch_PurchaseDetails_Container">
|
||||
<div>
|
||||
Details @AjaxHelpers.AjaxLoader("ajaxPurchaseDetails")
|
||||
</div>
|
||||
@Html.EditorFor(model => model.DeviceBatch.PurchaseDetails)
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var model = {
|
||||
$field: $('#DeviceBatch_PurchaseDetails'),
|
||||
fieldName: 'PurchaseDetails',
|
||||
$ajax_loading: null,
|
||||
$ajax_ok: null,
|
||||
updated: function () {
|
||||
if (!model.$ajax_loading)
|
||||
model.$ajax_loading = $('#ajax' + model.fieldName + '_loading');
|
||||
if (!model.$ajax_ok)
|
||||
model.$ajax_ok = $('#ajax' + model.fieldName + '_ok');
|
||||
model.$ajax_loading.show();
|
||||
var data = {};
|
||||
data[model.fieldName] = model.$field.tinymce().getContent();
|
||||
$.ajax({
|
||||
url: '@(Url.Action(MVC.API.DeviceBatch.UpdatePurchaseDetails(Model.DeviceBatch.Id)))',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
traditional: true,
|
||||
type: 'POST',
|
||||
success: function (d) {
|
||||
if (d == 'OK') {
|
||||
model.$ajax_loading.hide();
|
||||
model.$ajax_ok.show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
model.$ajax_loading.hide();
|
||||
alert('Unable to update purchase details: ' + d);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to update purchase details: ' + errorThrown);
|
||||
model.$ajax_loading.hide();
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
model.$field.tinymce({
|
||||
theme: 'simple',
|
||||
setup: function (ed) {
|
||||
ed.onInit.add(function (ed) {
|
||||
$(ed.getWin()).blur(model.updated);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Default Device Model:
|
||||
</th>
|
||||
<td>
|
||||
@Html.DropDownListFor(model => model.DeviceBatch.DefaultDeviceModelId, Model.DeviceModels)
|
||||
@AjaxHelpers.AjaxSave()
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
document.DiscoFunctions.PropertyChangeHelper(
|
||||
$('#DeviceBatch_DefaultDeviceModelId'),
|
||||
null,
|
||||
'@(Url.Action(MVC.API.DeviceBatch.UpdateDefaultDeviceModelId(Model.DeviceBatch.Id)))',
|
||||
'DefaultDeviceModelId'
|
||||
);
|
||||
});
|
||||
</script>
|
||||
<br />
|
||||
<span class="smallMessage">Devices added offline will default to this Device Model.
|
||||
Once a device enrols the Device Model will be accurately represented.</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Warranty:
|
||||
</th>
|
||||
<td class="details">
|
||||
<table class="sub">
|
||||
<tr>
|
||||
<th class="name" style="width: 100px">
|
||||
Valid Until:
|
||||
</th>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.DeviceBatch.WarrantyValidUntil)
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script>
|
||||
$(function () {
|
||||
var dateField = $('#DeviceBatch_WarrantyValidUntil');
|
||||
document.DiscoFunctions.DateChangeHelper(
|
||||
dateField,
|
||||
'Warranty Valid Until',
|
||||
'@(Url.Action(MVC.API.DeviceBatch.UpdateWarrantyValidUntil(Model.DeviceBatch.Id)))',
|
||||
'WarrantyValidUntil',
|
||||
null,
|
||||
true
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="DeviceBatch_WarrantyDetails_Container">
|
||||
<div>
|
||||
Details @AjaxHelpers.AjaxLoader("ajaxWarrantyDetails")
|
||||
</div>
|
||||
@Html.EditorFor(model => model.DeviceBatch.WarrantyDetails)
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var model = {
|
||||
$field: $('#DeviceBatch_WarrantyDetails'),
|
||||
fieldName: 'WarrantyDetails',
|
||||
$ajax_loading: null,
|
||||
$ajax_ok: null,
|
||||
updated: function () {
|
||||
if (!model.$ajax_loading)
|
||||
model.$ajax_loading = $('#ajax' + model.fieldName + '_loading');
|
||||
if (!model.$ajax_ok)
|
||||
model.$ajax_ok = $('#ajax' + model.fieldName + '_ok');
|
||||
model.$ajax_loading.show();
|
||||
var data = {};
|
||||
data[model.fieldName] = model.$field.tinymce().getContent();
|
||||
$.ajax({
|
||||
url: '@(Url.Action(MVC.API.DeviceBatch.UpdateWarrantyDetails(Model.DeviceBatch.Id)))',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
traditional: true,
|
||||
type: 'POST',
|
||||
success: function (d) {
|
||||
if (d == 'OK') {
|
||||
model.$ajax_loading.hide();
|
||||
model.$ajax_ok.show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
model.$ajax_loading.hide();
|
||||
alert('Unable to update warranty details: ' + d);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to update warranty details: ' + errorThrown);
|
||||
model.$ajax_loading.hide();
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
model.$field.tinymce({
|
||||
theme: 'simple',
|
||||
setup: function (ed) {
|
||||
ed.onInit.add(function (ed) {
|
||||
$(ed.getWin()).blur(model.updated);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Insurance:
|
||||
</th>
|
||||
<td class="details">
|
||||
<table class="sub">
|
||||
<tr>
|
||||
<th class="name" style="width: 100px">
|
||||
Supplier:
|
||||
</th>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.DeviceBatch.InsuranceSupplier)
|
||||
@AjaxHelpers.AjaxSave()
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
document.DiscoFunctions.PropertyChangeHelper(
|
||||
$('#DeviceBatch_InsuranceSupplier'),
|
||||
'Insurance Supplier',
|
||||
'@(Url.Action(MVC.API.DeviceBatch.UpdateInsuranceSupplier(Model.DeviceBatch.Id)))',
|
||||
'InsuranceSupplier'
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="name">
|
||||
Insured Date:
|
||||
</th>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.DeviceBatch.InsuredDate)
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script>
|
||||
$(function () {
|
||||
var dateField = $('#DeviceBatch_InsuredDate');
|
||||
document.DiscoFunctions.DateChangeHelper(
|
||||
dateField,
|
||||
'Insured Date',
|
||||
'@(Url.Action(MVC.API.DeviceBatch.UpdateInsuredDate(Model.DeviceBatch.Id)))',
|
||||
'InsuredDate',
|
||||
null,
|
||||
true
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="name">
|
||||
Insured Until:
|
||||
</th>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.DeviceBatch.InsuredUntil)
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script>
|
||||
$(function () {
|
||||
var dateField = $('#DeviceBatch_InsuredUntil');
|
||||
document.DiscoFunctions.DateChangeHelper(
|
||||
dateField,
|
||||
'Insured Until',
|
||||
'@(Url.Action(MVC.API.DeviceBatch.UpdateInsuredUntil(Model.DeviceBatch.Id)))',
|
||||
'InsuredUntil',
|
||||
null,
|
||||
true
|
||||
);
|
||||
});
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<div id="DeviceBatch_InsuranceDetails_Container">
|
||||
<div>
|
||||
Details @AjaxHelpers.AjaxLoader("ajaxInsuranceDetails")
|
||||
</div>
|
||||
@Html.EditorFor(model => model.DeviceBatch.InsuranceDetails)
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var model = {
|
||||
$DeviceBatch_Comments: $('#DeviceBatch_InsuranceDetails'),
|
||||
$ajax_loading: null,
|
||||
$ajax_ok: null,
|
||||
updated: function () {
|
||||
if (!model.$ajax_loading)
|
||||
model.$ajax_loading = $('#ajaxInsuranceDetails_loading');
|
||||
if (!model.$ajax_ok)
|
||||
model.$ajax_ok = $('#ajaxInsuranceDetails_ok');
|
||||
model.$ajax_loading.show();
|
||||
var data = { InsuranceDetails: model.$DeviceBatch_Comments.tinymce().getContent() };
|
||||
$.ajax({
|
||||
url: '@(Url.Action(MVC.API.DeviceBatch.UpdateInsuranceDetails(Model.DeviceBatch.Id)))',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
traditional: true,
|
||||
type: 'POST',
|
||||
success: function (d) {
|
||||
if (d == 'OK') {
|
||||
model.$ajax_loading.hide();
|
||||
model.$ajax_ok.show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
model.$ajax_loading.hide();
|
||||
alert('Unable to update insurance details: ' + d);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to update insurance details: ' + errorThrown);
|
||||
model.$ajax_loading.hide();
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
model.$DeviceBatch_Comments.tinymce({
|
||||
theme: 'simple',
|
||||
setup: function (ed) {
|
||||
//ed.onChange.add(model.updatedThrottle);
|
||||
ed.onInit.add(function (ed) {
|
||||
$(ed.getWin()).blur(model.updated);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Comments:<br />
|
||||
@AjaxHelpers.AjaxLoader("ajaxComments")
|
||||
</th>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.DeviceBatch.Comments)
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var model = {
|
||||
$DeviceBatch_Comments: $('#DeviceBatch_Comments'),
|
||||
$ajax_loading: null,
|
||||
$ajax_ok: null,
|
||||
updated: function () {
|
||||
if (!model.$ajax_loading)
|
||||
model.$ajax_loading = $('#ajaxComments_loading');
|
||||
if (!model.$ajax_ok)
|
||||
model.$ajax_ok = $('#ajaxComments_ok');
|
||||
model.$ajax_loading.show();
|
||||
var data = { Comments: model.$DeviceBatch_Comments.tinymce().getContent() };
|
||||
$.ajax({
|
||||
url: '@(Url.Action(MVC.API.DeviceBatch.UpdateComments(Model.DeviceBatch.Id)))',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
traditional: true,
|
||||
type: 'POST',
|
||||
success: function (d) {
|
||||
if (d == 'OK') {
|
||||
model.$ajax_loading.hide();
|
||||
model.$ajax_ok.show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
model.$ajax_loading.hide();
|
||||
alert('Unable to update comments: ' + d);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to update comments: ' + errorThrown);
|
||||
model.$ajax_loading.hide();
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
model.$DeviceBatch_Comments.tinymce({
|
||||
theme: 'simple',
|
||||
setup: function (ed) {
|
||||
//ed.onChange.add(model.updatedThrottle);
|
||||
ed.onInit.add(function (ed) {
|
||||
$(ed.getWin()).blur(model.updated);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="actionBar">
|
||||
@if (Model.CanDelete)
|
||||
{
|
||||
@Html.ActionLinkButton("Delete", MVC.API.DeviceBatch.Delete(Model.DeviceBatch.Id, true), "buttonDelete")
|
||||
}
|
||||
@if (Model.DeviceCount > 0)
|
||||
{
|
||||
@Html.ActionLinkButton("View Devices", MVC.Search.Query(Model.DeviceBatch.Id.ToString(), "DeviceBatch"))
|
||||
}
|
||||
</div>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,122 @@
|
||||
@{
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Batches", MVC.Config.DeviceBatch.Index(null), "Timeline");
|
||||
Html.BundleDeferred("~/Style/Timeline");
|
||||
Html.BundleDeferred("~/ClientScripts/Modules/Timeline");
|
||||
}
|
||||
<div id="deviceBatchesTimeline" style="height: 550px;">
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
var dataUrl = '@(Url.Action(MVC.API.DeviceBatch.Timeline()))';
|
||||
var tl;
|
||||
|
||||
$(function () {
|
||||
|
||||
var eventSource = new Timeline.DefaultEventSource();
|
||||
|
||||
var currentDate = new Date();
|
||||
currentDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDay(), 10, 0, 0);
|
||||
var tomorrowDate = new Date();
|
||||
tomorrowDate.setDate(currentDate.getDate() + 1);
|
||||
var sixMonthsDate = new Date();
|
||||
sixMonthsDate.setDate(currentDate.getDate());
|
||||
sixMonthsDate.setMonth(currentDate.getMonth() + 6);
|
||||
|
||||
var hotZoneStart1 = new Date(currentDate.getFullYear(), 0, 1, 10, 0, 0);
|
||||
var hotZoneEnd1 = new Date(currentDate.getFullYear(), 11, 31, 10, 0, 0);
|
||||
var hotZoneStart2 = new Date(currentDate.getFullYear() + 1, 0, 1, 10, 0, 0);
|
||||
var hotZoneEnd2 = new Date(currentDate.getFullYear() + 1, 11, 31, 10, 0, 0);
|
||||
//hotZoneEnd.setDate(hotZoneEnd.getDate() - 1);
|
||||
|
||||
//hotZoneStart = hotZoneStart.toLocaleDateString();
|
||||
//hotZoneEnd = hotZoneEnd.toLocaleDateString();
|
||||
|
||||
|
||||
var bandInfos = [
|
||||
Timeline.createHotZoneBandInfo({
|
||||
zones: [
|
||||
{
|
||||
start: hotZoneStart1,
|
||||
end: hotZoneEnd1,
|
||||
magnify: 4,
|
||||
unit: Timeline.DateTime.MONTH
|
||||
},
|
||||
{
|
||||
start: hotZoneStart2,
|
||||
end: hotZoneEnd2,
|
||||
magnify: 4,
|
||||
unit: Timeline.DateTime.MONTH
|
||||
}
|
||||
],
|
||||
eventSource: eventSource,
|
||||
width: "85%",
|
||||
intervalUnit: Timeline.DateTime.YEAR,
|
||||
intervalPixels: 150,
|
||||
timeZone: 10,
|
||||
date: sixMonthsDate
|
||||
}),
|
||||
Timeline.createBandInfo({
|
||||
eventSource: eventSource,
|
||||
width: "15%",
|
||||
intervalUnit: Timeline.DateTime.YEAR,
|
||||
intervalPixels: 150,
|
||||
overview: true,
|
||||
timeZone: 10,
|
||||
date: sixMonthsDate
|
||||
})
|
||||
];
|
||||
bandInfos[1].syncWith = 0;
|
||||
bandInfos[1].highlight = true;
|
||||
|
||||
for (var i = 0; i < bandInfos.length; i++) {
|
||||
bandInfos[i].decorators = [
|
||||
new Timeline.SpanHighlightDecorator({
|
||||
startDate: currentDate,
|
||||
endDate: tomorrowDate,
|
||||
color: "#CC2222",
|
||||
opacity: 50
|
||||
}),
|
||||
new Timeline.SpanHighlightDecorator({
|
||||
startDate: hotZoneStart1,
|
||||
endDate: hotZoneEnd1,
|
||||
color: "#CEA5A5",
|
||||
opacity: 50
|
||||
}),
|
||||
new Timeline.SpanHighlightDecorator({
|
||||
startDate: hotZoneStart2,
|
||||
endDate: hotZoneEnd2,
|
||||
color: "#CCB7B7",
|
||||
opacity: 50
|
||||
})
|
||||
];
|
||||
}
|
||||
|
||||
tl = Timeline.create($('#deviceBatchesTimeline')[0], bandInfos);
|
||||
|
||||
var tlResizeLayoutHandle = null;
|
||||
$(window).resize(function () {
|
||||
if (tlResizeLayoutHandle)
|
||||
window.clearTimeout(tlResizeLayoutHandle);
|
||||
tlResizeLayoutHandle = window.setTimeout(function () {
|
||||
tlResizeLayoutHandle = null;
|
||||
tl.layout();
|
||||
}, 500);
|
||||
});
|
||||
|
||||
// Load Events
|
||||
$.ajax({
|
||||
url: dataUrl,
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
success: function (data) {
|
||||
eventSource.loadJSON(data, dataUrl);
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to load Timeline Data: ' + errorThrown);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,131 @@
|
||||
#pragma warning disable 1591
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17929
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Disco.Web.Areas.Config.Views.DeviceBatch
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Helpers;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Ajax;
|
||||
using System.Web.Mvc.Html;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.WebPages;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/DeviceBatch/Timeline.cshtml")]
|
||||
public class Timeline : System.Web.Mvc.WebViewPage<dynamic>
|
||||
{
|
||||
public Timeline()
|
||||
{
|
||||
}
|
||||
public override void Execute()
|
||||
{
|
||||
|
||||
#line 1 "..\..\Areas\Config\Views\DeviceBatch\Timeline.cshtml"
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Batches", MVC.Config.DeviceBatch.Index(null), "Timeline");
|
||||
Html.BundleDeferred("~/Style/Timeline");
|
||||
Html.BundleDeferred("~/ClientScripts/Modules/Timeline");
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n<div");
|
||||
|
||||
WriteLiteral(" id=\"deviceBatchesTimeline\"");
|
||||
|
||||
WriteLiteral(" style=\"height: 550px;\"");
|
||||
|
||||
WriteLiteral(">\r\n</div>\r\n<script");
|
||||
|
||||
WriteLiteral(" type=\"text/javascript\"");
|
||||
|
||||
WriteLiteral(">\r\n (function () {\r\n var dataUrl = \'");
|
||||
|
||||
|
||||
#line 10 "..\..\Areas\Config\Views\DeviceBatch\Timeline.cshtml"
|
||||
Write(Url.Action(MVC.API.DeviceBatch.Timeline()));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\';\r\n var tl;\r\n\r\n $(function () {\r\n\r\n var eventSource = n" +
|
||||
"ew Timeline.DefaultEventSource();\r\n\r\n var currentDate = new Date();\r\n" +
|
||||
" currentDate = new Date(currentDate.getFullYear(), currentDate.getMon" +
|
||||
"th(), currentDate.getDay(), 10, 0, 0);\r\n var tomorrowDate = new Date(" +
|
||||
");\r\n tomorrowDate.setDate(currentDate.getDate() + 1);\r\n va" +
|
||||
"r sixMonthsDate = new Date();\r\n sixMonthsDate.setDate(currentDate.get" +
|
||||
"Date());\r\n sixMonthsDate.setMonth(currentDate.getMonth() + 6);\r\n " +
|
||||
" \r\n var hotZoneStart1 = new Date(currentDate.getFullYear(), 0, " +
|
||||
"1, 10, 0, 0);\r\n var hotZoneEnd1 = new Date(currentDate.getFullYear()," +
|
||||
" 11, 31, 10, 0, 0);\r\n var hotZoneStart2 = new Date(currentDate.getFul" +
|
||||
"lYear() + 1, 0, 1, 10, 0, 0);\r\n var hotZoneEnd2 = new Date(currentDat" +
|
||||
"e.getFullYear() + 1, 11, 31, 10, 0, 0);\r\n //hotZoneEnd.setDate(hotZon" +
|
||||
"eEnd.getDate() - 1);\r\n\r\n //hotZoneStart = hotZoneStart.toLocaleDateSt" +
|
||||
"ring();\r\n //hotZoneEnd = hotZoneEnd.toLocaleDateString();\r\n\r\n\r\n " +
|
||||
" var bandInfos = [\r\n Timeline.createHotZoneBandInfo({\r\n " +
|
||||
" zones: [\r\n {\r\n start: h" +
|
||||
"otZoneStart1,\r\n end: hotZoneEnd1,\r\n " +
|
||||
" magnify: 4,\r\n unit: Timeline.DateTime.MONTH\r\n " +
|
||||
" },\r\n {\r\n start: hotZoneStart" +
|
||||
"2,\r\n end: hotZoneEnd2,\r\n magnify: " +
|
||||
"4,\r\n unit: Timeline.DateTime.MONTH\r\n }" +
|
||||
"\r\n ],\r\n eventSource: eventSource,\r\n " +
|
||||
" width: \"85%\",\r\n intervalUnit: Timeline.DateTime." +
|
||||
"YEAR,\r\n intervalPixels: 150,\r\n timeZone: 1" +
|
||||
"0,\r\n date: sixMonthsDate\r\n }),\r\n " +
|
||||
" Timeline.createBandInfo({\r\n eventSource: eventSource,\r\n " +
|
||||
" width: \"15%\",\r\n intervalUnit: Timeline.DateTi" +
|
||||
"me.YEAR,\r\n intervalPixels: 150,\r\n overview" +
|
||||
": true,\r\n timeZone: 10,\r\n date: sixMonthsD" +
|
||||
"ate\r\n })\r\n ];\r\n bandInfos[1].syncWith = 0;\r" +
|
||||
"\n bandInfos[1].highlight = true;\r\n\r\n for (var i = 0; i < b" +
|
||||
"andInfos.length; i++) {\r\n bandInfos[i].decorators = [\r\n " +
|
||||
" new Timeline.SpanHighlightDecorator({\r\n startDa" +
|
||||
"te: currentDate,\r\n endDate: tomorrowDate,\r\n " +
|
||||
" color: \"#CC2222\",\r\n opacity: 50\r\n " +
|
||||
" }),\r\n new Timeline.SpanHighlightDecorator({\r\n " +
|
||||
" startDate: hotZoneStart1,\r\n endDate: hotZon" +
|
||||
"eEnd1,\r\n color: \"#CEA5A5\",\r\n opaci" +
|
||||
"ty: 50\r\n }),\r\n new Timeline.SpanHighlightD" +
|
||||
"ecorator({\r\n startDate: hotZoneStart2,\r\n " +
|
||||
" endDate: hotZoneEnd2,\r\n color: \"#CCB7B7\",\r\n " +
|
||||
" opacity: 50\r\n })\r\n ];\r\n " +
|
||||
" }\r\n\r\n tl = Timeline.create($(\'#deviceBatchesTimeline\')[0], band" +
|
||||
"Infos);\r\n\r\n var tlResizeLayoutHandle = null;\r\n $(window).r" +
|
||||
"esize(function () {\r\n if (tlResizeLayoutHandle)\r\n " +
|
||||
" window.clearTimeout(tlResizeLayoutHandle);\r\n tlResizeLayoutHa" +
|
||||
"ndle = window.setTimeout(function () {\r\n tlResizeLayoutHandle" +
|
||||
" = null;\r\n tl.layout();\r\n }, 500);\r\n " +
|
||||
" });\r\n\r\n // Load Events\r\n $.ajax({\r\n url: " +
|
||||
"dataUrl,\r\n dataType: \'json\',\r\n type: \'POST\',\r\n " +
|
||||
" success: function (data) {\r\n eventSource.loadJSON" +
|
||||
"(data, dataUrl);\r\n },\r\n error: function (jqXHR, te" +
|
||||
"xtStatus, errorThrown) {\r\n alert(\'Unable to load Timeline Dat" +
|
||||
"a: \' + errorThrown);\r\n }\r\n });\r\n });\r\n\r\n })(" +
|
||||
");\r\n\r\n</script>\r\n");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
@@ -0,0 +1,5 @@
|
||||
@model Disco.Web.Areas.Config.Models.DeviceModel.DeviceComponentsModel
|
||||
@{
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Models", MVC.Config.DeviceModel.Index(null), "Generic Components");
|
||||
}
|
||||
@Html.Partial(MVC.Config.DeviceModel.Views._DeviceComponentsTable, Model)
|
||||
@@ -0,0 +1,63 @@
|
||||
#pragma warning disable 1591
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17929
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Disco.Web.Areas.Config.Views.DeviceModel
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Helpers;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Ajax;
|
||||
using System.Web.Mvc.Html;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.WebPages;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/DeviceModel/GenericComponents.cshtml")]
|
||||
public class GenericComponents : System.Web.Mvc.WebViewPage<Disco.Web.Areas.Config.Models.DeviceModel.DeviceComponentsModel>
|
||||
{
|
||||
public GenericComponents()
|
||||
{
|
||||
}
|
||||
public override void Execute()
|
||||
{
|
||||
|
||||
#line 2 "..\..\Areas\Config\Views\DeviceModel\GenericComponents.cshtml"
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Models", MVC.Config.DeviceModel.Index(null), "Generic Components");
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
|
||||
#line 5 "..\..\Areas\Config\Views\DeviceModel\GenericComponents.cshtml"
|
||||
Write(Html.Partial(MVC.Config.DeviceModel.Views._DeviceComponentsTable, Model));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
@@ -0,0 +1,46 @@
|
||||
@model Disco.Web.Areas.Config.Models.DeviceModel.IndexModel
|
||||
@{
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Models");
|
||||
}
|
||||
<table class="tableData">
|
||||
<tr>
|
||||
<th>
|
||||
Name/Description
|
||||
</th>
|
||||
<th>
|
||||
Manufacturer
|
||||
</th>
|
||||
<th>
|
||||
Model
|
||||
</th>
|
||||
<th>
|
||||
Type
|
||||
</th>
|
||||
<th>
|
||||
Device Count
|
||||
</th>
|
||||
</tr>
|
||||
@foreach (var item in Model.DeviceModels)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.ActionLink(item.ToString(), MVC.Config.DeviceModel.Index(item.Id))
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Manufacturer)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Model)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ModelType)
|
||||
</td>
|
||||
<td>
|
||||
@item.DeviceCount.ToString("n0")
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
<div class="actionBar">
|
||||
@Html.ActionLinkButton("Generic Components", MVC.Config.DeviceModel.GenericComponents())
|
||||
</div>
|
||||
@@ -0,0 +1,173 @@
|
||||
#pragma warning disable 1591
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17929
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Disco.Web.Areas.Config.Views.DeviceModel
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Helpers;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Ajax;
|
||||
using System.Web.Mvc.Html;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.WebPages;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/DeviceModel/Index.cshtml")]
|
||||
public class Index : System.Web.Mvc.WebViewPage<Disco.Web.Areas.Config.Models.DeviceModel.IndexModel>
|
||||
{
|
||||
public Index()
|
||||
{
|
||||
}
|
||||
public override void Execute()
|
||||
{
|
||||
|
||||
#line 2 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Models");
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n<table");
|
||||
|
||||
WriteLiteral(" class=\"tableData\"");
|
||||
|
||||
WriteLiteral(@">
|
||||
<tr>
|
||||
<th>
|
||||
Name/Description
|
||||
</th>
|
||||
<th>
|
||||
Manufacturer
|
||||
</th>
|
||||
<th>
|
||||
Model
|
||||
</th>
|
||||
<th>
|
||||
Type
|
||||
</th>
|
||||
<th>
|
||||
Device Count
|
||||
</th>
|
||||
</tr>
|
||||
");
|
||||
|
||||
|
||||
#line 23 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 23 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
|
||||
foreach (var item in Model.DeviceModels)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <tr>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 27 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
|
||||
Write(Html.ActionLink(item.ToString(), MVC.Config.DeviceModel.Index(item.Id)));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 30 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
|
||||
Write(Html.DisplayFor(modelItem => item.Manufacturer));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 33 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
|
||||
Write(Html.DisplayFor(modelItem => item.Model));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 36 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
|
||||
Write(Html.DisplayFor(modelItem => item.ModelType));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 39 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
|
||||
Write(item.DeviceCount.ToString("n0"));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n </tr>\r\n");
|
||||
|
||||
|
||||
#line 42 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</table>\r\n<div");
|
||||
|
||||
WriteLiteral(" class=\"actionBar\"");
|
||||
|
||||
WriteLiteral(">\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 45 "..\..\Areas\Config\Views\DeviceModel\Index.cshtml"
|
||||
Write(Html.ActionLinkButton("Generic Components", MVC.Config.DeviceModel.GenericComponents()));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n</div>");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
@@ -0,0 +1,205 @@
|
||||
@model Disco.Web.Areas.Config.Models.DeviceModel.ShowModel
|
||||
@{
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Models", MVC.Config.DeviceModel.Index(null), Model.DeviceModel.ToString());
|
||||
}
|
||||
<div class="form" style="width: 530px">
|
||||
<table>
|
||||
<tr>
|
||||
<th style="width: 150px">
|
||||
Id:
|
||||
</th>
|
||||
<td>
|
||||
@Html.DisplayFor(model => model.DeviceModel.Id)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Description:
|
||||
</th>
|
||||
<td>@Html.EditorFor(model => model.DeviceModel.Description)
|
||||
@AjaxHelpers.AjaxSave()
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Manufacturer:
|
||||
</th>
|
||||
<td>
|
||||
@Html.DisplayFor(model => model.DeviceModel.Manufacturer)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Model:
|
||||
</th>
|
||||
<td>
|
||||
@Html.DisplayFor(model => model.DeviceModel.Model)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Default Purchase Date:
|
||||
</th>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.DeviceModel.DefaultPurchaseDate)
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Default Warranty Provider:
|
||||
</th>
|
||||
<td>
|
||||
@Html.DropDownListFor(model => model.DeviceModel.DefaultWarrantyProvider, Model.WarrantyProviders.ToSelectListItems(Model.DeviceModel.DefaultWarrantyProvider, true, "None"))
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Type:
|
||||
</th>
|
||||
<td>
|
||||
@Html.DisplayFor(model => model.DeviceModel.ModelType)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
Image:
|
||||
</th>
|
||||
<td>
|
||||
<img alt="Model Image" src="@Url.Action(MVC.API.DeviceModel.Image(Model.DeviceModel.Id, Model.DeviceModel.ImageHash()))" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>
|
||||
<label for="DeviceModel_Image">
|
||||
Update Image:
|
||||
</label>
|
||||
</th>
|
||||
<td>
|
||||
@using (Html.BeginForm(MVC.API.DeviceModel.Image(Model.DeviceModel.Id, true, null), FormMethod.Post, new { enctype = "multipart/form-data" }))
|
||||
{
|
||||
<input type="file" name="Image" id="Image" style="width: 250px;" />
|
||||
<input class="button" type="submit" value="Update" />
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var $Description = $('#DeviceModel_Description');
|
||||
var $DescriptionAjaxSave = $Description.next('.ajaxSave');
|
||||
$Description
|
||||
.watermark('Model Description')
|
||||
.focus(function () { $Description.select() })
|
||||
.keydown(function (e) {
|
||||
$DescriptionAjaxSave.show();
|
||||
if (e.which == 13) {
|
||||
$(this).blur();
|
||||
}
|
||||
}).blur(function () {
|
||||
$DescriptionAjaxSave.hide();
|
||||
})
|
||||
.change(function () {
|
||||
$DescriptionAjaxSave.hide();
|
||||
var $ajaxLoading = $DescriptionAjaxSave.next('.ajaxLoading').show();
|
||||
var data = { Description: $Description.val() };
|
||||
$.ajax({
|
||||
url: '@Url.Action(MVC.API.DeviceModel.UpdateDescription(Model.DeviceModel.Id))',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
success: function (d) {
|
||||
if (d == 'OK') {
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
$ajaxLoading.hide();
|
||||
alert('Unable to update description: ' + d);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to update description: ' + textStatus);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var $dataField = $('#DeviceModel_DefaultPurchaseDate');
|
||||
var $ajaxLoading = $dataField.next('.ajaxLoading');
|
||||
var dateFieldValue = $dataField.val();
|
||||
var dateFieldChangeToken = null;
|
||||
$dataField
|
||||
.watermark('None')
|
||||
.datepicker({
|
||||
changeYear: true,
|
||||
changeMonth: true,
|
||||
dateFormat: 'yy/mm/dd'
|
||||
})
|
||||
.change(function () {
|
||||
var dateText = $dataField.val();
|
||||
if (dateFieldValue.toLowerCase() != dateText.toLowerCase()) {
|
||||
dateFieldValue = dateText;
|
||||
if (dateFieldChangeToken)
|
||||
window.clearTimeout(dateFieldChangeToken);
|
||||
dateFieldChangeToken = window.setTimeout(function () {
|
||||
$ajaxLoading.show();
|
||||
var data = {};
|
||||
data['DefaultPurchaseDate'] = dateFieldValue;
|
||||
$.getJSON('@(Url.Action(MVC.API.DeviceModel.UpdateDefaultPurchaseDate(Model.DeviceModel.Id)))', data, function (response, result) {
|
||||
if (result != 'success' || response != 'OK') {
|
||||
alert('Unable to change Date:\n' + response);
|
||||
$ajaxLoading.hide();
|
||||
} else {
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
}
|
||||
})
|
||||
dateFieldChangeToken = null;
|
||||
}, 500);
|
||||
}
|
||||
}).focus(function () {
|
||||
$(this).select();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var $DefaultWarrantyProvider = $('#DeviceModel_DefaultWarrantyProvider');
|
||||
var $ajaxLoading = $DefaultWarrantyProvider.next('.ajaxLoading');
|
||||
$DefaultWarrantyProvider
|
||||
.change(function () {
|
||||
$ajaxLoading.show();
|
||||
var data = { DefaultWarrantyProvider: $DefaultWarrantyProvider.val() };
|
||||
$.ajax({
|
||||
url: '@Url.Action(MVC.API.DeviceModel.UpdateDefaultWarrantyProvider(Model.DeviceModel.Id))',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
success: function (d) {
|
||||
if (d == 'OK') {
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
$ajaxLoading.hide();
|
||||
alert('Unable to default warranty provider: ' + d);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to default warranty provider: ' + textStatus);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
<h2>
|
||||
Components</h2>
|
||||
@Html.Partial(MVC.Config.DeviceModel.Views._DeviceComponentsTable, Model.DeviceComponentsModel)
|
||||
<div class="actionBar">
|
||||
@if (Model.CanDelete)
|
||||
{
|
||||
@Html.ActionLinkButton("Delete", MVC.API.DeviceModel.Delete(Model.DeviceModel.Id, true), "buttonDelete")
|
||||
}
|
||||
@Html.ActionLinkButton("View Devices", MVC.Search.Query(Model.DeviceModel.Id.ToString(), "DeviceModel"))
|
||||
</div>
|
||||
@@ -0,0 +1,458 @@
|
||||
#pragma warning disable 1591
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17929
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Disco.Web.Areas.Config.Views.DeviceModel
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Helpers;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Ajax;
|
||||
using System.Web.Mvc.Html;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.WebPages;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/DeviceModel/Show.cshtml")]
|
||||
public class Show : System.Web.Mvc.WebViewPage<Disco.Web.Areas.Config.Models.DeviceModel.ShowModel>
|
||||
{
|
||||
public Show()
|
||||
{
|
||||
}
|
||||
public override void Execute()
|
||||
{
|
||||
|
||||
#line 2 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Models", MVC.Config.DeviceModel.Index(null), Model.DeviceModel.ToString());
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n<div");
|
||||
|
||||
WriteLiteral(" class=\"form\"");
|
||||
|
||||
WriteLiteral(" style=\"width: 530px\"");
|
||||
|
||||
WriteLiteral(">\r\n <table>\r\n <tr>\r\n <th");
|
||||
|
||||
WriteLiteral(" style=\"width: 150px\"");
|
||||
|
||||
WriteLiteral(">\r\n Id:\r\n </th>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 12 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
Write(Html.DisplayFor(model => model.DeviceModel.Id));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n </tr>\r\n <tr>\r\n <th>\r\n " +
|
||||
" Description:\r\n </th>\r\n <td>");
|
||||
|
||||
|
||||
#line 19 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
Write(Html.EditorFor(model => model.DeviceModel.Description));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 20 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
Write(AjaxHelpers.AjaxSave());
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 21 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
Write(AjaxHelpers.AjaxLoader());
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n </tr>\r\n <tr>\r\n <th>\r\n " +
|
||||
" Manufacturer:\r\n </th>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 29 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
Write(Html.DisplayFor(model => model.DeviceModel.Manufacturer));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n </tr>\r\n <tr>\r\n <th>\r\n " +
|
||||
" Model:\r\n </th>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 37 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
Write(Html.DisplayFor(model => model.DeviceModel.Model));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n </tr>\r\n <tr>\r\n <th>\r\n " +
|
||||
" Default Purchase Date:\r\n </th>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 45 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
Write(Html.EditorFor(model => model.DeviceModel.DefaultPurchaseDate));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 46 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
Write(AjaxHelpers.AjaxLoader());
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n </tr>\r\n <tr>\r\n <th>\r\n " +
|
||||
" Default Warranty Provider:\r\n </th>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 54 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
Write(Html.DropDownListFor(model => model.DeviceModel.DefaultWarrantyProvider, Model.WarrantyProviders.ToSelectListItems(Model.DeviceModel.DefaultWarrantyProvider, true, "None")));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 55 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
Write(AjaxHelpers.AjaxLoader());
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n </tr>\r\n <tr>\r\n <th>\r\n " +
|
||||
" Type:\r\n </th>\r\n <td>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 63 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
Write(Html.DisplayFor(model => model.DeviceModel.ModelType));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </td>\r\n </tr>\r\n <tr>\r\n <th>\r\n " +
|
||||
" Image:\r\n </th>\r\n <td>\r\n <img");
|
||||
|
||||
WriteLiteral(" alt=\"Model Image\"");
|
||||
|
||||
WriteAttribute("src", Tuple.Create(" src=\"", 2151), Tuple.Create("\"", 2248)
|
||||
|
||||
#line 71 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 2157), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.DeviceModel.Image(Model.DeviceModel.Id, Model.DeviceModel.ImageHash()))
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 2157), false)
|
||||
);
|
||||
|
||||
WriteLiteral(" />\r\n </td>\r\n </tr>\r\n <tr>\r\n <th>\r\n " +
|
||||
" <label");
|
||||
|
||||
WriteLiteral(" for=\"DeviceModel_Image\"");
|
||||
|
||||
WriteLiteral(">\r\n Update Image:\r\n </label>\r\n </th>" +
|
||||
"\r\n <td>\r\n");
|
||||
|
||||
|
||||
#line 81 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 81 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
using (Html.BeginForm(MVC.API.DeviceModel.Image(Model.DeviceModel.Id, true, null), FormMethod.Post, new { enctype = "multipart/form-data" }))
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <input");
|
||||
|
||||
WriteLiteral(" type=\"file\"");
|
||||
|
||||
WriteLiteral(" name=\"Image\"");
|
||||
|
||||
WriteLiteral(" id=\"Image\"");
|
||||
|
||||
WriteLiteral(" style=\"width: 250px;\"");
|
||||
|
||||
WriteLiteral(" />\r\n");
|
||||
|
||||
WriteLiteral(" <input");
|
||||
|
||||
WriteLiteral(" class=\"button\"");
|
||||
|
||||
WriteLiteral(" type=\"submit\"");
|
||||
|
||||
WriteLiteral(" value=\"Update\"");
|
||||
|
||||
WriteLiteral(" />\r\n");
|
||||
|
||||
|
||||
#line 85 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" </td>\r\n </tr>\r\n </table>\r\n <script");
|
||||
|
||||
WriteLiteral(" type=\"text/javascript\"");
|
||||
|
||||
WriteLiteral(@">
|
||||
$(function () {
|
||||
var $Description = $('#DeviceModel_Description');
|
||||
var $DescriptionAjaxSave = $Description.next('.ajaxSave');
|
||||
$Description
|
||||
.watermark('Model Description')
|
||||
.focus(function () { $Description.select() })
|
||||
.keydown(function (e) {
|
||||
$DescriptionAjaxSave.show();
|
||||
if (e.which == 13) {
|
||||
$(this).blur();
|
||||
}
|
||||
}).blur(function () {
|
||||
$DescriptionAjaxSave.hide();
|
||||
})
|
||||
.change(function () {
|
||||
$DescriptionAjaxSave.hide();
|
||||
var $ajaxLoading = $DescriptionAjaxSave.next('.ajaxLoading').show();
|
||||
var data = { Description: $Description.val() };
|
||||
$.ajax({
|
||||
url: '");
|
||||
|
||||
|
||||
#line 109 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
Write(Url.Action(MVC.API.DeviceModel.UpdateDescription(Model.DeviceModel.Id)));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(@"',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
success: function (d) {
|
||||
if (d == 'OK') {
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
$ajaxLoading.hide();
|
||||
alert('Unable to update description: ' + d);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to update description: ' + textStatus);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script");
|
||||
|
||||
WriteLiteral(" type=\"text/javascript\"");
|
||||
|
||||
WriteLiteral(@">
|
||||
$(function () {
|
||||
var $dataField = $('#DeviceModel_DefaultPurchaseDate');
|
||||
var $ajaxLoading = $dataField.next('.ajaxLoading');
|
||||
var dateFieldValue = $dataField.val();
|
||||
var dateFieldChangeToken = null;
|
||||
$dataField
|
||||
.watermark('None')
|
||||
.datepicker({
|
||||
changeYear: true,
|
||||
changeMonth: true,
|
||||
dateFormat: 'yy/mm/dd'
|
||||
})
|
||||
.change(function () {
|
||||
var dateText = $dataField.val();
|
||||
if (dateFieldValue.toLowerCase() != dateText.toLowerCase()) {
|
||||
dateFieldValue = dateText;
|
||||
if (dateFieldChangeToken)
|
||||
window.clearTimeout(dateFieldChangeToken);
|
||||
dateFieldChangeToken = window.setTimeout(function () {
|
||||
$ajaxLoading.show();
|
||||
var data = {};
|
||||
data['DefaultPurchaseDate'] = dateFieldValue;
|
||||
$.getJSON('");
|
||||
|
||||
|
||||
#line 151 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
Write(Url.Action(MVC.API.DeviceModel.UpdateDefaultPurchaseDate(Model.DeviceModel.Id)));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(@"', data, function (response, result) {
|
||||
if (result != 'success' || response != 'OK') {
|
||||
alert('Unable to change Date:\n' + response);
|
||||
$ajaxLoading.hide();
|
||||
} else {
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
}
|
||||
})
|
||||
dateFieldChangeToken = null;
|
||||
}, 500);
|
||||
}
|
||||
}).focus(function () {
|
||||
$(this).select();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script");
|
||||
|
||||
WriteLiteral(" type=\"text/javascript\"");
|
||||
|
||||
WriteLiteral(@">
|
||||
$(function () {
|
||||
var $DefaultWarrantyProvider = $('#DeviceModel_DefaultWarrantyProvider');
|
||||
var $ajaxLoading = $DefaultWarrantyProvider.next('.ajaxLoading');
|
||||
$DefaultWarrantyProvider
|
||||
.change(function () {
|
||||
$ajaxLoading.show();
|
||||
var data = { DefaultWarrantyProvider: $DefaultWarrantyProvider.val() };
|
||||
$.ajax({
|
||||
url: '");
|
||||
|
||||
|
||||
#line 176 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
Write(Url.Action(MVC.API.DeviceModel.UpdateDefaultWarrantyProvider(Model.DeviceModel.Id)));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(@"',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
success: function (d) {
|
||||
if (d == 'OK') {
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
$ajaxLoading.hide();
|
||||
alert('Unable to default warranty provider: ' + d);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to default warranty provider: ' + textStatus);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
<h2>
|
||||
Components</h2>
|
||||
");
|
||||
|
||||
|
||||
#line 198 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
Write(Html.Partial(MVC.Config.DeviceModel.Views._DeviceComponentsTable, Model.DeviceComponentsModel));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n<div");
|
||||
|
||||
WriteLiteral(" class=\"actionBar\"");
|
||||
|
||||
WriteLiteral(">\r\n");
|
||||
|
||||
|
||||
#line 200 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 200 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
if (Model.CanDelete)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 202 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
Write(Html.ActionLinkButton("Delete", MVC.API.DeviceModel.Delete(Model.DeviceModel.Id, true), "buttonDelete"));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 202 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 204 "..\..\Areas\Config\Views\DeviceModel\Show.cshtml"
|
||||
Write(Html.ActionLinkButton("View Devices", MVC.Search.Query(Model.DeviceModel.Id.ToString(), "DeviceModel")));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n</div>\r\n");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
@@ -0,0 +1,270 @@
|
||||
@model Disco.Web.Areas.Config.Models.DeviceModel.DeviceComponentsModel
|
||||
@{
|
||||
Html.BundleDeferred("~/ClientScripts/Modules/Disco-jQueryExtensions");
|
||||
}
|
||||
<table id="deviceComponents" data-devicemodelid="@(Model.DeviceModelId.HasValue ? Model.DeviceModelId.Value.ToString() : string.Empty)">
|
||||
<tr>
|
||||
<th>
|
||||
Description
|
||||
</th>
|
||||
<th>
|
||||
Cost
|
||||
</th>
|
||||
<th>
|
||||
Job Types
|
||||
</th>
|
||||
<th class="actions">
|
||||
|
||||
</th>
|
||||
</tr>
|
||||
@foreach (var item in Model.DeviceComponents)
|
||||
{
|
||||
<tr data-devicecomponentid="@item.Id">
|
||||
<td>
|
||||
<input type="text" class="description" value="@item.Description" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" class="cost" value="@item.Cost.ToString("C")" />
|
||||
</td>
|
||||
<td>
|
||||
<span class="edit@(item.JobSubTypes.Count > 0 ? " editAlert" : string.Empty)"></span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="remove"></span>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<a href="#" id="addDeviceComponent">Add Component</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var $deviceComponents = $('#deviceComponents');
|
||||
|
||||
$('#addDeviceComponent').click(function () {
|
||||
var dc = $('<tr><td><input type="text" class="description" /></td><td><input type="text" class="cost" /></td><td><span class="edit"></span></td><td><span class="remove"></span></td></tr>');
|
||||
dc.find('input').focus(function () { $(this).select() })
|
||||
dc.insertBefore($deviceComponents.find('tr').last());
|
||||
dc.find('input.description').focus();
|
||||
return false;
|
||||
});
|
||||
|
||||
var removeComponentConfirmed = function (id, row) {
|
||||
var data = { id: id };
|
||||
$.ajax({
|
||||
url: '@Url.Action(MVC.API.DeviceModel.ComponentRemove())',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
success: function (d) {
|
||||
if (d == 'OK') {
|
||||
row.remove();
|
||||
} else {
|
||||
alert('Unable to remove component: ' + d);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to remove component: ' + textStatus);
|
||||
}
|
||||
});
|
||||
}
|
||||
var removeComponent = function () {
|
||||
var componentRow = $(this).closest('tr');
|
||||
var id = componentRow.attr('data-devicecomponentid');
|
||||
if (id) {
|
||||
var dialog = $("#dialogConfirmRemove");
|
||||
var buttons = dialog.dialog("option", "buttons");
|
||||
buttons['Remove'] = function () { removeComponentConfirmed(id, componentRow); $(this).dialog("close"); };
|
||||
var buttons = dialog.dialog("option", "buttons", buttons);
|
||||
dialog.dialog('open');
|
||||
} else {
|
||||
// New - Remove
|
||||
componentRow.remove();
|
||||
}
|
||||
}
|
||||
var updateComponent = function () {
|
||||
var componentRow = $(this).closest('tr');
|
||||
componentRow.find('input').attr('disabled', true).addClass('updating');
|
||||
|
||||
var id = componentRow.attr('data-devicecomponentid');
|
||||
if (id) {
|
||||
// Update
|
||||
var data = {
|
||||
id: id,
|
||||
Description: componentRow.find('input.description').val(),
|
||||
Cost: componentRow.find('input.cost').val()
|
||||
};
|
||||
$.ajax({
|
||||
url: '@Url.Action(MVC.API.DeviceModel.ComponentUpdate())',
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
data: data,
|
||||
success: function (d) {
|
||||
componentRow.find('input').attr('disabled', false).removeClass('updating');
|
||||
if (d.Result == 'OK') {
|
||||
componentRow.find('input.description').val(d.Component.Description);
|
||||
componentRow.find('input.cost').val(d.Component.Cost);
|
||||
} else {
|
||||
alert('Unable to update component: ' + d.Result);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to update component: ' + textStatus);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Add
|
||||
id = componentRow.closest('table').attr('data-devicemodelid');
|
||||
var data = {
|
||||
id: id,
|
||||
Description: componentRow.find('input.description').val(),
|
||||
Cost: componentRow.find('input.cost').val()
|
||||
};
|
||||
$.ajax({
|
||||
url: '@Url.Action(MVC.API.DeviceModel.ComponentAdd(null, null, null))',
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
data: data,
|
||||
success: function (d) {
|
||||
componentRow.find('input').attr('disabled', false).removeClass('updating');
|
||||
if (d.Result == 'OK') {
|
||||
componentRow.attr('data-devicecomponentid', d.Component.Id);
|
||||
componentRow.find('input.description').val(d.Component.Description);
|
||||
componentRow.find('input.cost').val(d.Component.Cost);
|
||||
} else {
|
||||
alert('Unable to add component: ' + d.Result);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to add component: ' + textStatus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
var editComponentJobTypes = function () {
|
||||
var edit$this = $(this);
|
||||
var componentRow = edit$this.closest('tr');
|
||||
|
||||
var id = componentRow.attr('data-devicecomponentid');
|
||||
|
||||
if (id) {
|
||||
var data = {
|
||||
id: id
|
||||
};
|
||||
$.ajax({
|
||||
url: '@Url.Action(MVC.API.DeviceModel.Component())',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
success: function (d) {
|
||||
componentRow.find('input').attr('disabled', false).removeClass('updating');
|
||||
if (d.Result == 'OK') {
|
||||
$dialogUpdateJobTypes = $('#dialogUpdateJobTypes');
|
||||
$dialogUpdateJobTypes.find('input:checked').each(function () { $(this).attr('checked', false) });
|
||||
for (var i = 0; i < d.Component.JobSubTypes.length; i++) {
|
||||
var sjt = d.Component.JobSubTypes[i];
|
||||
$dialogUpdateJobTypes.find('#SubTypes_' + sjt).attr('checked', true);
|
||||
}
|
||||
$('#CheckboxBulkSelect_dialogUpdateJobTypes').checkboxBulkSelect('update');
|
||||
var buttons = $dialogUpdateJobTypes.dialog("option", "buttons");
|
||||
buttons['Save'] = function () {
|
||||
$dialogUpdateJobTypes.dialog("disable");
|
||||
var selectedSJTs = [];
|
||||
$dialogUpdateJobTypes.find('input:checked').each(function () { selectedSJTs.push($(this).val()) });
|
||||
|
||||
var data = {
|
||||
id: id,
|
||||
JobSubTypes: selectedSJTs
|
||||
};
|
||||
$.ajax({
|
||||
url: '@Url.Action(MVC.API.DeviceModel.ComponentUpdateJobSubTypes())',
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
traditional: true,
|
||||
data: data,
|
||||
success: function (d) {
|
||||
if (d.Result == 'OK') {
|
||||
if (d.Component.JobSubTypes.length > 0) {
|
||||
edit$this.addClass('editAlert');
|
||||
} else {
|
||||
edit$this.removeClass('editAlert');
|
||||
}
|
||||
$dialogUpdateJobTypes.dialog("enable");
|
||||
$dialogUpdateJobTypes.dialog("close");
|
||||
} else {
|
||||
alert('Unable to update component sub types: ' + d.Result);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to update component sub types: ' + textStatus);
|
||||
}
|
||||
});
|
||||
};
|
||||
var buttons = $dialogUpdateJobTypes.dialog("option", "buttons", buttons);
|
||||
$dialogUpdateJobTypes.dialog('open');
|
||||
} else {
|
||||
alert('Unable to load component: ' + d.Result);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to load component: ' + textStatus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$("#dialogConfirmRemove").dialog({
|
||||
resizable: false,
|
||||
height: 140,
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
buttons: {
|
||||
"Remove": function () {
|
||||
$(this).dialog("close");
|
||||
},
|
||||
Cancel: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#dialogUpdateJobTypes').dialog({
|
||||
resizable: false,
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
width: 550,
|
||||
buttons: {
|
||||
"Save": function () {
|
||||
$(this).dialog("close");
|
||||
},
|
||||
Cancel: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#CheckboxBulkSelect_dialogUpdateJobTypes').checkboxBulkSelect({ parentSelector: 'div' });
|
||||
|
||||
$deviceComponents.find('input').live('change', updateComponent).focus(function () { $(this).select() });
|
||||
$deviceComponents.find('span.remove').live('click', removeComponent);
|
||||
$deviceComponents.find('span.edit').live('click', editComponentJobTypes);
|
||||
|
||||
});
|
||||
</script>
|
||||
<div id="dialogUpdateJobTypes" title="Update Job Types">
|
||||
<div>
|
||||
<h2>
|
||||
Hardware Non-Warranty Job Types</h2>
|
||||
@CommonHelpers.CheckBoxList("SubTypes", Model.JobSubTypes.ToSelectListItems(), 2)
|
||||
<br />
|
||||
<span id="CheckboxBulkSelect_dialogUpdateJobTypes" class="checkboxBulkSelectContainer">
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="dialogConfirmRemove" title="Delete this Component?">
|
||||
<p>
|
||||
<span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
|
||||
This item will be permanently deleted and cannot be recovered. Are you sure?</p>
|
||||
</div>
|
||||
@@ -0,0 +1,412 @@
|
||||
#pragma warning disable 1591
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.17929
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Disco.Web.Areas.Config.Views.DeviceModel
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Helpers;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Mvc.Ajax;
|
||||
using System.Web.Mvc.Html;
|
||||
using System.Web.Routing;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.WebPages;
|
||||
using Disco.BI.Extensions;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Web;
|
||||
using Disco.Web.Extensions;
|
||||
|
||||
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "1.5.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/DeviceModel/_DeviceComponentsTable.cshtml")]
|
||||
public class DeviceComponentsTable : System.Web.Mvc.WebViewPage<Disco.Web.Areas.Config.Models.DeviceModel.DeviceComponentsModel>
|
||||
{
|
||||
public DeviceComponentsTable()
|
||||
{
|
||||
}
|
||||
public override void Execute()
|
||||
{
|
||||
|
||||
#line 2 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
|
||||
|
||||
Html.BundleDeferred("~/ClientScripts/Modules/Disco-jQueryExtensions");
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n<table");
|
||||
|
||||
WriteLiteral(" id=\"deviceComponents\"");
|
||||
|
||||
WriteLiteral(" data-devicemodelid=\"");
|
||||
|
||||
|
||||
#line 5 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
|
||||
Write(Model.DeviceModelId.HasValue ? Model.DeviceModelId.Value.ToString() : string.Empty);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\"");
|
||||
|
||||
WriteLiteral(">\r\n <tr>\r\n <th>\r\n Description\r\n </th>\r\n <th>\r\n" +
|
||||
" Cost\r\n </th>\r\n <th>\r\n Job Types\r\n </" +
|
||||
"th>\r\n <th");
|
||||
|
||||
WriteLiteral(" class=\"actions\"");
|
||||
|
||||
WriteLiteral(">\r\n \r\n </th>\r\n </tr>\r\n");
|
||||
|
||||
|
||||
#line 20 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 20 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
|
||||
foreach (var item in Model.DeviceComponents)
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <tr");
|
||||
|
||||
WriteLiteral(" data-devicecomponentid=\"");
|
||||
|
||||
|
||||
#line 22 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
|
||||
Write(item.Id);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\"");
|
||||
|
||||
WriteLiteral(">\r\n <td>\r\n <input");
|
||||
|
||||
WriteLiteral(" type=\"text\"");
|
||||
|
||||
WriteLiteral(" class=\"description\"");
|
||||
|
||||
WriteAttribute("value", Tuple.Create(" value=\"", 710), Tuple.Create("\"", 735)
|
||||
|
||||
#line 24 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 718), Tuple.Create<System.Object, System.Int32>(item.Description
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 718), false)
|
||||
);
|
||||
|
||||
WriteLiteral(" />\r\n </td>\r\n <td>\r\n <input");
|
||||
|
||||
WriteLiteral(" type=\"text\"");
|
||||
|
||||
WriteLiteral(" class=\"cost\"");
|
||||
|
||||
WriteAttribute("value", Tuple.Create(" value=\"", 825), Tuple.Create("\"", 857)
|
||||
|
||||
#line 27 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 833), Tuple.Create<System.Object, System.Int32>(item.Cost.ToString("C")
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 833), false)
|
||||
);
|
||||
|
||||
WriteLiteral(" />\r\n </td>\r\n <td>\r\n <span");
|
||||
|
||||
WriteAttribute("class", Tuple.Create(" class=\"", 921), Tuple.Create("\"", 992)
|
||||
, Tuple.Create(Tuple.Create("", 929), Tuple.Create("edit", 929), true)
|
||||
|
||||
#line 30 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 933), Tuple.Create<System.Object, System.Int32>(item.JobSubTypes.Count > 0 ? " editAlert" : string.Empty
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 933), false)
|
||||
);
|
||||
|
||||
WriteLiteral("></span>\r\n </td>\r\n <td>\r\n <span");
|
||||
|
||||
WriteLiteral(" class=\"remove\"");
|
||||
|
||||
WriteLiteral("></span>\r\n </td>\r\n </tr>\r\n");
|
||||
|
||||
|
||||
#line 36 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <tr>\r\n <td");
|
||||
|
||||
WriteLiteral(" colspan=\"4\"");
|
||||
|
||||
WriteLiteral(">\r\n <a");
|
||||
|
||||
WriteLiteral(" href=\"#\"");
|
||||
|
||||
WriteLiteral(" id=\"addDeviceComponent\"");
|
||||
|
||||
WriteLiteral(">Add Component</a>\r\n </td>\r\n </tr>\r\n</table>\r\n<script");
|
||||
|
||||
WriteLiteral(" type=\"text/javascript\"");
|
||||
|
||||
WriteLiteral(@">
|
||||
$(function () {
|
||||
var $deviceComponents = $('#deviceComponents');
|
||||
|
||||
$('#addDeviceComponent').click(function () {
|
||||
var dc = $('<tr><td><input type=""text"" class=""description"" /></td><td><input type=""text"" class=""cost"" /></td><td><span class=""edit""></span></td><td><span class=""remove""></span></td></tr>');
|
||||
dc.find('input').focus(function () { $(this).select() })
|
||||
dc.insertBefore($deviceComponents.find('tr').last());
|
||||
dc.find('input.description').focus();
|
||||
return false;
|
||||
});
|
||||
|
||||
var removeComponentConfirmed = function (id, row) {
|
||||
var data = { id: id };
|
||||
$.ajax({
|
||||
url: '");
|
||||
|
||||
|
||||
#line 58 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
|
||||
Write(Url.Action(MVC.API.DeviceModel.ComponentRemove()));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\',\r\n dataType: \'json\',\r\n data: data,\r\n " +
|
||||
" success: function (d) {\r\n if (d == \'OK\') {\r\n " +
|
||||
" row.remove();\r\n } else {\r\n a" +
|
||||
"lert(\'Unable to remove component: \' + d);\r\n }\r\n " +
|
||||
" },\r\n error: function (jqXHR, textStatus, errorThrown) {\r\n " +
|
||||
" alert(\'Unable to remove component: \' + textStatus);\r\n " +
|
||||
" }\r\n });\r\n }\r\n var removeComponent = function () {\r\n " +
|
||||
" var componentRow = $(this).closest(\'tr\');\r\n var id = compo" +
|
||||
"nentRow.attr(\'data-devicecomponentid\');\r\n if (id) {\r\n " +
|
||||
"var dialog = $(\"#dialogConfirmRemove\");\r\n var buttons = dialog.di" +
|
||||
"alog(\"option\", \"buttons\");\r\n buttons[\'Remove\'] = function () { re" +
|
||||
"moveComponentConfirmed(id, componentRow); $(this).dialog(\"close\"); };\r\n " +
|
||||
" var buttons = dialog.dialog(\"option\", \"buttons\", buttons);\r\n " +
|
||||
" dialog.dialog(\'open\');\r\n } else {\r\n // New - Remove" +
|
||||
"\r\n componentRow.remove();\r\n }\r\n }\r\n var " +
|
||||
"updateComponent = function () {\r\n var componentRow = $(this).closest(" +
|
||||
"\'tr\');\r\n componentRow.find(\'input\').attr(\'disabled\', true).addClass(\'" +
|
||||
"updating\');\r\n\r\n var id = componentRow.attr(\'data-devicecomponentid\');" +
|
||||
"\r\n if (id) {\r\n // Update\r\n var data = {" +
|
||||
"\r\n id: id,\r\n Description: componentRow.fin" +
|
||||
"d(\'input.description\').val(),\r\n Cost: componentRow.find(\'inpu" +
|
||||
"t.cost\').val()\r\n };\r\n $.ajax({\r\n " +
|
||||
" url: \'");
|
||||
|
||||
|
||||
#line 100 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
|
||||
Write(Url.Action(MVC.API.DeviceModel.ComponentUpdate()));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(@"',
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
data: data,
|
||||
success: function (d) {
|
||||
componentRow.find('input').attr('disabled', false).removeClass('updating');
|
||||
if (d.Result == 'OK') {
|
||||
componentRow.find('input.description').val(d.Component.Description);
|
||||
componentRow.find('input.cost').val(d.Component.Cost);
|
||||
} else {
|
||||
alert('Unable to update component: ' + d.Result);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to update component: ' + textStatus);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Add
|
||||
id = componentRow.closest('table').attr('data-devicemodelid');
|
||||
var data = {
|
||||
id: id,
|
||||
Description: componentRow.find('input.description').val(),
|
||||
Cost: componentRow.find('input.cost').val()
|
||||
};
|
||||
$.ajax({
|
||||
url: '");
|
||||
|
||||
|
||||
#line 126 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
|
||||
Write(Url.Action(MVC.API.DeviceModel.ComponentAdd(null, null, null)));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(@"',
|
||||
dataType: 'json',
|
||||
type: 'POST',
|
||||
data: data,
|
||||
success: function (d) {
|
||||
componentRow.find('input').attr('disabled', false).removeClass('updating');
|
||||
if (d.Result == 'OK') {
|
||||
componentRow.attr('data-devicecomponentid', d.Component.Id);
|
||||
componentRow.find('input.description').val(d.Component.Description);
|
||||
componentRow.find('input.cost').val(d.Component.Cost);
|
||||
} else {
|
||||
alert('Unable to add component: ' + d.Result);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to add component: ' + textStatus);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
var editComponentJobTypes = function () {
|
||||
var edit$this = $(this);
|
||||
var componentRow = edit$this.closest('tr');
|
||||
|
||||
var id = componentRow.attr('data-devicecomponentid');
|
||||
|
||||
if (id) {
|
||||
var data = {
|
||||
id: id
|
||||
};
|
||||
$.ajax({
|
||||
url: '");
|
||||
|
||||
|
||||
#line 157 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
|
||||
Write(Url.Action(MVC.API.DeviceModel.Component()));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\',\r\n dataType: \'json\',\r\n data: data,\r\n " +
|
||||
" success: function (d) {\r\n componentRow.fin" +
|
||||
"d(\'input\').attr(\'disabled\', false).removeClass(\'updating\');\r\n " +
|
||||
" if (d.Result == \'OK\') {\r\n $dialogUpdateJobTypes " +
|
||||
"= $(\'#dialogUpdateJobTypes\');\r\n $dialogUpdateJobTypes" +
|
||||
".find(\'input:checked\').each(function () { $(this).attr(\'checked\', false) });\r\n " +
|
||||
" for (var i = 0; i < d.Component.JobSubTypes.length; i+" +
|
||||
"+) {\r\n var sjt = d.Component.JobSubTypes[i];\r\n " +
|
||||
" $dialogUpdateJobTypes.find(\'#SubTypes_\' + sjt).attr" +
|
||||
"(\'checked\', true);\r\n }\r\n $" +
|
||||
"(\'#CheckboxBulkSelect_dialogUpdateJobTypes\').checkboxBulkSelect(\'update\');\r\n " +
|
||||
" var buttons = $dialogUpdateJobTypes.dialog(\"option\", \"bu" +
|
||||
"ttons\");\r\n buttons[\'Save\'] = function () {\r\n " +
|
||||
" $dialogUpdateJobTypes.dialog(\"disable\");\r\n " +
|
||||
" var selectedSJTs = [];\r\n $dialog" +
|
||||
"UpdateJobTypes.find(\'input:checked\').each(function () { selectedSJTs.push($(this" +
|
||||
").val()) });\r\n\r\n var data = {\r\n " +
|
||||
" id: id,\r\n JobSubTypes: sele" +
|
||||
"ctedSJTs\r\n };\r\n $." +
|
||||
"ajax({\r\n url: \'");
|
||||
|
||||
|
||||
#line 181 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
|
||||
Write(Url.Action(MVC.API.DeviceModel.ComponentUpdateJobSubTypes()));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\',\r\n dataType: \'json\',\r\n " +
|
||||
" type: \'POST\',\r\n traditional: tr" +
|
||||
"ue,\r\n data: data,\r\n " +
|
||||
" success: function (d) {\r\n if (d" +
|
||||
".Result == \'OK\') {\r\n if (d.Component." +
|
||||
"JobSubTypes.length > 0) {\r\n edit$" +
|
||||
"this.addClass(\'editAlert\');\r\n } else " +
|
||||
"{\r\n edit$this.removeClass(\'editAl" +
|
||||
"ert\');\r\n }\r\n " +
|
||||
" $dialogUpdateJobTypes.dialog(\"enable\");\r\n " +
|
||||
" $dialogUpdateJobTypes.dialog(\"close\");\r\n " +
|
||||
" } else {\r\n al" +
|
||||
"ert(\'Unable to update component sub types: \' + d.Result);\r\n " +
|
||||
" }\r\n },\r\n " +
|
||||
" error: function (jqXHR, textStatus, errorThrown) {\r\n " +
|
||||
" alert(\'Unable to update component sub types: \' + t" +
|
||||
"extStatus);\r\n }\r\n " +
|
||||
" });\r\n };\r\n var buttons" +
|
||||
" = $dialogUpdateJobTypes.dialog(\"option\", \"buttons\", buttons);\r\n " +
|
||||
" $dialogUpdateJobTypes.dialog(\'open\');\r\n } els" +
|
||||
"e {\r\n alert(\'Unable to load component: \' + d.Result);" +
|
||||
"\r\n }\r\n },\r\n error: " +
|
||||
"function (jqXHR, textStatus, errorThrown) {\r\n alert(\'Unab" +
|
||||
"le to load component: \' + textStatus);\r\n }\r\n }" +
|
||||
");\r\n }\r\n\r\n }\r\n\r\n $(\"#dialogConfirmRemove\").dialog({\r\n " +
|
||||
" resizable: false,\r\n height: 140,\r\n modal: true,\r" +
|
||||
"\n autoOpen: false,\r\n buttons: {\r\n \"Remove\":" +
|
||||
" function () {\r\n $(this).dialog(\"close\");\r\n }," +
|
||||
"\r\n Cancel: function () {\r\n $(this).dialog(\"clo" +
|
||||
"se\");\r\n }\r\n }\r\n });\r\n\r\n $(\'#dialogUpdate" +
|
||||
"JobTypes\').dialog({\r\n resizable: false,\r\n modal: true,\r\n " +
|
||||
" autoOpen: false,\r\n width: 550,\r\n buttons: {\r\n " +
|
||||
" \"Save\": function () {\r\n $(this).dialog(\"close\");" +
|
||||
"\r\n },\r\n Cancel: function () {\r\n " +
|
||||
" $(this).dialog(\"close\");\r\n }\r\n }\r\n });\r\n\r\n " +
|
||||
" $(\'#CheckboxBulkSelect_dialogUpdateJobTypes\').checkboxBulkSelect({ parentSel" +
|
||||
"ector: \'div\' });\r\n\r\n $deviceComponents.find(\'input\').live(\'change\', updat" +
|
||||
"eComponent).focus(function () { $(this).select() });\r\n $deviceComponents." +
|
||||
"find(\'span.remove\').live(\'click\', removeComponent);\r\n $deviceComponents.f" +
|
||||
"ind(\'span.edit\').live(\'click\', editComponentJobTypes);\r\n\r\n });\r\n</script>\r\n<d" +
|
||||
"iv");
|
||||
|
||||
WriteLiteral(" id=\"dialogUpdateJobTypes\"");
|
||||
|
||||
WriteLiteral(" title=\"Update Job Types\"");
|
||||
|
||||
WriteLiteral(">\r\n <div>\r\n <h2>\r\n Hardware Non-Warranty Job Types</h2>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 260 "..\..\Areas\Config\Views\DeviceModel\_DeviceComponentsTable.cshtml"
|
||||
Write(CommonHelpers.CheckBoxList("SubTypes", Model.JobSubTypes.ToSelectListItems(), 2));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n <br />\r\n <span");
|
||||
|
||||
WriteLiteral(" id=\"CheckboxBulkSelect_dialogUpdateJobTypes\"");
|
||||
|
||||
WriteLiteral(" class=\"checkboxBulkSelectContainer\"");
|
||||
|
||||
WriteLiteral(">\r\n </span>\r\n </div>\r\n</div>\r\n<div");
|
||||
|
||||
WriteLiteral(" id=\"dialogConfirmRemove\"");
|
||||
|
||||
WriteLiteral(" title=\"Delete this Component?\"");
|
||||
|
||||
WriteLiteral(">\r\n <p>\r\n <span");
|
||||
|
||||
WriteLiteral(" class=\"ui-icon ui-icon-alert\"");
|
||||
|
||||
WriteLiteral(" style=\"float: left; margin: 0 7px 20px 0;\"");
|
||||
|
||||
WriteLiteral("></span>\r\n This item will be permanently deleted and cannot be recovered. " +
|
||||
"Are you sure?</p>\r\n</div>\r\n");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user