Feature: Device Importing - Initial
This commit is contained in:
@@ -464,5 +464,27 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
|
||||
#endregion
|
||||
|
||||
public virtual ActionResult ImportParse(HttpPostedFileBase ImportFile)
|
||||
{
|
||||
if (ImportFile == null || ImportFile.ContentLength == 0)
|
||||
throw new ArgumentNullException("ImportFile");
|
||||
|
||||
var status = Disco.BI.DeviceBI.Importing.ImportParseTask.Run(ImportFile.InputStream);
|
||||
|
||||
status.SetFinishedUrl(Url.Action(MVC.API.Device.ImportProcess(status.SessionId)));
|
||||
|
||||
return RedirectToAction(MVC.Config.Logging.TaskStatus(status.SessionId));
|
||||
}
|
||||
|
||||
public virtual ActionResult ImportProcess(string ParseTaskSessionKey)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(ParseTaskSessionKey))
|
||||
throw new ArgumentNullException("ParseTaskSessionKey");
|
||||
|
||||
var status = Disco.BI.DeviceBI.Importing.ImportProcessTask.Run(ParseTaskSessionKey);
|
||||
|
||||
return RedirectToAction(MVC.Config.Logging.TaskStatus(status.SessionId));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Disco.Web.Controllers
|
||||
if (!string.IsNullOrEmpty(m.Device.SerialNumber) && dbContext.Devices.Count(d => d.SerialNumber == m.Device.SerialNumber) > 0)
|
||||
ModelState.AddModelError("Device.SerialNumber", "A Device what this Serial Number already exists");
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
@@ -76,6 +76,19 @@ namespace Disco.Web.Controllers
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Import
|
||||
[HttpGet]
|
||||
public virtual ActionResult Import()
|
||||
{
|
||||
Models.Device.ImportModel m = new Models.Device.ImportModel();
|
||||
|
||||
// UI Extensions
|
||||
UIExtensions.ExecuteExtensions<DeviceImportModel>(this.ControllerContext, m);
|
||||
|
||||
return View();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Show
|
||||
public virtual ActionResult Show(string id)
|
||||
{
|
||||
@@ -118,7 +131,7 @@ namespace Disco.Web.Controllers
|
||||
HideClosedJobs = true,
|
||||
EnablePaging = false
|
||||
};
|
||||
m.Jobs.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.DeviceSerialNumber == m.Device.SerialNumber).OrderByDescending(j => j.Id));
|
||||
m.Jobs.Fill(dbContext, BI.JobBI.Searching.BuildJobTableModel(dbContext).Where(j => j.DeviceSerialNumber == m.Device.SerialNumber).OrderByDescending(j => j.Id));
|
||||
|
||||
m.Certificates = dbContext.DeviceCertificates.Where(c => c.DeviceSerialNumber == m.Device.SerialNumber).ToList();
|
||||
|
||||
|
||||
@@ -513,6 +513,7 @@
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Models\Device\AddOfflineModel.cs" />
|
||||
<Compile Include="Models\Device\ImportModel.cs" />
|
||||
<Compile Include="Models\Device\IndexModel.cs" />
|
||||
<Compile Include="Models\Device\ShowModel.cs" />
|
||||
<Compile Include="Models\InitialConfig\CompleteModel.cs" />
|
||||
@@ -566,6 +567,11 @@
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>_Subject.cshtml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Device\Import.generated.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Import.cshtml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\Device\Index.generated.cs">
|
||||
<DependentUpon>Index.cshtml</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
@@ -1444,6 +1450,10 @@
|
||||
<Generator>RazorGenerator</Generator>
|
||||
<LastGenOutput>_Subject.generated.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Include="Views\Device\Import.cshtml">
|
||||
<Generator>RazorGenerator</Generator>
|
||||
<LastGenOutput>Import.generated.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Include="Views\Device\Index.cshtml">
|
||||
<Generator>RazorGenerator</Generator>
|
||||
<LastGenOutput>Index.generated.cs</LastGenOutput>
|
||||
@@ -1911,7 +1921,7 @@
|
||||
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
|
||||
</WebProjectProperties>
|
||||
</FlavorProperties>
|
||||
<UserProperties BuildVersion_StartDate="2011/7/1" BuildVersion_BuildAction="Both" BuildVersion_UseGlobalSettings="False" BuildVersion_DetectChanges="False" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_UpdateFileVersion="True" />
|
||||
<UserProperties BuildVersion_UpdateFileVersion="True" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.DeltaBaseYear.MonthAndDayStamp.TimeStamp" BuildVersion_DetectChanges="False" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildAction="Both" BuildVersion_StartDate="2011/7/1" />
|
||||
</VisualStudio>
|
||||
</ProjectExtensions>
|
||||
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using Disco.Models.UI.Device;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace Disco.Web.Models.Device
|
||||
{
|
||||
public class ImportModel : DeviceImportModel
|
||||
{
|
||||
[Required, Display(Name="Import File")]
|
||||
public HttpPostedFileBase ImportFile { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.2.0722.1715")]
|
||||
[assembly: AssemblyFileVersion("1.2.0722.1715")]
|
||||
[assembly: AssemblyVersion("1.2.0722.2112")]
|
||||
[assembly: AssemblyFileVersion("1.2.0722.2112")]
|
||||
@@ -1107,6 +1107,7 @@ namespace Disco.Web.Controllers
|
||||
{
|
||||
public readonly string Index = "Index";
|
||||
public readonly string AddOffline = "AddOffline";
|
||||
public readonly string Import = "Import";
|
||||
public readonly string Show = "Show";
|
||||
}
|
||||
|
||||
@@ -1115,6 +1116,7 @@ namespace Disco.Web.Controllers
|
||||
{
|
||||
public const string Index = "Index";
|
||||
public const string AddOffline = "AddOffline";
|
||||
public const string Import = "Import";
|
||||
public const string Show = "Show";
|
||||
}
|
||||
|
||||
@@ -1148,12 +1150,14 @@ namespace Disco.Web.Controllers
|
||||
public readonly string _DeviceTable = "_DeviceTable";
|
||||
public readonly string _ViewStart = "_ViewStart";
|
||||
public readonly string AddOffline = "AddOffline";
|
||||
public readonly string Import = "Import";
|
||||
public readonly string Index = "Index";
|
||||
public readonly string Show = "Show";
|
||||
}
|
||||
public readonly string _DeviceTable = "~/Views/Device/_DeviceTable.cshtml";
|
||||
public readonly string _ViewStart = "~/Views/Device/_ViewStart.cshtml";
|
||||
public readonly string AddOffline = "~/Views/Device/AddOffline.cshtml";
|
||||
public readonly string Import = "~/Views/Device/Import.cshtml";
|
||||
public readonly string Index = "~/Views/Device/Index.cshtml";
|
||||
public readonly string Show = "~/Views/Device/Show.cshtml";
|
||||
static readonly _DevicePartsClass s_DeviceParts = new _DevicePartsClass();
|
||||
@@ -1213,6 +1217,15 @@ namespace Disco.Web.Controllers
|
||||
return callInfo;
|
||||
}
|
||||
|
||||
partial void ImportOverride(T4MVC_System_Web_Mvc_ActionResult callInfo);
|
||||
|
||||
public override System.Web.Mvc.ActionResult Import()
|
||||
{
|
||||
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.Import);
|
||||
ImportOverride(callInfo);
|
||||
return callInfo;
|
||||
}
|
||||
|
||||
partial void ShowOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string id);
|
||||
|
||||
public override System.Web.Mvc.ActionResult Show(string id)
|
||||
@@ -3268,6 +3281,18 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.AttachmentRemove);
|
||||
}
|
||||
[NonAction]
|
||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||
public virtual System.Web.Mvc.ActionResult ImportParse()
|
||||
{
|
||||
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ImportParse);
|
||||
}
|
||||
[NonAction]
|
||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||
public virtual System.Web.Mvc.ActionResult ImportProcess()
|
||||
{
|
||||
return new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ImportProcess);
|
||||
}
|
||||
|
||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||
public DeviceController Actions { get { return MVC.API.Device; } }
|
||||
@@ -3302,6 +3327,8 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
public readonly string Attachment = "Attachment";
|
||||
public readonly string Attachments = "Attachments";
|
||||
public readonly string AttachmentRemove = "AttachmentRemove";
|
||||
public readonly string ImportParse = "ImportParse";
|
||||
public readonly string ImportProcess = "ImportProcess";
|
||||
}
|
||||
|
||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||
@@ -3325,6 +3352,8 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
public const string Attachment = "Attachment";
|
||||
public const string Attachments = "Attachments";
|
||||
public const string AttachmentRemove = "AttachmentRemove";
|
||||
public const string ImportParse = "ImportParse";
|
||||
public const string ImportProcess = "ImportProcess";
|
||||
}
|
||||
|
||||
|
||||
@@ -3492,6 +3521,22 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
{
|
||||
public readonly string id = "id";
|
||||
}
|
||||
static readonly ActionParamsClass_ImportParse s_params_ImportParse = new ActionParamsClass_ImportParse();
|
||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||
public ActionParamsClass_ImportParse ImportParseParams { get { return s_params_ImportParse; } }
|
||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||
public class ActionParamsClass_ImportParse
|
||||
{
|
||||
public readonly string ImportFile = "ImportFile";
|
||||
}
|
||||
static readonly ActionParamsClass_ImportProcess s_params_ImportProcess = new ActionParamsClass_ImportProcess();
|
||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||
public ActionParamsClass_ImportProcess ImportProcessParams { get { return s_params_ImportProcess; } }
|
||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||
public class ActionParamsClass_ImportProcess
|
||||
{
|
||||
public readonly string ParseTaskSessionKey = "ParseTaskSessionKey";
|
||||
}
|
||||
static readonly ViewsClass s_views = new ViewsClass();
|
||||
[GeneratedCode("T4MVC", "2.0"), DebuggerNonUserCode]
|
||||
public ViewsClass Views { get { return s_views; } }
|
||||
@@ -3711,6 +3756,26 @@ namespace Disco.Web.Areas.API.Controllers
|
||||
return callInfo;
|
||||
}
|
||||
|
||||
partial void ImportParseOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, System.Web.HttpPostedFileBase ImportFile);
|
||||
|
||||
public override System.Web.Mvc.ActionResult ImportParse(System.Web.HttpPostedFileBase ImportFile)
|
||||
{
|
||||
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ImportParse);
|
||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "ImportFile", ImportFile);
|
||||
ImportParseOverride(callInfo, ImportFile);
|
||||
return callInfo;
|
||||
}
|
||||
|
||||
partial void ImportProcessOverride(T4MVC_System_Web_Mvc_ActionResult callInfo, string ParseTaskSessionKey);
|
||||
|
||||
public override System.Web.Mvc.ActionResult ImportProcess(string ParseTaskSessionKey)
|
||||
{
|
||||
var callInfo = new T4MVC_System_Web_Mvc_ActionResult(Area, Name, ActionNames.ImportProcess);
|
||||
ModelUnbinderHelpers.AddRouteValues(callInfo.RouteValueDictionary, "ParseTaskSessionKey", ParseTaskSessionKey);
|
||||
ImportProcessOverride(callInfo, ParseTaskSessionKey);
|
||||
return callInfo;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
@model Disco.Web.Models.Device.ImportModel
|
||||
@{
|
||||
ViewBag.Title = Html.ToBreadcrumb("Devices", MVC.Device.Index(), "Import Devices");
|
||||
}
|
||||
@using (Html.BeginForm(MVC.API.Device.ImportParse(), FormMethod.Post, new { enctype = "multipart/form-data" }))
|
||||
{
|
||||
@Html.ValidationSummary()
|
||||
<div id="importDialog" class="form" style="width: 450px">
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
@Html.LabelFor(m => m.ImportFile)
|
||||
</th>
|
||||
<td>
|
||||
<input id="ImportFile" name="ImportFile" type="file" data-val="true" data-val-required="An Import File is required." />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p class="actions">
|
||||
<input type="submit" class="button" value="Import" />
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
#pragma warning disable 1591
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.18051
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Disco.Web.Views.Device
|
||||
{
|
||||
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", "2.0.0.0")]
|
||||
[System.Web.WebPages.PageVirtualPathAttribute("~/Views/Device/Import.cshtml")]
|
||||
public partial class Import : System.Web.Mvc.WebViewPage<Disco.Web.Models.Device.ImportModel>
|
||||
{
|
||||
public Import()
|
||||
{
|
||||
}
|
||||
public override void Execute()
|
||||
{
|
||||
|
||||
#line 2 "..\..\Views\Device\Import.cshtml"
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Devices", MVC.Device.Index(), "Import Devices");
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
|
||||
#line 5 "..\..\Views\Device\Import.cshtml"
|
||||
using (Html.BeginForm(MVC.API.Device.ImportParse(), FormMethod.Post, new { enctype = "multipart/form-data" }))
|
||||
{
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 7 "..\..\Views\Device\Import.cshtml"
|
||||
Write(Html.ValidationSummary());
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 7 "..\..\Views\Device\Import.cshtml"
|
||||
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" id=\"importDialog\"");
|
||||
|
||||
WriteLiteral(" class=\"form\"");
|
||||
|
||||
WriteLiteral(" style=\"width: 450px\"");
|
||||
|
||||
WriteLiteral(">\r\n <table>\r\n <tr>\r\n <th>\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 12 "..\..\Views\Device\Import.cshtml"
|
||||
Write(Html.LabelFor(m => m.ImportFile));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </th>\r\n <td>\r\n <input");
|
||||
|
||||
WriteLiteral(" id=\"ImportFile\"");
|
||||
|
||||
WriteLiteral(" name=\"ImportFile\"");
|
||||
|
||||
WriteLiteral(" type=\"file\"");
|
||||
|
||||
WriteLiteral(" data-val=\"true\"");
|
||||
|
||||
WriteLiteral(" data-val-required=\"An Import File is required.\"");
|
||||
|
||||
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=\"Import\"");
|
||||
|
||||
WriteLiteral(" />\r\n </p>\r\n </div>\r\n");
|
||||
|
||||
|
||||
#line 23 "..\..\Views\Device\Import.cshtml"
|
||||
}
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma warning restore 1591
|
||||
@@ -5,5 +5,6 @@
|
||||
Search for a Device</h3>
|
||||
@Html.Partial(MVC.Shared.Views._SearchDialog, "devices")
|
||||
<div class="actionBar">
|
||||
@Html.ActionLinkButton("Import Devices", MVC.Device.Import())
|
||||
@Html.ActionLinkButton("Add Offline Device", MVC.Device.AddOffline())
|
||||
</div>
|
||||
|
||||
@@ -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.
|
||||
@@ -67,6 +67,17 @@ WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 8 "..\..\Views\Device\Index.cshtml"
|
||||
Write(Html.ActionLinkButton("Import Devices", MVC.Device.Import()));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 9 "..\..\Views\Device\Index.cshtml"
|
||||
Write(Html.ActionLinkButton("Add Offline Device", MVC.Device.AddOffline()));
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user