Feature: Decommission Reasons

As requested in #1
This commit is contained in:
Gary Sharp committed 2013-09-05 18:23:59 +10:00
1 parent f3efa56750
commit 29a6057443
11 files changed
+405 -56

No files matched your search

@@ -58,12 +58,13 @@ namespace Disco.BI.Extensions
return true;
}
public static void OnDecommission(this Device d)
public static void OnDecommission(this Device d, Disco.Models.Repository.Device.DecommissionReasons Reason)
{
if (!d.CanDecommission())
throw new InvalidOperationException("Decommission of Device is Denied");
d.DecommissionedDate = DateTime.Now;
d.DecommissionReason = Reason;
// Disable AD Account
if (d.ComputerName != null)
@@ -87,6 +88,7 @@ namespace Disco.BI.Extensions
throw new InvalidOperationException("Recommission of Device is Denied");
d.DecommissionedDate = null;
d.DecommissionReason = null;
// Enable AD Account
if (d.ComputerName != null)
+30 -1
View File
@@ -178,10 +178,39 @@ namespace Disco.BI.Extensions
return null;
}
public static string ReasonMessage(this Disco.Models.Repository.Device.DecommissionReasons r)
{
switch (r)
{
case Device.DecommissionReasons.EndOfLife:
return "End of Life";
case Device.DecommissionReasons.Sold:
return "Sold";
case Device.DecommissionReasons.Stolen:
return "Stolen";
case Device.DecommissionReasons.Lost:
return "Lost";
case Device.DecommissionReasons.Damaged:
return "Damaged";
case Device.DecommissionReasons.Donated:
return "Donated";
default:
return "Unknown";
}
}
public static string ReasonMessage(this Disco.Models.Repository.Device.DecommissionReasons? r)
{
if (!r.HasValue)
return "Not Decommissioned";
return r.Value.ReasonMessage();
}
public static string Status(this Device Device)
{
if (Device.DecommissionedDate.HasValue)
return "Decommissioned";
return string.Format("Decommissioned ({0})", Device.DecommissionReason.ReasonMessage());
if (!Device.EnrolledDate.HasValue)
return "Not Enrolled";
+8 -1
View File
@@ -109,6 +109,10 @@
<Compile Include="Migrations\201302210057463_DBv7.Designer.cs">
<DependentUpon>201302210057463_DBv7.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201309050648129_DBv8.cs" />
<Compile Include="Migrations\201309050648129_DBv8.Designer.cs">
<DependentUpon>201309050648129_DBv8.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Migrations\DiscoDataMigrator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -146,6 +150,9 @@
<EmbeddedResource Include="Migrations\201302210057463_DBv7.resx">
<DependentUpon>201302210057463_DBv7.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\201309050648129_DBv8.resx">
<DependentUpon>201309050648129_DBv8.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
@@ -159,7 +166,7 @@
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>
<UserProperties BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_StartDate="2011/7/1" BuildVersion_DetectChanges="False" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildAction="Both" />
<UserProperties BuildVersion_BuildAction="Both" BuildVersion_UseGlobalSettings="False" BuildVersion_DetectChanges="False" BuildVersion_StartDate="2011/7/1" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" />
</VisualStudio>
</ProjectExtensions>
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
+27
View File
@@ -0,0 +1,27 @@
// <auto-generated />
namespace Disco.Data.Migrations
{
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
public sealed partial class DBv8 : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv8));
string IMigrationMetadata.Id
{
get { return "201309050648129_DBv8"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}
@@ -0,0 +1,21 @@
namespace Disco.Data.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class DBv8 : DbMigration
{
public override void Up()
{
AddColumn("dbo.Devices", "DecommissionReason", c => c.Int());
// Set DecommissionedReason to default ('End Of Life') for any previously decommissioned devices.
Sql("UPDATE dbo.Devices SET DecommissionReason=0 WHERE NOT DecommissionedDate IS NULL");
}
public override void Down()
{
DropColumn("dbo.Devices", "DecommissionReason");
}
}
}
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Target" xml:space="preserve">
<value>H4sIAAAAAAAEAO1dWXPcOJJ+34j9D4p62p2IsXy3PSHPhFuSe6yxLY1kdz86qCqoxBgWWUOy3NJv24f9SfsXFrxxZOIieJRaT7YKYCIzkUgkri//73/+9+hvd5vo4AdJszCJ3y2ePXm6OCDxMlmF8frdYpff/PnN4m9//c//ODpdbe4Ofm3qvSjq0S/j7N3iNs+3fzk8zJa3ZBNkTzbhMk2y5CZ/skw2h8EqOXz+9Onbw2fPDgklsaC0Dg6OLndxHm5I+Qf98ziJl2Sb74Loc7IiUVb/TkuuSqoHX4INybbBkrxbnITZMnlyEuTBk0uyTbIwT9L7xcH7KAwoM1ckulkcbF/+5VtGrvI0iddX2yAPg+jr/ZbQ8psgykjN+l+2L025f/q84P4wiOMkp+SS2En6RSsXleyUaiC/L9gqpXu3oEq4Cde7tKT/MSdcdfrBP8g99wP96SJNtiTN7y/JTU3kakl/WRwc6mtScmK9o0OxjfY7nnzBNf0jT6mVLA4+hHdk9YnE6/y2VfDn4K755Q01lW9xSG2KfpOnO1r6ZRdFwXVE2uqHylZLVkdu89cg2tlKSv+raLb6m2316LAzAqVpnCTL3YbE+Vey2UZBTlws4+PKvruLb6w08KK33k9ItkzDbTXGrNp+/qp34y7m/bpvox/CKCfp6d02JVnmW2zZ6AAGqEnlJP6QpJum7Z+TJCJBrJflS/AjXJceSyB6llxf7a5Lr7s4uCRRWSe7DbeVj34imvR37oMPabK5TCLA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ygp8YSIp9JnDFXi/t3kN+O69LGYzKIwIuDAwHNYMEBkeobHGxG3VvJmzSjICAx/AiUh6jLmHeVN6ehCCx4vWo7Y8+RWlB3bRWuvLnHIQwT4Nz1Xk5TqV1Ah0sQqtpOd52GvYsooUN7G1lQ16YABALSYhyUOaZC4GSa5idgelaTpekbt+Jzout6/6QlQfJ3FOmEQ3YRwUV410IeLrF29eWp89xkXd3pd+Tu+2YVqOTV/JP5cmWTrNYTtGjXXcpw3GFaDzhlwHcVtARTtvtdtwvgpI8fkxK/F8WrV9owMuje6pWtkxx2vnMyk6obW/1fnNp/CGfluuT94tnkrq5D64SgoQoLruM13lnKojbqs/11T/VD6GqCu/0FSurs52vLzU1U/iwqTb+q+eyt1QKVzRCSCWUtsJlTECfUA9qoKzj/FNMRBKkt9r3/NLceWy07NaNIjAxygi6+IxSaN7exK/hkXvLTvTeGlP4yJJ42SdBtvi/mpN5o0Fmb8Hy3+VTqLRxGuLj+nov7v/+X4bZJ0qX9go4ueUBEX0RPv7/Tol5Y8tpdc26qgofaAzSbykjlCm9uy5Ri2FQoMlFarIn9B1yfO3L9++/un5W41emq/LDAhdT7x68/bti5ev3mqU0nz9Mb4gaZl7uOH6p2c/vX3z+u2zNxplNBSuPl91XfHyxau3P7148+K1oeifWd5fv/np2duXP73+6cVrk4H8PssSqvnC63OTQZU0pnbYHe4Fzw31kgesZ4c/6qaB+xZ8jUt583kX5eE2CpfU21NH++SJPK4NW2ohDMSWuueFQmt/kpqqjw7zsLj5FGd5GoRxLoe7ITXYbRBZyC/QMAyai45rWxNLTsiWxEXca6EcEzaEJGAyR23DQoCvU97RIWNwJnbIpdNW2wScW1u0BL0BKOmiFmZuyz0MDGJlNLOC9LtfxnQhZKxU9/sFlr5S7PqLJt063/l6Lya2gBrXoF4LkXM0u0K0YG5aNYGJjQtN6aa2Line truncated
</data>
</root>
+11
View File
@@ -41,6 +41,7 @@ namespace Disco.Models.Repository
public DateTime? EnrolledDate { get; set; }
public DateTime? LastEnrolDate { get; set; }
public DateTime? DecommissionedDate { get; set; }
public DecommissionReasons? DecommissionReason { get; set; }
[ForeignKey("DeviceModelId")]
public virtual DeviceModel DeviceModel { get; set; }
@@ -65,5 +66,15 @@ namespace Disco.Models.Repository
else
return this.SerialNumber;
}
public enum DecommissionReasons
{
EndOfLife = 0,
Sold = 10,
Stolen = 20,
Lost = 30,
Damaged = 40,
Donated = 50
}
}
}
@@ -213,7 +213,7 @@ namespace Disco.Web.Areas.API.Controllers
#endregion
#region Device Actions
public virtual ActionResult Decommission(string id, bool redirect)
public virtual ActionResult Decommission(string id, int Reason, bool redirect)
{
var d = dbContext.Devices.Find(id);
dbContext.Configuration.LazyLoadingEnabled = true;
@@ -221,7 +221,7 @@ namespace Disco.Web.Areas.API.Controllers
{
if (d.CanDecommission())
{
d.OnDecommission();
d.OnDecommission((Disco.Models.Repository.Device.DecommissionReasons)Reason);
dbContext.SaveChanges();
if (redirect)
+7 -3
View File
@@ -143,6 +143,8 @@ namespace Links
public static string Url(string fileName) { return T4MVCHelpers.ProcessVirtualPath(URLPATH + "/" + fileName); }
public static readonly string disco_dataTables_extensions_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(URLPATH + "/disco.dataTables.extensions.min.js") ? Url("disco.dataTables.extensions.min.js") : Url("disco.dataTables.extensions.js");
public static readonly string disco_uicore_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(URLPATH + "/disco.uicore.min.js") ? Url("disco.uicore.min.js") : Url("disco.uicore.js");
public static readonly string disco_unobtrusiveValidation_extensions_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(URLPATH + "/disco.unobtrusiveValidation.extensions.min.js") ? Url("disco.unobtrusiveValidation.extensions.min.js") : Url("disco.unobtrusiveValidation.extensions.js");
public static readonly string jquery_2_0_2_js = T4MVCHelpers.IsProduction() && T4Extensions.FileExists(URLPATH + "/jquery-2.0.2.min.js") ? Url("jquery-2.0.2.min.js") : Url("jquery-2.0.2.js");
@@ -3491,6 +3493,7 @@ namespace Disco.Web.Areas.API.Controllers
public class ActionParamsClass_Decommission
{
public readonly string id = "id";
public readonly string Reason = "Reason";
public readonly string redirect = "redirect";
}
static readonly ActionParamsClass_Recommission s_params_Recommission = new ActionParamsClass_Recommission();
@@ -3697,14 +3700,15 @@ namespace Disco.Web.Areas.API.Controllers
return callInfo;
}
partial void DecommissionOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id, bool redirect);
partial void DecommissionOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id, int Reason, bool redirect);
public override System.Web.Mvc.ActionResult Decommission(string id, bool redirect)
public override System.Web.Mvc.ActionResult Decommission(string id, int Reason, bool redirect)
{
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Decommission);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "id", id);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "Reason", Reason);
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "redirect", redirect);
DecommissionOverride(callInfo, id, redirect);
DecommissionOverride(callInfo, id, Reason, redirect);
return callInfo;
}
@@ -590,17 +590,30 @@
}
@if (Model.Device.CanDecommission())
{
@Html.ActionLinkSmallButton("Decommission", MVC.API.Device.Decommission(Model.Device.SerialNumber, true), "Device_Show_Device_Actions_Decommission_Button")
<div id="Device_Show_Device_Actions_Decommission_Dialog" class="dialog" title="Decommission this Device?">
<p>
<span class="ui-icon ui-icon-alert" style="float: left; margin: 0 7px 20px 0;"></span>
Are you sure?
</p>
@Html.ActionLinkSmallButton("Decommission", MVC.API.Device.Decommission(), "Device_Show_Device_Actions_Decommission_Button")
<div id="Device_Show_Device_Actions_Decommission_Dialog" class="dialog" title="Device Decommissioning">
<div class="clearfix" style="margin-bottom: 10px;">
<span class="ui-icon ui-icon-info" style="float: left; margin: 0 7px 0 0;"></span>
Why was this Device Decommissioned?
</div>
<div>
<ul class="none">
@foreach (Device.DecommissionReasons decommissionReason in Enum.GetValues(typeof(Device.DecommissionReasons)))
{
<li>
<input type="radio" id="Device_Show_Device_Actions_Decommission_Reason_@((int)decommissionReason)"
name="Device_Show_Device_Actions_Decommission_Reason" value="@((int)decommissionReason)" @((decommissionReason== Device.DecommissionReasons.EndOfLife) ? "checked=\"checked\"" : string.Empty)/>
<label for="Device_Show_Device_Actions_Decommission_Reason_@((int)decommissionReason)">@(decommissionReason.ReasonMessage())</label>
</li>
}
</ul>
</div>
</div>
<script type="text/javascript">
$(function () {
var button = $('#Device_Show_Device_Actions_Decommission_Button');
var buttonDialog = null;
var deviceSerialNumber = '@(Model.Device.SerialNumber)';
button.click(function () {
@@ -608,15 +621,20 @@
buttonDialog = $('#Device_Show_Device_Actions_Decommission_Dialog')
.dialog({
resizable: false,
height: 140,
modal: true,
autoOpen: false,
buttons: {
"Decommission": function () {
var reasonId = buttonDialog.find('input:checked').val();
var $this = $(this);
$this.dialog("disable");
$this.dialog("option", "buttons", null);
window.location.href = button.attr('href');
var url = button.attr('href') + '/' + deviceSerialNumber + '?Reason=' + reasonId + '&redirect=True';
window.location.href = url;
},
Cancel: function () {
$(this).dialog("close");
@@ -2,7 +2,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18033
// Runtime Version:4.0.30319.18051
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -1886,7 +1886,7 @@ WriteLiteral(" ");
#line hidden
#line 593 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
Write(Html.ActionLinkSmallButton("Decommission", MVC.API.Device.Decommission(Model.Device.SerialNumber, true), "Device_Show_Device_Actions_Decommission_Button"));
Write(Html.ActionLinkSmallButton("Decommission", MVC.API.Device.Decommission(), "Device_Show_Device_Actions_Decommission_Button"));
#line default
@@ -1904,16 +1904,111 @@ WriteLiteral(" id=\"Device_Show_Device_Actions_Decommission_Dialog\"");
WriteLiteral(" class=\"dialog\"");
WriteLiteral(" title=\"Decommission this Device?\"");
WriteLiteral(" title=\"Device Decommissioning\"");
WriteLiteral(">\r\n <p>\r\n <span");
WriteLiteral(">\r\n <div");
WriteLiteral(" class=\"ui-icon ui-icon-alert\"");
WriteLiteral(" class=\"clearfix\"");
WriteLiteral(" style=\"float: left; margin: 0 7px 20px 0;\"");
WriteLiteral(" style=\"margin-bottom: 10px;\"");
WriteLiteral("></span>\r\n Are you sure?\r\n </p>\r\n " +
" </div>\r\n");
WriteLiteral(">\r\n <span");
WriteLiteral(" class=\"ui-icon ui-icon-info\"");
WriteLiteral(" style=\"float: left; margin: 0 7px 0 0;\"");
WriteLiteral("></span>\r\n Why was this Device Decommissioned?\r\n " +
" </div>\r\n <div>\r\n <ul");
WriteLiteral(" class=\"none\"");
WriteLiteral(">\r\n");
#line 601 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
#line default
#line hidden
#line 601 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
foreach (Device.DecommissionReasons decommissionReason in Enum.GetValues(typeof(Device.DecommissionReasons)))
{
#line default
#line hidden
WriteLiteral(" <li>\r\n <input");
WriteLiteral(" type=\"radio\"");
WriteAttribute("id", Tuple.Create(" id=\"", 37225), Tuple.Create("\"", 37303)
, Tuple.Create(Tuple.Create("", 37230), Tuple.Create("Device_Show_Device_Actions_Decommission_Reason_", 37230), true)
#line 604 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
, Tuple.Create(Tuple.Create("", 37277), Tuple.Create<System.Object, System.Int32>((int)decommissionReason
#line default
#line hidden
, 37277), false)
);
WriteLiteral("\r\n name=\"Device_Show_Device_Actions_Decomm" +
"ission_Reason\"");
WriteAttribute("value", Tuple.Create(" value=\"", 37399), Tuple.Create("\"", 37433)
#line 605 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
, Tuple.Create(Tuple.Create("", 37407), Tuple.Create<System.Object, System.Int32>((int)decommissionReason
#line default
#line hidden
, 37407), false)
);
WriteLiteral(" ");
#line 605 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
Write((decommissionReason== Device.DecommissionReasons.EndOfLife) ? "checked=\"checked\"" : string.Empty);
#line default
#line hidden
WriteLiteral("/>\r\n <label");
WriteAttribute("for", Tuple.Create(" for=\"", 37582), Tuple.Create("\"", 37661)
, Tuple.Create(Tuple.Create("", 37588), Tuple.Create("Device_Show_Device_Actions_Decommission_Reason_", 37588), true)
#line 606 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
, Tuple.Create(Tuple.Create("", 37635), Tuple.Create<System.Object, System.Int32>((int)decommissionReason
#line default
#line hidden
, 37635), false)
);
WriteLiteral(">");
#line 606 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
Write(decommissionReason.ReasonMessage());
#line default
#line hidden
WriteLiteral("</label>\r\n </li>\r\n");
#line 608 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
}
#line default
#line hidden
WriteLiteral(" </ul>\r\n </div>\r\n </div>" +
"\r\n");
WriteLiteral(" <script");
@@ -1921,32 +2016,44 @@ WriteLiteral(" type=\"text/javascript\"");
WriteLiteral(">\r\n $(function () {\r\n var button = $(\'#" +
"Device_Show_Device_Actions_Decommission_Button\');\r\n var b" +
"uttonDialog = null;\r\n\r\n button.click(function () {\r\n\r\n " +
" if (!buttonDialog) {\r\n b" +
"uttonDialog = $(\'#Device_Show_Device_Actions_Decommission_Dialog\')\r\n " +
" .dialog({\r\n " +
" resizable: false,\r\n " +
" height: 140,\r\n " +
" modal: true,\r\n " +
" autoOpen: false,\r\n butt" +
"ons: {\r\n \"Decommissio" +
"n\": function () {\r\n " +
" var $this = $(this);\r\n " +
" $this.dialog(\"disable\");\r\n " +
" $this.dialog(\"option\", \"buttons\", null);\r\n " +
" window.location.href = button.attr(" +
"\'href\');\r\n },\r\n " +
" Cancel: function () {\r\n " +
" $(this).dialog(\"clo" +
"se\");\r\n }\r\n " +
" }\r\n " +
" });\r\n }\r\n\r\n " +
" buttonDialog.dialog(\'open\');\r\n return false;\r\n" +
" });\r\n\r\n });\r\n </script" +
">\r\n");
"uttonDialog = null;\r\n var deviceSerialNumber = \'");
#line 634 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
#line 616 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
Write(Model.Device.SerialNumber);
#line default
#line hidden
WriteLiteral("\';\r\n\r\n button.click(function () {\r\n\r\n " +
" if (!buttonDialog) {\r\n buttonDialog = $(\'#" +
"Device_Show_Device_Actions_Decommission_Dialog\')\r\n " +
" .dialog({\r\n " +
" resizable: false,\r\n " +
" modal: true,\r\n autoOp" +
"en: false,\r\n buttons: {\r\n" +
" \"Decommission\": func" +
"tion () {\r\n\r\n var" +
" reasonId = buttonDialog.find(\'input:checked\').val();\r\n " +
" \r\n " +
" var $this = $(this);\r\n " +
" $this.dialog(\"disable\");\r\n " +
" $this.dialog(\"option\", \"buttons\", null)" +
";\r\n\r\n var url = b" +
"utton.attr(\'href\') + \'/\' + deviceSerialNumber + \'?Reason=\' + reasonId + \'&redire" +
"ct=True\';\r\n\r\n win" +
"dow.location.href = url;\r\n " +
" },\r\n Cancel: fu" +
"nction () {\r\n $(t" +
"his).dialog(\"close\");\r\n " +
" }\r\n }\r\n " +
" });\r\n }\r\n\r\n " +
" buttonDialog.dialog(\'open\');\r\n " +
" return false;\r\n });\r\n\r\n });\r\n " +
" </script>\r\n");
#line 652 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
}
@@ -1955,7 +2062,7 @@ WriteLiteral(">\r\n $(function () {\r\n
WriteLiteral(" ");
#line 635 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
#line 653 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
if (Model.Device.CanRecommission())
{
@@ -1963,14 +2070,14 @@ WriteLiteral(" ");
#line default
#line hidden
#line 637 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
#line 655 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
Write(Html.ActionLinkSmallButton("Recommission", MVC.API.Device.Recommission(Model.Device.SerialNumber, true), "Device_Show_Device_Actions_Recommission_Button"));
#line default
#line hidden
#line 637 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
#line 655 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
@@ -2027,7 +2134,7 @@ WriteLiteral(@">
");
#line 673 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
#line 691 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
}
@@ -2036,7 +2143,7 @@ WriteLiteral(@">
WriteLiteral(" ");
#line 674 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
#line 692 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
if (Model.Device.CanDelete())
{
@@ -2044,14 +2151,14 @@ WriteLiteral(" ");
#line default
#line hidden
#line 676 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
#line 694 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
Write(Html.ActionLinkSmallButton("Delete Device", MVC.API.Device.Delete(Model.Device.SerialNumber, true), "Device_Show_Device_Actions_Delete_Button"));
#line default
#line hidden
#line 676 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
#line 694 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
@@ -2113,7 +2220,7 @@ WriteLiteral(@">
");
#line 714 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
#line 732 "..\..\Views\Device\DeviceParts\_Subject.cshtml"
}