qol: remove this

This commit is contained in:
Gary Sharp
2025-07-20 11:39:42 +10:00
parent b4e54c9edf
commit 4e518d6684
56 changed files with 282 additions and 282 deletions
+10 -10
View File
@@ -30,15 +30,15 @@ namespace Disco.ClientBootstrapper
public BootstrapperLoop(IStatus StatusUI, LoopCompleteCallback Callback) public BootstrapperLoop(IStatus StatusUI, LoopCompleteCallback Callback)
{ {
this.statusUI = StatusUI; statusUI = StatusUI;
this.mLoopCompleteCallback = Callback; mLoopCompleteCallback = Callback;
this.errorMessage = new StringBuilder(); errorMessage = new StringBuilder();
} }
public void Start() public void Start()
{ {
this.LoopThread = new Thread(new ThreadStart(loopHost)); LoopThread = new Thread(new ThreadStart(loopHost));
this.LoopThread.Start(); LoopThread.Start();
} }
private void loopHost() private void loopHost()
@@ -133,9 +133,9 @@ namespace Disco.ClientBootstrapper
if (!Interop.NetworkInterop.PingDiscoIct(DiscoServerName)) if (!Interop.NetworkInterop.PingDiscoIct(DiscoServerName))
{ {
// Client Failed // Client Failed
if (this.mLoopCompleteCallback != null) if (mLoopCompleteCallback != null)
{ {
this.mLoopCompleteCallback.BeginInvoke(null, null); mLoopCompleteCallback.BeginInvoke(null, null);
} }
return; return;
} }
@@ -197,15 +197,15 @@ namespace Disco.ClientBootstrapper
Interop.CertificateInterop.RemoveTempCerts(); Interop.CertificateInterop.RemoveTempCerts();
// Pause if Error // Pause if Error
if (this.errorMessage.Length > 0) if (errorMessage.Length > 0)
{ {
Program.SleepThread(10000, true); Program.SleepThread(10000, true);
} }
// End Of Loop // End Of Loop
if (this.mLoopCompleteCallback != null) if (mLoopCompleteCallback != null)
{ {
this.mLoopCompleteCallback.BeginInvoke(null, null); mLoopCompleteCallback.BeginInvoke(null, null);
} }
} }
+6 -6
View File
@@ -22,9 +22,9 @@ namespace Disco.ClientBootstrapper
public void Start(CompleteCallback Callback) public void Start(CompleteCallback Callback)
{ {
this.mCompleteCallback = Callback; mCompleteCallback = Callback;
this.LoopThread = new Thread(new ThreadStart(loopHost)); LoopThread = new Thread(new ThreadStart(loopHost));
this.LoopThread.Start(); LoopThread.Start();
} }
private void loopHost() private void loopHost()
{ {
@@ -33,10 +33,10 @@ namespace Disco.ClientBootstrapper
//Program.Status.UpdateStatus(null, null, "Testing UI"); //Program.Status.UpdateStatus(null, null, "Testing UI");
//Program.SleepThread(5000, false); //Program.SleepThread(5000, false);
Interop.InstallInterop.Install(this.InstallLocation, this.WimImageId, this.TempPath); Interop.InstallInterop.Install(InstallLocation, WimImageId, TempPath);
if (this.mCompleteCallback != null) if (mCompleteCallback != null)
{ {
this.mCompleteCallback.BeginInvoke(null, null); mCompleteCallback.BeginInvoke(null, null);
} }
} }
catch (Exception ex) catch (Exception ex)
@@ -27,28 +27,28 @@ namespace Disco.ClientBootstrapper.Interop
private void UpdateFromWmi(ManagementObject wmiObject) private void UpdateFromWmi(ManagementObject wmiObject)
{ {
this.WmiPath = (string)wmiObject.GetPropertyValue("__PATH"); WmiPath = (string)wmiObject.GetPropertyValue("__PATH");
this.Index = (UInt32)wmiObject.GetPropertyValue("Index"); Index = (UInt32)wmiObject.GetPropertyValue("Index");
this.Guid = Guid.Parse((string)wmiObject.GetPropertyValue("GUID")); Guid = Guid.Parse((string)wmiObject.GetPropertyValue("GUID"));
this.MACAddress = (string)wmiObject.GetPropertyValue("MACAddress"); MACAddress = (string)wmiObject.GetPropertyValue("MACAddress");
this.Name = (string)wmiObject.GetPropertyValue("Name"); Name = (string)wmiObject.GetPropertyValue("Name");
this.NetConnectionID = (string)wmiObject.GetPropertyValue("NetConnectionID"); NetConnectionID = (string)wmiObject.GetPropertyValue("NetConnectionID");
this.Speed = (UInt64)wmiObject.GetPropertyValue("Speed"); Speed = (UInt64)wmiObject.GetPropertyValue("Speed");
var connectionStatus = ConnectionStatus; var connectionStatus = ConnectionStatus;
this.IsWireless = true; IsWireless = true;
try try
{ {
var wirelessConnectionStatus = WirelessConnectionStatus; var wirelessConnectionStatus = WirelessConnectionStatus;
} }
catch (Exception) { catch (Exception) {
this.IsWireless = false; IsWireless = false;
}; };
} }
public int WirelessConnectionStatus public int WirelessConnectionStatus
{ {
get { get {
if (this.IsWireless) if (IsWireless)
{ {
IntPtr handle = IntPtr.Zero; IntPtr handle = IntPtr.Zero;
uint negotiatedVersion; uint negotiatedVersion;
@@ -61,17 +61,17 @@ namespace Disco.ClientBootstrapper.Interop
uint dataSize; uint dataSize;
var interfaceGuid = this.Guid; var interfaceGuid = Guid;
if (NetworkInterop.WlanQueryInterface(handle, ref interfaceGuid, NetworkInterop.WLAN_INTF_OPCODE.wlan_intf_opcode_interface_state, IntPtr.Zero, out dataSize, ref ptr, IntPtr.Zero) != 0) if (NetworkInterop.WlanQueryInterface(handle, ref interfaceGuid, NetworkInterop.WLAN_INTF_OPCODE.wlan_intf_opcode_interface_state, IntPtr.Zero, out dataSize, ref ptr, IntPtr.Zero) != 0)
throw new NotSupportedException("This network adapter does not support Wireless"); throw new NotSupportedException("This network adapter does not support Wireless");
this.LastWirelessConnectionStatus = Marshal.ReadInt32(ptr); LastWirelessConnectionStatus = Marshal.ReadInt32(ptr);
NetworkInterop.WlanFreeMemory(ptr); NetworkInterop.WlanFreeMemory(ptr);
return this.LastWirelessConnectionStatus; return LastWirelessConnectionStatus;
} }
finally finally
{ {
@@ -115,11 +115,11 @@ namespace Disco.ClientBootstrapper.Interop
{ {
get get
{ {
using (var wmiObject = new ManagementObject(this.WmiPath)) using (var wmiObject = new ManagementObject(WmiPath))
{ {
this.LastConnectionStatus = (UInt16)wmiObject.GetPropertyValue("NetConnectionStatus"); LastConnectionStatus = (UInt16)wmiObject.GetPropertyValue("NetConnectionStatus");
} }
return this.LastConnectionStatus; return LastConnectionStatus;
} }
} }
public string ConnectionStatusMeaning(UInt16 status) public string ConnectionStatusMeaning(UInt16 status)
@@ -239,7 +239,7 @@ namespace Disco.ClientBootstrapper.Interop
public bool AddProfile(IntPtr WlanHandle, Guid interfaceGuid) public bool AddProfile(IntPtr WlanHandle, Guid interfaceGuid)
{ {
var pInterfaceGuid = interfaceGuid; var pInterfaceGuid = interfaceGuid;
var pProfileXml = this.ProfileXml; var pProfileXml = ProfileXml;
uint pFlag = 0; uint pFlag = 0;
uint failReason; uint failReason;
return (WlanSetProfile(WlanHandle, ref pInterfaceGuid, pFlag, pProfileXml, null, true, IntPtr.Zero, out failReason) == 0); return (WlanSetProfile(WlanHandle, ref pInterfaceGuid, pFlag, pProfileXml, null, true, IntPtr.Zero, out failReason) == 0);
@@ -80,20 +80,20 @@ namespace Disco.ClientBootstrapper.Interop
uint regHive = (uint)hive; uint regHive = (uint)hive;
this.Hive = hive; Hive = hive;
this.SubKey = subKey; SubKey = subKey;
RegLoadKey(regHive, subKey, filePath); RegLoadKey(regHive, subKey, filePath);
this.IsUnloaded = false; IsUnloaded = false;
} }
public void Unload() public void Unload()
{ {
if (!IsUnloaded) if (!IsUnloaded)
{ {
uint regHive = (uint)this.Hive; uint regHive = (uint)Hive;
string subKey = this.SubKey; string subKey = SubKey;
RegUnLoadKey(regHive, subKey); RegUnLoadKey(regHive, subKey);
this.IsUnloaded = true; IsUnloaded = true;
} }
} }
@@ -480,7 +480,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
// //
//Never commit changes when destroying this object. //Never commit changes when destroying this object.
// //
this.DismountImage(false); DismountImage(false);
} }
GC.KeepAlive(this); GC.KeepAlive(this);
} }
+13 -13
View File
@@ -28,17 +28,17 @@ namespace Disco.Data.Configuration
{ {
get get
{ {
return ConfigurationCache.GetScopeKeys(Database, this.Scope); return ConfigurationCache.GetScopeKeys(Database, Scope);
} }
} }
private void SetValue<T>(string Key, T Value) private void SetValue<T>(string Key, T Value)
{ {
ConfigurationCache.Helpers<T>.SetValue(Database, this.Scope, Key, Value); ConfigurationCache.Helpers<T>.SetValue(Database, Scope, Key, Value);
} }
private T GetValue<T>(string Key, T Default) private T GetValue<T>(string Key, T Default)
{ {
return ConfigurationCache.Helpers<T>.GetValue(Database, this.Scope, Key, Default); return ConfigurationCache.Helpers<T>.GetValue(Database, Scope, Key, Default);
} }
protected void Set<T>(T Value, [CallerMemberName] string Key = null) protected void Set<T>(T Value, [CallerMemberName] string Key = null)
@@ -46,7 +46,7 @@ namespace Disco.Data.Configuration
if (Key == null) if (Key == null)
throw new ArgumentNullException("Key"); throw new ArgumentNullException("Key");
this.SetValue(Key, Value); SetValue(Key, Value);
} }
protected T Get<T>(T Default, [CallerMemberName] string Key = null) protected T Get<T>(T Default, [CallerMemberName] string Key = null)
@@ -54,17 +54,17 @@ namespace Disco.Data.Configuration
if (Key == null) if (Key == null)
throw new ArgumentNullException("Key"); throw new ArgumentNullException("Key");
return this.GetValue(Key, Default); return GetValue(Key, Default);
} }
protected void SetObsfucated(string Value, [CallerMemberName] string Key = null) protected void SetObsfucated(string Value, [CallerMemberName] string Key = null)
{ {
this.Set(Value.Obsfucate(), Key); Set(Value.Obsfucate(), Key);
} }
protected string GetDeobsfucated(string Default, [CallerMemberName] string Key = null) protected string GetDeobsfucated(string Default, [CallerMemberName] string Key = null)
{ {
var obsfucatedValue = this.Get<string>(null, Key); var obsfucatedValue = Get<string>(null, Key);
if (obsfucatedValue == null) if (obsfucatedValue == null)
return Default; return Default;
@@ -74,35 +74,35 @@ namespace Disco.Data.Configuration
protected void RemoveScope() protected void RemoveScope()
{ {
ConfigurationCache.RemoveScope(Database, this.Scope); ConfigurationCache.RemoveScope(Database, Scope);
} }
protected void RemoveItem(string Key) protected void RemoveItem(string Key)
{ {
ConfigurationCache.RemoveScopeKey(Database, this.Scope, Key); ConfigurationCache.RemoveScopeKey(Database, Scope, Key);
} }
[Obsolete("Types are automatically serialized/deserialized if required, use Set<T>(T Value) instead.")] [Obsolete("Types are automatically serialized/deserialized if required, use Set<T>(T Value) instead.")]
protected void SetAsJson<T>(T Value, [CallerMemberName] string Key = null) protected void SetAsJson<T>(T Value, [CallerMemberName] string Key = null)
{ {
this.Set(Value, Key); Set(Value, Key);
} }
[Obsolete("Types are automatically serialized/deserialized if required, use Get<T>(T Default) instead.")] [Obsolete("Types are automatically serialized/deserialized if required, use Get<T>(T Default) instead.")]
protected T GetFromJson<T>(T Default, [CallerMemberName] string Key = null) protected T GetFromJson<T>(T Default, [CallerMemberName] string Key = null)
{ {
return this.Get(Default, Key); return Get(Default, Key);
} }
[Obsolete("Types are automatically serialized/deserialized if required, use Set<T>(T Value) instead.")] [Obsolete("Types are automatically serialized/deserialized if required, use Set<T>(T Value) instead.")]
protected void SetAsEnum<T>(T Value, [CallerMemberName] string Key = null) protected void SetAsEnum<T>(T Value, [CallerMemberName] string Key = null)
{ {
this.Set(Value, Key); Set(Value, Key);
} }
[Obsolete("Types are automatically serialized/deserialized if required, use Set<T>(T Value) instead.")] [Obsolete("Types are automatically serialized/deserialized if required, use Set<T>(T Value) instead.")]
protected T GetFromEnum<T>(T Default, [CallerMemberName] string Key = null) protected T GetFromEnum<T>(T Default, [CallerMemberName] string Key = null)
{ {
return this.Get(Default, Key); return Get(Default, Key);
} }
} }
} }
@@ -13,7 +13,7 @@ namespace Disco.Data.Configuration.Modules
{ {
get get
{ {
var v = this.Get(1); var v = Get(1);
if (v > 0) if (v > 0)
return v; return v;
else else
@@ -24,21 +24,21 @@ namespace Disco.Data.Configuration.Modules
if (value < 1) if (value < 1)
throw new ArgumentOutOfRangeException("value", "Expected >= 1"); throw new ArgumentOutOfRangeException("value", "Expected >= 1");
this.Set(value); Set(value);
} }
} }
public int DefaultAddDeviceOfflineDeviceProfileId public int DefaultAddDeviceOfflineDeviceProfileId
{ {
get get
{ {
return this.Get(0); return Get(0);
} }
set set
{ {
if (value < 0) if (value < 0)
throw new ArgumentOutOfRangeException("value", "Expected >= 0"); throw new ArgumentOutOfRangeException("value", "Expected >= 0");
this.Set(value); Set(value);
} }
} }
+2 -2
View File
@@ -11,7 +11,7 @@ namespace Disco.Data.Repository
public DiscoDataContext() public DiscoDataContext()
{ {
this._Configuration = new Lazy<Configuration.SystemConfiguration>(() => new Configuration.SystemConfiguration(this)); _Configuration = new Lazy<Configuration.SystemConfiguration>(() => new Configuration.SystemConfiguration(this));
} }
public virtual DbSet<ConfigurationItem> ConfigurationItems { get; set; } public virtual DbSet<ConfigurationItem> ConfigurationItems { get; set; }
@@ -60,7 +60,7 @@ namespace Disco.Data.Repository
{ {
get get
{ {
return this._Configuration.Value; return _Configuration.Value;
} }
} }
@@ -55,8 +55,8 @@ namespace Disco.Data.Repository
public DiscoDatabaseConnectionFactory(IDbConnectionFactory Default) public DiscoDatabaseConnectionFactory(IDbConnectionFactory Default)
{ {
this.DefaultConnectionFactory = Default; DefaultConnectionFactory = Default;
this.SqlCeConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0"); SqlCeConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0");
} }
public DbConnection CreateConnection(string nameOrConnectionString) public DbConnection CreateConnection(string nameOrConnectionString)
+2 -2
View File
@@ -73,9 +73,9 @@ namespace Disco.Models.Repository
public override string ToString() public override string ToString()
{ {
if (DeviceModel != null) if (DeviceModel != null)
return string.Format("{0} - {1}", this.DeviceModel, this.SerialNumber); return string.Format("{0} - {1}", DeviceModel, SerialNumber);
else else
return this.SerialNumber; return SerialNumber;
} }
[NotMapped] [NotMapped]
@@ -53,11 +53,11 @@ namespace Disco.Models.Repository
public override string ToString() public override string ToString()
{ {
if (string.IsNullOrWhiteSpace(this.Name)) if (string.IsNullOrWhiteSpace(Name))
{ {
return string.Format("{0}: {1}", this.Id, this.PurchaseDate.ToLongDateString()); return string.Format("{0}: {1}", Id, PurchaseDate.ToLongDateString());
} }
return this.Name; return Name;
} }
} }
} }
@@ -48,11 +48,11 @@ namespace Disco.Models.Repository
public override string ToString() public override string ToString()
{ {
if (string.IsNullOrEmpty(this.ShortName)) if (string.IsNullOrEmpty(ShortName))
{ {
return this.Name; return Name;
} }
return string.Format("{0} ({1})", this.Name, this.ShortName); return string.Format("{0} ({1})", Name, ShortName);
} }
[StringLength(200)] [StringLength(200)]
+2 -2
View File
@@ -79,9 +79,9 @@ namespace Disco.Models.Repository
#region Helper Members #region Helper Members
public decimal JobComponentsTotalCost() public decimal JobComponentsTotalCost()
{ {
if (this.JobComponents != null) if (JobComponents != null)
{ {
return this.JobComponents.Sum(jc => jc.Cost); return JobComponents.Sum(jc => jc.Cost);
} }
return decimal.Zero; return decimal.Zero;
} }
+1 -1
View File
@@ -30,7 +30,7 @@ namespace Disco.Models.Repository
public override string ToString() public override string ToString()
{ {
return this.Description; return Description;
} }
} }
} }
+1 -1
View File
@@ -14,7 +14,7 @@ namespace Disco.Models.Repository
public override string ToString() public override string ToString()
{ {
return this.Description; return Description;
} }
public static class JobTypeIds public static class JobTypeIds
@@ -28,7 +28,7 @@ namespace Disco.Models.Repository
public override string ToString() public override string ToString()
{ {
return this.Name; return Name;
} }
} }
} }
@@ -31,7 +31,7 @@ namespace Disco.Models.Repository
public override string ToString() public override string ToString()
{ {
return this.Name; return Name;
} }
} }
} }
+11 -11
View File
@@ -73,32 +73,32 @@ namespace Disco.Models.Repository
{ {
var changed = false; var changed = false;
if (!this.UserId.Equals(u.UserId, StringComparison.OrdinalIgnoreCase)) if (!UserId.Equals(u.UserId, StringComparison.OrdinalIgnoreCase))
throw new ArgumentException("User Id's do not match", nameof(u)); throw new ArgumentException("User Id's do not match", nameof(u));
if (this.Surname != u.Surname) if (Surname != u.Surname)
{ {
this.Surname = u.Surname; Surname = u.Surname;
changed = true; changed = true;
} }
if (this.GivenName != u.GivenName) if (GivenName != u.GivenName)
{ {
this.GivenName = u.GivenName; GivenName = u.GivenName;
changed = true; changed = true;
} }
if (this.DisplayName != u.DisplayName) if (DisplayName != u.DisplayName)
{ {
this.DisplayName = u.DisplayName; DisplayName = u.DisplayName;
changed = true; changed = true;
} }
if (this.EmailAddress != u.EmailAddress) if (EmailAddress != u.EmailAddress)
{ {
this.EmailAddress = u.EmailAddress; EmailAddress = u.EmailAddress;
changed = true; changed = true;
} }
if (this.PhoneNumber != u.PhoneNumber) if (PhoneNumber != u.PhoneNumber)
{ {
this.PhoneNumber = u.PhoneNumber; PhoneNumber = u.PhoneNumber;
changed = true; changed = true;
} }
@@ -13,24 +13,24 @@ namespace Disco.Models.Services.Documents
public DocumentState(int SequenceNumber) public DocumentState(int SequenceNumber)
{ {
this.SequenceNumber = SequenceNumber; this.SequenceNumber = SequenceNumber;
this.FieldCache = new Hashtable(); FieldCache = new Hashtable();
this.ScopeCache = new Hashtable(); ScopeCache = new Hashtable();
this.DocumentCache = new Hashtable(); DocumentCache = new Hashtable();
} }
public void FlushFieldCache() public void FlushFieldCache()
{ {
FlushDictionary(this.FieldCache); FlushDictionary(FieldCache);
} }
public void FlushScopeCache() public void FlushScopeCache()
{ {
FlushFieldCache(); FlushFieldCache();
FlushDictionary(this.ScopeCache); FlushDictionary(ScopeCache);
} }
public void FlushDocumentCache() public void FlushDocumentCache()
{ {
FlushScopeCache(); FlushScopeCache();
FlushDictionary(this.DocumentCache); FlushDictionary(DocumentCache);
} }
private static void FlushDictionary(Hashtable d) private static void FlushDictionary(Hashtable d)
{ {
@@ -13,12 +13,12 @@ namespace Disco.Models.Services.Jobs.JobLists
{ {
get get
{ {
return this.JobId.ToString(); return JobId.ToString();
} }
set set
{ {
base.Id = value; base.Id = value;
this.JobId = int.Parse(value); JobId = int.Parse(value);
} }
} }
#pragma warning restore 618 #pragma warning restore 618
@@ -11,12 +11,12 @@ namespace Disco.Models.Services.Searching
public DeviceSearchResultItem() public DeviceSearchResultItem()
{ {
this.LazyScoreValue = new Lazy<string[]>(BuildScoreValues, false); LazyScoreValue = new Lazy<string[]>(BuildScoreValues, false);
} }
public string Id { get; set; } public string Id { get; set; }
public string Type { get { return type; } } public string Type { get { return type; } }
public string Description { get { return string.Format("{0} ({1})", this.Id, this.ComputerName); } } public string Description { get { return string.Format("{0} ({1})", Id, ComputerName); } }
public string[] ScoreValues { get { return LazyScoreValue.Value; } } public string[] ScoreValues { get { return LazyScoreValue.Value; } }
public string AssetNumber { get; set; } public string AssetNumber { get; set; }
@@ -46,23 +46,23 @@ namespace Disco.Models.Services.Searching
private string[] BuildScoreValues() private string[] BuildScoreValues()
{ {
if (this.AssignedUserId == null) if (AssignedUserId == null)
{ {
return new string[] { return new string[] {
this.Id, Id,
this.AssetNumber, AssetNumber,
this.ComputerName ComputerName
}; };
} }
else else
{ {
return new string[] { return new string[] {
this.Id, Id,
this.AssetNumber, AssetNumber,
this.ComputerName, ComputerName,
this.AssignedUserId.Substring(this.AssignedUserId.IndexOf('\\') + 1), AssignedUserId.Substring(AssignedUserId.IndexOf('\\') + 1),
this.AssignedUserId, AssignedUserId,
this.AssignedUserDisplayName AssignedUserDisplayName
}; };
} }
} }
@@ -9,12 +9,12 @@ namespace Disco.Models.Services.Searching
public JobSearchResultItem() public JobSearchResultItem()
{ {
this.LazyScoreValue = new Lazy<string[]>(BuildScoreValues, false); LazyScoreValue = new Lazy<string[]>(BuildScoreValues, false);
} }
public virtual string Id { get; set; } public virtual string Id { get; set; }
public string Type { get { return type; } } public string Type { get { return type; } }
public string Description { get { return string.Format("{0} ({1}; {2})", this.Id, this.UserId, this.DeviceSerialNumber); } } public string Description { get { return string.Format("{0} ({1}; {2})", Id, UserId, DeviceSerialNumber); } }
public string[] ScoreValues { get { return LazyScoreValue.Value; } } public string[] ScoreValues { get { return LazyScoreValue.Value; } }
public string DeviceSerialNumber { get; set; } public string DeviceSerialNumber { get; set; }
@@ -25,21 +25,21 @@ namespace Disco.Models.Services.Searching
private string[] BuildScoreValues() private string[] BuildScoreValues()
{ {
if (this.UserId == null) if (UserId == null)
{ {
return new string[] { return new string[] {
this.Id, Id,
this.DeviceSerialNumber DeviceSerialNumber
}; };
} }
else else
{ {
return new string[] { return new string[] {
this.Id, Id,
this.UserId.Substring(this.UserId.IndexOf('\\') + 1), UserId.Substring(UserId.IndexOf('\\') + 1),
this.UserId, UserId,
this.UserDisplayName, UserDisplayName,
this.DeviceSerialNumber DeviceSerialNumber
}; };
} }
} }
@@ -11,13 +11,13 @@ namespace Disco.Models.Services.Searching
public UserSearchResultItem() public UserSearchResultItem()
{ {
this.LazyScoreValue = new Lazy<string[]>(BuildScoreValues, false); LazyScoreValue = new Lazy<string[]>(BuildScoreValues, false);
} }
public string Id { get; set; } public string Id { get; set; }
public string FriendlyId { get; set; } public string FriendlyId { get; set; }
public string Type { get { return type; } } public string Type { get { return type; } }
public string Description { get { return string.Format("{0} ({1})", this.DisplayName, this.Id); } } public string Description { get { return string.Format("{0} ({1})", DisplayName, Id); } }
public string[] ScoreValues { get { return LazyScoreValue.Value; } } public string[] ScoreValues { get { return LazyScoreValue.Value; } }
public string DisplayName { get; set; } public string DisplayName { get; set; }
@@ -34,9 +34,9 @@ namespace Disco.Models.Services.Searching
private string[] BuildScoreValues() private string[] BuildScoreValues()
{ {
return new string[] { return new string[] {
this.Id.Substring(this.Id.IndexOf('\\') + 1), Id.Substring(Id.IndexOf('\\') + 1),
this.Id, Id,
this.DisplayName DisplayName
}; };
} }
} }
@@ -28,7 +28,7 @@ namespace Disco.Web.Extensions
protected override void WriteFile(HttpResponseBase response) protected override void WriteFile(HttpResponseBase response)
{ {
response.OutputStream.Write(this.FileBuffer, Start, Length); response.OutputStream.Write(FileBuffer, Start, Length);
} }
} }
} }
@@ -14,10 +14,10 @@ namespace Disco.Web.Areas.API.Models.Job
public _DateChangeModel SetDateTime(DateTime? date) public _DateChangeModel SetDateTime(DateTime? date)
{ {
this.DateTimeFriendly = date.FromNow(null); DateTimeFriendly = date.FromNow(null);
this.DateTimeISO8601 = date.ToISO8601(); DateTimeISO8601 = date.ToISO8601();
this.DateTimeUnixEpoc = date.ToUnixEpoc() ?? -1; DateTimeUnixEpoc = date.ToUnixEpoc() ?? -1;
this.DateTimeFull = date.ToFullDateTime(null); DateTimeFull = date.ToFullDateTime(null);
return this; return this;
} }
@@ -43,7 +43,7 @@ namespace Disco.Web.Areas.Config.Controllers
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigAuthorizationRoleShowModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigAuthorizationRoleShowModel>(ControllerContext, m);
return View(MVC.Config.AuthorizationRole.Views.Show, m); return View(MVC.Config.AuthorizationRole.Views.Show, m);
} }
@@ -66,7 +66,7 @@ namespace Disco.Web.Areas.Config.Controllers
}; };
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigAuthorizationRoleIndexModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigAuthorizationRoleIndexModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -81,7 +81,7 @@ namespace Disco.Web.Areas.Config.Controllers
}; };
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigAuthorizationRoleCreateModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigAuthorizationRoleCreateModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -106,7 +106,7 @@ namespace Disco.Web.Areas.Config.Controllers
} }
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigAuthorizationRoleCreateModel>(this.ControllerContext, model); UIExtensions.ExecuteExtensions<ConfigAuthorizationRoleCreateModel>(ControllerContext, model);
return View(model); return View(model);
} }
@@ -65,7 +65,7 @@ namespace Disco.Web.Areas.Config.Controllers
m.BulkGenerateDocumentTemplates = Database.DocumentTemplates.Where(t => !t.IsHidden).ToList(); m.BulkGenerateDocumentTemplates = Database.DocumentTemplates.Where(t => !t.IsHidden).ToList();
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceBatchShowModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDeviceBatchShowModel>(ControllerContext, m);
return View(MVC.Config.DeviceBatch.Views.Show, m); return View(MVC.Config.DeviceBatch.Views.Show, m);
} }
@@ -74,7 +74,7 @@ namespace Disco.Web.Areas.Config.Controllers
var m = Models.DeviceBatch.IndexModel.Build(Database); var m = Models.DeviceBatch.IndexModel.Build(Database);
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceBatchIndexModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDeviceBatchIndexModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -90,7 +90,7 @@ namespace Disco.Web.Areas.Config.Controllers
}; };
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceBatchCreateModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDeviceBatchCreateModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -115,7 +115,7 @@ namespace Disco.Web.Areas.Config.Controllers
} }
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceBatchCreateModel>(this.ControllerContext, model); UIExtensions.ExecuteExtensions<ConfigDeviceBatchCreateModel>(ControllerContext, model);
return View(model); return View(model);
} }
@@ -126,7 +126,7 @@ namespace Disco.Web.Areas.Config.Controllers
var m = new Models.DeviceBatch.TimelineModel(); var m = new Models.DeviceBatch.TimelineModel();
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceBatchTimelineModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDeviceBatchTimelineModel>(ControllerContext, m);
return View(); return View();
} }
@@ -49,7 +49,7 @@ namespace Disco.Web.Areas.Config.Controllers
} }
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceFlagShowModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDeviceFlagShowModel>(ControllerContext, m);
return View(MVC.Config.DeviceFlag.Views.Show, m); return View(MVC.Config.DeviceFlag.Views.Show, m);
} }
@@ -70,7 +70,7 @@ namespace Disco.Web.Areas.Config.Controllers
}; };
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceFlagIndexModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDeviceFlagIndexModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -90,7 +90,7 @@ namespace Disco.Web.Areas.Config.Controllers
}; };
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceFlagCreateModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDeviceFlagCreateModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -115,7 +115,7 @@ namespace Disco.Web.Areas.Config.Controllers
} }
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceFlagCreateModel>(this.ControllerContext, model); UIExtensions.ExecuteExtensions<ConfigDeviceFlagCreateModel>(ControllerContext, model);
return View(model); return View(model);
} }
@@ -91,7 +91,7 @@ namespace Disco.Web.Areas.Config.Controllers
m.BulkGenerateDocumentTemplates = Database.DocumentTemplates.Where(t => !t.IsHidden).ToList(); m.BulkGenerateDocumentTemplates = Database.DocumentTemplates.Where(t => !t.IsHidden).ToList();
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceProfileShowModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDeviceProfileShowModel>(ControllerContext, m);
return View(MVC.Config.DeviceProfile.Views.Show, m); return View(MVC.Config.DeviceProfile.Views.Show, m);
} }
@@ -100,7 +100,7 @@ namespace Disco.Web.Areas.Config.Controllers
var m = Models.DeviceProfile.IndexModel.Build(Database); var m = Models.DeviceProfile.IndexModel.Build(Database);
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceProfileIndexModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDeviceProfileIndexModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -121,7 +121,7 @@ namespace Disco.Web.Areas.Config.Controllers
}; };
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceProfileCreateModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDeviceProfileCreateModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -148,7 +148,7 @@ namespace Disco.Web.Areas.Config.Controllers
} }
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceProfileCreateModel>(this.ControllerContext, model); UIExtensions.ExecuteExtensions<ConfigDeviceProfileCreateModel>(ControllerContext, model);
return View(model); return View(model);
} }
@@ -166,7 +166,7 @@ namespace Disco.Web.Areas.Config.Controllers
m.DeviceProfilesAndNone.Insert(0, new DeviceProfile() { Id = 0, Name = "<No Default>" }); m.DeviceProfilesAndNone.Insert(0, new DeviceProfile() { Id = 0, Name = "<No Default>" });
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDeviceProfileDefaultsModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDeviceProfileDefaultsModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -43,7 +43,7 @@ namespace Disco.Web.Areas.Config.Controllers
}; };
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDocumentTemplateIndexModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDocumentTemplateIndexModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -72,7 +72,7 @@ namespace Disco.Web.Areas.Config.Controllers
m.BulkGenerateDownloadFilename = bulkGenerateFilename; m.BulkGenerateDownloadFilename = bulkGenerateFilename;
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDocumentTemplateShowModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDocumentTemplateShowModel>(ControllerContext, m);
return View(MVC.Config.DocumentTemplate.Views.Show, m); return View(MVC.Config.DocumentTemplate.Views.Show, m);
} }
@@ -99,7 +99,7 @@ namespace Disco.Web.Areas.Config.Controllers
m.DocumentTemplatesSelected = m.Package.GetDocumentTemplates(m.DocumentTemplates); m.DocumentTemplatesSelected = m.Package.GetDocumentTemplates(m.DocumentTemplates);
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDocumentTemplateShowPackageModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDocumentTemplateShowPackageModel>(ControllerContext, m);
return View(MVC.Config.DocumentTemplate.Views.ShowPackage, m); return View(MVC.Config.DocumentTemplate.Views.ShowPackage, m);
} }
@@ -110,7 +110,7 @@ namespace Disco.Web.Areas.Config.Controllers
var m = new ImportStatusModel(); var m = new ImportStatusModel();
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDocumentTemplateImportStatusModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDocumentTemplateImportStatusModel>(ControllerContext, m);
return View(); return View();
} }
@@ -124,7 +124,7 @@ namespace Disco.Web.Areas.Config.Controllers
}; };
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDocumentTemplateUndetectedPagesModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDocumentTemplateUndetectedPagesModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -136,7 +136,7 @@ namespace Disco.Web.Areas.Config.Controllers
m.UpdateModel(Database); m.UpdateModel(Database);
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDocumentTemplateCreateModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDocumentTemplateCreateModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -174,7 +174,7 @@ namespace Disco.Web.Areas.Config.Controllers
} }
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDocumentTemplateCreateModel>(this.ControllerContext, model); UIExtensions.ExecuteExtensions<ConfigDocumentTemplateCreateModel>(ControllerContext, model);
return View(model); return View(model);
} }
@@ -185,7 +185,7 @@ namespace Disco.Web.Areas.Config.Controllers
var m = new CreatePackageModel(); var m = new CreatePackageModel();
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDocumentTemplateCreatePackageModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigDocumentTemplateCreatePackageModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -210,7 +210,7 @@ namespace Disco.Web.Areas.Config.Controllers
} }
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigDocumentTemplateCreatePackageModel>(this.ControllerContext, model); UIExtensions.ExecuteExtensions<ConfigDocumentTemplateCreatePackageModel>(ControllerContext, model);
return View(model); return View(model);
} }
@@ -19,7 +19,7 @@ namespace Disco.Web.Areas.Config.Controllers
}; };
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigEnrolmentIndexModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigEnrolmentIndexModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -34,7 +34,7 @@ namespace Disco.Web.Areas.Config.Controllers
m.DeviceBatches = Database.DeviceBatches.ToList(); m.DeviceBatches = Database.DeviceBatches.ToList();
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigEnrolmentStatusModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigEnrolmentStatusModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -26,7 +26,7 @@ namespace Disco.Web.Areas.Config.Controllers
}; };
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigJobPreferencesIndexModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigJobPreferencesIndexModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -55,7 +55,7 @@ namespace Disco.Web.Areas.Config.Controllers
} }
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigJobQueueShowModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigJobQueueShowModel>(ControllerContext, m);
return View(MVC.Config.JobQueue.Views.Show, m); return View(MVC.Config.JobQueue.Views.Show, m);
} }
@@ -71,7 +71,7 @@ namespace Disco.Web.Areas.Config.Controllers
}; };
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigJobQueueIndexModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigJobQueueIndexModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -92,7 +92,7 @@ namespace Disco.Web.Areas.Config.Controllers
}; };
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigJobQueueCreateModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigJobQueueCreateModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -117,7 +117,7 @@ namespace Disco.Web.Areas.Config.Controllers
} }
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigJobQueueCreateModel>(this.ControllerContext, model); UIExtensions.ExecuteExtensions<ConfigJobQueueCreateModel>(ControllerContext, model);
return View(model); return View(model);
} }
@@ -29,7 +29,7 @@ namespace Disco.Web.Areas.Config.Controllers
} }
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigLoggingIndexModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigLoggingIndexModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -46,7 +46,7 @@ namespace Disco.Web.Areas.Config.Controllers
var m = new Models.Shared.TaskStatusModel() { SessionId = taskStatus.SessionId }; var m = new Models.Shared.TaskStatusModel() { SessionId = taskStatus.SessionId };
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigSharedTaskStatusModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigSharedTaskStatusModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -22,7 +22,7 @@ namespace Disco.Web.Areas.Config.Controllers
viewModel.OrganisationAddresses = Database.DiscoConfiguration.OrganisationAddresses.Addresses.OrderBy(a => a.Name).ToList(); viewModel.OrganisationAddresses = Database.DiscoConfiguration.OrganisationAddresses.Addresses.OrderBy(a => a.Name).ToList();
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigOrganisationIndexModel>(this.ControllerContext, viewModel); UIExtensions.ExecuteExtensions<ConfigOrganisationIndexModel>(ControllerContext, viewModel);
return View(viewModel); return View(viewModel);
} }
@@ -50,7 +50,7 @@ namespace Disco.Web.Areas.Config.Controllers
} }
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigUserFlagShowModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigUserFlagShowModel>(ControllerContext, m);
return View(MVC.Config.UserFlag.Views.Show, m); return View(MVC.Config.UserFlag.Views.Show, m);
} }
@@ -71,7 +71,7 @@ namespace Disco.Web.Areas.Config.Controllers
}; };
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigUserFlagIndexModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigUserFlagIndexModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -91,7 +91,7 @@ namespace Disco.Web.Areas.Config.Controllers
}; };
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigUserFlagCreateModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<ConfigUserFlagCreateModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -116,7 +116,7 @@ namespace Disco.Web.Areas.Config.Controllers
} }
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<ConfigUserFlagCreateModel>(this.ControllerContext, model); UIExtensions.ExecuteExtensions<ConfigUserFlagCreateModel>(ControllerContext, model);
return View(model); return View(model);
} }
@@ -18,7 +18,7 @@ namespace Disco.Web.Areas.Config.Models.AuthorizationRole
{ {
get get
{ {
var rootNode = FancyTreeNode.FromClaimNavigatorItem(this.ClaimNavigator, false); var rootNode = FancyTreeNode.FromClaimNavigatorItem(ClaimNavigator, false);
rootNode.expanded = true; rootNode.expanded = true;
return new FancyTreeNode[] { return new FancyTreeNode[] {
@@ -22,15 +22,15 @@ namespace Disco.Web.Areas.Config.Models.DeviceProfile
{ {
get get
{ {
if (string.IsNullOrEmpty(this.DeviceProfile.OrganisationalUnit)) if (string.IsNullOrEmpty(DeviceProfile.OrganisationalUnit))
{ {
var domain = ActiveDirectory.Context.PrimaryDomain; var domain = ActiveDirectory.Context.PrimaryDomain;
return domain.FriendlyDistinguishedNamePath(domain.DefaultComputerContainer); return domain.FriendlyDistinguishedNamePath(domain.DefaultComputerContainer);
} }
else else
{ {
var domain = ActiveDirectory.Context.GetDomainFromDistinguishedName(this.DeviceProfile.OrganisationalUnit); var domain = ActiveDirectory.Context.GetDomainFromDistinguishedName(DeviceProfile.OrganisationalUnit);
return domain.FriendlyDistinguishedNamePath(this.DeviceProfile.OrganisationalUnit); return domain.FriendlyDistinguishedNamePath(DeviceProfile.OrganisationalUnit);
} }
} }
} }
@@ -49,9 +49,9 @@ namespace Disco.Web.Areas.Config.Models.DocumentTemplate
public void UpdateModel(DiscoDataContext Database) public void UpdateModel(DiscoDataContext Database)
{ {
if (this.JobTypes == null) if (JobTypes == null)
JobTypes = Database.JobTypes.ToList(); JobTypes = Database.JobTypes.ToList();
if (this.JobSubTypes == null) if (JobSubTypes == null)
JobSubTypes = Database.JobSubTypes.ToList(); JobSubTypes = Database.JobSubTypes.ToList();
} }
@@ -43,20 +43,20 @@ namespace Disco.Web.Areas.Config.Models.DocumentTemplate
public void UpdateModel(DiscoDataContext Database) public void UpdateModel(DiscoDataContext Database)
{ {
switch (this.DocumentTemplate.Scope) switch (DocumentTemplate.Scope)
{ {
case Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.Device: case Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.Device:
this.StoredInstanceCount = Database.DeviceAttachments.Count(a => a.DocumentTemplateId == this.DocumentTemplate.Id); StoredInstanceCount = Database.DeviceAttachments.Count(a => a.DocumentTemplateId == DocumentTemplate.Id);
break; break;
case Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.Job: case Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.Job:
this.StoredInstanceCount = Database.JobAttachments.Count(a => a.DocumentTemplateId == this.DocumentTemplate.Id); StoredInstanceCount = Database.JobAttachments.Count(a => a.DocumentTemplateId == DocumentTemplate.Id);
break; break;
case Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.User: case Disco.Models.Repository.DocumentTemplate.DocumentTemplateScopes.User:
this.StoredInstanceCount = Database.UserAttachments.Count(a => a.DocumentTemplateId == this.DocumentTemplate.Id); StoredInstanceCount = Database.UserAttachments.Count(a => a.DocumentTemplateId == DocumentTemplate.Id);
break; break;
} }
if (this.JobTypes == null) if (JobTypes == null)
JobTypes = Database.JobTypes.Include("JobSubTypes").ToList(); JobTypes = Database.JobTypes.Include("JobSubTypes").ToList();
UserFlags = Database.UserFlags.ToList(); UserFlags = Database.UserFlags.ToList();
@@ -18,7 +18,7 @@ namespace Disco.Web.Areas.Config.Models.DocumentTemplate
list.Add(new SelectListItem() { Selected = false, Value = "--DEVICE", Text = "<Generic Device Document>" }); 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 = true, Value = "--JOB", Text = "<Generic Job Document>" });
list.Add(new SelectListItem() { Selected = false, Value = "--USER", Text = "<Generic User Document>" }); list.Add(new SelectListItem() { Selected = false, Value = "--USER", Text = "<Generic User Document>" });
list.AddRange(this.DocumentTemplates.ToSelectListItems()); list.AddRange(DocumentTemplates.ToSelectListItems());
return list; return list;
} }
} }
@@ -67,7 +67,7 @@ namespace Disco.Web.Areas.Config.Models.JobPreferences
new KeyValuePair<int, string>(56, "8 Weeks") new KeyValuePair<int, string>(56, "8 Weeks")
}; };
var current = this.LongRunningJobDaysThreshold; var current = LongRunningJobDaysThreshold;
if (!options.Any(o => o.Key == current)) if (!options.Any(o => o.Key == current))
{ {
options.Add(new KeyValuePair<int, string>(current, string.Format("{0} Days", current))); options.Add(new KeyValuePair<int, string>(current, string.Format("{0} Days", current)));
@@ -103,7 +103,7 @@ namespace Disco.Web.Areas.Config.Models.JobPreferences
new KeyValuePair<int, string>(60 * 24 * 7 * 8, "8 weeks") new KeyValuePair<int, string>(60 * 24 * 7 * 8, "8 weeks")
}; };
var current = this.StaleJobMinutesThreshold; var current = StaleJobMinutesThreshold;
if (!options.Any(o => o.Key == current)) if (!options.Any(o => o.Key == current))
{ {
options.Add(new KeyValuePair<int, string>(current, string.Format("{0} Minutes", current))); options.Add(new KeyValuePair<int, string>(current, string.Format("{0} Minutes", current)));
@@ -11,10 +11,10 @@ namespace Disco.Web.Areas.Config.Models.Plugins
public PluginConfigurationViewModel(PluginConfigurationHandler.PluginConfigurationHandlerGetResponse response) public PluginConfigurationViewModel(PluginConfigurationHandler.PluginConfigurationHandlerGetResponse response)
{ {
this.Manifest = response.Manifest; Manifest = response.Manifest;
this.PluginViewType = response.ViewType; PluginViewType = response.ViewType;
this.PluginViewModel = response.Model; PluginViewModel = response.Model;
} }
} }
} }
@@ -49,28 +49,28 @@ namespace Disco.Web.Areas.Config.Models.SystemConfig
{ {
get get
{ {
return this.DatabaseConnectionString.Value.DataSource; return DatabaseConnectionString.Value.DataSource;
} }
} }
public string DatabaseName public string DatabaseName
{ {
get get
{ {
return this.DatabaseConnectionString.Value.InitialCatalog; return DatabaseConnectionString.Value.InitialCatalog;
} }
} }
public string DatabaseAuthentication public string DatabaseAuthentication
{ {
get get
{ {
return this.DatabaseConnectionString.Value.IntegratedSecurity ? "Integrated Authentication" : "SQL Authentication"; return DatabaseConnectionString.Value.IntegratedSecurity ? "Integrated Authentication" : "SQL Authentication";
} }
} }
public string DatabaseSqlAuthUsername public string DatabaseSqlAuthUsername
{ {
get get
{ {
return this.DatabaseConnectionString.Value.IntegratedSecurity ? null : this.DatabaseConnectionString.Value.UserID; return DatabaseConnectionString.Value.IntegratedSecurity ? null : DatabaseConnectionString.Value.UserID;
} }
} }
#endregion #endregion
@@ -21,27 +21,27 @@ namespace Disco.Web.Areas.Public.Models.UserHeldDevices
{ {
var uhdm = new UserHeldDeviceModel() var uhdm = new UserHeldDeviceModel()
{ {
UserId = this.UserId, UserId = UserId,
UserDisplayName = this.UserDisplayName, UserDisplayName = UserDisplayName,
ReadyForReturn = this.ReadyForReturn, ReadyForReturn = ReadyForReturn,
WaitingForUserAction = this.WaitingForUserAction, WaitingForUserAction = WaitingForUserAction,
DeviceProfileId = this.DeviceProfileId, DeviceProfileId = DeviceProfileId,
DeviceAddress = (this.DeviceAddressId.HasValue ? Database.DiscoConfiguration.OrganisationAddresses.GetAddress(this.DeviceAddressId.Value)?.ShortName : string.Empty) DeviceAddress = (DeviceAddressId.HasValue ? Database.DiscoConfiguration.OrganisationAddresses.GetAddress(DeviceAddressId.Value)?.ShortName : string.Empty)
}; };
var n = DateTime.Now; var n = DateTime.Now;
if (!this.ReadyForReturn && this.EstimatedReturnTime.HasValue && this.EstimatedReturnTime.Value > n) if (!ReadyForReturn && EstimatedReturnTime.HasValue && EstimatedReturnTime.Value > n)
{ {
uhdm.EstimatedReturnTime = this.EstimatedReturnTime.FromNow(); uhdm.EstimatedReturnTime = EstimatedReturnTime.FromNow();
} }
if (this.ReadyForReturn) if (ReadyForReturn)
{ {
uhdm.ReadyForReturnSince = this.ReadyForReturnSince.FromNow(); uhdm.ReadyForReturnSince = ReadyForReturnSince.FromNow();
uhdm.IsAlert = (this.ReadyForReturnSince.Value < DateTime.Now.AddDays(-3)); uhdm.IsAlert = (ReadyForReturnSince.Value < DateTime.Now.AddDays(-3));
} }
if (this.WaitingForUserAction) if (WaitingForUserAction)
{ {
uhdm.WaitingForUserActionSince = this.WaitingForUserActionSince.FromNow(); uhdm.WaitingForUserActionSince = WaitingForUserActionSince.FromNow();
uhdm.IsAlert = (this.WaitingForUserActionSince.Value < n.AddDays(-6)); uhdm.IsAlert = (WaitingForUserActionSince.Value < n.AddDays(-6));
} }
return uhdm; return uhdm;
} }
+6 -6
View File
@@ -29,7 +29,7 @@ namespace Disco.Web.Controllers
Models.Device.IndexModel m = new Models.Device.IndexModel(); Models.Device.IndexModel m = new Models.Device.IndexModel();
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<DeviceIndexModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<DeviceIndexModel>(ControllerContext, m);
return View(); return View();
} }
@@ -57,7 +57,7 @@ namespace Disco.Web.Controllers
} }
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<DeviceAddOfflineModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<DeviceAddOfflineModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -162,7 +162,7 @@ namespace Disco.Web.Controllers
m.CompletedImportSessionContext = Areas.API.Controllers.DeviceController.Import_RetrieveContext(Id, Remove: true); m.CompletedImportSessionContext = Areas.API.Controllers.DeviceController.Import_RetrieveContext(Id, Remove: true);
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<DeviceImportModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<DeviceImportModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -184,7 +184,7 @@ namespace Disco.Web.Controllers
}; };
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<DeviceImportHeadersModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<DeviceImportHeadersModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -210,7 +210,7 @@ namespace Disco.Web.Controllers
}; };
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<DeviceImportReviewModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<DeviceImportReviewModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -328,7 +328,7 @@ namespace Disco.Web.Controllers
} }
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<DeviceShowModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<DeviceShowModel>(ControllerContext, m);
return View(m); return View(m);
} }
+19 -19
View File
@@ -54,7 +54,7 @@ namespace Disco.Web.Controllers
m.PendingEnrolments = WindowsDeviceEnrolment.GetPendingEnrolments(); m.PendingEnrolments = WindowsDeviceEnrolment.GetPendingEnrolments();
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobIndexModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobIndexModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -73,7 +73,7 @@ namespace Disco.Web.Controllers
m.JobTable = ManagedJobList.OpenJobsTable(q => q.Where(j => j.ActiveJobQueues.Any(jqj => jqj.QueueId == queueToken.JobQueue.Id))); m.JobTable = ManagedJobList.OpenJobsTable(q => q.Where(j => j.ActiveJobQueues.Any(jqj => jqj.QueueId == queueToken.JobQueue.Id)));
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobListModel>(ControllerContext, m);
return View(Views.List, m); return View(Views.List, m);
} }
@@ -85,7 +85,7 @@ namespace Disco.Web.Controllers
m.JobTable = ManagedJobList.OpenJobsTable(q => q.OrderBy(j => j.JobId)); m.JobTable = ManagedJobList.OpenJobsTable(q => q.OrderBy(j => j.JobId));
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobListModel>(ControllerContext, m);
return View(Views.List, m); return View(Views.List, m);
} }
@@ -98,7 +98,7 @@ namespace Disco.Web.Controllers
m.JobTable = ManagedJobList.OpenJobsTable(ManagedJobList.AwaitingTechnicianActionFilter); m.JobTable = ManagedJobList.OpenJobsTable(ManagedJobList.AwaitingTechnicianActionFilter);
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobListModel>(ControllerContext, m);
return View(Views.List, m); return View(Views.List, m);
} }
@@ -114,7 +114,7 @@ namespace Disco.Web.Controllers
.OrderBy(j => j.JobId)); .OrderBy(j => j.JobId));
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobListModel>(ControllerContext, m);
return View(Views.List, m); return View(Views.List, m);
} }
@@ -130,7 +130,7 @@ namespace Disco.Web.Controllers
).OrderBy(j => j.JobId)); ).OrderBy(j => j.JobId));
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobListModel>(ControllerContext, m);
return View(Views.List, m); return View(Views.List, m);
} }
@@ -148,7 +148,7 @@ namespace Disco.Web.Controllers
)); ));
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobListModel>(ControllerContext, m);
return View(Views.List, m); return View(Views.List, m);
} }
@@ -162,7 +162,7 @@ namespace Disco.Web.Controllers
).OrderBy(j => j.JobId)); ).OrderBy(j => j.JobId));
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobListModel>(ControllerContext, m);
return View(Views.List, m); return View(Views.List, m);
} }
@@ -176,7 +176,7 @@ namespace Disco.Web.Controllers
).OrderBy(j => j.JobId)); ).OrderBy(j => j.JobId));
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobListModel>(ControllerContext, m);
return View(Views.List, m); return View(Views.List, m);
} }
@@ -190,7 +190,7 @@ namespace Disco.Web.Controllers
).OrderBy(j => j.JobId)); ).OrderBy(j => j.JobId));
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobListModel>(ControllerContext, m);
return View(Views.List, m); return View(Views.List, m);
} }
@@ -204,7 +204,7 @@ namespace Disco.Web.Controllers
).OrderBy(j => j.JobId)); ).OrderBy(j => j.JobId));
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobListModel>(ControllerContext, m);
return View(Views.List, m); return View(Views.List, m);
} }
@@ -221,7 +221,7 @@ namespace Disco.Web.Controllers
).OrderBy(j => j.JobId)); ).OrderBy(j => j.JobId));
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobListModel>(ControllerContext, m);
return View(Views.List, m); return View(Views.List, m);
} }
@@ -241,7 +241,7 @@ namespace Disco.Web.Controllers
m.JobTable.Fill(Database, Disco.Services.Searching.Search.BuildJobTableModel(Database).Where(j => j.ClosedDate > closedThreshold).OrderBy(j => j.Id), true); m.JobTable.Fill(Database, Disco.Services.Searching.Search.BuildJobTableModel(Database).Where(j => j.ClosedDate > closedThreshold).OrderBy(j => j.Id), true);
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobListModel>(ControllerContext, m);
return View(Views.List, m); return View(Views.List, m);
} }
@@ -257,7 +257,7 @@ namespace Disco.Web.Controllers
m.JobTable.ShowType = false; m.JobTable.ShowType = false;
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobListModel>(ControllerContext, m);
return View(Views.List, m); return View(Views.List, m);
} }
@@ -271,7 +271,7 @@ namespace Disco.Web.Controllers
m.JobTable = ManagedJobList.OpenJobsTable(q => q.Where(j => j.OpenedDate < longRunningThreshold).OrderBy(j => j.JobId)); m.JobTable = ManagedJobList.OpenJobsTable(q => q.Where(j => j.OpenedDate < longRunningThreshold).OrderBy(j => j.JobId));
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobListModel>(ControllerContext, m);
return View(Views.List, m); return View(Views.List, m);
} }
@@ -287,7 +287,7 @@ namespace Disco.Web.Controllers
m.JobTable.ShowDates = false; m.JobTable.ShowDates = false;
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobListModel>(ControllerContext, m);
return View(Views.List, m); return View(Views.List, m);
} }
@@ -393,7 +393,7 @@ namespace Disco.Web.Controllers
} }
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobShowModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobShowModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -414,7 +414,7 @@ namespace Disco.Web.Controllers
m.RegenerateCommentsOnTypeChange = isTypeDynamic; m.RegenerateCommentsOnTypeChange = isTypeDynamic;
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobCreateModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobCreateModel>(ControllerContext, m);
return View(m); return View(m);
} }
@@ -426,7 +426,7 @@ namespace Disco.Web.Controllers
if (!ModelState.IsValid) if (!ModelState.IsValid)
{ {
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobCreateModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<JobCreateModel>(ControllerContext, m);
return View(m); return View(m);
} }
+1 -1
View File
@@ -269,7 +269,7 @@ namespace Disco.Web.Controllers
} }
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<SearchQueryModel>(this.ControllerContext, m); UIExtensions.ExecuteExtensions<SearchQueryModel>(ControllerContext, m);
return View(m); return View(m);
} }
+1 -1
View File
@@ -18,7 +18,7 @@ namespace Disco.Web.Models.Device
public int StatisticImportRecords public int StatisticImportRecords
{ {
get { return this.StatisticNewRecords + StatisticModifiedRecords; } get { return StatisticNewRecords + StatisticModifiedRecords; }
} }
public IEnumerable<Tuple<DeviceImportFieldTypes, string>> HeaderTypes { get; set; } public IEnumerable<Tuple<DeviceImportFieldTypes, string>> HeaderTypes { get; set; }
@@ -11,9 +11,9 @@ namespace Disco.Web.Models.InitialConfig
public DatabaseModel() public DatabaseModel()
{ {
// Set Defaults // Set Defaults
this.Server = "(local)"; Server = "(local)";
this.DatabaseName = "Disco"; DatabaseName = "Disco";
this.AuthMethod = "SSPI"; AuthMethod = "SSPI";
} }
public static DatabaseModel FromConnectionString(string ConnectionString) public static DatabaseModel FromConnectionString(string ConnectionString)
@@ -51,11 +51,11 @@ namespace Disco.Web.Models.InitialConfig
{ {
var csb = new SqlConnectionStringBuilder() var csb = new SqlConnectionStringBuilder()
{ {
DataSource = this.Server, DataSource = Server,
InitialCatalog = this.DatabaseName, InitialCatalog = DatabaseName,
IntegratedSecurity = (this.AuthMethod.Equals("SSPI", StringComparison.OrdinalIgnoreCase)), IntegratedSecurity = (AuthMethod.Equals("SSPI", StringComparison.OrdinalIgnoreCase)),
UserID = (this.AuthMethod.Equals("SQL", StringComparison.OrdinalIgnoreCase)) ? this.Auth_SQL_Username : string.Empty, UserID = (AuthMethod.Equals("SQL", StringComparison.OrdinalIgnoreCase)) ? Auth_SQL_Username : string.Empty,
Password = (this.AuthMethod.Equals("SQL", StringComparison.OrdinalIgnoreCase)) ? this.Auth_SQL_Password : string.Empty, Password = (AuthMethod.Equals("SQL", StringComparison.OrdinalIgnoreCase)) ? Auth_SQL_Password : string.Empty,
ApplicationName = "Disco ICT WebApp", ApplicationName = "Disco ICT WebApp",
MultipleActiveResultSets = true, MultipleActiveResultSets = true,
Pooling = true Pooling = true
@@ -21,10 +21,10 @@ namespace Disco.Web.Models.InitialConfig
{ {
if (!string.IsNullOrWhiteSpace(FileStoreLocation)) if (!string.IsNullOrWhiteSpace(FileStoreLocation))
{ {
var branches = this.FileStoreLocation.ToUpper().Split(Path.DirectorySeparatorChar); var branches = FileStoreLocation.ToUpper().Split(Path.DirectorySeparatorChar);
var branchesCase = this.FileStoreLocation.Split(Path.DirectorySeparatorChar); var branchesCase = FileStoreLocation.Split(Path.DirectorySeparatorChar);
FileStoreDirectoryModel branchModel; FileStoreDirectoryModel branchModel;
FileStoreDirectoryModel branchParent = this.DirectoryModel; FileStoreDirectoryModel branchParent = DirectoryModel;
for (int i = 0; i < branches.Length; i++) for (int i = 0; i < branches.Length; i++)
{ {
var branch = branches[i]; var branch = branches[i];
@@ -154,10 +154,10 @@ namespace Disco.Web.Models.InitialConfig
internal void ExpandSubDirectories() internal void ExpandSubDirectories()
{ {
if (this.SubDirectories == null) if (SubDirectories == null)
{ {
this.SubDirectories = new Dictionary<string, FileStoreDirectoryModel>(); SubDirectories = new Dictionary<string, FileStoreDirectoryModel>();
if (!this.IsNew) if (!IsNew)
{ {
var dirInfo = new DirectoryInfo(Path); var dirInfo = new DirectoryInfo(Path);
if (dirInfo.Exists) if (dirInfo.Exists)
@@ -167,13 +167,13 @@ namespace Disco.Web.Models.InitialConfig
if (((subDir.Attributes & FileAttributes.System) != FileAttributes.System) && if (((subDir.Attributes & FileAttributes.System) != FileAttributes.System) &&
((subDir.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)) ((subDir.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden))
{ {
this.SubDirectories.Add(subDir.Name.ToUpper(), FileStoreDirectoryModel.FromInfo(subDir)); SubDirectories.Add(subDir.Name.ToUpper(), FileStoreDirectoryModel.FromInfo(subDir));
} }
} }
} }
else else
{ {
this.IsNew = true; IsNew = true;
} }
} }
} }
@@ -15,7 +15,7 @@ namespace Disco.Web.Models.InitialConfig
{ {
if (_OrganisationNameCache != null) if (_OrganisationNameCache != null)
{ {
this.OrganisationName = _OrganisationNameCache; OrganisationName = _OrganisationNameCache;
return true; return true;
} }
@@ -23,8 +23,8 @@ namespace Disco.Web.Models.InitialConfig
if (whoAmIResult != null && !string.IsNullOrWhiteSpace(whoAmIResult.Item2)) if (whoAmIResult != null && !string.IsNullOrWhiteSpace(whoAmIResult.Item2))
{ {
this.OrganisationName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(whoAmIResult.Item2); OrganisationName = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(whoAmIResult.Item2);
_OrganisationNameCache = this.OrganisationName; _OrganisationNameCache = OrganisationName;
return true; return true;
} }
+20 -20
View File
@@ -42,24 +42,24 @@ namespace Disco.Web.Models.Job
public void UpdateModel(DiscoDataContext Database, AuthorizationToken Authorization) public void UpdateModel(DiscoDataContext Database, AuthorizationToken Authorization)
{ {
if (this.JobTypes == null) if (JobTypes == null)
this.JobTypes = Database.JobTypes.Include("JobSubTypes.JobQueues").FilterCreatableTypePermissions(Authorization).ToList(); JobTypes = Database.JobTypes.Include("JobSubTypes.JobQueues").FilterCreatableTypePermissions(Authorization).ToList();
if (!string.IsNullOrEmpty(DeviceSerialNumber)) if (!string.IsNullOrEmpty(DeviceSerialNumber))
{ {
this.Device = Database.Devices.Include("DeviceModel").Where(d => d.SerialNumber == DeviceSerialNumber).FirstOrDefault(); Device = Database.Devices.Include("DeviceModel").Where(d => d.SerialNumber == DeviceSerialNumber).FirstOrDefault();
if (this.Device == null) if (Device == null)
{ {
throw new ArgumentException("Invalid Device Serial Number Specified", "DeviceSerialNumber"); throw new ArgumentException("Invalid Device Serial Number Specified", "DeviceSerialNumber");
} }
if (string.IsNullOrEmpty(this.UserId) && !string.IsNullOrEmpty(this.Device.AssignedUserId)) if (string.IsNullOrEmpty(UserId) && !string.IsNullOrEmpty(Device.AssignedUserId))
{ {
this.UserId = this.Device.AssignedUserId; UserId = Device.AssignedUserId;
} }
if (string.IsNullOrEmpty(this.Type)) if (string.IsNullOrEmpty(Type))
this.Type = this.JobTypes.Any(jt => jt.Id == Disco.Models.Repository.JobType.JobTypeIds.HWar) ? Disco.Models.Repository.JobType.JobTypeIds.HWar : this.JobTypes.First().Id; Type = JobTypes.Any(jt => jt.Id == Disco.Models.Repository.JobType.JobTypeIds.HWar) ? Disco.Models.Repository.JobType.JobTypeIds.HWar : JobTypes.First().Id;
if (string.IsNullOrEmpty(this.UserId)) if (string.IsNullOrEmpty(UserId))
{ {
// No User - Remove User Types // No User - Remove User Types
foreach (var jobType in JobTypes.ToArray()) foreach (var jobType in JobTypes.ToArray())
@@ -94,20 +94,20 @@ namespace Disco.Web.Models.Job
} }
// Set Default Job Type for Users // Set Default Job Type for Users
if (string.IsNullOrEmpty(this.Type)) if (string.IsNullOrEmpty(Type))
this.Type = this.JobTypes.Any(jt => jt.Id == Disco.Models.Repository.JobType.JobTypeIds.SApp) ? Disco.Models.Repository.JobType.JobTypeIds.SApp : this.JobTypes.First().Id; Type = JobTypes.Any(jt => jt.Id == Disco.Models.Repository.JobType.JobTypeIds.SApp) ? Disco.Models.Repository.JobType.JobTypeIds.SApp : JobTypes.First().Id;
} }
if (!string.IsNullOrEmpty(UserId)) if (!string.IsNullOrEmpty(UserId))
{ {
this.User = Database.Users.Find(UserId); User = Database.Users.Find(UserId);
if (this.User == null) if (User == null)
{ {
throw new ArgumentException("Invalid User Id Specified", "UserId"); throw new ArgumentException("Invalid User Id Specified", "UserId");
} }
if (string.IsNullOrEmpty(this.Type)) if (string.IsNullOrEmpty(Type))
this.Type = Disco.Models.Repository.JobType.JobTypeIds.SApp; Type = Disco.Models.Repository.JobType.JobTypeIds.SApp;
} }
if (this.User == null && this.Device == null) if (User == null && Device == null)
{ {
throw new InvalidOperationException("A Job must reference a Device and/or a User"); throw new InvalidOperationException("A Job must reference a Device and/or a User");
} }
@@ -118,9 +118,9 @@ namespace Disco.Web.Models.Job
{ {
get get
{ {
if (!string.IsNullOrEmpty(this.Type)) if (!string.IsNullOrEmpty(Type))
{ {
return this.JobTypes.FirstOrDefault(m => m.Id == this.Type); return JobTypes.FirstOrDefault(m => m.Id == Type);
} }
return null; return null;
} }
@@ -131,8 +131,8 @@ namespace Disco.Web.Models.Job
{ {
if (SubTypes != null) if (SubTypes != null)
{ {
var subTypes = this.SubTypes; var subTypes = SubTypes;
return this.JobTypes.SelectMany(jt => jt.JobSubTypes).Where(m => subTypes.Contains(String.Format("{0}_{1}", m.JobTypeId, m.Id))).ToList(); return JobTypes.SelectMany(jt => jt.JobSubTypes).Where(m => subTypes.Contains(String.Format("{0}_{1}", m.JobTypeId, m.Id))).ToList();
} }
return null; return null;
} }
+7 -7
View File
@@ -50,11 +50,11 @@ namespace Disco.Web.Models.Job
public Dictionary<string, string> ProviderProperties() public Dictionary<string, string> ProviderProperties()
{ {
Dictionary<string, string> p = default(Dictionary<string, string>); Dictionary<string, string> p = default(Dictionary<string, string>);
if (!string.IsNullOrEmpty(this.ProviderPropertiesJson)) if (!string.IsNullOrEmpty(ProviderPropertiesJson))
{ {
try try
{ {
p = JsonConvert.DeserializeObject<Dictionary<string, string>>(this.ProviderPropertiesJson); p = JsonConvert.DeserializeObject<Dictionary<string, string>>(ProviderPropertiesJson);
} }
catch (Exception) catch (Exception)
{ {
@@ -98,7 +98,7 @@ namespace Disco.Web.Models.Job
} }
// Update TechUser's Details [#12] // Update TechUser's Details [#12]
this.TechUser = UserService.GetUser(UserService.CurrentUserId, Database, true); TechUser = UserService.GetUser(UserService.CurrentUserId, Database, true);
RepairProviders = Plugins.GetPluginFeatures(typeof(RepairProviderFeature)); RepairProviders = Plugins.GetPluginFeatures(typeof(RepairProviderFeature));
@@ -113,16 +113,16 @@ namespace Disco.Web.Models.Job
if (!string.IsNullOrEmpty(RepairProviderId) && RepairProviderId != "MANUAL") if (!string.IsNullOrEmpty(RepairProviderId) && RepairProviderId != "MANUAL")
RepairProvider = Plugins.GetPluginFeature(RepairProviderId, typeof(RepairProviderFeature)); RepairProvider = Plugins.GetPluginFeature(RepairProviderId, typeof(RepairProviderFeature));
this.OrganisationAddresses = Database.DiscoConfiguration.OrganisationAddresses.Addresses.OrderBy(a => a.Name).ToList(); OrganisationAddresses = Database.DiscoConfiguration.OrganisationAddresses.Addresses.OrderBy(a => a.Name).ToList();
if (!IsPostBack && !this.OrganisationAddressId.HasValue) if (!IsPostBack && !OrganisationAddressId.HasValue)
{ {
OrganisationAddressId = Job.Device.DeviceProfile.DefaultOrganisationAddress; OrganisationAddressId = Job.Device.DeviceProfile.DefaultOrganisationAddress;
if (!OrganisationAddressId.HasValue && OrganisationAddresses.Count == 1) if (!OrganisationAddressId.HasValue && OrganisationAddresses.Count == 1)
OrganisationAddressId = OrganisationAddresses[0].Id; OrganisationAddressId = OrganisationAddresses[0].Id;
} }
if (this.OrganisationAddressId.HasValue) if (OrganisationAddressId.HasValue)
this.OrganisationAddress = this.OrganisationAddresses.FirstOrDefault(oa => oa.Id == this.OrganisationAddressId.Value); OrganisationAddress = OrganisationAddresses.FirstOrDefault(oa => oa.Id == OrganisationAddressId.Value);
if (!string.IsNullOrEmpty(RepairDescription)) if (!string.IsNullOrEmpty(RepairDescription))
RepairDescription = RepairDescription.Trim(); RepairDescription = RepairDescription.Trim();
+7 -7
View File
@@ -51,11 +51,11 @@ namespace Disco.Web.Models.Job
public Dictionary<string, string> ProviderProperties() public Dictionary<string, string> ProviderProperties()
{ {
Dictionary<string, string> p = default(Dictionary<string, string>); Dictionary<string, string> p = default(Dictionary<string, string>);
if (!string.IsNullOrEmpty(this.ProviderPropertiesJson)) if (!string.IsNullOrEmpty(ProviderPropertiesJson))
{ {
try try
{ {
p = JsonConvert.DeserializeObject<Dictionary<string, string>>(this.ProviderPropertiesJson); p = JsonConvert.DeserializeObject<Dictionary<string, string>>(ProviderPropertiesJson);
} }
catch (Exception) catch (Exception)
{ {
@@ -98,7 +98,7 @@ namespace Disco.Web.Models.Job
} }
// Update TechUser's Details [#12] // Update TechUser's Details [#12]
this.TechUser = UserService.GetUser(UserService.CurrentUserId, Database, true); TechUser = UserService.GetUser(UserService.CurrentUserId, Database, true);
WarrantyProviders = Plugins.GetPluginFeatures(typeof(WarrantyProviderFeature)); WarrantyProviders = Plugins.GetPluginFeatures(typeof(WarrantyProviderFeature));
@@ -113,16 +113,16 @@ namespace Disco.Web.Models.Job
if (!string.IsNullOrEmpty(WarrantyProviderId) && WarrantyProviderId != "MANUAL") if (!string.IsNullOrEmpty(WarrantyProviderId) && WarrantyProviderId != "MANUAL")
WarrantyProvider = Plugins.GetPluginFeature(WarrantyProviderId, typeof(WarrantyProviderFeature)); WarrantyProvider = Plugins.GetPluginFeature(WarrantyProviderId, typeof(WarrantyProviderFeature));
this.OrganisationAddresses = Database.DiscoConfiguration.OrganisationAddresses.Addresses.OrderBy(a => a.Name).ToList(); OrganisationAddresses = Database.DiscoConfiguration.OrganisationAddresses.Addresses.OrderBy(a => a.Name).ToList();
if (!IsPostBack && !this.OrganisationAddressId.HasValue) if (!IsPostBack && !OrganisationAddressId.HasValue)
{ {
OrganisationAddressId = Job.Device.DeviceProfile.DefaultOrganisationAddress; OrganisationAddressId = Job.Device.DeviceProfile.DefaultOrganisationAddress;
if (!OrganisationAddressId.HasValue && OrganisationAddresses.Count == 1) if (!OrganisationAddressId.HasValue && OrganisationAddresses.Count == 1)
OrganisationAddressId = OrganisationAddresses[0].Id; OrganisationAddressId = OrganisationAddresses[0].Id;
} }
if (this.OrganisationAddressId.HasValue) if (OrganisationAddressId.HasValue)
this.OrganisationAddress = this.OrganisationAddresses.FirstOrDefault(oa => oa.Id == this.OrganisationAddressId.Value); OrganisationAddress = OrganisationAddresses.FirstOrDefault(oa => oa.Id == OrganisationAddressId.Value);
if (!string.IsNullOrEmpty(FaultDescription)) if (!string.IsNullOrEmpty(FaultDescription))
FaultDescription = FaultDescription.Trim(); FaultDescription = FaultDescription.Trim();