Feature #33: Enhanced Device Importing

Dynamic device importing. better input parsing and 5 additional import
fields.
This commit is contained in:
Gary Sharp
2014-05-25 16:34:06 +10:00
parent 6a45348bdb
commit e9042f7666
68 changed files with 6775 additions and 3039 deletions
@@ -83,19 +83,19 @@ namespace Disco.Models.Services.Devices.Exporting
public bool ProfileShortName { get; set; }
// User
[Display(ShortName = "Assigned User", Name = "Identifier", Description = "The identifier of the user assigned with the device")]
[Display(ShortName = "Assigned User", Name = "Identifier", Description = "The identifier of the user assigned to the device")]
public bool AssignedUserId { get; set; }
[Display(ShortName = "Assigned User", Name = "Assigned Date", Description = "The date the device was assigned to the user")]
public bool AssignedUserDate { get; set; }
[Display(ShortName = "Assigned User", Name = "Display Name", Description = "The display name of the user assigned with the device")]
[Display(ShortName = "Assigned User", Name = "Display Name", Description = "The display name of the user assigned to the device")]
public bool AssignedUserDisplayName { get; set; }
[Display(ShortName = "Assigned User", Name = "Surname", Description = "The surname of the user assigned with the device")]
[Display(ShortName = "Assigned User", Name = "Surname", Description = "The surname of the user assigned to the device")]
public bool AssignedUserSurname { get; set; }
[Display(ShortName = "Assigned User", Name = "Given Name", Description = "The given name of the user assigned with the device")]
[Display(ShortName = "Assigned User", Name = "Given Name", Description = "The given name of the user assigned to the device")]
public bool AssignedUserGivenName { get; set; }
[Display(ShortName = "Assigned User", Name = "Phone Number", Description = "The phone number of the user assigned with the device")]
[Display(ShortName = "Assigned User", Name = "Phone Number", Description = "The phone number of the user assigned to the device")]
public bool AssignedUserPhoneNumber { get; set; }
[Display(ShortName = "Assigned User", Name = "Email Address", Description = "The email address of the user assigned with the device")]
[Display(ShortName = "Assigned User", Name = "Email Address", Description = "The email address of the user assigned to the device")]
public bool AssignedUserEmailAddress { get; set; }
// Jobs
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Services.Devices.Importing
{
public enum DeviceImportFieldTypes
{
[Required, Display(Name = "Device Serial Number", Description = "The device serial number")]
DeviceSerialNumber,
[Display(Name = "Device Asset Number", Description = "The device asset number")]
DeviceAssetNumber,
[Display(Name = "Device Location", Description = "The device location")]
DeviceLocation,
[Display(Name = "Device Decommissioned Date", Description = "The date the device was decommissioned in Disco")]
DeviceDecommissionedDate,
[Display(Name = "Device Decommissioned Reason", Description = "The reason the device was decommissioned")]
DeviceDecommissionedReason,
[Display(Name = "Device LAN MAC Address", Description = "The LAN MAC Address associated with the device")]
DetailLanMacAddress,
[Display(Name = "Device Wireless LAN MAC Address", Description = "The Wireless LAN MAC Address associated with the device")]
DetailWLanMacAddress,
[Display(Name = "Device AC Adapter", Description = "The AC Adapter associated with the device")]
DetailACAdapter,
[Display(Name = "Model Identifier", Description = "The identifier of the device model associated with the device")]
ModelId,
[Display(Name = "Batch Identifier", Description = "The identifier of the device batch associated with the device")]
BatchId,
[Display(Name = "Profile Identifier", Description = "The identifier of the device profile associated with the device")]
ProfileId,
[Display(Name = "Assigned User Identifier", Description = "The identifier of the user assigned to the device")]
AssignedUserId,
[Display(Name = "Ignore Column", Description = "The column will be ignored during the import")]
IgnoreColumn
}
}
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Services.Devices.Importing
{
public interface IDeviceImportContext
{
string SessionId { get; }
string Filename { get; }
List<Tuple<string, DeviceImportFieldTypes>> Header { get; }
List<Tuple<string, DeviceImportFieldTypes, Func<string[], string>, Type>> ParsedHeaders { get; }
List<string[]> RawData { get; }
List<IDeviceImportRecord> Records { get; }
int AffectedRecords { get; }
}
}
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Services.Devices.Importing
{
public interface IDeviceImportField
{
DeviceImportFieldTypes FieldType { get; }
EntityState? FieldAction { get; }
string ErrorMessage { get; }
object RawParsedValue { get; }
string FriendlyValue { get; }
string FriendlyPreviousValue { get; }
}
}
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Services.Devices.Importing
{
public interface IDeviceImportRecord
{
string DeviceSerialNumber { get; }
IEnumerable<IDeviceImportField> Fields { get; }
EntityState RecordAction { get; }
bool HasError { get; }
}
}