Feature: Held Devices Noticeboard

Provides a noticeboard for all devices, not just those assigned to
users.
This commit is contained in:
Gary Sharp
2013-07-04 15:29:46 +10:00
parent b1d16ae87c
commit aa54d93e8e
37 changed files with 2412 additions and 252 deletions
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
namespace Disco.Web.Areas.Public.Models.HeldDevices
{
public class HeldDeviceModel
{
public string DeviceSerialNumber { get; set; }
public string DeviceComputerName { get; set; }
public int DeviceProfileId { get; set; }
public string DeviceAddress { get; set; }
public string DeviceLocation { get; set; }
public string DeviceDescription
{
get
{
StringBuilder sb = new StringBuilder(this.DeviceSerialNumber);
if (UserId != null)
sb.Append(" - ").Append(this.UserDisplayName).Append(" (").Append(this.UserId).Append(")");
if (!string.IsNullOrWhiteSpace(this.DeviceLocation))
sb.Append(" - ").Append(this.DeviceLocation);
else if (UserId == null)
sb.Append(" - ").Append(this.DeviceComputerName);
return sb.ToString();
}
}
public string UserId { get; set; }
public string UserDisplayName { get; set; }
public bool WaitingForUserAction { get; set; }
public string WaitingForUserActionSince { get; set; }
public bool ReadyForReturn { get; set; }
public string EstimatedReturnTime { get; set; }
public string ReadyForReturnSince { get; set; }
public bool IsAlert { get; set; }
}
}
@@ -0,0 +1,61 @@
using Disco.Data.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Disco.BI.Extensions;
namespace Disco.Web.Areas.Public.Models.HeldDevices
{
public class HeldDeviceQueryModel
{
public int JobId { get; set; }
public string DeviceSerialNumber { get; set; }
public string DeviceComputerName { get; set; }
public int DeviceProfileId { get; set; }
public int? DeviceAddressId { get; set; }
public string DeviceLocation { get; set; }
public string UserId { get; set; }
public string UserDisplayName { get; set; }
public bool ReadyForReturn { get; set; }
public bool WaitingForUserAction { get; set; }
public DateTime? EstimatedReturnTime { get; set; }
public DateTime? ReadyForReturnSince { get; set; }
public DateTime? WaitingForUserActionSince { get; set; }
public HeldDeviceModel ToUserHeldDeviceModel(DiscoDataContext dbContext)
{
var uhdm = new HeldDeviceModel()
{
DeviceSerialNumber = this.DeviceSerialNumber,
DeviceComputerName = this.DeviceComputerName,
DeviceLocation = this.DeviceLocation,
DeviceProfileId = this.DeviceProfileId,
DeviceAddress = (this.DeviceAddressId.HasValue ? dbContext.DiscoConfiguration.OrganisationAddresses.GetAddress(this.DeviceAddressId.Value).ShortName : string.Empty),
UserId = this.UserId,
UserDisplayName = this.UserDisplayName,
ReadyForReturn = this.ReadyForReturn,
WaitingForUserAction = this.WaitingForUserAction
};
var n = DateTime.Now;
if (!this.ReadyForReturn && this.EstimatedReturnTime.HasValue && this.EstimatedReturnTime.Value > n)
{
uhdm.EstimatedReturnTime = this.EstimatedReturnTime.ToFuzzy();
}
if (this.ReadyForReturn)
{
uhdm.ReadyForReturnSince = this.ReadyForReturnSince.ToFuzzy();
uhdm.IsAlert = (this.ReadyForReturnSince.Value < DateTime.Now.AddDays(-3));
}
if (this.WaitingForUserAction)
{
uhdm.WaitingForUserActionSince = this.WaitingForUserActionSince.ToFuzzy();
uhdm.IsAlert = (this.WaitingForUserActionSince.Value < n.AddDays(-6));
}
return uhdm;
}
}
}
@@ -37,20 +37,6 @@ namespace Disco.Web.Areas.Public.Models.UserHeldDevices
if (!this.ReadyForReturn && this.EstimatedReturnTime.HasValue && this.EstimatedReturnTime.Value > n)
{
uhdm.EstimatedReturnTime = this.EstimatedReturnTime.ToFuzzy();
if (this.EstimatedReturnTime.Value.Date == n.Date)
{
if (this.EstimatedReturnTime.Value < n.AddHours(2))
{
if (this.EstimatedReturnTime.Value < n.AddMinutes(12))
{
uhdm.UpdateAt = this.EstimatedReturnTime.Value;
}
else
{
uhdm.UpdateAt = this.EstimatedReturnTime.Value.AddMinutes(-10);
}
}
}
}
if (this.ReadyForReturn)
{
@@ -15,7 +15,6 @@ namespace Disco.Web.Areas.Public.Models.UserHeldDevices
public bool IsAlert { get; set; }
public bool WaitingForUserAction { get; set; }
public string WaitingForUserActionSince { get; set; }
public Nullable<DateTime> UpdateAt { get; set; }
public int DeviceProfileId { get; set; }
public string DeviceAddress { get; set; }
}