Feature: Job Queues

Also UI style, theme and element changes
This commit is contained in:
Gary Sharp
2014-02-03 14:50:08 +11:00
parent bdb3e1e6b4
commit 3f63281dc4
212 changed files with 17334 additions and 5441 deletions
@@ -1,5 +1,5 @@
using Disco.Data.Repository;
using Disco.Models.Authorization;
using Disco.Models.Services.Authorization;
using Disco.Models.Repository;
using Disco.Services.Users;
using System;
+49 -25
View File
@@ -338,20 +338,53 @@ namespace Disco.BI.Extensions
#endregion
#region Close
public static bool CanClose(this Job j)
public static void OnCloseNormally(this Job j, User Technician)
{
if (!j.CanCloseNormally())
throw new InvalidOperationException("Close was Denied");
j.ClosedDate = DateTime.Now;
j.ClosedTechUserId = Technician.Id;
}
private static bool CanCloseNever(this Job j, JobQueueJob IgnoreJobQueueJob = null)
{
if (!UserService.CurrentAuthorization.Has(Claims.Job.Actions.Close))
return false;
if (j.ClosedDate.HasValue)
return false; // Job already Closed
return true; // Job already Closed
if (j.DeviceHeld.HasValue && !j.DeviceReturnedDate.HasValue)
return false; // Device not returned to User
return true; // Device not returned to User
if (j.WaitingForUserAction.HasValue)
return false; // Job waiting on User Action
return true; // Job waiting on User Action
if (IgnoreJobQueueJob == null)
{
if (j.JobQueues.Any(jqj => !jqj.RemovedDate.HasValue))
return true; // Job associated with a Job Queue
}
else
{
if (j.JobQueues.Any(jqj => jqj.Id != IgnoreJobQueueJob.Id && !jqj.RemovedDate.HasValue))
return true; // Job associated with a Job Queue
}
return false;
}
public static bool CanCloseNormally(this Job j)
{
if (j.CanCloseNever())
return false;
return j.CanCloseNormallyInternal();
}
private static bool CanCloseNormallyInternal(this Job j)
{
switch (j.JobTypeId)
{
case JobType.JobTypeIds.HWar:
@@ -374,36 +407,27 @@ namespace Disco.BI.Extensions
return true;
}
public static void OnClose(this Job j, User Technician)
{
if (!j.CanClose())
throw new InvalidOperationException("Close was Denied");
j.ClosedDate = DateTime.Now;
j.ClosedTechUserId = Technician.Id;
public static bool CanCloseJobNormallyAfterRemoved(this JobQueueJob jqj)
{
if (jqj.Job.CanCloseNever(jqj))
return false;
return jqj.Job.CanCloseNormallyInternal();
}
#endregion
#region Force Close
public static bool CanForceClose(this Job j)
public static bool CanCloseForced(this Job j)
{
if (!UserService.CurrentAuthorization.Has(Claims.Job.Actions.ForceClose))
return false;
var canCloseNormally = j.CanClose();
if (canCloseNormally)
if (j.CanCloseNever())
return false;
// Check for Override
if (j.ClosedDate.HasValue)
return false; // Job already Closed
if (j.DeviceHeld.HasValue && !j.DeviceReturnedDate.HasValue)
return false; // Device not returned to User
if (j.WaitingForUserAction.HasValue)
return false; // Job waiting on User Action
if (j.CanCloseNormally())
return false;
switch (j.JobTypeId)
{
@@ -427,9 +451,9 @@ namespace Disco.BI.Extensions
return false;
}
public static void OnForceClose(this Job j, DiscoDataContext Database, User Technician, string Reason)
public static void OnCloseForced(this Job j, DiscoDataContext Database, User Technician, string Reason)
{
if (!j.CanForceClose())
if (!j.CanCloseForced())
throw new InvalidOperationException("Force Close was Denied");
// Write Log
-102
View File
@@ -44,108 +44,6 @@ namespace Disco.BI.Extensions
return ja;
}
public static Tuple<string, string> Status(this Job j)
{
var statusId = j.CalculateStatusId();
return new Tuple<string, string>(statusId, JobBI.Utilities.JobStatusDescription(statusId, j));
}
public static JobTableModel.JobTableItemModelIncludeStatus ToJobTableItemModelIncludeStatus(this Job j)
{
var i = new JobTableModel.JobTableItemModelIncludeStatus()
{
Id = j.Id,
OpenedDate = j.OpenedDate,
ClosedDate = j.ClosedDate,
TypeId = j.JobTypeId,
TypeDescription = j.JobType.Description,
Location = j.DeviceHeldLocation,
WaitingForUserAction = j.WaitingForUserAction,
DeviceReadyForReturn = j.DeviceReadyForReturn,
DeviceHeld = j.DeviceHeld,
DeviceReturnedDate = j.DeviceReturnedDate
};
if (j.Device != null)
{
i.DeviceSerialNumber = j.DeviceSerialNumber;
i.DeviceModelDescription = j.Device.DeviceModel.Description;
i.DeviceAddressId = j.Device.DeviceProfile.DefaultOrganisationAddress;
if (j.JobMetaWarranty != null)
{
i.JobMetaWarranty_ExternalReference = j.JobMetaWarranty.ExternalReference;
i.JobMetaWarranty_ExternalCompletedDate = j.JobMetaWarranty.ExternalCompletedDate;
i.JobMetaWarranty_ExternalName = j.JobMetaWarranty.ExternalName;
}
if (j.JobMetaNonWarranty != null)
{
i.JobMetaNonWarranty_RepairerLoggedDate = j.JobMetaNonWarranty.RepairerLoggedDate;
i.JobMetaNonWarranty_RepairerCompletedDate = j.JobMetaNonWarranty.RepairerCompletedDate;
i.JobMetaNonWarranty_AccountingChargeAddedDate = j.JobMetaNonWarranty.AccountingChargeAddedDate;
i.JobMetaNonWarranty_AccountingChargePaidDate = j.JobMetaNonWarranty.AccountingChargePaidDate;
i.JobMetaNonWarranty_AccountingChargeRequiredDate = j.JobMetaNonWarranty.AccountingChargeRequiredDate;
i.JobMetaNonWarranty_IsInsuranceClaim = j.JobMetaNonWarranty.IsInsuranceClaim;
i.JobMetaNonWarranty_RepairerName = j.JobMetaNonWarranty.RepairerName;
if (j.JobMetaInsurance != null)
{
i.JobMetaInsurance_ClaimFormSentDate = j.JobMetaInsurance.ClaimFormSentDate;
}
}
}
if (j.User != null)
{
i.UserId = j.UserId;
i.UserDisplayName = j.User.DisplayName;
}
if (j.OpenedTechUser != null)
{
i.OpenedTechUserId = j.OpenedTechUserId;
i.OpenedTechUserDisplayName = j.OpenedTechUser.DisplayName;
}
return i;
}
public static string CalculateStatusId(this Job j)
{
return j.ToJobTableItemModelIncludeStatus().CalculateStatusId();
}
public static string CalculateStatusId(this JobTableModel.JobTableItemModelIncludeStatus j)
{
if (j.ClosedDate.HasValue)
return Job.JobStatusIds.Closed;
if (j.TypeId == JobType.JobTypeIds.HWar)
{
if (!string.IsNullOrEmpty(j.JobMetaWarranty_ExternalReference) && !j.JobMetaWarranty_ExternalCompletedDate.HasValue)
return Job.JobStatusIds.AwaitingWarrantyRepair; // Job Logged - but not marked as completed
}
if (j.TypeId == JobType.JobTypeIds.HNWar)
{
if (j.JobMetaNonWarranty_RepairerLoggedDate.HasValue && !j.JobMetaNonWarranty_RepairerCompletedDate.HasValue)
return Job.JobStatusIds.AwaitingRepairs; // Repairs logged - but not complete
if (j.JobMetaNonWarranty_AccountingChargeAddedDate.HasValue && !j.JobMetaNonWarranty_AccountingChargePaidDate.HasValue)
return Job.JobStatusIds.AwaitingAccountingPayment; // Accounting Charge Added, but not paid
if (j.JobMetaNonWarranty_AccountingChargeRequiredDate.HasValue && (!j.JobMetaNonWarranty_AccountingChargePaidDate.HasValue || !j.JobMetaNonWarranty_AccountingChargeAddedDate.HasValue))
return Job.JobStatusIds.AwaitingAccountingCharge; // Accounting Charge Required, but not added or paid
if (j.JobMetaNonWarranty_RepairerLoggedDate.HasValue && j.JobMetaNonWarranty_IsInsuranceClaim.Value && !j.JobMetaInsurance_ClaimFormSentDate.HasValue)
return Job.JobStatusIds.AwaitingInsuranceProcessing; // Is insurance claim, but no Claim Form Sent
}
if (j.WaitingForUserAction.HasValue)
return Job.JobStatusIds.AwaitingUserAction; // Awaiting for User
if (j.DeviceReadyForReturn.HasValue && !j.DeviceReturnedDate.HasValue)
return Job.JobStatusIds.AwaitingDeviceReturn; // Device not returned to User
return Job.JobStatusIds.Open;
}
public static List<DocumentTemplate> AvailableDocumentTemplates(this Job j, DiscoDataContext Database, User User, DateTime TimeStamp)
{
var dts = Database.DocumentTemplates.Include("JobSubTypes")
@@ -0,0 +1,216 @@
using Disco.Data.Repository;
using Disco.Models.Repository;
using Disco.Services.Authorization;
using Disco.Services.Jobs.JobQueues;
using Disco.Services.Users;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.BI.Extensions
{
public static class JobQueueActionExtensions
{
#region Edit Sla
public static bool CanEditSla(this JobQueueJob jqj)
{
if (jqj.RemovedDate.HasValue)
return false;
if (UserService.CurrentAuthorization.Has(Claims.Job.Properties.JobQueueProperties.EditAnySLA))
{
// Can edit ANY queue
return true;
}
else if (UserService.CurrentAuthorization.Has(Claims.Job.Properties.JobQueueProperties.EditOwnSLA))
{
// Can edit from OWN queue
return JobQueueService.UsersQueues(UserService.CurrentUser).Any(q => q.JobQueue.Id == jqj.JobQueueId);
}
else
{
return false;
}
}
public static void OnEditSla(this JobQueueJob jqj, DateTime? SlaExpiresDate)
{
if (!jqj.CanEditSla())
throw new InvalidOperationException("Editing job SLA for this queue is denied");
if (SlaExpiresDate.HasValue && jqj.AddedDate > SlaExpiresDate.Value)
throw new ArgumentException("The SLA Expires Date must be greater than the Added Date", "SLAExpiresDate");
jqj.SLAExpiresDate = SlaExpiresDate;
}
#endregion
#region Edit Priority
public static bool CanEditPriority(this JobQueueJob jqj)
{
if (jqj.RemovedDate.HasValue)
return false;
if (UserService.CurrentAuthorization.Has(Claims.Job.Properties.JobQueueProperties.EditAnyPriority))
{
// Can edit ANY queue
return true;
}
else if (UserService.CurrentAuthorization.Has(Claims.Job.Properties.JobQueueProperties.EditOwnPriority))
{
// Can edit from OWN queue
return JobQueueService.UsersQueues(UserService.CurrentUser).Any(q => q.JobQueue.Id == jqj.JobQueueId);
}
else
{
return false;
}
}
public static void OnEditPriority(this JobQueueJob jqj, JobQueuePriority Priority)
{
if (!jqj.CanEditPriority())
throw new InvalidOperationException("Editing job priority for this queue is denied");
jqj.Priority = Priority;
}
#endregion
#region Edit Comments
private static bool CanEditComments(this JobQueueJob jqj)
{
if (UserService.CurrentAuthorization.Has(Claims.Job.Properties.JobQueueProperties.EditAnyComments))
{
// Can edit ANY queue
return true;
}
else if (UserService.CurrentAuthorization.Has(Claims.Job.Properties.JobQueueProperties.EditOwnComments))
{
// Can edit from OWN queue
return JobQueueService.UsersQueues(UserService.CurrentUser).Any(q => q.JobQueue.Id == jqj.JobQueueId);
}
else
{
return false;
}
}
public static bool CanEditAddedComment(this JobQueueJob jqj)
{
return jqj.CanEditComments();
}
public static bool CanEditRemovedComment(this JobQueueJob jqj)
{
if (!jqj.RemovedDate.HasValue)
return false;
return jqj.CanEditComments();
}
public static void OnEditAddedComment(this JobQueueJob jqj, string AddedComment)
{
if (!jqj.CanEditAddedComment())
throw new InvalidOperationException("Editing job added comments for this queue is denied");
jqj.AddedComment = string.IsNullOrWhiteSpace(AddedComment) ? null : AddedComment.Trim();
}
public static void OnEditRemovedComment(this JobQueueJob jqj, string RemovedComment)
{
if (!jqj.CanEditRemovedComment())
throw new InvalidOperationException("Editing job removed comments for this queue is denied");
jqj.RemovedComment = string.IsNullOrWhiteSpace(RemovedComment) ? null : RemovedComment.Trim();
}
#endregion
#region Remove
public static bool CanRemove(this JobQueueJob jqj)
{
if (jqj.RemovedDate.HasValue)
return false;
if (UserService.CurrentAuthorization.Has(Claims.Job.Actions.RemoveAnyQueues))
{
// Can remove from ANY queue
return true;
}
else if (UserService.CurrentAuthorization.Has(Claims.Job.Actions.RemoveOwnQueues))
{
// Can remove from OWN queue
return JobQueueService.UsersQueues(UserService.CurrentUser).Any(q => q.JobQueue.Id == jqj.JobQueueId);
}
else
{
return false;
}
}
public static void OnRemove(this JobQueueJob jqj, User Technician, string Comment)
{
if (!jqj.CanRemove())
throw new InvalidOperationException("Removing job from queue is Denied");
jqj.RemovedDate = DateTime.Now;
jqj.RemovedUserId = Technician.Id;
jqj.RemovedComment = string.IsNullOrWhiteSpace(Comment) ? null : Comment.Trim();
}
#endregion
#region Add
public static bool CanAddQueues(this Job j)
{
// Job Closed?
if (j.ClosedDate.HasValue)
return false;
if (UserService.CurrentAuthorization.HasAny(Claims.Job.Actions.AddAnyQueues, Claims.Job.Actions.AddOwnQueues))
return true;
return false;
}
public static bool CanAddQueue(this Job j, JobQueue jq)
{
// Shortcut
if (!j.CanAddQueues())
return false;
// Already in Queue?
if (j.JobQueues.Count(jjq => !jjq.RemovedDate.HasValue && jjq.JobQueueId == jq.Id) > 0)
return false;
// Can add ANY queue
if (UserService.CurrentAuthorization.Has(Claims.Job.Actions.AddAnyQueues))
return true;
// Can add OWN queue
if (UserService.CurrentAuthorization.Has(Claims.Job.Actions.AddOwnQueues))
{
return JobQueueService.UsersQueues(UserService.CurrentUser).Any(q => q.JobQueue.Id == jq.Id);
}
return false;
}
public static JobQueueJob OnAddQueue(this Job j, DiscoDataContext Database, JobQueue jq, User Technician, string Comment, DateTime? SLAExpires, JobQueuePriority Priority)
{
if (!j.CanAddQueue(jq))
throw new InvalidOperationException("Adding job to queue is Denied");
if (SLAExpires.HasValue && SLAExpires.Value < DateTime.Now)
throw new ArgumentException("The SLA Date must be greater than the current time", "SLAExpires");
var jqj = new JobQueueJob()
{
JobQueueId = jq.Id,
JobId = j.Id,
AddedDate = DateTime.Now,
AddedUserId = Technician.Id,
AddedComment = string.IsNullOrWhiteSpace(Comment) ? null : Comment.Trim(),
SLAExpiresDate = SLAExpires,
Priority = Priority
};
Database.JobQueueJobs.Add(jqj);
return jqj;
}
#endregion
}
}
-188
View File
@@ -1,188 +0,0 @@
using Disco.Data.Repository;
using Disco.Data.Repository.Monitor;
using Disco.Models.BI.Job;
using Disco.Models.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Disco.BI.Extensions;
using System.Reactive.Linq;
using Disco.Services.Users;
namespace Disco.BI.JobBI
{
using FilterFunc = Func<IQueryable<Job>, IQueryable<Job>>;
using SortFunc = Func<IEnumerable<Disco.Models.BI.Job.JobTableModel.JobTableItemModel>, IEnumerable<Disco.Models.BI.Job.JobTableModel.JobTableItemModel>>;
using Disco.Services.Logging;
public class ManagedJobList : JobTableModel, IDisposable
{
public string Name { get; set; }
public FilterFunc FilterFunction { get; set; }
public SortFunc SortFunction { get; set; }
private IDisposable unsubscribeToken;
private object updateLock = new object();
public override List<JobTableItemModel> Items
{
get
{
return base.Items.PermissionsFiltered(UserService.CurrentAuthorization);
}
set
{
throw new InvalidOperationException("Items cannot be manually set in a Managed Job List");
}
}
public ManagedJobList Initialize(DiscoDataContext Database)
{
// Can only Initialize once
if (base.Items != null)
return ReInitialize(Database);
lock (updateLock)
{
// Subscribe for Changes
// - Job (or Job Meta) Changes
// - Device Profile Address Changes (for multi-campus Schools)
// - Device Model Description Changes
// - Device's Profile or Model Changes
unsubscribeToken = RepositoryMonitor.StreamAfterCommit
.Where(n => n.EntityType == typeof(Job) ||
n.EntityType == typeof(JobMetaWarranty) ||
n.EntityType == typeof(JobMetaNonWarranty) ||
n.EntityType == typeof(JobMetaInsurance) ||
(n.EventType == RepositoryMonitorEventType.Modified && (
(n.EntityType == typeof(DeviceProfile) && n.ModifiedProperties.Contains("DefaultOrganisationAddress")) ||
(n.EntityType == typeof(DeviceModel) && n.ModifiedProperties.Contains("Description")) ||
(n.EntityType == typeof(Device) && n.ModifiedProperties.Contains("DeviceProfileId") || n.ModifiedProperties.Contains("DeviceModelId"))
)))
.Subscribe(JobNotification, NotificationError);
// Initially fill table
base.Items = this.SortFunction(this.DetermineItems(Database, this.FilterFunction(Database.Jobs))).ToList();
}
return this;
}
public ManagedJobList ReInitialize(DiscoDataContext Database)
{
return ReInitialize(Database, null, null);
}
public ManagedJobList ReInitialize(DiscoDataContext Database, FilterFunc FilterFunction)
{
return ReInitialize(Database, FilterFunction, null);
}
public ManagedJobList ReInitialize(DiscoDataContext Database, FilterFunc FilterFunction, SortFunc SortFunction)
{
if (Database == null)
throw new ArgumentNullException("Database");
lock (updateLock)
{
if (FilterFunction != null)
this.FilterFunction = FilterFunction;
if (SortFunction != null)
this.SortFunction = SortFunction;
base.Items = this.SortFunction(this.DetermineItems(Database, this.FilterFunction(Database.Jobs))).ToList();
}
return this;
}
private void NotificationError(Exception ex)
{
SystemLog.LogException(string.Format("Disco.BI.JobBI.ManagedJobList: [{0}]", this.Name), ex);
}
private void JobNotification(RepositoryMonitorEvent e)
{
List<int> jobIds = null;
JobTableItemModel[] existingItems = null;
if (e.EntityType == typeof(Job))
jobIds = new List<int>() { ((Job)e.Entity).Id };
else
if (e.EntityType == typeof(JobMetaWarranty))
jobIds = new List<int>() { ((JobMetaWarranty)e.Entity).JobId };
else
if (e.EntityType == typeof(JobMetaNonWarranty))
jobIds = new List<int>() { ((JobMetaNonWarranty)e.Entity).JobId };
else
if (e.EntityType == typeof(JobMetaInsurance))
jobIds = new List<int>() { ((JobMetaInsurance)e.Entity).JobId };
else
if (e.EntityType == typeof(DeviceProfile))
{
int deviceProfileId = ((DeviceProfile)e.Entity).Id;
existingItems = base.Items.Where(i => i.DeviceProfileId == deviceProfileId).ToArray();
}
else
if (e.EntityType == typeof(DeviceModel))
{
int deviceModelId = ((DeviceModel)e.Entity).Id;
existingItems = base.Items.Where(i => i.DeviceModelId == deviceModelId).ToArray();
}
else
if (e.EntityType == typeof(Device))
{
string deviceSerialNumber = ((Device)e.Entity).SerialNumber;
existingItems = base.Items.Where(i => i.DeviceSerialNumber == deviceSerialNumber).ToArray();
}
else
return; // Subscription should never reach
if (jobIds == null)
{
if (existingItems == null)
throw new InvalidOperationException("Notification algorithm didn't indicate any Jobs for update");
else
jobIds = existingItems.Select(i => i.Id).ToList();
}
if (jobIds.Count == 0)
return;
else
UpdateJobs(e.Database, jobIds, existingItems);
}
private void UpdateJobs(DiscoDataContext Database, List<int> jobIds, JobTableItemModel[] existingItems = null)
{
lock (updateLock)
{
// Check for existing items, if not handed them
if (existingItems == null)
existingItems = base.Items.Where(i => jobIds.Contains(i.Id)).ToArray();
var updatedItems = this.DetermineItems(Database, this.FilterFunction(Database.Jobs.Where(j => jobIds.Contains(j.Id))));
var refreshedList = base.Items.ToList();
// Remove Existing
if (existingItems.Length > 0)
foreach (var existingItem in existingItems)
refreshedList.Remove(existingItem);
// Add Updated Items
if (updatedItems.Count > 0)
foreach (var updatedItem in updatedItems)
refreshedList.Add(updatedItem);
// Reorder
base.Items = this.SortFunction(refreshedList).ToList();
}
}
public void Dispose()
{
if (unsubscribeToken != null)
{
unsubscribeToken.Dispose();
unsubscribeToken = null;
}
}
}
}
+4 -7
View File
@@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Disco.Models.BI.Job;
using Disco.Data.Repository;
using Disco.Data.Repository;
using Disco.Models.Repository;
using Disco.BI.Extensions;
using Disco.Models.Services.Jobs.JobLists;
using Disco.Services;
using System.Linq;
namespace Disco.BI.JobBI
{
+28 -78
View File
@@ -40,6 +40,34 @@ namespace Disco.BI.JobBI
Database.Jobs.Add(j);
// Job Queues
var queues = from st in subTypes
from jq in st.JobQueues
group st by jq into g
select new { queue = g.Key, subTypes = g };
foreach (var queue in queues)
{
var commentBuilder = new StringBuilder("Automatically added by:");
foreach (var subType in queue.subTypes)
{
commentBuilder.AppendLine();
commentBuilder.Append(subType.Description);
}
var jqj = new JobQueueJob()
{
JobQueueId = queue.queue.Id,
Job = j,
AddedDate = DateTime.Now,
AddedUserId = initialTech.Id,
AddedComment = commentBuilder.ToString(),
SLAExpiresDate = queue.queue.DefaultSLAExpiry.HasValue ? (DateTime?)DateTime.Now.AddMinutes(queue.queue.DefaultSLAExpiry.Value) : null,
Priority = JobQueuePriority.Normal
};
Database.JobQueueJobs.Add(jqj);
}
switch (type.Id)
{
case JobType.JobTypeIds.HWar:
@@ -89,83 +117,5 @@ namespace Disco.BI.JobBI
return j;
}
public static string JobStatusDescription(string StatusId, Job j = null)
{
switch (StatusId)
{
case Job.JobStatusIds.Open:
return "Open";
case Job.JobStatusIds.Closed:
return "Closed";
case Job.JobStatusIds.AwaitingWarrantyRepair:
if (j == null)
return "Awaiting Warranty Repair";
else
if (j.DeviceHeld.HasValue)
return string.Format("Awaiting Warranty Repair ({0})", j.JobMetaWarranty.ExternalName);
else
return string.Format("Awaiting Warranty Repair - Not Held ({0})", j.JobMetaWarranty.ExternalName);
case Job.JobStatusIds.AwaitingRepairs:
if (j == null)
return "Awaiting Repairs";
else
if (j.DeviceHeld.HasValue)
return string.Format("Awaiting Repairs ({0})", j.JobMetaNonWarranty.RepairerName);
else
return string.Format("Awaiting Repairs - Not Held ({0})", j.JobMetaNonWarranty.RepairerName);
case Job.JobStatusIds.AwaitingDeviceReturn:
return "Awaiting Device Return";
case Job.JobStatusIds.AwaitingUserAction:
return "Awaiting User Action";
case Job.JobStatusIds.AwaitingAccountingPayment:
return "Awaiting Accounting Payment";
case Job.JobStatusIds.AwaitingAccountingCharge:
return "Awaiting Accounting Charge";
case Job.JobStatusIds.AwaitingInsuranceProcessing:
return "Awaiting Insurance Processing";
default:
return "Unknown";
}
}
public static string JobStatusDescription(string StatusId, JobTableModel.JobTableItemModelIncludeStatus j = null)
{
switch (StatusId)
{
case Job.JobStatusIds.Open:
return "Open";
case Job.JobStatusIds.Closed:
return "Closed";
case Job.JobStatusIds.AwaitingWarrantyRepair:
if (j == null)
return "Awaiting Warranty Repair";
else
if (j.DeviceHeld.HasValue)
return string.Format("Awaiting Warranty Repair ({0})", j.JobMetaWarranty_ExternalName);
else
return string.Format("Awaiting Warranty Repair - Not Held ({0})", j.JobMetaWarranty_ExternalName);
case Job.JobStatusIds.AwaitingRepairs:
if (j == null)
return "Awaiting Repairs";
else
if (j.DeviceHeld.HasValue)
return string.Format("Awaiting Repairs ({0})", j.JobMetaNonWarranty_RepairerName);
else
return string.Format("Awaiting Repairs - Not Held ({0})", j.JobMetaNonWarranty_RepairerName);
case Job.JobStatusIds.AwaitingDeviceReturn:
return "Awaiting Device Return";
case Job.JobStatusIds.AwaitingUserAction:
return "Awaiting User Action";
case Job.JobStatusIds.AwaitingAccountingPayment:
return "Awaiting Accounting Payment";
case Job.JobStatusIds.AwaitingAccountingCharge:
return "Awaiting Accounting Charge";
case Job.JobStatusIds.AwaitingInsuranceProcessing:
return "Awaiting Insurance Processing";
default:
return "Unknown";
}
}
}
}
+1 -2
View File
@@ -155,7 +155,7 @@
<Compile Include="BI\Extensions\JobActionExtensions.cs" />
<Compile Include="BI\Extensions\JobExtensions.cs" />
<Compile Include="BI\Extensions\JobFlagExtensions.cs" />
<Compile Include="BI\Extensions\JobTableExtensions.cs" />
<Compile Include="BI\Extensions\JobQueueActionExtensions.cs" />
<Compile Include="BI\Extensions\UserExtensions.cs" />
<Compile Include="BI\Extensions\WirelessCertificateExtensions.cs" />
<Compile Include="BI\Extensions\DeviceExtensions.cs" />
@@ -196,7 +196,6 @@
<Compile Include="BI\Interop\SignalRHandlers\ScheduledTasksStatusNotifications.cs" />
<Compile Include="BI\Interop\SignalRHandlers\SignalRAuthenticationWorkaround.cs" />
<Compile Include="BI\Interop\SignalRHandlers\UserHeldDeviceNotifications.cs" />
<Compile Include="BI\JobBI\ManagedJobList.cs" />
<Compile Include="BI\JobBI\Searching.cs" />
<Compile Include="BI\JobBI\Statistics\DailyOpenedClosed.cs" />
<Compile Include="BI\JobBI\Utilities.cs" />
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.1128.1503")]
[assembly: AssemblyFileVersion("1.2.1128.1503")]
[assembly: AssemblyVersion("1.2.1229.1537")]
[assembly: AssemblyFileVersion("1.2.1229.1537")]
+7
View File
@@ -126,6 +126,10 @@
<Compile Include="Migrations\201310282325491_DBv11.Designer.cs">
<DependentUpon>201310282325491_DBv11.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201401270857381_DBv12.cs" />
<Compile Include="Migrations\201401270857381_DBv12.Designer.cs">
<DependentUpon>201401270857381_DBv12.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Migrations\DiscoDataMigrator.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
@@ -174,6 +178,9 @@
<EmbeddedResource Include="Migrations\201310282325491_DBv11.resx">
<DependentUpon>201310282325491_DBv11.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\201401270857381_DBv12.resx">
<DependentUpon>201401270857381_DBv12.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
+27
View File
@@ -0,0 +1,27 @@
// <auto-generated />
namespace Disco.Data.Migrations
{
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
public sealed partial class DBv12 : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(DBv12));
string IMigrationMetadata.Id
{
get { return "201401270857381_DBv12"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}
@@ -0,0 +1,86 @@
namespace Disco.Data.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class DBv12 : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.JobQueueJobs",
c => new
{
Id = c.Int(nullable: false, identity: true),
JobQueueId = c.Int(nullable: false),
JobId = c.Int(nullable: false),
AddedDate = c.DateTime(nullable: false),
AddedUserId = c.String(nullable: false, maxLength: 50),
AddedComment = c.String(),
RemovedDate = c.DateTime(),
RemovedUserId = c.String(maxLength: 50),
RemovedComment = c.String(),
SLAExpiresDate = c.DateTime(),
Priority = c.Byte(nullable: false),
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.JobQueues", t => t.JobQueueId)
.ForeignKey("dbo.Jobs", t => t.JobId)
.ForeignKey("dbo.Users", t => t.AddedUserId)
.ForeignKey("dbo.Users", t => t.RemovedUserId)
.Index(t => t.JobQueueId)
.Index(t => t.JobId)
.Index(t => t.AddedUserId)
.Index(t => t.RemovedUserId);
CreateTable(
"dbo.JobQueues",
c => new
{
Id = c.Int(nullable: false, identity: true),
Name = c.String(nullable: false, maxLength: 100),
Description = c.String(nullable: false, maxLength: 500),
Icon = c.String(nullable: false, maxLength: 25),
IconColour = c.String(nullable: false, maxLength: 10),
DefaultSLAExpiry = c.Int(),
Priority = c.Byte(nullable: false),
SubjectIds = c.String(),
})
.PrimaryKey(t => t.Id);
CreateTable(
"dbo.JobQueues_JobSubTypes",
c => new
{
JobQueue_Id = c.Int(nullable: false),
JobSubType_Id = c.String(nullable: false, maxLength: 20),
JobSubType_JobTypeId = c.String(nullable: false, maxLength: 5),
})
.PrimaryKey(t => new { t.JobQueue_Id, t.JobSubType_Id, t.JobSubType_JobTypeId })
.ForeignKey("dbo.JobQueues", t => t.JobQueue_Id, cascadeDelete: true)
.ForeignKey("dbo.JobSubTypes", t => new { t.JobSubType_Id, t.JobSubType_JobTypeId }, cascadeDelete: true)
.Index(t => t.JobQueue_Id)
.Index(t => new { t.JobSubType_Id, t.JobSubType_JobTypeId });
}
public override void Down()
{
DropIndex("dbo.JobQueues_JobSubTypes", new[] { "JobSubType_Id", "JobSubType_JobTypeId" });
DropIndex("dbo.JobQueues_JobSubTypes", new[] { "JobQueue_Id" });
DropIndex("dbo.JobQueueJobs", new[] { "RemovedUserId" });
DropIndex("dbo.JobQueueJobs", new[] { "AddedUserId" });
DropIndex("dbo.JobQueueJobs", new[] { "JobId" });
DropIndex("dbo.JobQueueJobs", new[] { "JobQueueId" });
DropForeignKey("dbo.JobQueues_JobSubTypes", new[] { "JobSubType_Id", "JobSubType_JobTypeId" }, "dbo.JobSubTypes");
DropForeignKey("dbo.JobQueues_JobSubTypes", "JobQueue_Id", "dbo.JobQueues");
DropForeignKey("dbo.JobQueueJobs", "RemovedUserId", "dbo.Users");
DropForeignKey("dbo.JobQueueJobs", "AddedUserId", "dbo.Users");
DropForeignKey("dbo.JobQueueJobs", "JobId", "dbo.Jobs");
DropForeignKey("dbo.JobQueueJobs", "JobQueueId", "dbo.JobQueues");
DropTable("dbo.JobQueues_JobSubTypes");
DropTable("dbo.JobQueues");
DropTable("dbo.JobQueueJobs");
}
}
}
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.1128.1503")]
[assembly: AssemblyFileVersion("1.2.1128.1503")]
[assembly: AssemblyVersion("1.2.1229.1537")]
[assembly: AssemblyFileVersion("1.2.1229.1537")]
@@ -48,6 +48,9 @@ namespace Disco.Data.Repository
public virtual DbSet<JobMetaNonWarranty> JobMetaNonWarranties { get; set; }
public virtual DbSet<JobMetaInsurance> JobMetaInsurances { get; set; }
public virtual DbSet<JobQueue> JobQueues { get; set; }
public virtual DbSet<JobQueueJob> JobQueueJobs { get; set; }
public Configuration.SystemConfiguration DiscoConfiguration
{
get
@@ -62,6 +65,7 @@ namespace Disco.Data.Repository
modelBuilder.Entity<DeviceComponent>().HasMany(m => m.JobSubTypes).WithMany(m => m.DeviceComponents).Map(m => m.ToTable("DeviceComponents_JobSubTypes"));
modelBuilder.Entity<DocumentTemplate>().HasMany(m => m.JobSubTypes).WithMany(m => m.AttachmentTypes).Map(m => m.ToTable("DocumentTemplates_JobSubTypes"));
modelBuilder.Entity<JobQueue>().HasMany(m => m.JobSubTypes).WithMany(m => m.JobQueues).Map(m => m.ToTable("JobQueues_JobSubTypes"));
modelBuilder.Entity<Job>().HasMany(m => m.JobSubTypes).WithMany(m => m.Jobs).Map(m => m.ToTable("Jobs_JobSubTypes"));
modelBuilder.Entity<User>().HasMany(m => m.Jobs).WithOptional(m => m.User);
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace Disco.Models.BI.Config
{
+1 -5
View File
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.BI.Device
{
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace Disco.Models.BI.Device
{
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace Disco.Models.BI.DocumentTemplates
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.IO;
namespace Disco.Models.BI.Expressions
{
-124
View File
@@ -1,124 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Disco.Models.BI.Job
{
public class JobTableModel
{
public bool ShowId { get; set; }
public bool? ShowDeviceAddress { get; set; }
public bool ShowDates { get; set; }
public bool ShowType { get; set; }
public bool ShowDevice { get; set; }
public bool ShowUser { get; set; }
public bool ShowTechnician { get; set; }
public bool ShowLocation { get; set; }
public bool ShowStatus { get; set; }
public bool IsSmallTable { get; set; }
public bool HideClosedJobs { get; set; }
public bool EnablePaging { get; set; }
public bool EnableFilter { get; set; }
public virtual List<JobTableItemModel> Items { get; set; }
public JobTableModel()
{
ShowId = true;
ShowDates = true;
ShowType = true;
ShowDevice = true;
ShowUser = true;
ShowTechnician = true;
EnablePaging = true;
EnableFilter = true;
}
private JobTableModel CloneEmptyModel()
{
return new JobTableModel()
{
ShowId = this.ShowId,
ShowDeviceAddress = this.ShowDeviceAddress,
ShowDates = this.ShowDates,
ShowType = this.ShowType,
ShowDevice = this.ShowDevice,
ShowUser = this.ShowUser,
ShowTechnician = this.ShowTechnician,
ShowLocation = this.ShowLocation,
ShowStatus = this.ShowStatus,
IsSmallTable = this.IsSmallTable,
HideClosedJobs = this.HideClosedJobs,
EnablePaging = this.EnablePaging,
EnableFilter = this.EnableFilter
};
}
public IDictionary<string, JobTableModel> MultiCampusModels
{
get
{
var items = this.Items;
if (items == null || items.Count > 0)
{
return items.OrderBy(i => i.DeviceAddress).GroupBy(i => i.DeviceAddress).ToDictionary(
ig => ig.Key ?? string.Empty,
ig =>
{
var jtm = this.CloneEmptyModel();
jtm.Items = ig.ToList();
return jtm;
}
);
}
else
{
return null;
}
}
}
public class JobTableItemModel
{
public int Id { get; set; }
public DateTime OpenedDate { get; set; }
public DateTime? ClosedDate { get; set; }
public string TypeId { get; set; }
public string TypeDescription { get; set; }
public string DeviceSerialNumber { get; set; }
public int? DeviceModelId { get; set; }
public string DeviceModelDescription { get; set; }
public int? DeviceProfileId { get; set; }
public int? DeviceAddressId { get; set; }
public string DeviceAddress { get; set; }
public string UserId { get; set; }
public string UserDisplayName { get; set; }
public string OpenedTechUserId { get; set; }
public string OpenedTechUserDisplayName { get; set; }
public string StatusDescription { get; set; }
public string StatusId { get; set; }
public string Location { get; set; }
}
public class JobTableItemModelIncludeStatus : JobTableItemModel
{
public string JobMetaWarranty_ExternalReference { get; set; }
public DateTime? JobMetaWarranty_ExternalCompletedDate { get; set; }
public DateTime? JobMetaNonWarranty_RepairerLoggedDate { get; set; }
public DateTime? JobMetaNonWarranty_RepairerCompletedDate { get; set; }
public DateTime? JobMetaNonWarranty_AccountingChargeAddedDate { get; set; }
public DateTime? JobMetaNonWarranty_AccountingChargePaidDate { get; set; }
public DateTime? JobMetaNonWarranty_AccountingChargeRequiredDate { get; set; }
public bool? JobMetaNonWarranty_IsInsuranceClaim { get; set; }
public DateTime? JobMetaInsurance_ClaimFormSentDate { get; set; }
public DateTime? WaitingForUserAction { get; set; }
public DateTime? DeviceReadyForReturn { get; set; }
public DateTime? DeviceHeld { get; set; }
public DateTime? DeviceReturnedDate { get; set; }
public string JobMetaWarranty_ExternalName { get; set; }
public string JobMetaNonWarranty_RepairerName { get; set; }
}
}
}
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Disco.Models.BI.Job.Statistics
{
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Disco.Models.BI.Search
{
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Disco.Models.BI.Search
{
public class UserSearchResultItem
+14 -4
View File
@@ -45,9 +45,9 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Authorization\IAuthorizationToken.cs" />
<Compile Include="Authorization\IClaimNavigatorItem.cs" />
<Compile Include="Authorization\IRoleToken.cs" />
<Compile Include="Services\Authorization\IAuthorizationToken.cs" />
<Compile Include="Services\Authorization\IClaimNavigatorItem.cs" />
<Compile Include="Services\Authorization\IRoleToken.cs" />
<Compile Include="BI\Config\OrganisationAddress.cs" />
<Compile Include="BI\Device\ImportDevice.cs" />
<Compile Include="BI\Device\ImportDeviceSession.cs" />
@@ -62,7 +62,6 @@
<Compile Include="BI\Interop\Community\UpdateRequestBase.cs" />
<Compile Include="BI\Interop\Community\UpdateRequestV1.cs" />
<Compile Include="BI\Interop\Community\UpdateResponse.cs" />
<Compile Include="BI\Job\JobTableModel.cs" />
<Compile Include="BI\Job\Statistics\DailyOpenedClosedItem.cs" />
<Compile Include="BI\Search\DeviceSearchResultItem.cs" />
<Compile Include="BI\Search\UserSearchResultItem.cs" />
@@ -100,10 +99,18 @@
<Compile Include="Repository\Job\JobMeta\JobMetaWarranty.cs" />
<Compile Include="Repository\Job\JobSubType.cs" />
<Compile Include="Repository\Job\JobType.cs" />
<Compile Include="Repository\Job\Queue\JobQueue.cs" />
<Compile Include="Repository\Job\Queue\JobQueueJob.cs" />
<Compile Include="Repository\Job\Queue\JobQueuePriority.cs" />
<Compile Include="Repository\User\User.cs" />
<Compile Include="Repository\User\UserAttachment.cs" />
<Compile Include="Repository\User\UserDetail.cs" />
<Compile Include="Repository\User\AuthorizationRole.cs" />
<Compile Include="Services\Jobs\JobLists\JobTableItemModel.cs" />
<Compile Include="Services\Jobs\JobLists\JobTableModel.cs" />
<Compile Include="Services\Jobs\JobLists\JobTableStatusItemModel.cs" />
<Compile Include="Services\Jobs\JobLists\JobTableStatusQueueItemModel.cs" />
<Compile Include="Services\Jobs\JobQueues\IJobQueueToken.cs" />
<Compile Include="UI\BaseUIModel.cs" />
<Compile Include="UI\Config\AuthorizationRole\ConfigAuthorizationRoleCreateModel.cs" />
<Compile Include="UI\Config\AuthorizationRole\ConfigAuthorizationRoleIndexModel.cs" />
@@ -132,6 +139,9 @@
<Compile Include="UI\Config\Enrolment\ConfigEnrolmentIndexModel.cs" />
<Compile Include="UI\Config\Enrolment\ConfigEnrolmentStatusModel.cs" />
<Compile Include="UI\Config\JobPreferences\ConfigJobPreferencesIndexModel.cs" />
<Compile Include="UI\Config\JobQueue\ConfigJobQueueCreateModel.cs" />
<Compile Include="UI\Config\JobQueue\ConfigJobQueueIndexModel.cs" />
<Compile Include="UI\Config\JobQueue\ConfigJobQueueShowModel.cs" />
<Compile Include="UI\Config\Logging\ConfigLoggingIndexModel.cs" />
<Compile Include="UI\Config\Logging\ConfigLoggingTaskStatusModel.cs" />
<Compile Include="UI\Config\Organisation\ConfigOrganisationIndexModel.cs" />
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.1128.1503")]
[assembly: AssemblyFileVersion("1.2.1128.1503")]
[assembly: AssemblyVersion("1.2.1229.1537")]
[assembly: AssemblyFileVersion("1.2.1229.1537")]
+2
View File
@@ -70,6 +70,8 @@ namespace Disco.Models.Repository
public virtual IList<JobComponent> JobComponents { get; set; }
public virtual IList<JobLog> JobLogs { get; set; }
public virtual IList<JobQueueJob> JobQueues { get; set; }
public virtual JobMetaInsurance JobMetaInsurance { get; set; }
public virtual JobMetaWarranty JobMetaWarranty { get; set; }
public virtual JobMetaNonWarranty JobMetaNonWarranty { get; set; }
@@ -18,6 +18,7 @@ namespace Disco.Models.Repository
public virtual IList<DocumentTemplate> AttachmentTypes { get; set; }
public virtual IList<DeviceComponent> DeviceComponents { get; set; }
public virtual IList<JobQueue> JobQueues { get; set; }
[ForeignKey("JobTypeId")]
public virtual JobType JobType { get; set; }
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Repository
{
public class JobQueue
{
[Key]
public int Id { get; set; }
[Required, StringLength(100)]
public string Name { get; set; }
[Required, StringLength(500), DataType(DataType.MultilineText)]
public string Description { get; set; }
[Required, StringLength(25)]
public string Icon { get; set; }
[Required, StringLength(10)]
public string IconColour { get; set; }
public int? DefaultSLAExpiry { get; set; }
[Required]
public JobQueuePriority Priority { get; set; }
public string SubjectIds { get; set; }
public virtual IList<JobSubType> JobSubTypes { get; set; }
public virtual IList<JobQueueJob> QueueJobs { get; set; }
public override string ToString()
{
return this.Name;
}
}
}
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Repository
{
public class JobQueueJob
{
public int Id { get; set; }
[Required]
public int JobQueueId { get; set; }
[Required]
public int JobId { get; set; }
[Required]
public DateTime AddedDate { get; set; }
[Required]
public string AddedUserId { get; set; }
public string AddedComment { get; set; }
public DateTime? RemovedDate { get; set; }
public string RemovedUserId { get; set; }
public string RemovedComment { get; set; }
public DateTime? SLAExpiresDate { get; set; }
public JobQueuePriority Priority { get; set; }
[ForeignKey("JobQueueId")]
public virtual JobQueue JobQueue { get; set; }
[ForeignKey("JobId")]
public virtual Job Job { get; set; }
[ForeignKey("AddedUserId")]
public virtual User AddedUser { get; set; }
[ForeignKey("RemovedUserId")]
public virtual User RemovedUser { get; set; }
}
}
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Repository
{
public enum JobQueuePriority : byte
{
High = 2,
Normal = 1,
Low = 0
}
}
@@ -1,11 +1,7 @@
using Disco.Models.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Authorization
namespace Disco.Models.Services.Authorization
{
public interface IAuthorizationToken
{
@@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace Disco.Models.Authorization
namespace Disco.Models.Services.Authorization
{
public interface IClaimNavigatorItem
{
@@ -1,11 +1,7 @@
using Disco.Models.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.Authorization
namespace Disco.Models.Services.Authorization
{
public interface IRoleToken
{
@@ -0,0 +1,27 @@
using System;
namespace Disco.Models.Services.Jobs.JobLists
{
public class JobTableItemModel
{
public int Id { get; set; }
public DateTime OpenedDate { get; set; }
public DateTime? ClosedDate { get; set; }
public string JobTypeId { get; set; }
public string JobTypeDescription { get; set; }
public string DeviceSerialNumber { get; set; }
public int? DeviceModelId { get; set; }
public string DeviceModelDescription { get; set; }
public int? DeviceProfileId { get; set; }
public int? DeviceAddressId { get; set; }
public string DeviceAddress { get; set; }
public string UserId { get; set; }
public string UserDisplayName { get; set; }
public string OpenedTechUserId { get; set; }
public string OpenedTechUserDisplayName { get; set; }
public string StatusDescription { get; set; }
public string StatusId { get; set; }
public string DeviceHeldLocation { get; set; }
public Disco.Models.Repository.Job.UserManagementFlags? Flags { get; set; }
}
}
@@ -0,0 +1,36 @@
using System.Collections.Generic;
namespace Disco.Models.Services.Jobs.JobLists
{
public class JobTableModel
{
public bool ShowId { get; set; }
public bool? ShowDeviceAddress { get; set; }
public bool ShowDates { get; set; }
public bool ShowType { get; set; }
public bool ShowDevice { get; set; }
public bool ShowUser { get; set; }
public bool ShowTechnician { get; set; }
public bool ShowLocation { get; set; }
public bool ShowStatus { get; set; }
public bool IsSmallTable { get; set; }
public bool HideClosedJobs { get; set; }
public bool EnablePaging { get; set; }
public bool EnableFilter { get; set; }
public virtual IEnumerable<JobTableItemModel> Items { get; set; }
public JobTableModel()
{
ShowId = true;
ShowDates = true;
ShowType = true;
ShowDevice = true;
ShowUser = true;
ShowTechnician = true;
EnablePaging = true;
EnableFilter = true;
}
}
}
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
namespace Disco.Models.Services.Jobs.JobLists
{
public class JobTableStatusItemModel : JobTableItemModel
{
public string JobMetaWarranty_ExternalReference { get; set; }
public DateTime? JobMetaWarranty_ExternalLoggedDate { get; set; }
public DateTime? JobMetaWarranty_ExternalCompletedDate { get; set; }
public DateTime? JobMetaNonWarranty_RepairerLoggedDate { get; set; }
public DateTime? JobMetaNonWarranty_RepairerCompletedDate { get; set; }
public DateTime? JobMetaNonWarranty_AccountingChargeAddedDate { get; set; }
public DateTime? JobMetaNonWarranty_AccountingChargePaidDate { get; set; }
public DateTime? JobMetaNonWarranty_AccountingChargeRequiredDate { get; set; }
public bool? JobMetaNonWarranty_IsInsuranceClaim { get; set; }
public DateTime? JobMetaInsurance_ClaimFormSentDate { get; set; }
public DateTime? WaitingForUserAction { get; set; }
public DateTime? DeviceReadyForReturn { get; set; }
public DateTime? DeviceHeld { get; set; }
public DateTime? DeviceReturnedDate { get; set; }
public string JobMetaWarranty_ExternalName { get; set; }
public string JobMetaNonWarranty_RepairerName { get; set; }
public IEnumerable<JobTableStatusQueueItemModel> ActiveJobQueues { get; set; }
}
}
@@ -0,0 +1,14 @@
using Disco.Models.Repository;
using System;
namespace Disco.Models.Services.Jobs.JobLists
{
public class JobTableStatusQueueItemModel
{
public int Id { get; set; }
public int QueueId { get; set; }
public DateTime AddedDate { get; set; }
public DateTime? SLAExpiresDate { get; set; }
public JobQueuePriority Priority { get; set; }
}
}
@@ -0,0 +1,11 @@
using Disco.Models.Repository;
using System.Collections.ObjectModel;
namespace Disco.Models.Services.Jobs.JobQueues
{
public interface IJobQueueToken
{
JobQueue JobQueue { get; }
ReadOnlyCollection<string> SubjectIds { get; }
}
}
@@ -1,4 +1,4 @@
using Disco.Models.Authorization;
using Disco.Models.Services.Authorization;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -1,4 +1,4 @@
using Disco.Models.Authorization;
using Disco.Models.Services.Authorization;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -11,11 +11,7 @@ namespace Disco.Models.UI.Config.DocumentTemplate
Disco.Models.Repository.DocumentTemplate DocumentTemplate { get; set; }
int StoredInstanceCount { get; set; }
List<string> Types { get; set; }
List<string> SubTypes { get; set; }
List<Disco.Models.Repository.JobType> JobTypes { get; set; }
List<Disco.Models.Repository.JobSubType> JobSubTypes { get; set; }
List<string> Scopes { get; }
}
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.UI.Config.JobQueue
{
public interface ConfigJobQueueCreateModel : BaseUIModel
{
Repository.JobQueue JobQueue { get; set; }
}
}
@@ -0,0 +1,14 @@
using Disco.Models.Services.Jobs.JobQueues;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.UI.Config.JobQueue
{
public interface ConfigJobQueueIndexModel : BaseUIModel
{
List<IJobQueueToken> Tokens { get; set; }
}
}
@@ -0,0 +1,21 @@
using Disco.Models.Services.Jobs.JobQueues;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.UI.Config.JobQueue
{
public interface ConfigJobQueueShowModel : BaseUIModel
{
IJobQueueToken Token { get; set; }
int OpenJobCount { get; set; }
int TotalJobCount { get; set; }
List<Disco.Models.Repository.JobType> JobTypes { get; set; }
bool CanDelete { get; set; }
}
}
+2 -5
View File
@@ -1,8 +1,5 @@
using System;
using Disco.Models.Services.Jobs.JobLists;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.UI.Device
{
@@ -15,7 +12,7 @@ namespace Disco.Models.UI.Device
List<Disco.Models.Repository.DeviceBatch> DeviceBatches { get; set; }
Disco.Models.BI.Job.JobTableModel Jobs { get; set; }
JobTableModel Jobs { get; set; }
List<Disco.Models.Repository.DeviceCertificate> Certificates { get; set; }
-1
View File
@@ -28,6 +28,5 @@ namespace Disco.Models.UI.Job
Disco.Models.Repository.Device Device { get; set; }
Disco.Models.Repository.User User { get; set; }
List<Disco.Models.Repository.JobType> JobTypes { get; set; }
List<Disco.Models.Repository.JobSubType> JobSubTypes { get; set; }
}
}
+2 -7
View File
@@ -1,15 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Disco.Models.BI.Job;
using Disco.Models.Services.Jobs.JobLists;
namespace Disco.Models.UI.Job
{
public interface JobIndexModel : BaseUIModel
{
JobTableModel OpenJobs { get; set; }
JobTableModel MyJobs { get; set; }
JobTableModel LongRunningJobs { get; set; }
}
}
+3 -7
View File
@@ -1,14 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Disco.Models.Services.Jobs.JobLists;
namespace Disco.Models.UI.Job
{
public interface JobListModel : BaseUIModel
{
string Title { get; set; }
Disco.Models.BI.Job.JobTableModel JobTable { get; set; }
JobTableModel JobTable { get; set; }
}
}
}
+1
View File
@@ -12,5 +12,6 @@ namespace Disco.Models.UI.Job
TimeSpan? LongRunning { get; set; }
List<Repository.DocumentTemplate> AvailableDocumentTemplates { get; set; }
List<Repository.JobSubType> UpdatableJobSubTypes { get; set; }
List<Repository.JobQueue> AvailableQueues { get; set; }
}
}
+5 -7
View File
@@ -1,8 +1,6 @@
using System;
using Disco.Models.BI.Search;
using Disco.Models.Services.Jobs.JobLists;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.UI.Search
{
@@ -12,8 +10,8 @@ namespace Disco.Models.UI.Search
string Term { get; set; }
bool Success { get; set; }
string ErrorMessage { get; set; }
List<Disco.Models.BI.Search.DeviceSearchResultItem> Devices { get; set; }
Disco.Models.BI.Job.JobTableModel Jobs { get; set; }
List<Disco.Models.BI.Search.UserSearchResultItem> Users { get; set; }
List<DeviceSearchResultItem> Devices { get; set; }
JobTableModel Jobs { get; set; }
List<UserSearchResultItem> Users { get; set; }
}
}
+4 -7
View File
@@ -1,18 +1,15 @@
using Disco.Models.Authorization;
using System;
using Disco.Models.Services.Authorization;
using Disco.Models.Services.Jobs.JobLists;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Models.UI.User
{
public interface UserShowModel : BaseUIModel
{
Disco.Models.Repository.User User { get; set; }
Disco.Models.BI.Job.JobTableModel Jobs { get; set; }
JobTableModel Jobs { get; set; }
List<Disco.Models.Repository.DocumentTemplate> DocumentTemplates { get; set; }
IAuthorizationToken AuthorizationToken { get; set; }
IClaimNavigatorItem ClaimNavigator { get; set; }
}
}
}
@@ -1,4 +1,4 @@
using Disco.Models.Authorization;
using Disco.Models.Services.Authorization;
using Disco.Models.Repository;
using Disco.Services.Authorization.Roles;
using System;
@@ -1,4 +1,4 @@
using Disco.Models.Authorization;
using Disco.Models.Services.Authorization;
using Disco.Services.Authorization.Roles;
using System;
using System.Collections.Generic;
+244 -82
View File
@@ -5,7 +5,7 @@
// This file was generated by a T4 template.
// Don't change it directly as your change would get overwritten. Instead, make changes
// to the .tt file (i.e. the T4 template) and save it to regenerate this file.
using Disco.Models.Authorization;
using Disco.Models.Services.Authorization;
using Disco.Models.Repository;
using Disco.Services.Authorization.Roles;
using System;
@@ -68,6 +68,10 @@ namespace Disco.Services.Authorization
{ "Config.Organisation.Show", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.Organisation.Show, (c, v) => c.Config.Organisation.Show = v, "Show Organisation Details", "Can show the organisation details", false) },
{ "Config.JobPreferences.Configure", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.JobPreferences.Configure, (c, v) => c.Config.JobPreferences.Configure = v, "Configure Job Preferences", "Can configure job preferences", false) },
{ "Config.JobPreferences.Show", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.JobPreferences.Show, (c, v) => c.Config.JobPreferences.Show = v, "Show Job Preferences", "Can show job preferences", false) },
{ "Config.JobQueue.Configure", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.JobQueue.Configure, (c, v) => c.Config.JobQueue.Configure = v, "Configure Job Queues", "Can configure job queues", false) },
{ "Config.JobQueue.Create", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.JobQueue.Create, (c, v) => c.Config.JobQueue.Create = v, "Create Job Queues", "Can create job queues", false) },
{ "Config.JobQueue.Delete", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.JobQueue.Delete, (c, v) => c.Config.JobQueue.Delete = v, "Delete Job Queues", "Can delete job queues", false) },
{ "Config.JobQueue.Show", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.JobQueue.Show, (c, v) => c.Config.JobQueue.Show = v, "Show Job Queues", "Can show job queues", false) },
{ "Config.Show", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Config.Show, (c, v) => c.Config.Show = v, "Show Configuration", "Can show the configuration menu", false) },
{ "Job.Lists.AllOpen", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Lists.AllOpen, (c, v) => c.Job.Lists.AllOpen = v, "All Open List", "Can show list", false) },
{ "Job.Lists.AwaitingFinanceAgreementBreach", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Lists.AwaitingFinanceAgreementBreach, (c, v) => c.Job.Lists.AwaitingFinanceAgreementBreach = v, "Awaiting Finance Agreement Breach List", "Can show list (NOTE: Requires Awaiting Finance List)", false) },
@@ -79,11 +83,16 @@ namespace Disco.Services.Authorization
{ "Job.Lists.AwaitingUserAction", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Lists.AwaitingUserAction, (c, v) => c.Job.Lists.AwaitingUserAction = v, "Awaiting User Action List", "Can show list", false) },
{ "Job.Lists.DevicesAwaitingRepair", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Lists.DevicesAwaitingRepair, (c, v) => c.Job.Lists.DevicesAwaitingRepair = v, "Devices Awaiting Repair List", "Can show list", false) },
{ "Job.Lists.DevicesReadyForReturn", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Lists.DevicesReadyForReturn, (c, v) => c.Job.Lists.DevicesReadyForReturn = v, "Devices Ready For Return List", "Can show list", false) },
{ "Job.Lists.JobQueueLists", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Lists.JobQueueLists, (c, v) => c.Job.Lists.JobQueueLists = v, "Job Queue Lists", "Can show job queue lists", false) },
{ "Job.Lists.Locations", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Lists.Locations, (c, v) => c.Job.Lists.Locations = v, "Locations List", "Can show list", false) },
{ "Job.Lists.LongRunningJobs", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Lists.LongRunningJobs, (c, v) => c.Job.Lists.LongRunningJobs = v, "Long Running Jobs List", "Can show list", false) },
{ "Job.Lists.MyJobs", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Lists.MyJobs, (c, v) => c.Job.Lists.MyJobs = v, "My Jobs List", "Can show list", false) },
{ "Job.Lists.MyJobsOrphaned", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Lists.MyJobsOrphaned, (c, v) => c.Job.Lists.MyJobsOrphaned = v, "My Jobs List (Includes No Queue)", "Can show list", false) },
{ "Job.Lists.RecentlyClosed", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Lists.RecentlyClosed, (c, v) => c.Job.Lists.RecentlyClosed = v, "Recently Closed List", "Can show list", false) },
{ "Job.Actions.AddAttachments", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.AddAttachments, (c, v) => c.Job.Actions.AddAttachments = v, "Add Attachments", "Can add attachments to jobs", false) },
{ "Job.Actions.AddLogs", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.AddLogs, (c, v) => c.Job.Actions.AddLogs = v, "Add Logs", "Can add job logs", false) },
{ "Job.Actions.AddAnyQueues", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.AddAnyQueues, (c, v) => c.Job.Actions.AddAnyQueues = v, "Add to Any Queues", "Can add to any job queues", false) },
{ "Job.Actions.AddOwnQueues", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.AddOwnQueues, (c, v) => c.Job.Actions.AddOwnQueues = v, "Add to Own Queues", "Can add to own job queues", false) },
{ "Job.Actions.Close", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.Close, (c, v) => c.Job.Actions.Close = v, "Close Jobs", "Can close jobs", false) },
{ "Job.Actions.ConvertHWarToHNWar", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.ConvertHWarToHNWar, (c, v) => c.Job.Actions.ConvertHWarToHNWar = v, "Convert HWar Jobs To HNWar", "Can convert warranty jobs to non-warranty jobs", false) },
{ "Job.Actions.Create", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.Create, (c, v) => c.Job.Actions.Create = v, "Create Jobs", "Can create jobs", false) },
@@ -94,6 +103,8 @@ namespace Disco.Services.Authorization
{ "Job.Actions.LogWarranty", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.LogWarranty, (c, v) => c.Job.Actions.LogWarranty = v, "Log Warranty", "Can log warranty for jobs", false) },
{ "Job.Actions.RemoveAnyAttachments", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.RemoveAnyAttachments, (c, v) => c.Job.Actions.RemoveAnyAttachments = v, "Remove Any Attachments", "Can remove any attachments from jobs", false) },
{ "Job.Actions.RemoveAnyLogs", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.RemoveAnyLogs, (c, v) => c.Job.Actions.RemoveAnyLogs = v, "Remove Any Logs", "Can remove any job logs", false) },
{ "Job.Actions.RemoveAnyQueues", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.RemoveAnyQueues, (c, v) => c.Job.Actions.RemoveAnyQueues = v, "Remove from Any Queues", "Can remove from any job queues", false) },
{ "Job.Actions.RemoveOwnQueues", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.RemoveOwnQueues, (c, v) => c.Job.Actions.RemoveOwnQueues = v, "Remove from Own Queues", "Can remove from own job queues", false) },
{ "Job.Actions.RemoveOwnAttachments", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.RemoveOwnAttachments, (c, v) => c.Job.Actions.RemoveOwnAttachments = v, "Remove Own Attachments", "Can remove own attachments from jobs", false) },
{ "Job.Actions.RemoveOwnLogs", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.RemoveOwnLogs, (c, v) => c.Job.Actions.RemoveOwnLogs = v, "Remove Own Logs", "Can remove own job logs", false) },
{ "Job.Actions.Reopen", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Actions.Reopen, (c, v) => c.Job.Actions.Reopen = v, "Reopen Jobs", "Can reopen jobs", false) },
@@ -120,6 +131,12 @@ namespace Disco.Services.Authorization
{ "Job.Properties.NonWarrantyProperties.RepairerLoggedDate", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.RepairerLoggedDate, (c, v) => c.Job.Properties.NonWarrantyProperties.RepairerLoggedDate = v, "Repairer Logged Date Property", "Can update property", false) },
{ "Job.Properties.NonWarrantyProperties.RepairerName", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.RepairerName, (c, v) => c.Job.Properties.NonWarrantyProperties.RepairerName = v, "Repairer Name Property", "Can update property", false) },
{ "Job.Properties.NonWarrantyProperties.RepairerReference", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.NonWarrantyProperties.RepairerReference, (c, v) => c.Job.Properties.NonWarrantyProperties.RepairerReference = v, "Repairer Reference Property", "Can update property", false) },
{ "Job.Properties.JobQueueProperties.EditAnyComments", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.JobQueueProperties.EditAnyComments, (c, v) => c.Job.Properties.JobQueueProperties.EditAnyComments = v, "Edit Any Comments", "Can edit any job queue comments", false) },
{ "Job.Properties.JobQueueProperties.EditAnyPriority", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.JobQueueProperties.EditAnyPriority, (c, v) => c.Job.Properties.JobQueueProperties.EditAnyPriority = v, "Edit Any Priority", "Can edit any job queue Priority", false) },
{ "Job.Properties.JobQueueProperties.EditAnySLA", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.JobQueueProperties.EditAnySLA, (c, v) => c.Job.Properties.JobQueueProperties.EditAnySLA = v, "Edit Any SLA", "Can edit any job queue SLA", false) },
{ "Job.Properties.JobQueueProperties.EditOwnComments", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.JobQueueProperties.EditOwnComments, (c, v) => c.Job.Properties.JobQueueProperties.EditOwnComments = v, "Edit Own Comments", "Can edit own job queue comments", false) },
{ "Job.Properties.JobQueueProperties.EditOwnPriority", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.JobQueueProperties.EditOwnPriority, (c, v) => c.Job.Properties.JobQueueProperties.EditOwnPriority = v, "Edit Own Priority", "Can edit own job queue Priority", false) },
{ "Job.Properties.JobQueueProperties.EditOwnSLA", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.JobQueueProperties.EditOwnSLA, (c, v) => c.Job.Properties.JobQueueProperties.EditOwnSLA = v, "Edit Own SLA", "Can edit own job queue SLA", false) },
{ "Job.Properties.DeviceHeldLocation", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.DeviceHeldLocation, (c, v) => c.Job.Properties.DeviceHeldLocation = v, "Device Held Location Property", "Can update property", false) },
{ "Job.Properties.DeviceHeld", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.DeviceHeld, (c, v) => c.Job.Properties.DeviceHeld = v, "Device Held Property", "Can update property", false) },
{ "Job.Properties.DeviceReadyForReturn", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Properties.DeviceReadyForReturn, (c, v) => c.Job.Properties.DeviceReadyForReturn = v, "Device Ready For Return Property", "Can update property", false) },
@@ -140,6 +157,7 @@ namespace Disco.Services.Authorization
{ "Job.ShowDailyChart", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.ShowDailyChart, (c, v) => c.Job.ShowDailyChart = v, "Show Daily Opened & Closed", "Can show daily opened & closed chart", false) },
{ "Job.ShowFlags", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.ShowFlags, (c, v) => c.Job.ShowFlags = v, "Show Flags", "Can show job flags", false) },
{ "Job.Show", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.Show, (c, v) => c.Job.Show = v, "Show Jobs", "Can show jobs", false) },
{ "Job.ShowJobsQueues", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.ShowJobsQueues, (c, v) => c.Job.ShowJobsQueues = v, "Show Jobs Queues", "Can show jobs queues", false) },
{ "Job.ShowLogs", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.ShowLogs, (c, v) => c.Job.ShowLogs = v, "Show Logs", "Can show job logs", false) },
{ "Job.ShowNonWarrantyComponents", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.ShowNonWarrantyComponents, (c, v) => c.Job.ShowNonWarrantyComponents = v, "Show Non-Warranty Components", "Can show non-warranty job components", false) },
{ "Job.ShowNonWarrantyFinance", new Tuple<Func<RoleClaims, bool>, Action<RoleClaims, bool>, string, string, bool>(c => c.Job.ShowNonWarrantyFinance, (c, v) => c.Job.ShowNonWarrantyFinance = v, "Show Non-Warranty Finance", "Can show non-warranty job finance", false) },
@@ -189,29 +207,23 @@ namespace Disco.Services.Authorization
_claimNavigator =
new ClaimNavigatorItem("Claims", "Permissions", "Top-level node for all permissions", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config", "Configuration", "Permissions related to Disco Configuration", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.DeviceCertificate", "Device Certificate", "Permissions related to Device Certificates", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.DeviceCertificate.DownloadCertificates", false)
}),
new ClaimNavigatorItem("Config.Enrolment", "Enrolment", "Permissions related to Device Enrolment", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.Enrolment.Configure", false),
new ClaimNavigatorItem("Config.Enrolment.DownloadBootstrapper", false),
new ClaimNavigatorItem("Config.Enrolment.Show", false),
new ClaimNavigatorItem("Config.Enrolment.ShowStatus", false)
}),
new ClaimNavigatorItem("Config.DeviceBatch", "Device Batch", "Permissions related to Device Batches", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.DeviceBatch", "Device Batches", "Permissions related to Device Batches", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.DeviceBatch.Configure", false),
new ClaimNavigatorItem("Config.DeviceBatch.Create", false),
new ClaimNavigatorItem("Config.DeviceBatch.Delete", false),
new ClaimNavigatorItem("Config.DeviceBatch.Show", false),
new ClaimNavigatorItem("Config.DeviceBatch.ShowTimeline", false)
}),
new ClaimNavigatorItem("Config.DeviceModel", "Device Model", "Permissions related to Device Models", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.DeviceCertificate", "Device Certificates", "Permissions related to Device Certificates", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.DeviceCertificate.DownloadCertificates", false)
}),
new ClaimNavigatorItem("Config.DeviceModel", "Device Models", "Permissions related to Device Models", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.DeviceModel.ConfigureComponents", false),
new ClaimNavigatorItem("Config.DeviceModel.Configure", false),
new ClaimNavigatorItem("Config.DeviceModel.Delete", false),
new ClaimNavigatorItem("Config.DeviceModel.Show", false)
}),
new ClaimNavigatorItem("Config.DeviceProfile", "Device Profile", "Permissions related to Device Profiles", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.DeviceProfile", "Device Profiles", "Permissions related to Device Profiles", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.DeviceProfile.ConfigureComputerNameTemplate", false),
new ClaimNavigatorItem("Config.DeviceProfile.ConfigureDefaults", false),
new ClaimNavigatorItem("Config.DeviceProfile.Configure", false),
@@ -219,7 +231,7 @@ namespace Disco.Services.Authorization
new ClaimNavigatorItem("Config.DeviceProfile.Delete", false),
new ClaimNavigatorItem("Config.DeviceProfile.Show", false)
}),
new ClaimNavigatorItem("Config.DocumentTemplate", "Document Template", "Permissions related to Document Templates", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.DocumentTemplate", "Document Templates", "Permissions related to Document Templates", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.DocumentTemplate.BulkGenerate", false),
new ClaimNavigatorItem("Config.DocumentTemplate.Configure", false),
new ClaimNavigatorItem("Config.DocumentTemplate.ConfigureFilterExpression", false),
@@ -230,20 +242,25 @@ namespace Disco.Services.Authorization
new ClaimNavigatorItem("Config.DocumentTemplate.UndetectedPages", false),
new ClaimNavigatorItem("Config.DocumentTemplate.Upload", false)
}),
new ClaimNavigatorItem("Config.Enrolment", "Enrolment", "Permissions related to Device Enrolment", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.Enrolment.Configure", false),
new ClaimNavigatorItem("Config.Enrolment.DownloadBootstrapper", false),
new ClaimNavigatorItem("Config.Enrolment.Show", false),
new ClaimNavigatorItem("Config.Enrolment.ShowStatus", false)
}),
new ClaimNavigatorItem("Config.JobPreferences", "Job Preferences", "Permissions related to Job Preferences", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.JobPreferences.Configure", false),
new ClaimNavigatorItem("Config.JobPreferences.Show", false)
}),
new ClaimNavigatorItem("Config.JobQueue", "Job Queues", "Permissions related to Job Queues", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.JobQueue.Configure", false),
new ClaimNavigatorItem("Config.JobQueue.Create", false),
new ClaimNavigatorItem("Config.JobQueue.Delete", false),
new ClaimNavigatorItem("Config.JobQueue.Show", false)
}),
new ClaimNavigatorItem("Config.Logging", "Logging", "Permissions related to Logging", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.Logging.Show", false)
}),
new ClaimNavigatorItem("Config.Plugin", "Plugin", "Permissions related to Plugins", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.Plugin.Configure", false),
new ClaimNavigatorItem("Config.Plugin.InstallLocal", false),
new ClaimNavigatorItem("Config.Plugin.Install", false),
new ClaimNavigatorItem("Config.Plugin.Show", false),
new ClaimNavigatorItem("Config.Plugin.Uninstall", false)
}),
new ClaimNavigatorItem("Config.System", "System", "Permissions related to System Configuration", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.System.ConfigureProxy", false),
new ClaimNavigatorItem("Config.System.Show", false)
}),
new ClaimNavigatorItem("Config.Organisation", "Organisation Details", "Permissions related to the Organisation Details", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.Organisation.ConfigureAddresses", false),
new ClaimNavigatorItem("Config.Organisation.ConfigureLogo", false),
@@ -251,31 +268,25 @@ namespace Disco.Services.Authorization
new ClaimNavigatorItem("Config.Organisation.ConfigureName", false),
new ClaimNavigatorItem("Config.Organisation.Show", false)
}),
new ClaimNavigatorItem("Config.JobPreferences", "Job Preferences", "Permissions related to Job Preferences", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.JobPreferences.Configure", false),
new ClaimNavigatorItem("Config.JobPreferences.Show", false)
new ClaimNavigatorItem("Config.Plugin", "Plugin", "Permissions related to Plugins", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.Plugin.Configure", false),
new ClaimNavigatorItem("Config.Plugin.InstallLocal", false),
new ClaimNavigatorItem("Config.Plugin.Install", false),
new ClaimNavigatorItem("Config.Plugin.Show", false),
new ClaimNavigatorItem("Config.Plugin.Uninstall", false)
}),
new ClaimNavigatorItem("Config.Show", false)
new ClaimNavigatorItem("Config.Show", false),
new ClaimNavigatorItem("Config.System", "System", "Permissions related to System Configuration", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Config.System.ConfigureProxy", false),
new ClaimNavigatorItem("Config.System.Show", false)
})
}),
new ClaimNavigatorItem("Job", "Job", "Permissions related to Jobs", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Job.Lists", "Lists", "Permissions related to Job Lists", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Job.Lists.AllOpen", false),
new ClaimNavigatorItem("Job.Lists.AwaitingFinanceAgreementBreach", false),
new ClaimNavigatorItem("Job.Lists.AwaitingFinanceCharge", false),
new ClaimNavigatorItem("Job.Lists.AwaitingFinanceInsuranceProcessing", false),
new ClaimNavigatorItem("Job.Lists.AwaitingFinance", false),
new ClaimNavigatorItem("Job.Lists.AwaitingFinancePayment", false),
new ClaimNavigatorItem("Job.Lists.AwaitingTechnicianAction", false),
new ClaimNavigatorItem("Job.Lists.AwaitingUserAction", false),
new ClaimNavigatorItem("Job.Lists.DevicesAwaitingRepair", false),
new ClaimNavigatorItem("Job.Lists.DevicesReadyForReturn", false),
new ClaimNavigatorItem("Job.Lists.Locations", false),
new ClaimNavigatorItem("Job.Lists.LongRunningJobs", false),
new ClaimNavigatorItem("Job.Lists.RecentlyClosed", false)
}),
new ClaimNavigatorItem("Job.Actions", "Actions", "Permissions related to Job Actions", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Job.Actions.AddAttachments", false),
new ClaimNavigatorItem("Job.Actions.AddLogs", false),
new ClaimNavigatorItem("Job.Actions.AddAnyQueues", false),
new ClaimNavigatorItem("Job.Actions.AddOwnQueues", false),
new ClaimNavigatorItem("Job.Actions.Close", false),
new ClaimNavigatorItem("Job.Actions.ConvertHWarToHNWar", false),
new ClaimNavigatorItem("Job.Actions.Create", false),
@@ -286,19 +297,27 @@ namespace Disco.Services.Authorization
new ClaimNavigatorItem("Job.Actions.LogWarranty", false),
new ClaimNavigatorItem("Job.Actions.RemoveAnyAttachments", false),
new ClaimNavigatorItem("Job.Actions.RemoveAnyLogs", false),
new ClaimNavigatorItem("Job.Actions.RemoveAnyQueues", false),
new ClaimNavigatorItem("Job.Actions.RemoveOwnQueues", false),
new ClaimNavigatorItem("Job.Actions.RemoveOwnAttachments", false),
new ClaimNavigatorItem("Job.Actions.RemoveOwnLogs", false),
new ClaimNavigatorItem("Job.Actions.Reopen", false),
new ClaimNavigatorItem("Job.Actions.UpdateSubTypes", false)
}),
new ClaimNavigatorItem("Job.Properties", "Job Properties", "Permissions related to Job Properties", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Job.Properties.WarrantyProperties", "Warranty Properties", "Permissions related to Warranty Job Properties", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Job.Properties.WarrantyProperties.ExternalCompletedDate", false),
new ClaimNavigatorItem("Job.Properties.WarrantyProperties.ExternalLoggedDate", false),
new ClaimNavigatorItem("Job.Properties.WarrantyProperties.ExternalName", false),
new ClaimNavigatorItem("Job.Properties.WarrantyProperties.ExternalReference", false),
new ClaimNavigatorItem("Job.Properties.WarrantyProperties.ProviderDetails", false),
new ClaimNavigatorItem("Job.Properties.WarrantyProperties.WarrantyCompleted", false)
new ClaimNavigatorItem("Job.Properties.DeviceHeldLocation", false),
new ClaimNavigatorItem("Job.Properties.DeviceHeld", false),
new ClaimNavigatorItem("Job.Properties.DeviceReadyForReturn", false),
new ClaimNavigatorItem("Job.Properties.DeviceReturned", false),
new ClaimNavigatorItem("Job.Properties.ExpectedClosedDate", false),
new ClaimNavigatorItem("Job.Properties.Flags", false),
new ClaimNavigatorItem("Job.Properties.JobQueueProperties", "Job Queue Properties", "Permissions related to Job Queue Job Properties", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Job.Properties.JobQueueProperties.EditAnyComments", false),
new ClaimNavigatorItem("Job.Properties.JobQueueProperties.EditAnyPriority", false),
new ClaimNavigatorItem("Job.Properties.JobQueueProperties.EditAnySLA", false),
new ClaimNavigatorItem("Job.Properties.JobQueueProperties.EditOwnComments", false),
new ClaimNavigatorItem("Job.Properties.JobQueueProperties.EditOwnPriority", false),
new ClaimNavigatorItem("Job.Properties.JobQueueProperties.EditOwnSLA", false)
}),
new ClaimNavigatorItem("Job.Properties.NonWarrantyProperties", "Non Warranty Properties", "Permissions related to Non-Warranty Job Properties", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Job.Properties.NonWarrantyProperties.AccountingChargeAdded", false),
@@ -318,15 +337,47 @@ namespace Disco.Services.Authorization
new ClaimNavigatorItem("Job.Properties.NonWarrantyProperties.RepairerName", false),
new ClaimNavigatorItem("Job.Properties.NonWarrantyProperties.RepairerReference", false)
}),
new ClaimNavigatorItem("Job.Properties.DeviceHeldLocation", false),
new ClaimNavigatorItem("Job.Properties.DeviceHeld", false),
new ClaimNavigatorItem("Job.Properties.DeviceReadyForReturn", false),
new ClaimNavigatorItem("Job.Properties.DeviceReturned", false),
new ClaimNavigatorItem("Job.Properties.ExpectedClosedDate", false),
new ClaimNavigatorItem("Job.Properties.Flags", false),
new ClaimNavigatorItem("Job.Properties.NotWaitingForUserAction", false),
new ClaimNavigatorItem("Job.Properties.WaitingForUserAction", false)
new ClaimNavigatorItem("Job.Properties.WaitingForUserAction", false),
new ClaimNavigatorItem("Job.Properties.WarrantyProperties", "Warranty Properties", "Permissions related to Warranty Job Properties", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Job.Properties.WarrantyProperties.ExternalCompletedDate", false),
new ClaimNavigatorItem("Job.Properties.WarrantyProperties.ExternalLoggedDate", false),
new ClaimNavigatorItem("Job.Properties.WarrantyProperties.ExternalName", false),
new ClaimNavigatorItem("Job.Properties.WarrantyProperties.ExternalReference", false),
new ClaimNavigatorItem("Job.Properties.WarrantyProperties.ProviderDetails", false),
new ClaimNavigatorItem("Job.Properties.WarrantyProperties.WarrantyCompleted", false)
})
}),
new ClaimNavigatorItem("Job.Lists", "Lists", "Permissions related to Job Lists", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Job.Lists.AllOpen", false),
new ClaimNavigatorItem("Job.Lists.AwaitingFinanceAgreementBreach", false),
new ClaimNavigatorItem("Job.Lists.AwaitingFinanceCharge", false),
new ClaimNavigatorItem("Job.Lists.AwaitingFinanceInsuranceProcessing", false),
new ClaimNavigatorItem("Job.Lists.AwaitingFinance", false),
new ClaimNavigatorItem("Job.Lists.AwaitingFinancePayment", false),
new ClaimNavigatorItem("Job.Lists.AwaitingTechnicianAction", false),
new ClaimNavigatorItem("Job.Lists.AwaitingUserAction", false),
new ClaimNavigatorItem("Job.Lists.DevicesAwaitingRepair", false),
new ClaimNavigatorItem("Job.Lists.DevicesReadyForReturn", false),
new ClaimNavigatorItem("Job.Lists.JobQueueLists", false),
new ClaimNavigatorItem("Job.Lists.Locations", false),
new ClaimNavigatorItem("Job.Lists.LongRunningJobs", false),
new ClaimNavigatorItem("Job.Lists.MyJobs", false),
new ClaimNavigatorItem("Job.Lists.MyJobsOrphaned", false),
new ClaimNavigatorItem("Job.Lists.RecentlyClosed", false)
}),
new ClaimNavigatorItem("Job.Search", false),
new ClaimNavigatorItem("Job.ShowAttachments", false),
new ClaimNavigatorItem("Job.ShowDailyChart", false),
new ClaimNavigatorItem("Job.ShowFlags", false),
new ClaimNavigatorItem("Job.Show", false),
new ClaimNavigatorItem("Job.ShowJobsQueues", false),
new ClaimNavigatorItem("Job.ShowLogs", false),
new ClaimNavigatorItem("Job.ShowNonWarrantyComponents", false),
new ClaimNavigatorItem("Job.ShowNonWarrantyFinance", false),
new ClaimNavigatorItem("Job.ShowNonWarrantyInsurance", false),
new ClaimNavigatorItem("Job.ShowNonWarrantyRepairs", false),
new ClaimNavigatorItem("Job.ShowWarranty", false),
new ClaimNavigatorItem("Job.Types", "Types", "Permissions related to Job Types", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Job.Types.ShowHMisc", false),
new ClaimNavigatorItem("Job.Types.ShowHNWar", false),
@@ -335,27 +386,9 @@ namespace Disco.Services.Authorization
new ClaimNavigatorItem("Job.Types.ShowSOS", false),
new ClaimNavigatorItem("Job.Types.ShowSImg", false),
new ClaimNavigatorItem("Job.Types.ShowUMgmt", false)
}),
new ClaimNavigatorItem("Job.Search", false),
new ClaimNavigatorItem("Job.ShowAttachments", false),
new ClaimNavigatorItem("Job.ShowDailyChart", false),
new ClaimNavigatorItem("Job.ShowFlags", false),
new ClaimNavigatorItem("Job.Show", false),
new ClaimNavigatorItem("Job.ShowLogs", false),
new ClaimNavigatorItem("Job.ShowNonWarrantyComponents", false),
new ClaimNavigatorItem("Job.ShowNonWarrantyFinance", false),
new ClaimNavigatorItem("Job.ShowNonWarrantyInsurance", false),
new ClaimNavigatorItem("Job.ShowNonWarrantyRepairs", false),
new ClaimNavigatorItem("Job.ShowWarranty", false)
})
}),
new ClaimNavigatorItem("Device", "Device", "Permissions related to Devices", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Device.Properties", "Device Properties", "Permissions related to Device Properties", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Device.Properties.AssetNumber", false),
new ClaimNavigatorItem("Device.Properties.Details", false),
new ClaimNavigatorItem("Device.Properties.DeviceBatch", false),
new ClaimNavigatorItem("Device.Properties.DeviceProfile", false),
new ClaimNavigatorItem("Device.Properties.Location", false)
}),
new ClaimNavigatorItem("Device.Actions", "Actions", "Permissions related to Device Actions", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Device.Actions.AddAttachments", false),
new ClaimNavigatorItem("Device.Actions.AllowUnauthenticatedEnrol", false),
@@ -370,6 +403,13 @@ namespace Disco.Services.Authorization
new ClaimNavigatorItem("Device.Actions.RemoveAnyAttachments", false),
new ClaimNavigatorItem("Device.Actions.RemoveOwnAttachments", false)
}),
new ClaimNavigatorItem("Device.Properties", "Device Properties", "Permissions related to Device Properties", false, new List<IClaimNavigatorItem>() {
new ClaimNavigatorItem("Device.Properties.AssetNumber", false),
new ClaimNavigatorItem("Device.Properties.Details", false),
new ClaimNavigatorItem("Device.Properties.DeviceBatch", false),
new ClaimNavigatorItem("Device.Properties.DeviceProfile", false),
new ClaimNavigatorItem("Device.Properties.Location", false)
}),
new ClaimNavigatorItem("Device.Search", false),
new ClaimNavigatorItem("Device.ShowAssignmentHistory", false),
new ClaimNavigatorItem("Device.ShowAttachments", false),
@@ -500,6 +540,10 @@ namespace Disco.Services.Authorization
c.Config.Organisation.Show = true;
c.Config.JobPreferences.Configure = true;
c.Config.JobPreferences.Show = true;
c.Config.JobQueue.Configure = true;
c.Config.JobQueue.Create = true;
c.Config.JobQueue.Delete = true;
c.Config.JobQueue.Show = true;
c.Config.Show = true;
c.Job.Lists.AllOpen = true;
c.Job.Lists.AwaitingFinanceAgreementBreach = true;
@@ -511,11 +555,16 @@ namespace Disco.Services.Authorization
c.Job.Lists.AwaitingUserAction = true;
c.Job.Lists.DevicesAwaitingRepair = true;
c.Job.Lists.DevicesReadyForReturn = true;
c.Job.Lists.JobQueueLists = true;
c.Job.Lists.Locations = true;
c.Job.Lists.LongRunningJobs = true;
c.Job.Lists.MyJobs = true;
c.Job.Lists.MyJobsOrphaned = true;
c.Job.Lists.RecentlyClosed = true;
c.Job.Actions.AddAttachments = true;
c.Job.Actions.AddLogs = true;
c.Job.Actions.AddAnyQueues = true;
c.Job.Actions.AddOwnQueues = true;
c.Job.Actions.Close = true;
c.Job.Actions.ConvertHWarToHNWar = true;
c.Job.Actions.Create = true;
@@ -526,6 +575,8 @@ namespace Disco.Services.Authorization
c.Job.Actions.LogWarranty = true;
c.Job.Actions.RemoveAnyAttachments = true;
c.Job.Actions.RemoveAnyLogs = true;
c.Job.Actions.RemoveAnyQueues = true;
c.Job.Actions.RemoveOwnQueues = true;
c.Job.Actions.RemoveOwnAttachments = true;
c.Job.Actions.RemoveOwnLogs = true;
c.Job.Actions.Reopen = true;
@@ -552,6 +603,12 @@ namespace Disco.Services.Authorization
c.Job.Properties.NonWarrantyProperties.RepairerLoggedDate = true;
c.Job.Properties.NonWarrantyProperties.RepairerName = true;
c.Job.Properties.NonWarrantyProperties.RepairerReference = true;
c.Job.Properties.JobQueueProperties.EditAnyComments = true;
c.Job.Properties.JobQueueProperties.EditAnyPriority = true;
c.Job.Properties.JobQueueProperties.EditAnySLA = true;
c.Job.Properties.JobQueueProperties.EditOwnComments = true;
c.Job.Properties.JobQueueProperties.EditOwnPriority = true;
c.Job.Properties.JobQueueProperties.EditOwnSLA = true;
c.Job.Properties.DeviceHeldLocation = true;
c.Job.Properties.DeviceHeld = true;
c.Job.Properties.DeviceReadyForReturn = true;
@@ -572,6 +629,7 @@ namespace Disco.Services.Authorization
c.Job.ShowDailyChart = true;
c.Job.ShowFlags = true;
c.Job.Show = true;
c.Job.ShowJobsQueues = true;
c.Job.ShowLogs = true;
c.Job.ShowNonWarrantyComponents = true;
c.Job.ShowNonWarrantyFinance = true;
@@ -631,7 +689,7 @@ namespace Disco.Services.Authorization
public static class Config
{
/// <summary>Device Certificate
/// <summary>Device Certificates
/// <para>Permissions related to Device Certificates</para>
/// </summary>
public static class DeviceCertificate
@@ -670,7 +728,7 @@ namespace Disco.Services.Authorization
public const string ShowStatus = "Config.Enrolment.ShowStatus";
}
/// <summary>Device Batch
/// <summary>Device Batches
/// <para>Permissions related to Device Batches</para>
/// </summary>
public static class DeviceBatch
@@ -702,7 +760,7 @@ namespace Disco.Services.Authorization
public const string ShowTimeline = "Config.DeviceBatch.ShowTimeline";
}
/// <summary>Device Model
/// <summary>Device Models
/// <para>Permissions related to Device Models</para>
/// </summary>
public static class DeviceModel
@@ -729,7 +787,7 @@ namespace Disco.Services.Authorization
public const string Show = "Config.DeviceModel.Show";
}
/// <summary>Device Profile
/// <summary>Device Profiles
/// <para>Permissions related to Device Profiles</para>
/// </summary>
public static class DeviceProfile
@@ -766,7 +824,7 @@ namespace Disco.Services.Authorization
public const string Show = "Config.DeviceProfile.Show";
}
/// <summary>Document Template
/// <summary>Document Templates
/// <para>Permissions related to Document Templates</para>
/// </summary>
public static class DocumentTemplate
@@ -928,6 +986,33 @@ namespace Disco.Services.Authorization
public const string Show = "Config.JobPreferences.Show";
}
/// <summary>Job Queues
/// <para>Permissions related to Job Queues</para>
/// </summary>
public static class JobQueue
{
/// <summary>Configure Job Queues
/// <para>Can configure job queues</para>
/// </summary>
public const string Configure = "Config.JobQueue.Configure";
/// <summary>Create Job Queues
/// <para>Can create job queues</para>
/// </summary>
public const string Create = "Config.JobQueue.Create";
/// <summary>Delete Job Queues
/// <para>Can delete job queues</para>
/// </summary>
public const string Delete = "Config.JobQueue.Delete";
/// <summary>Show Job Queues
/// <para>Can show job queues</para>
/// </summary>
public const string Show = "Config.JobQueue.Show";
}
/// <summary>Show Configuration
/// <para>Can show the configuration menu</para>
/// </summary>
@@ -996,6 +1081,11 @@ namespace Disco.Services.Authorization
/// </summary>
public const string DevicesReadyForReturn = "Job.Lists.DevicesReadyForReturn";
/// <summary>Job Queue Lists
/// <para>Can show job queue lists</para>
/// </summary>
public const string JobQueueLists = "Job.Lists.JobQueueLists";
/// <summary>Locations List
/// <para>Can show list</para>
/// </summary>
@@ -1006,6 +1096,16 @@ namespace Disco.Services.Authorization
/// </summary>
public const string LongRunningJobs = "Job.Lists.LongRunningJobs";
/// <summary>My Jobs List
/// <para>Can show list</para>
/// </summary>
public const string MyJobs = "Job.Lists.MyJobs";
/// <summary>My Jobs List (Includes No Queue)
/// <para>Can show list</para>
/// </summary>
public const string MyJobsOrphaned = "Job.Lists.MyJobsOrphaned";
/// <summary>Recently Closed List
/// <para>Can show list</para>
/// </summary>
@@ -1028,6 +1128,16 @@ namespace Disco.Services.Authorization
/// </summary>
public const string AddLogs = "Job.Actions.AddLogs";
/// <summary>Add to Any Queues
/// <para>Can add to any job queues</para>
/// </summary>
public const string AddAnyQueues = "Job.Actions.AddAnyQueues";
/// <summary>Add to Own Queues
/// <para>Can add to own job queues</para>
/// </summary>
public const string AddOwnQueues = "Job.Actions.AddOwnQueues";
/// <summary>Close Jobs
/// <para>Can close jobs</para>
/// </summary>
@@ -1078,6 +1188,16 @@ namespace Disco.Services.Authorization
/// </summary>
public const string RemoveAnyLogs = "Job.Actions.RemoveAnyLogs";
/// <summary>Remove from Any Queues
/// <para>Can remove from any job queues</para>
/// </summary>
public const string RemoveAnyQueues = "Job.Actions.RemoveAnyQueues";
/// <summary>Remove from Own Queues
/// <para>Can remove from own job queues</para>
/// </summary>
public const string RemoveOwnQueues = "Job.Actions.RemoveOwnQueues";
/// <summary>Remove Own Attachments
/// <para>Can remove own attachments from jobs</para>
/// </summary>
@@ -1229,6 +1349,43 @@ namespace Disco.Services.Authorization
public const string RepairerReference = "Job.Properties.NonWarrantyProperties.RepairerReference";
}
/// <summary>Job Queue Properties
/// <para>Permissions related to Job Queue Job Properties</para>
/// </summary>
public static class JobQueueProperties
{
/// <summary>Edit Any Comments
/// <para>Can edit any job queue comments</para>
/// </summary>
public const string EditAnyComments = "Job.Properties.JobQueueProperties.EditAnyComments";
/// <summary>Edit Any Priority
/// <para>Can edit any job queue Priority</para>
/// </summary>
public const string EditAnyPriority = "Job.Properties.JobQueueProperties.EditAnyPriority";
/// <summary>Edit Any SLA
/// <para>Can edit any job queue SLA</para>
/// </summary>
public const string EditAnySLA = "Job.Properties.JobQueueProperties.EditAnySLA";
/// <summary>Edit Own Comments
/// <para>Can edit own job queue comments</para>
/// </summary>
public const string EditOwnComments = "Job.Properties.JobQueueProperties.EditOwnComments";
/// <summary>Edit Own Priority
/// <para>Can edit own job queue Priority</para>
/// </summary>
public const string EditOwnPriority = "Job.Properties.JobQueueProperties.EditOwnPriority";
/// <summary>Edit Own SLA
/// <para>Can edit own job queue SLA</para>
/// </summary>
public const string EditOwnSLA = "Job.Properties.JobQueueProperties.EditOwnSLA";
}
/// <summary>Device Held Location Property
/// <para>Can update property</para>
/// </summary>
@@ -1337,6 +1494,11 @@ namespace Disco.Services.Authorization
/// </summary>
public const string Show = "Job.Show";
/// <summary>Show Jobs Queues
/// <para>Can show jobs queues</para>
/// </summary>
public const string ShowJobsQueues = "Job.ShowJobsQueues";
/// <summary>Show Logs
/// <para>Can show job logs</para>
/// </summary>
+5 -4
View File
@@ -53,7 +53,7 @@
// This file was generated by a T4 template.
// Don't change it directly as your change would get overwritten. Instead, make changes
// to the .tt file (i.e. the T4 template) and save it to regenerate this file.
using Disco.Models.Authorization;
using Disco.Models.Services.Authorization;
using Disco.Models.Repository;
using Disco.Services.Authorization.Roles;
using System;
@@ -213,10 +213,11 @@ void WriteNavigator_Recurse(Permission p, string Prefix){
var groupPrefix = string.Concat(key, ".");
WriteLine("new ClaimNavigatorItem(\"{0}{1}\", \"{2}\", \"{3}\", {4}, new List<IClaimNavigatorItem>() {{", Prefix, p.Name, p.FriendlyName, p.Description, p.Hidden ? "true" : "false");
PushIndent(" ");
for (int childIndex = 0; childIndex < p.Children.Count; childIndex++)
var children = p.Children.OrderBy(c => c.FriendlyName).ToList();
for (int childIndex = 0; childIndex < children.Count; childIndex++)
{
WriteNavigator_Recurse(p.Children[childIndex], groupPrefix);
if (childIndex < p.Children.Count -1)
WriteNavigator_Recurse(children[childIndex], groupPrefix);
if (childIndex < children.Count -1)
WriteLine(",");
else
WriteLine(string.Empty);
@@ -5,6 +5,7 @@ using Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DeviceProfile
using Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DocumentTemplate;
using Disco.Services.Authorization.Roles.ClaimGroups.Configuration.Enrolment;
using Disco.Services.Authorization.Roles.ClaimGroups.Configuration.JobPreferences;
using Disco.Services.Authorization.Roles.ClaimGroups.Configuration.JobQueue;
using Disco.Services.Authorization.Roles.ClaimGroups.Configuration.Logging;
using Disco.Services.Authorization.Roles.ClaimGroups.Configuration.Origanisation;
using Disco.Services.Authorization.Roles.ClaimGroups.Configuration.Plugin;
@@ -28,6 +29,7 @@ namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration
this.System = new SystemClaims();
this.Organisation = new OrganisationClaims();
this.JobPreferences = new JobPreferencesClaims();
this.JobQueue = new JobQueueClaims();
}
[ClaimDetails("Show Configuration", "Can show the configuration menu")]
@@ -54,5 +56,7 @@ namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration
public OrganisationClaims Organisation { get; set; }
public JobPreferencesClaims JobPreferences { get; set; }
public JobQueueClaims JobQueue { get; set; }
}
}
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DeviceBatch
{
[ClaimDetails("Device Batch", "Permissions related to Device Batches")]
[ClaimDetails("Device Batches", "Permissions related to Device Batches")]
public class DeviceBatchClaims : BaseRoleClaimGroup
{
[ClaimDetails("Configure Device Batches", "Can configure device batches")]
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DeviceCertificate
{
[ClaimDetails("Device Certificate", "Permissions related to Device Certificates")]
[ClaimDetails("Device Certificates", "Permissions related to Device Certificates")]
public class DeviceCertificateClaims : BaseRoleClaimGroup
{
[ClaimDetails("Download Certificates", "Can download certificates")]
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DeviceModel
{
[ClaimDetails("Device Model", "Permissions related to Device Models")]
[ClaimDetails("Device Models", "Permissions related to Device Models")]
public class DeviceModelClaims : BaseRoleClaimGroup
{
[ClaimDetails("Configure Device Models", "Can configure device models")]
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DeviceProfile
{
[ClaimDetails("Device Profile", "Permissions related to Device Profiles")]
[ClaimDetails("Device Profiles", "Permissions related to Device Profiles")]
public class DeviceProfileClaims : BaseRoleClaimGroup
{
[ClaimDetails("Configure Device Profiles", "Can configure device profiles")]
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.DocumentTemplate
{
[ClaimDetails("Document Template", "Permissions related to Document Templates")]
[ClaimDetails("Document Templates", "Permissions related to Document Templates")]
public class DocumentTemplateClaims : BaseRoleClaimGroup
{
[ClaimDetails("Configure Document Templates", "Can configure document templates")]
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Authorization.Roles.ClaimGroups.Configuration.JobQueue
{
[ClaimDetails("Job Queues", "Permissions related to Job Queues")]
public class JobQueueClaims : BaseRoleClaimGroup
{
[ClaimDetails("Configure Job Queues", "Can configure job queues")]
public bool Configure { get; set; }
[ClaimDetails("Create Job Queues", "Can create job queues")]
public bool Create { get; set; }
[ClaimDetails("Delete Job Queues", "Can delete job queues")]
public bool Delete { get; set; }
[ClaimDetails("Show Job Queues", "Can show job queues")]
public bool Show { get; set; }
}
}
@@ -20,6 +20,15 @@ namespace Disco.Services.Authorization.Roles.ClaimGroups.Job
[ClaimDetails("Delete Jobs", "Can delete jobs")]
public bool Delete { get; set; }
[ClaimDetails("Add to Own Queues", "Can add to own job queues")]
public bool AddOwnQueues { get; set; }
[ClaimDetails("Add to Any Queues", "Can add to any job queues")]
public bool AddAnyQueues { get; set; }
[ClaimDetails("Remove from Own Queues", "Can remove from own job queues")]
public bool RemoveOwnQueues { get; set; }
[ClaimDetails("Remove from Any Queues", "Can remove from any job queues")]
public bool RemoveAnyQueues { get; set; }
[ClaimDetails("Log Warranty", "Can log warranty for jobs")]
public bool LogWarranty { get; set; }
[ClaimDetails("Log Repair", "Can log repair for non-warranty jobs")]
@@ -31,6 +31,9 @@ namespace Disco.Services.Authorization.Roles.ClaimGroups.Job
[ClaimDetails("Show Attachments", "Can show job attachments")]
public bool ShowAttachments { get; set; }
[ClaimDetails("Show Jobs Queues", "Can show jobs queues")]
public bool ShowJobsQueues { get; set; }
[ClaimDetails("Show Non-Warranty Components", "Can show non-warranty job components")]
public bool ShowNonWarrantyComponents { get; set; }
[ClaimDetails("Show Non-Warranty Finance", "Can show non-warranty job finance")]
@@ -9,6 +9,14 @@ namespace Disco.Services.Authorization.Roles.ClaimGroups.Job
[ClaimDetails("Lists", "Permissions related to Job Lists")]
public class JobListsClaims : BaseRoleClaimGroup
{
[ClaimDetails("Job Queue Lists", "Can show job queue lists")]
public bool JobQueueLists { get; set; }
[ClaimDetails("My Jobs List", "Can show list")]
public bool MyJobs { get; set; }
[ClaimDetails("My Jobs List (Includes No Queue)", "Can show list")]
public bool MyJobsOrphaned { get; set; }
[ClaimDetails("Awaiting Technician Action List", "Can show list")]
public bool AwaitingTechnicianAction { get; set; }
[ClaimDetails("Long Running Jobs List", "Can show list")]
@@ -13,10 +13,12 @@ namespace Disco.Services.Authorization.Roles.ClaimGroups.Job
{
this.WarrantyProperties = new JobWarrantyPropertiesClaims();
this.NonWarrantyProperties = new JobNonWarrantyPropertiesClaims();
this.JobQueueProperties = new JobQueuePropertiesClaims();
}
public JobWarrantyPropertiesClaims WarrantyProperties { get; set; }
public JobNonWarrantyPropertiesClaims NonWarrantyProperties { get; set; }
public JobQueuePropertiesClaims JobQueueProperties { get; set; }
[ClaimDetails("Device Held Property", "Can update property")]
public bool DeviceHeld { get; set; }
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Authorization.Roles.ClaimGroups.Job
{
[ClaimDetails("Job Queue Properties", "Permissions related to Job Queue Job Properties")]
public class JobQueuePropertiesClaims : BaseRoleClaimGroup
{
[ClaimDetails("Edit Any Comments", "Can edit any job queue comments")]
public bool EditAnyComments { get; set; }
[ClaimDetails("Edit Own Comments", "Can edit own job queue comments")]
public bool EditOwnComments { get; set; }
[ClaimDetails("Edit Any SLA", "Can edit any job queue SLA")]
public bool EditAnySLA { get; set; }
[ClaimDetails("Edit Own SLA", "Can edit own job queue SLA")]
public bool EditOwnSLA { get; set; }
[ClaimDetails("Edit Any Priority", "Can edit any job queue Priority")]
public bool EditAnyPriority { get; set; }
[ClaimDetails("Edit Own Priority", "Can edit own job queue Priority")]
public bool EditOwnPriority { get; set; }
}
}
@@ -1,5 +1,5 @@
using Disco.Data.Repository;
using Disco.Models.Authorization;
using Disco.Models.Services.Authorization;
using Disco.Models.Repository;
using System;
using System.Collections.Concurrent;
@@ -1,4 +1,4 @@
using Disco.Models.Authorization;
using Disco.Models.Services.Authorization;
using Disco.Models.Repository;
using Newtonsoft.Json;
using System;
+24
View File
@@ -75,6 +75,21 @@
</Reference>
<Reference Include="System.DirectoryServices" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Reactive.Core, Version=2.1.30214.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Rx-Core.2.1.30214.0\lib\Net45\System.Reactive.Core.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Interfaces, Version=2.1.30214.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Rx-Interfaces.2.1.30214.0\lib\Net45\System.Reactive.Interfaces.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Linq, Version=2.1.30214.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Rx-Linq.2.1.30214.0\lib\Net45\System.Reactive.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.PlatformServices">
<HintPath>..\packages\Rx-PlatformServices.2.1.30214.0\lib\Net45\System.Reactive.PlatformServices.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
@@ -130,6 +145,7 @@
<Compile Include="Authorization\Roles\ClaimGroups\Configuration\DocumentTemplate\DocumentTemplateClaims.cs" />
<Compile Include="Authorization\Roles\ClaimGroups\Configuration\Enrolment\EnrolmentClaims.cs" />
<Compile Include="Authorization\Roles\ClaimGroups\Configuration\JobPreferences\JobPreferencesClaims.cs" />
<Compile Include="Authorization\Roles\ClaimGroups\Configuration\JobQueue\JobQueueClaims.cs" />
<Compile Include="Authorization\Roles\ClaimGroups\Configuration\Logging\LoggingClaims.cs" />
<Compile Include="Authorization\Roles\ClaimGroups\Configuration\Origanisation\OrganisationClaims.cs" />
<Compile Include="Authorization\Roles\ClaimGroups\Configuration\Plugin\PluginClaims.cs" />
@@ -142,6 +158,7 @@
<Compile Include="Authorization\Roles\ClaimGroups\Job\JobNonWarrantyPropertiesClaims.cs" />
<Compile Include="Authorization\Roles\ClaimGroups\Job\JobClaims.cs" />
<Compile Include="Authorization\Roles\ClaimGroups\Job\JobPropertiesClaims.cs" />
<Compile Include="Authorization\Roles\ClaimGroups\Job\JobQueuePropertiesClaims.cs" />
<Compile Include="Authorization\Roles\ClaimGroups\Job\JobTypesClaims.cs" />
<Compile Include="Authorization\Roles\ClaimGroups\Job\JobWarrantyPropertiesClaims.cs" />
<Compile Include="Authorization\Claims.cs">
@@ -156,6 +173,13 @@
<Compile Include="Authorization\Roles\RoleClaims.cs" />
<Compile Include="Authorization\Roles\RoleToken.cs" />
<Compile Include="Extensions\DateTimeExtensions.cs" />
<Compile Include="Jobs\JobExtensions.cs" />
<Compile Include="Jobs\JobLists\JobTableExtensions.cs" />
<Compile Include="Jobs\JobQueues\Cache.cs" />
<Compile Include="Jobs\JobQueues\JobQueueDeleteTask.cs" />
<Compile Include="Jobs\JobQueues\JobQueueService.cs" />
<Compile Include="Jobs\JobQueues\JobQueueToken.cs" />
<Compile Include="Jobs\JobLists\ManagedJobList.cs" />
<Compile Include="Logging\LogBase.cs" />
<Compile Include="Logging\LogContext.cs" />
<Compile Include="Logging\LogReInitalizeJob.cs" />
+195
View File
@@ -0,0 +1,195 @@
using Disco.Models.Repository;
using Disco.Models.Services.Jobs.JobLists;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services
{
public static class JobExtensions
{
public static JobTableStatusItemModel ToJobTableStatusItemModel(this Job j)
{
var i = new JobTableStatusItemModel()
{
Id = j.Id,
OpenedDate = j.OpenedDate,
ClosedDate = j.ClosedDate,
JobTypeId = j.JobTypeId,
JobTypeDescription = j.JobType.Description,
DeviceHeldLocation = j.DeviceHeldLocation,
Flags = j.Flags,
WaitingForUserAction = j.WaitingForUserAction,
DeviceReadyForReturn = j.DeviceReadyForReturn,
DeviceHeld = j.DeviceHeld,
DeviceReturnedDate = j.DeviceReturnedDate
};
if (j.Device != null)
{
i.DeviceSerialNumber = j.DeviceSerialNumber;
i.DeviceModelDescription = j.Device.DeviceModel.Description;
i.DeviceAddressId = j.Device.DeviceProfile.DefaultOrganisationAddress;
if (j.JobMetaWarranty != null)
{
i.JobMetaWarranty_ExternalReference = j.JobMetaWarranty.ExternalReference;
i.JobMetaWarranty_ExternalLoggedDate = j.JobMetaWarranty.ExternalLoggedDate;
i.JobMetaWarranty_ExternalCompletedDate = j.JobMetaWarranty.ExternalCompletedDate;
i.JobMetaWarranty_ExternalName = j.JobMetaWarranty.ExternalName;
}
if (j.JobMetaNonWarranty != null)
{
i.JobMetaNonWarranty_RepairerLoggedDate = j.JobMetaNonWarranty.RepairerLoggedDate;
i.JobMetaNonWarranty_RepairerCompletedDate = j.JobMetaNonWarranty.RepairerCompletedDate;
i.JobMetaNonWarranty_AccountingChargeAddedDate = j.JobMetaNonWarranty.AccountingChargeAddedDate;
i.JobMetaNonWarranty_AccountingChargePaidDate = j.JobMetaNonWarranty.AccountingChargePaidDate;
i.JobMetaNonWarranty_AccountingChargeRequiredDate = j.JobMetaNonWarranty.AccountingChargeRequiredDate;
i.JobMetaNonWarranty_IsInsuranceClaim = j.JobMetaNonWarranty.IsInsuranceClaim;
i.JobMetaNonWarranty_RepairerName = j.JobMetaNonWarranty.RepairerName;
if (j.JobMetaInsurance != null)
{
i.JobMetaInsurance_ClaimFormSentDate = j.JobMetaInsurance.ClaimFormSentDate;
}
}
}
if (j.User != null)
{
i.UserId = j.UserId;
i.UserDisplayName = j.User.DisplayName;
}
if (j.OpenedTechUser != null)
{
i.OpenedTechUserId = j.OpenedTechUserId;
i.OpenedTechUserDisplayName = j.OpenedTechUser.DisplayName;
}
return i;
}
public static string JobStatusDescription(string StatusId, Job j = null)
{
switch (StatusId)
{
case Job.JobStatusIds.Open:
return "Open";
case Job.JobStatusIds.Closed:
return "Closed";
case Job.JobStatusIds.AwaitingWarrantyRepair:
if (j == null)
return "Awaiting Warranty Repair";
else
if (j.DeviceHeld.HasValue)
return string.Format("Awaiting Warranty Repair ({0})", j.JobMetaWarranty.ExternalName);
else
return string.Format("Awaiting Warranty Repair - Not Held ({0})", j.JobMetaWarranty.ExternalName);
case Job.JobStatusIds.AwaitingRepairs:
if (j == null)
return "Awaiting Repairs";
else
if (j.DeviceHeld.HasValue)
return string.Format("Awaiting Repairs ({0})", j.JobMetaNonWarranty.RepairerName);
else
return string.Format("Awaiting Repairs - Not Held ({0})", j.JobMetaNonWarranty.RepairerName);
case Job.JobStatusIds.AwaitingDeviceReturn:
return "Awaiting Device Return";
case Job.JobStatusIds.AwaitingUserAction:
return "Awaiting User Action";
case Job.JobStatusIds.AwaitingAccountingPayment:
return "Awaiting Accounting Payment";
case Job.JobStatusIds.AwaitingAccountingCharge:
return "Awaiting Accounting Charge";
case Job.JobStatusIds.AwaitingInsuranceProcessing:
return "Awaiting Insurance Processing";
default:
return "Unknown";
}
}
public static string JobStatusDescription(string StatusId, JobTableStatusItemModel j = null)
{
switch (StatusId)
{
case Job.JobStatusIds.Open:
return "Open";
case Job.JobStatusIds.Closed:
return "Closed";
case Job.JobStatusIds.AwaitingWarrantyRepair:
if (j == null)
return "Awaiting Warranty Repair";
else
if (j.DeviceHeld.HasValue)
return string.Format("Awaiting Warranty Repair ({0})", j.JobMetaWarranty_ExternalName);
else
return string.Format("Awaiting Warranty Repair - Not Held ({0})", j.JobMetaWarranty_ExternalName);
case Job.JobStatusIds.AwaitingRepairs:
if (j == null)
return "Awaiting Repairs";
else
if (j.DeviceHeld.HasValue)
return string.Format("Awaiting Repairs ({0})", j.JobMetaNonWarranty_RepairerName);
else
return string.Format("Awaiting Repairs - Not Held ({0})", j.JobMetaNonWarranty_RepairerName);
case Job.JobStatusIds.AwaitingDeviceReturn:
return "Awaiting Device Return";
case Job.JobStatusIds.AwaitingUserAction:
return "Awaiting User Action";
case Job.JobStatusIds.AwaitingAccountingPayment:
return "Awaiting Accounting Payment";
case Job.JobStatusIds.AwaitingAccountingCharge:
return "Awaiting Accounting Charge";
case Job.JobStatusIds.AwaitingInsuranceProcessing:
return "Awaiting Insurance Processing";
default:
return "Unknown";
}
}
public static string CalculateStatusId(this Job j)
{
return j.ToJobTableStatusItemModel().CalculateStatusId();
}
public static string CalculateStatusId(this JobTableStatusItemModel j)
{
if (j.ClosedDate.HasValue)
return Job.JobStatusIds.Closed;
if (j.JobTypeId == JobType.JobTypeIds.HWar)
{
if (!string.IsNullOrEmpty(j.JobMetaWarranty_ExternalReference) && !j.JobMetaWarranty_ExternalCompletedDate.HasValue)
return Job.JobStatusIds.AwaitingWarrantyRepair; // Job Logged - but not marked as completed
}
if (j.JobTypeId == JobType.JobTypeIds.HNWar)
{
if (j.JobMetaNonWarranty_RepairerLoggedDate.HasValue && !j.JobMetaNonWarranty_RepairerCompletedDate.HasValue)
return Job.JobStatusIds.AwaitingRepairs; // Repairs logged - but not complete
if (j.JobMetaNonWarranty_AccountingChargeAddedDate.HasValue && !j.JobMetaNonWarranty_AccountingChargePaidDate.HasValue)
return Job.JobStatusIds.AwaitingAccountingPayment; // Accounting Charge Added, but not paid
if (j.JobMetaNonWarranty_AccountingChargeRequiredDate.HasValue && (!j.JobMetaNonWarranty_AccountingChargePaidDate.HasValue || !j.JobMetaNonWarranty_AccountingChargeAddedDate.HasValue))
return Job.JobStatusIds.AwaitingAccountingCharge; // Accounting Charge Required, but not added or paid
if (j.JobMetaNonWarranty_RepairerLoggedDate.HasValue && j.JobMetaNonWarranty_IsInsuranceClaim.Value && !j.JobMetaInsurance_ClaimFormSentDate.HasValue)
return Job.JobStatusIds.AwaitingInsuranceProcessing; // Is insurance claim, but no Claim Form Sent
}
if (j.WaitingForUserAction.HasValue)
return Job.JobStatusIds.AwaitingUserAction; // Awaiting for User
if (j.DeviceReadyForReturn.HasValue && !j.DeviceReturnedDate.HasValue)
return Job.JobStatusIds.AwaitingDeviceReturn; // Device not returned to User
return Job.JobStatusIds.Open;
}
public static Tuple<string, string> Status(this Job j)
{
var statusId = j.CalculateStatusId();
return new Tuple<string, string>(statusId, JobStatusDescription(statusId, j));
}
}
}
@@ -1,17 +1,59 @@
using System;
using Disco.Data.Repository;
using Disco.Models.Repository;
using Disco.Models.Services.Jobs.JobLists;
using Disco.Services.Authorization;
using Disco.Services.Users;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Disco.Models.BI.Job;
using Disco.Models.Repository;
using Disco.Data.Repository;
using Disco.Services.Users;
using Disco.Services.Authorization;
using System.Threading.Tasks;
namespace Disco.BI.Extensions
namespace Disco.Services
{
public static class JobTableExtensions
{
private static JobTableModel CloneEmptyJobTableModel(JobTableModel Model)
{
return new JobTableModel()
{
ShowId = Model.ShowId,
ShowDeviceAddress = Model.ShowDeviceAddress,
ShowDates = Model.ShowDates,
ShowType = Model.ShowType,
ShowDevice = Model.ShowDevice,
ShowUser = Model.ShowUser,
ShowTechnician = Model.ShowTechnician,
ShowLocation = Model.ShowLocation,
ShowStatus = Model.ShowStatus,
IsSmallTable = Model.IsSmallTable,
HideClosedJobs = Model.HideClosedJobs,
EnablePaging = Model.EnablePaging,
EnableFilter = Model.EnableFilter
};
}
public static IDictionary<string, JobTableModel> MultiCampusModels(this JobTableModel Model)
{
var items = Model.Items;
if (items == null || items.Count() > 0)
{
return items.OrderBy(i => i.DeviceAddress).GroupBy(i => i.DeviceAddress).ToDictionary(
ig => ig.Key ?? string.Empty,
ig =>
{
var jtm = CloneEmptyJobTableModel(Model);
jtm.Items = ig.ToList();
return jtm;
}
);
}
else
{
return null;
}
}
private static List<string> FilterAllowedTypes(AuthorizationToken Authorization)
{
if (!Authorization.HasAll(Claims.Job.Types.ShowHMisc, Claims.Job.Types.ShowHNWar, Claims.Job.Types.ShowHWar, Claims.Job.Types.ShowSApp, Claims.Job.Types.ShowSImg, Claims.Job.Types.ShowSOS, Claims.Job.Types.ShowUMgmt))
@@ -50,24 +92,24 @@ namespace Disco.BI.Extensions
return Jobs;
}
public static List<JobTableModel.JobTableItemModel> PermissionsFiltered(this List<JobTableModel.JobTableItemModel> Items, AuthorizationToken Authorization)
public static IEnumerable<JobTableItemModel> PermissionsFiltered(this IEnumerable<JobTableItemModel> Items, AuthorizationToken Authorization)
{
if (Items != null && Items.Count > 0)
if (Items != null && Items.Count() > 0)
{
var allowedTypes = FilterAllowedTypes(Authorization);
if (allowedTypes != null)
{
return Items.Where(j => allowedTypes.Contains(j.TypeId)).ToList();
return Items.Where(j => allowedTypes.Contains(j.JobTypeId)).ToList();
}
}
return Items;
}
public static List<JobTableModel.JobTableItemModel> DetermineItems(this JobTableModel model, DiscoDataContext Database, IQueryable<Job> Jobs)
public static IEnumerable<JobTableItemModel> DetermineItems(this JobTableModel model, DiscoDataContext Database, IQueryable<Job> Jobs)
{
List<JobTableModel.JobTableItemModel> items;
List<JobTableItemModel> items;
// Permissions
var auth = UserService.CurrentAuthorization;
@@ -96,13 +138,13 @@ namespace Disco.BI.Extensions
if (model.ShowStatus)
{
var jobItems = Jobs.Select(j => new JobTableModel.JobTableItemModelIncludeStatus()
var jobItems = Jobs.Select(j => new JobTableStatusItemModel()
{
Id = j.Id,
OpenedDate = j.OpenedDate,
ClosedDate = j.ClosedDate,
TypeId = j.JobTypeId,
TypeDescription = j.JobType.Description,
JobTypeId = j.JobTypeId,
JobTypeDescription = j.JobType.Description,
DeviceSerialNumber = j.Device.SerialNumber,
DeviceProfileId = j.Device.DeviceProfileId,
DeviceModelId = j.Device.DeviceModelId,
@@ -112,9 +154,11 @@ namespace Disco.BI.Extensions
UserDisplayName = j.User.DisplayName,
OpenedTechUserId = j.OpenedTechUserId,
OpenedTechUserDisplayName = j.OpenedTechUser.DisplayName,
Location = j.DeviceHeldLocation,
DeviceHeldLocation = j.DeviceHeldLocation,
Flags = j.Flags,
JobMetaWarranty_ExternalReference = j.JobMetaWarranty.ExternalReference,
JobMetaWarranty_ExternalLoggedDate = j.JobMetaWarranty.ExternalLoggedDate,
JobMetaWarranty_ExternalCompletedDate = j.JobMetaWarranty.ExternalCompletedDate,
JobMetaNonWarranty_RepairerLoggedDate = j.JobMetaNonWarranty.RepairerLoggedDate,
JobMetaNonWarranty_RepairerCompletedDate = j.JobMetaNonWarranty.RepairerCompletedDate,
@@ -129,27 +173,35 @@ namespace Disco.BI.Extensions
DeviceHeld = j.DeviceHeld,
DeviceReturnedDate = j.DeviceReturnedDate,
JobMetaWarranty_ExternalName = j.JobMetaWarranty.ExternalName,
JobMetaNonWarranty_RepairerName = j.JobMetaNonWarranty.RepairerName
JobMetaNonWarranty_RepairerName = j.JobMetaNonWarranty.RepairerName,
ActiveJobQueues = j.JobQueues.Where(jq => !jq.RemovedDate.HasValue).Select(jq => new JobTableStatusQueueItemModel()
{
Id = jq.Id,
QueueId = jq.JobQueueId,
AddedDate = jq.AddedDate,
SLAExpiresDate = jq.SLAExpiresDate,
Priority = jq.Priority
})
});
items = new List<JobTableModel.JobTableItemModel>();
items = new List<JobTableItemModel>();
foreach (var j in jobItems)
{
j.StatusId = j.CalculateStatusId();
j.StatusDescription = JobBI.Utilities.JobStatusDescription(j.StatusId, j);
j.StatusDescription = JobExtensions.JobStatusDescription(j.StatusId, j);
items.Add(j);
}
}
else
{
items = Jobs.Select(j => new JobTableModel.JobTableItemModel()
items = Jobs.Select(j => new JobTableItemModel()
{
Id = j.Id,
OpenedDate = j.OpenedDate,
ClosedDate = j.ClosedDate,
TypeId = j.JobTypeId,
TypeDescription = j.JobType.Description,
JobTypeId = j.JobTypeId,
JobTypeDescription = j.JobType.Description,
DeviceSerialNumber = j.Device.SerialNumber,
DeviceProfileId = j.Device.DeviceProfileId,
DeviceModelId = j.Device.DeviceModelId,
@@ -159,7 +211,8 @@ namespace Disco.BI.Extensions
UserDisplayName = j.User.DisplayName,
OpenedTechUserId = j.OpenedTechUserId,
OpenedTechUserDisplayName = j.OpenedTechUser.DisplayName,
Location = j.DeviceHeldLocation
DeviceHeldLocation = j.DeviceHeldLocation,
Flags = j.Flags
}).ToList();
}
@@ -177,5 +230,21 @@ namespace Disco.BI.Extensions
{
model.Items = model.DetermineItems(Database, Jobs);
}
public static double? SlaPrecentageRemaining(this IEnumerable<JobTableStatusQueueItemModel> queueItems)
{
return queueItems.Where(i => i.SLAExpiresDate.HasValue).Min<JobTableStatusQueueItemModel, double?>(i =>
{
var total = (i.SLAExpiresDate.Value - i.AddedDate).Ticks;
var remaining = (i.SLAExpiresDate.Value - DateTime.Now).Ticks;
return ((double)remaining / total);
});
}
public static IEnumerable<JobTableStatusQueueItemModel> UsersQueueItems(this IEnumerable<JobTableStatusQueueItemModel> queueItems, AuthorizationToken Authorization)
{
var usersQueues = Jobs.JobQueues.JobQueueService.UsersQueues(Authorization).ToDictionary(q => q.JobQueue.Id);
return queueItems.Where(qi => usersQueues.ContainsKey(qi.QueueId));
}
}
}
@@ -0,0 +1,265 @@
using Disco.Data.Repository;
using Disco.Data.Repository.Monitor;
using Disco.Models.Repository;
using Disco.Models.Services.Jobs.JobLists;
using Disco.Services.Logging;
using Disco.Services.Users;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
namespace Disco.Services.Jobs.JobLists
{
using FilterFunc = Func<IQueryable<Job>, IQueryable<Job>>;
using SortFunc = Func<IEnumerable<JobTableItemModel>, IEnumerable<JobTableItemModel>>;
using OpenFilterFunc = Func<IEnumerable<JobTableStatusItemModel>, IEnumerable<JobTableStatusItemModel>>;
using Disco.Services.Authorization;
using Disco.Services.Jobs.JobQueues;
public class ManagedJobList : JobTableModel, IDisposable
{
private static ManagedJobList openJobs;
private IDisposable unsubscribeToken;
private object updateLock = new object();
public string Name { get; private set; }
public FilterFunc FilterFunction { get; private set; }
public SortFunc SortFunction { get; private set; }
public static OpenFilterFunc AwaitingTechnicianActionFilter = q => q.Where(j => j.ClosedDate == null && !j.WaitingForUserAction.HasValue
&& !(j.JobTypeId == JobType.JobTypeIds.HNWar && (j.JobMetaNonWarranty_RepairerLoggedDate.HasValue && j.JobMetaNonWarranty_IsInsuranceClaim.Value && !j.JobMetaInsurance_ClaimFormSentDate.HasValue))
&& !(j.JobTypeId == JobType.JobTypeIds.HNWar && (j.JobMetaNonWarranty_RepairerLoggedDate.HasValue && !j.JobMetaNonWarranty_RepairerCompletedDate.HasValue))
&& !(j.JobTypeId == JobType.JobTypeIds.HNWar && (j.JobMetaNonWarranty_RepairerLoggedDate.HasValue && j.JobMetaNonWarranty_AccountingChargeAddedDate.HasValue && !j.JobMetaNonWarranty_AccountingChargePaidDate.HasValue))
&& !(j.JobTypeId == JobType.JobTypeIds.HWar && (j.JobMetaWarranty_ExternalLoggedDate.HasValue && !j.JobMetaWarranty_ExternalCompletedDate.HasValue))
&& (j.DeviceHeld == null || j.DeviceReturnedDate != null || j.DeviceReadyForReturn == null));
static ManagedJobList()
{
using (var Database = new DiscoDataContext())
{
openJobs = new ManagedJobList(
Name: "Open Jobs",
FilterFunction: q => q.Where(j => !j.ClosedDate.HasValue),
SortFunction: q => q)
{
ShowDeviceAddress = true,
ShowLocation = true,
ShowStatus = true
}.Initialize(Database);
}
}
public static JobTableModel OpenJobsTable(OpenFilterFunc FilterFunction)
{
return new JobTableModel()
{
ShowStatus = true,
Items = FilterFunction(openJobs.Items.Cast<JobTableStatusItemModel>())
};
}
public static JobTableModel MyJobsTable(AuthorizationToken AuthToken)
{
IEnumerable<Tuple<JobTableStatusItemModel, byte, byte, DateTime?>> allJobs = null;
if (AuthToken.Has(Claims.Job.Lists.MyJobsOrphaned))
{
allJobs = AwaitingTechnicianActionFilter(
openJobs.Items.Cast<JobTableStatusItemModel>()
.Where(i => i.ActiveJobQueues == null || i.ActiveJobQueues.Count() == 0)
).Select(i => new Tuple<JobTableStatusItemModel, byte, byte, DateTime?>(i, (byte)JobQueuePriority.Normal, (byte)JobQueuePriority.Normal, null));
}
var usersQueues = JobQueueService.UsersQueues(AuthToken).ToDictionary(q => q.JobQueue.Id);
var queueJobs = openJobs.Items.Cast<JobTableStatusItemModel>()
.Where(i => i.ActiveJobQueues != null && i.ActiveJobQueues.Any(jqj => usersQueues.ContainsKey(jqj.QueueId)))
.Select(i => new Tuple<JobTableStatusItemModel, byte, byte, DateTime?>(
i,
(byte)i.ActiveJobQueues.Where(q => usersQueues.ContainsKey(q.QueueId)).Max(q => (int)usersQueues[q.QueueId].JobQueue.Priority),
(byte)i.ActiveJobQueues.Where(q => usersQueues.ContainsKey(q.QueueId)).Max(q => (int)q.Priority),
i.ActiveJobQueues.Where(q => usersQueues.ContainsKey(q.QueueId) && q.SLAExpiresDate.HasValue).Min(q => q.SLAExpiresDate)
));
if (allJobs != null)
allJobs = allJobs.Concat(queueJobs).ToList();
else
allJobs = queueJobs.ToList();
var allJobsSorted = allJobs
.OrderByDescending(i => i.Item2).ThenByDescending(i => i.Item3).ThenBy(i => i.Item4).ThenBy(i => i.Item1.OpenedDate).Select(q => q.Item1);
return new JobTableModel()
{
ShowStatus = true,
Items = allJobsSorted.ToList()
};
}
public override IEnumerable<JobTableItemModel> Items
{
get
{
return base.Items.PermissionsFiltered(UserService.CurrentAuthorization);
}
set
{
throw new InvalidOperationException("Items cannot be manually set in a Managed Job List");
}
}
public ManagedJobList(string Name, FilterFunc FilterFunction, SortFunc SortFunction)
{
this.Name = Name;
this.FilterFunction = FilterFunction;
this.SortFunction = SortFunction;
}
public ManagedJobList Initialize(DiscoDataContext Database)
{
// Can only Initialize once
if (base.Items != null)
return ReInitialize(Database);
lock (updateLock)
{
// Subscribe for Changes
// - Job (or Job Meta) Changes
// - Device Profile Address Changes (for multi-campus Schools)
// - Device Model Description Changes
// - Device's Profile or Model Changes
unsubscribeToken = RepositoryMonitor.StreamAfterCommit
.Where(n => n.EntityType == typeof(Job) ||
n.EntityType == typeof(JobQueueJob) ||
n.EntityType == typeof(JobMetaWarranty) ||
n.EntityType == typeof(JobMetaNonWarranty) ||
n.EntityType == typeof(JobMetaInsurance) ||
(n.EventType == RepositoryMonitorEventType.Modified && (
(n.EntityType == typeof(DeviceProfile) && n.ModifiedProperties.Contains("DefaultOrganisationAddress")) ||
(n.EntityType == typeof(DeviceModel) && n.ModifiedProperties.Contains("Description")) ||
(n.EntityType == typeof(Device) && n.ModifiedProperties.Contains("DeviceProfileId") || n.ModifiedProperties.Contains("DeviceModelId"))
)))
.Subscribe(JobNotification, NotificationError);
// Initially fill table
base.Items = this.SortFunction(this.DetermineItems(Database, this.FilterFunction(Database.Jobs))).ToList();
}
return this;
}
public ManagedJobList ReInitialize(DiscoDataContext Database)
{
return ReInitialize(Database, null, null);
}
public ManagedJobList ReInitialize(DiscoDataContext Database, FilterFunc FilterFunction)
{
return ReInitialize(Database, FilterFunction, null);
}
public ManagedJobList ReInitialize(DiscoDataContext Database, FilterFunc FilterFunction, SortFunc SortFunction)
{
if (Database == null)
throw new ArgumentNullException("Database");
lock (updateLock)
{
if (FilterFunction != null)
this.FilterFunction = FilterFunction;
if (SortFunction != null)
this.SortFunction = SortFunction;
base.Items = this.SortFunction(this.DetermineItems(Database, this.FilterFunction(Database.Jobs))).ToList();
}
return this;
}
private void NotificationError(Exception ex)
{
SystemLog.LogException(string.Format("Disco.Services.Jobs.JobLists.ManagedJobList: [{0}]", this.Name), ex);
}
private void JobNotification(RepositoryMonitorEvent e)
{
List<int> jobIds = null;
JobTableItemModel[] existingItems = null;
if (e.EntityType == typeof(Job))
jobIds = new List<int>() { ((Job)e.Entity).Id };
else if (e.EntityType == typeof(JobQueueJob))
jobIds = new List<int>() { ((JobQueueJob)e.Entity).JobId };
else if (e.EntityType == typeof(JobMetaWarranty))
jobIds = new List<int>() { ((JobMetaWarranty)e.Entity).JobId };
else if (e.EntityType == typeof(JobMetaNonWarranty))
jobIds = new List<int>() { ((JobMetaNonWarranty)e.Entity).JobId };
else if (e.EntityType == typeof(JobMetaInsurance))
jobIds = new List<int>() { ((JobMetaInsurance)e.Entity).JobId };
else if (e.EntityType == typeof(DeviceProfile))
{
int deviceProfileId = ((DeviceProfile)e.Entity).Id;
existingItems = base.Items.Where(i => i.DeviceProfileId == deviceProfileId).ToArray();
}
else if (e.EntityType == typeof(DeviceModel))
{
int deviceModelId = ((DeviceModel)e.Entity).Id;
existingItems = base.Items.Where(i => i.DeviceModelId == deviceModelId).ToArray();
}
else if (e.EntityType == typeof(Device))
{
string deviceSerialNumber = ((Device)e.Entity).SerialNumber;
existingItems = base.Items.Where(i => i.DeviceSerialNumber == deviceSerialNumber).ToArray();
}
else
return; // Subscription should never reach
if (jobIds == null)
{
if (existingItems == null)
throw new InvalidOperationException("Notification algorithm didn't indicate any Jobs for update");
else
jobIds = existingItems.Select(i => i.Id).ToList();
}
if (jobIds.Count == 0)
return;
else
UpdateJobs(e.Database, jobIds, existingItems);
}
private void UpdateJobs(DiscoDataContext Database, List<int> jobIds, JobTableItemModel[] existingItems = null)
{
lock (updateLock)
{
// Check for existing items, if not handed them
if (existingItems == null)
existingItems = base.Items.Where(i => jobIds.Contains(i.Id)).ToArray();
var updatedItems = this.DetermineItems(Database, this.FilterFunction(Database.Jobs.Where(j => jobIds.Contains(j.Id))));
var refreshedList = base.Items.ToList();
// Remove Existing
if (existingItems.Length > 0)
foreach (var existingItem in existingItems)
refreshedList.Remove(existingItem);
// Add Updated Items
if (updatedItems.Count() > 0)
foreach (var updatedItem in updatedItems)
refreshedList.Add(updatedItem);
// Reorder
base.Items = this.SortFunction(refreshedList).ToList();
}
}
public void Dispose()
{
if (unsubscribeToken != null)
{
unsubscribeToken.Dispose();
unsubscribeToken = null;
}
}
}
}
+313
View File
@@ -0,0 +1,313 @@
using Disco.Data.Repository;
using Disco.Models.Repository;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Jobs.JobQueues
{
internal class Cache
{
private ConcurrentDictionary<int, JobQueueToken> _Cache;
private Dictionary<string, List<JobQueueToken>> _SubjectCache;
private ReadOnlyCollection<KeyValuePair<string, string>> _Icons;
private ReadOnlyCollection<KeyValuePair<string, string>> _IconColourCache;
private ReadOnlyCollection<KeyValuePair<int, string>> _SlaOptions;
public Cache(DiscoDataContext Database)
{
Initialize(Database);
}
private void Initialize(DiscoDataContext Database)
{
// Queues from Database
var queues = Database.JobQueues.ToList();
// Default System Queue
//var defaultQueue = new JobQueue()
//{
// Id = 0,
// Name = "Default Queue",
// Description = "Default system queue for orphaned jobs",
// Icon = "question-circle",
// IconColour = "F0A30A",
// DefaultSLAExpiry = null,
// Priority = JobQueuePriority.Normal,
// SubjectIds = null
//};
//queues.Add(defaultQueue);
// Add Queues to In-Memory Cache
this._Cache = new ConcurrentDictionary<int, JobQueueToken>(queues.Select(q => new KeyValuePair<int, JobQueueToken>(q.Id, JobQueueToken.FromJobQueue(q))));
// Calculate Queue Subject Cache
CalculateSubjectCache();
#region Predefined Options
// Icons
if (this._Icons == null)
{
this._Icons = new List<KeyValuePair<string, string>>(){
new KeyValuePair<string, string>("ambulance" , "Ambulance"),
new KeyValuePair<string, string>("anchor" , "Anchor"),
new KeyValuePair<string, string>("android" , "Android"),
new KeyValuePair<string, string>("apple" , "Apple"),
new KeyValuePair<string, string>("archive" , "Archive"),
new KeyValuePair<string, string>("arrow-circle-down" , "Arrow Circle Down"),
new KeyValuePair<string, string>("arrow-circle-left" , "Arrow Circle Left"),
new KeyValuePair<string, string>("arrow-circle-right" , "Arrow Circle Right"),
new KeyValuePair<string, string>("arrow-circle-up" , "Arrow Circle Up"),
new KeyValuePair<string, string>("asterisk" , "Asterisk"),
new KeyValuePair<string, string>("ban" , "Ban"),
new KeyValuePair<string, string>("beer" , "Beer"),
new KeyValuePair<string, string>("bell" , "Bell"),
new KeyValuePair<string, string>("bolt" , "Bolt"),
new KeyValuePair<string, string>("book" , "Book"),
new KeyValuePair<string, string>("bookmark" , "Bookmark"),
new KeyValuePair<string, string>("briefcase" , "Briefcase"),
new KeyValuePair<string, string>("bug" , "Bug"),
new KeyValuePair<string, string>("building-o" , "Building"),
new KeyValuePair<string, string>("bullhorn" , "Bullhorn"),
new KeyValuePair<string, string>("bullseye" , "Bullseye"),
new KeyValuePair<string, string>("calendar" , "Calendar"),
new KeyValuePair<string, string>("calendar-o" , "Calendar"),
new KeyValuePair<string, string>("check-circle" , "Check Circle"),
new KeyValuePair<string, string>("clock-o" , "Clock"),
new KeyValuePair<string, string>("cloud" , "Cloud"),
new KeyValuePair<string, string>("coffee" , "Coffee"),
new KeyValuePair<string, string>("comments" , "Comments"),
new KeyValuePair<string, string>("compass" , "Compass"),
new KeyValuePair<string, string>("credit-card" , "Credit Card"),
new KeyValuePair<string, string>("crosshairs" , "Crosshairs"),
new KeyValuePair<string, string>("desktop" , "Desktop"),
new KeyValuePair<string, string>("dollar" , "Dollar"),
new KeyValuePair<string, string>("dot-circle-o" , "Dot Circle"),
new KeyValuePair<string, string>("envelope" , "Envelope"),
new KeyValuePair<string, string>("exclamation" , "Exclamation"),
new KeyValuePair<string, string>("eye" , "Eye"),
new KeyValuePair<string, string>("female" , "Female"),
new KeyValuePair<string, string>("fighter-jet" , "Fighter Jet"),
new KeyValuePair<string, string>("film" , "Film"),
new KeyValuePair<string, string>("filter" , "Filter"),
new KeyValuePair<string, string>("fire" , "Fire"),
new KeyValuePair<string, string>("fire-extinguisher" , "Fire Extinguisher"),
new KeyValuePair<string, string>("flask" , "Flask"),
new KeyValuePair<string, string>("frown-o" , "Frown"),
new KeyValuePair<string, string>("gamepad" , "Gamepad"),
new KeyValuePair<string, string>("gift" , "Gift"),
new KeyValuePair<string, string>("glass" , "Glass"),
new KeyValuePair<string, string>("globe" , "Globe"),
new KeyValuePair<string, string>("hand-o-down" , "Hand Down"),
new KeyValuePair<string, string>("hand-o-left" , "Hand Left"),
new KeyValuePair<string, string>("hand-o-right" , "Hand Right"),
new KeyValuePair<string, string>("hand-o-up" , "Hand Up"),
new KeyValuePair<string, string>("hdd-o" , "Hdd"),
new KeyValuePair<string, string>("heart" , "Heart"),
new KeyValuePair<string, string>("home" , "Home"),
new KeyValuePair<string, string>("info" , "Info"),
new KeyValuePair<string, string>("key" , "Key"),
new KeyValuePair<string, string>("keyboard-o" , "Keyboard"),
new KeyValuePair<string, string>("laptop" , "Laptop"),
new KeyValuePair<string, string>("leaf" , "Leaf"),
new KeyValuePair<string, string>("legal" , "Legal"),
new KeyValuePair<string, string>("lightbulb-o" , "Lightbulb"),
new KeyValuePair<string, string>("linux" , "Linux"),
new KeyValuePair<string, string>("location-arrow" , "Location Arrow"),
new KeyValuePair<string, string>("magnet" , "Magnet"),
new KeyValuePair<string, string>("male" , "Male"),
new KeyValuePair<string, string>("map-marker" , "Map Marker"),
new KeyValuePair<string, string>("medkit" , "Medkit"),
new KeyValuePair<string, string>("meh-o" , "Meh"),
new KeyValuePair<string, string>("microphone" , "Microphone"),
new KeyValuePair<string, string>("microphone-slash" , "Microphone Slash"),
new KeyValuePair<string, string>("minus-circle" , "Minus Circle"),
new KeyValuePair<string, string>("mobile" , "Mobile"),
new KeyValuePair<string, string>("money" , "Money"),
new KeyValuePair<string, string>("moon-o" , "Moon"),
new KeyValuePair<string, string>("music" , "Music"),
new KeyValuePair<string, string>("paperclip" , "Paperclip"),
new KeyValuePair<string, string>("pencil" , "Pencil"),
new KeyValuePair<string, string>("phone" , "Phone"),
new KeyValuePair<string, string>("picture-o" , "Picture"),
new KeyValuePair<string, string>("plane" , "Plane"),
new KeyValuePair<string, string>("power-off" , "Power Off"),
new KeyValuePair<string, string>("print" , "Print"),
new KeyValuePair<string, string>("puzzle-piece" , "Puzzle Piece"),
new KeyValuePair<string, string>("question" , "Question"),
new KeyValuePair<string, string>("question-circle" , "Question Circle"),
new KeyValuePair<string, string>("random" , "Random"),
new KeyValuePair<string, string>("retweet" , "Retweet"),
new KeyValuePair<string, string>("road" , "Road"),
new KeyValuePair<string, string>("rocket" , "Rocket"),
new KeyValuePair<string, string>("shield" , "Shield"),
new KeyValuePair<string, string>("shopping-cart" , "Shopping Cart"),
new KeyValuePair<string, string>("smile-o" , "Smile"),
new KeyValuePair<string, string>("star" , "Star"),
new KeyValuePair<string, string>("suitcase" , "Suitcase"),
new KeyValuePair<string, string>("sun-o" , "Sun"),
new KeyValuePair<string, string>("tablet" , "Tablet"),
new KeyValuePair<string, string>("tachometer" , "Tachometer"),
new KeyValuePair<string, string>("tasks" , "Tasks"),
new KeyValuePair<string, string>("thumbs-down" , "Thumbs Down"),
new KeyValuePair<string, string>("thumbs-o-down" , "Thumbs Down"),
new KeyValuePair<string, string>("thumbs-o-up" , "Thumbs Up"),
new KeyValuePair<string, string>("thumbs-up" , "Thumbs Up"),
new KeyValuePair<string, string>("thumb-tack" , "Thumb Tack"),
new KeyValuePair<string, string>("trash-o" , "Trash"),
new KeyValuePair<string, string>("trophy" , "Trophy"),
new KeyValuePair<string, string>("truck" , "Truck"),
new KeyValuePair<string, string>("umbrella" , "Umbrella"),
new KeyValuePair<string, string>("wheelchair" , "Wheelchair"),
new KeyValuePair<string, string>("windows" , "Windows"),
new KeyValuePair<string, string>("wrench" , "Wrench")
}.AsReadOnly();
}
// Icon Colours
if (this._IconColourCache == null)
{
this._IconColourCache = new List<KeyValuePair<string, string>>(){
new KeyValuePair<string, string>("lime" , "Lime"),
new KeyValuePair<string, string>("green" , "Green"),
new KeyValuePair<string, string>("emerald" , "Emerald"),
new KeyValuePair<string, string>("teal" , "Teal"),
new KeyValuePair<string, string>("cyan" , "Cyan"),
new KeyValuePair<string, string>("cobalt" , "Cobalt"),
new KeyValuePair<string, string>("indigo" , "Indigo"),
new KeyValuePair<string, string>("violet" , "Violet"),
new KeyValuePair<string, string>("pink" , "Pink"),
new KeyValuePair<string, string>("magenta" , "Magenta"),
new KeyValuePair<string, string>("crimson" , "Crimson"),
new KeyValuePair<string, string>("red" , "Red"),
new KeyValuePair<string, string>("orange" , "Orange"),
new KeyValuePair<string, string>("amber" , "Amber"),
new KeyValuePair<string, string>("yellow" , "Yellow"),
new KeyValuePair<string, string>("brown" , "Brown"),
new KeyValuePair<string, string>("olive" , "Olive"),
new KeyValuePair<string, string>("steel" , "Steel"),
new KeyValuePair<string, string>("mauve" , "Mauve"),
new KeyValuePair<string, string>("sienna" , "Sienna")
}.AsReadOnly();
}
// SLA Options
if (this._SlaOptions == null)
{
this._SlaOptions = new List<KeyValuePair<int, string>>()
{
new KeyValuePair<int, string>(0, "<None>"),
new KeyValuePair<int, string>(15, "15 minutes"),
new KeyValuePair<int, string>(30, "30 minutes"),
new KeyValuePair<int, string>(60, "1 hour"),
new KeyValuePair<int, string>(60 * 2, "2 hours"),
new KeyValuePair<int, string>(60 * 4, "4 hours"),
new KeyValuePair<int, string>(60 * 8, "8 hours"),
new KeyValuePair<int, string>(60 * 24, "1 day"),
new KeyValuePair<int, string>(60 * 24 * 2, "2 days"),
new KeyValuePair<int, string>(60 * 24 * 3, "3 days"),
new KeyValuePair<int, string>(60 * 24 * 4, "4 days"),
new KeyValuePair<int, string>(60 * 24 * 5, "5 days"),
new KeyValuePair<int, string>(60 * 24 * 6, "6 days"),
new KeyValuePair<int, string>(60 * 24 * 7, "1 week"),
new KeyValuePair<int, string>(60 * 24 * 7 * 2, "2 weeks"),
new KeyValuePair<int, string>(60 * 24 * 7 * 3, "3 weeks"),
new KeyValuePair<int, string>(60 * 24 * 7 * 4, "4 weeks"),
new KeyValuePair<int, string>(60 * 24 * 7 * 4 * 2, "2 months"),
new KeyValuePair<int, string>(60 * 24 * 7 * 4 * 3, "3 months"),
new KeyValuePair<int, string>(60 * 24 * 7 * 4 * 4, "4 months"),
new KeyValuePair<int, string>(60 * 24 * 7 * 4 * 5, "5 months"),
new KeyValuePair<int, string>(60 * 24 * 7 * 4 * 6, "6 months")
}.AsReadOnly();
}
#endregion
}
private void CalculateSubjectCache()
{
_SubjectCache = (from c in _Cache.Values.ToList()
from s in c.SubjectIds
group c by s into subjectId
select subjectId).ToDictionary(g => g.Key.ToLower(), g => g.ToList());
}
public ReadOnlyCollection<KeyValuePair<string, string>> Icons { get { return this._Icons; } }
public ReadOnlyCollection<KeyValuePair<string, string>> IconColours { get { return this._IconColourCache; } }
public ReadOnlyCollection<KeyValuePair<int, string>> SlaOptions { get { return this._SlaOptions; } }
public JobQueueToken UpdateQueue(JobQueue JobQueue)
{
var token = JobQueueToken.FromJobQueue(JobQueue);
JobQueueToken existingToken;
if (_Cache.TryGetValue(JobQueue.Id, out existingToken))
{
if (_Cache.TryUpdate(JobQueue.Id, token, existingToken))
{
if (existingToken.JobQueue.SubjectIds != token.JobQueue.SubjectIds)
CalculateSubjectCache();
return token;
}
else
return null;
}
else
{
if (_Cache.TryAdd(JobQueue.Id, token))
{
CalculateSubjectCache();
return token;
}
else
return null;
}
}
public bool RemoveQueue(int JobQueueId)
{
JobQueueToken token;
if (_Cache.TryRemove(JobQueueId, out token))
{
CalculateSubjectCache();
return true;
}
else
{
return false;
}
}
public JobQueueToken GetQueue(int JobQueueId)
{
JobQueueToken token;
if (_Cache.TryGetValue(JobQueueId, out token))
return token;
else
return null;
}
public ReadOnlyCollection<JobQueueToken> GetQueues()
{
return _Cache.Values.ToList().AsReadOnly();
}
private IEnumerable<JobQueueToken> GetQueuesForSubject(string SubjectId)
{
List<JobQueueToken> tokens;
if (_SubjectCache.TryGetValue(SubjectId.ToLower(), out tokens))
return tokens;
else
return Enumerable.Empty<JobQueueToken>();
}
public ReadOnlyCollection<JobQueueToken> GetQueuesForSubject(IEnumerable<string> SubjectIds)
{
return SubjectIds.SelectMany(sid => GetQueuesForSubject(sid)).Distinct().ToList().AsReadOnly();
}
public void ReInitializeCache(DiscoDataContext Database)
{
Initialize(Database);
}
}
}
@@ -0,0 +1,39 @@
using Disco.Data.Repository;
using Disco.Services.Tasks;
using Quartz;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Disco.Services.Jobs.JobQueues
{
public class JobQueueDeleteTask : ScheduledTask
{
public override string TaskName { get { return "Job Queues - Delete Queue"; } }
public override bool SingleInstanceTask { get { return false; }}
public override bool CancelInitiallySupported { get { return false; } }
public override bool LogExceptionsOnly { get { return true; } }
protected override void ExecuteTask()
{
int jobQueueId = (int)this.ExecutionContext.JobDetail.JobDataMap["JobQueueId"];
using (DiscoDataContext Database = new DiscoDataContext())
{
JobQueueService.DeleteJobQueue(Database, jobQueueId, this.Status);
}
}
public static ScheduledTaskStatus ScheduleNow(int JobQueueId)
{
JobDataMap taskData = new JobDataMap() { { "JobQueueId", JobQueueId } };
var instance = new JobQueueDeleteTask();
return instance.ScheduleTask(taskData);
}
}
}
@@ -0,0 +1,187 @@
using Disco.Data.Repository;
using Disco.Models.Repository;
using Disco.Services.Authorization;
using Disco.Services.Tasks;
using Disco.Services.Users;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace Disco.Services.Jobs.JobQueues
{
public static class JobQueueService
{
private const string _cacheHttpRequestKey = "Disco_UserQueuesToken_{0}";
private static Cache _cache;
public static void Initialize(DiscoDataContext Database)
{
_cache = new Cache(Database);
}
public static ReadOnlyCollection<KeyValuePair<string, string>> IconColours { get { return _cache.IconColours; } }
public static ReadOnlyCollection<KeyValuePair<string, string>> Icons { get { return _cache.Icons; } }
public static ReadOnlyCollection<KeyValuePair<int, string>> SlaOptions { get { return _cache.SlaOptions; } }
public static ReadOnlyCollection<JobQueueToken> GetQueues() { return _cache.GetQueues(); }
public static JobQueueToken GetQueue(int JobQueueId) { return _cache.GetQueue(JobQueueId); }
#region Job Queues Maintenance
public static JobQueueToken CreateJobQueue(DiscoDataContext Database, JobQueue JobQueue)
{
// Verify
if (string.IsNullOrWhiteSpace(JobQueue.Name))
throw new ArgumentException("The Job Queue Name is required");
if (string.IsNullOrWhiteSpace(JobQueue.Description))
throw new ArgumentException("The Job Queue Description is required");
// Name Unique
if (_cache.GetQueues().Count(q => q.JobQueue.Name == JobQueue.Name) > 0)
throw new ArgumentException("Another Job Queue already exists with that name", "JobQueue");
// Clone to break reference
var queue = new JobQueue()
{
Name = JobQueue.Name,
Description = JobQueue.Description,
Icon = JobQueue.Icon,
IconColour = JobQueue.IconColour,
DefaultSLAExpiry = JobQueue.DefaultSLAExpiry,
Priority = JobQueue.Priority,
SubjectIds = JobQueue.SubjectIds
};
Database.JobQueues.Add(queue);
Database.SaveChanges();
return _cache.UpdateQueue(queue);
}
public static JobQueueToken UpdateJobQueue(DiscoDataContext Database, JobQueue JobQueue)
{
// Verify
if (string.IsNullOrWhiteSpace(JobQueue.Name))
throw new ArgumentException("The Job Queue Name is required");
if (string.IsNullOrWhiteSpace(JobQueue.Description))
throw new ArgumentException("The Job Queue Description is required");
// Name Unique
if (_cache.GetQueues().Count(q => q.JobQueue.Id != JobQueue.Id && q.JobQueue.Name == JobQueue.Name) > 0)
throw new ArgumentException("Another Job Queue already exists with that name", "JobQueue");
Database.SaveChanges();
return _cache.UpdateQueue(JobQueue);
}
public static void DeleteJobQueue(DiscoDataContext Database, int JobQueueId, ScheduledTaskStatus Status)
{
JobQueue queue = Database.JobQueues.Find(JobQueueId);
// Validate: Current Jobs?
int currentJobCount = Database.JobQueueJobs.Count(jqj => jqj.JobQueueId == queue.Id && jqj.RemovedDate.HasValue);
if (currentJobCount > 0)
throw new InvalidOperationException("The Job Queue cannot be deleted because it contains jobs");
// Delete History
Status.UpdateStatus(0, string.Format("Removing '{0}' [{1}] Job Queue", queue.Name, queue.Id), "Starting");
var jobQueueJobs = Database.JobQueueJobs.Include("Job").Where(jsj => jsj.JobQueueId == queue.Id).ToList();
if (jobQueueJobs.Count > 0)
{
double progressInterval = 90 / jobQueueJobs.Count;
for (int jqjIndex = 0; jqjIndex < jobQueueJobs.Count; jqjIndex++)
{
var jqj = jobQueueJobs[jqjIndex];
Status.UpdateStatus(jqjIndex * progressInterval, string.Format("Merging history into job #{0} logs", jqj.JobId));
// Write Logs
Database.JobLogs.Add(new JobLog()
{
JobId = jqj.JobId,
TechUserId = jqj.AddedUserId,
Timestamp = jqj.AddedDate,
Comments = string.Format("Added to Job Queue: {1}{0}Priority: {2}{0}Comment: {3}", Environment.NewLine, queue.Name, jqj.Priority.ToString(), string.IsNullOrWhiteSpace(jqj.AddedComment) ? "<none>" : jqj.AddedComment)
});
Database.JobLogs.Add(new JobLog()
{
JobId = jqj.JobId,
TechUserId = jqj.RemovedUserId,
Timestamp = jqj.RemovedDate.Value,
Comments = string.Format("Removed from Job Queue: {1}{0}Comment: {2}", Environment.NewLine, queue.Name, string.IsNullOrWhiteSpace(jqj.RemovedComment) ? "<none>" : jqj.RemovedComment)
});
// Delete JQJ
Database.JobQueueJobs.Remove(jqj);
// Save Changes
Database.SaveChanges();
}
}
// Delete Queue
Status.UpdateStatus(90, "Deleting Queue");
Database.JobQueues.Remove(queue);
Database.SaveChanges();
// Remove from Cache
_cache.RemoveQueue(JobQueueId);
Status.Finished(string.Format("Successfully Deleted Job Queue: '{0}' [{1}]", queue.Name, queue.Id));
}
#endregion
public static ReadOnlyCollection<JobQueueToken> UsersQueues(User User)
{
return UsersQueues(User.Id);
}
public static ReadOnlyCollection<JobQueueToken> UsersQueues(string UserId)
{
var userAuth = UserService.GetAuthorization(UserId);
return UsersQueues(userAuth);
}
public static ReadOnlyCollection<JobQueueToken> UsersQueues(AuthorizationToken UserAuthorization)
{
string cacheKey = string.Format(_cacheHttpRequestKey, UserAuthorization.User.Id);
ReadOnlyCollection<JobQueueToken> tokens = null;
// Check for ASP.NET
if (HttpContext.Current != null)
{
tokens = (ReadOnlyCollection<JobQueueToken>)HttpContext.Current.Items[_cacheHttpRequestKey];
}
if (tokens == null)
{
var subjectIds = (new string[] { UserAuthorization.User.Id }).Concat(UserAuthorization.GroupMembership);
tokens = _cache.GetQueuesForSubject(subjectIds);
HttpContext.Current.Items[_cacheHttpRequestKey] = tokens;
}
return tokens;
}
public static string RandomIcon()
{
var rnd = new Random();
var unusedIcons = _cache.Icons.Select(i => i.Key).Except(_cache.GetQueues().Select(q => q.JobQueue.Icon)).ToList();
if (unusedIcons.Count > 0)
return unusedIcons[rnd.Next(unusedIcons.Count - 1)];
else
return _cache.Icons[rnd.Next(_cache.Icons.Count - 1)].Key;
}
public static string RandomIconColour()
{
var rnd = new Random();
var unusedColours = _cache.IconColours.Select(i => i.Key).Except(_cache.GetQueues().Select(q => q.JobQueue.IconColour)).ToList();
if (unusedColours.Count > 0)
return unusedColours[rnd.Next(unusedColours.Count - 1)];
else
return _cache.IconColours[rnd.Next(_cache.IconColours.Count - 1)].Key;
}
}
}
@@ -0,0 +1,27 @@
using Disco.Models.Repository;
using Disco.Models.Services.Jobs.JobQueues;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
namespace Disco.Services.Jobs.JobQueues
{
public class JobQueueToken : IJobQueueToken
{
public JobQueue JobQueue { get; private set; }
internal HashSet<string> SubjectIdHashes { get; private set; }
public ReadOnlyCollection<string> SubjectIds { get; private set; }
public static JobQueueToken FromJobQueue(JobQueue JobQueue)
{
string[] sg = (JobQueue.SubjectIds == null ? new string[0] : JobQueue.SubjectIds.Split(',').ToArray());
return new JobQueueToken()
{
JobQueue = JobQueue,
SubjectIdHashes = new HashSet<string>(sg.Select(i => i.ToLower())),
SubjectIds = sg.ToList().AsReadOnly()
};
}
}
}
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.1128.1503")]
[assembly: AssemblyFileVersion("1.2.1128.1503")]
[assembly: AssemblyVersion("1.2.1229.1537")]
[assembly: AssemblyFileVersion("1.2.1229.1537")]
@@ -264,6 +264,10 @@ namespace Disco.Services.Tasks
{
Finished(this._finishedMessage, this._finishedUrl);
}
public void Finished(string FinishedMessage)
{
Finished(FinishedMessage, this._finishedUrl);
}
public void Finished(string FinishedMessage, string FinishedUrl)
{
List<string> changedProperties = new List<string>() { "IsRunning", "FinishedTimestamp" };
+5
View File
@@ -11,6 +11,11 @@
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
<package id="RazorGenerator.Mvc" version="2.1.2" targetFramework="net45" />
<package id="Rx-Core" version="2.1.30214.0" targetFramework="net45" />
<package id="Rx-Interfaces" version="2.1.30214.0" targetFramework="net45" />
<package id="Rx-Linq" version="2.1.30214.0" targetFramework="net45" />
<package id="Rx-Main" version="2.1.30214.0" targetFramework="net45" />
<package id="Rx-PlatformServices" version="2.1.30214.0" targetFramework="net45" />
<package id="SqlServerCompact" version="4.0.8854.1" targetFramework="net40" />
<package id="WebActivatorEx" version="2.0.3" targetFramework="net45" />
</packages>
@@ -9,22 +9,39 @@ namespace Disco.Web.Extensions
{
public static class JobSubTypeExtensions
{
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobSubType> jobSubTypes, List<JobSubType> SelectedItems)
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobSubType> jobSubTypes, IEnumerable<JobSubType> SelectedItems, bool IncludeQueueIcons = false)
{
List<string> selectedIds = default(List<string>);
if (SelectedItems != null)
selectedIds = SelectedItems.Select(i => string.Format("{0}_{1}", i.JobTypeId, i.Id)).ToList();
return jobSubTypes.ToSelectListItems(selectedIds);
}
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobSubType> jobSubTypes, List<string> SelectedIds = null)
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobSubType> jobSubTypes, List<string> SelectedIds = null, bool IncludeQueueIcons = false)
{
if (SelectedIds == null)
return jobSubTypes.Select(jst => new SelectListItem { Value = string.Format("{0}_{1}", jst.JobTypeId, jst.Id), Text = jst.Description }).ToList();
return jobSubTypes.Select(jst => new SelectListItem { Value = string.Format("{0}_{1}", jst.JobTypeId, jst.Id), Text = IncludeQueueIcons ? jst.DescriptionWithIcons() : jst.Description }).ToList();
else
return jobSubTypes.Select(jst => new SelectListItem { Value = string.Format("{0}_{1}", jst.JobTypeId, jst.Id), Text = jst.Description, Selected = (SelectedIds.Contains(string.Format("{0}_{1}", jst.JobTypeId, jst.Id))) }).ToList();
return jobSubTypes.Select(jst => new SelectListItem { Value = string.Format("{0}_{1}", jst.JobTypeId, jst.Id), Text = IncludeQueueIcons ? jst.DescriptionWithIcons() : jst.Description, Selected = (SelectedIds.Contains(string.Format("{0}_{1}", jst.JobTypeId, jst.Id))) }).ToList();
}
public static string DescriptionWithIcons(this JobSubType jst)
{
if (jst.JobQueues.Count > 0)
{
var sb = new System.Text.StringBuilder(System.Web.HttpUtility.HtmlEncode(jst.Description));
foreach (var jq in jst.JobQueues)
sb.AppendFormat("&nbsp;<i class=\"fa fa-{0} fa-fw d-{1}\" title=\"{2}\"></i>", jq.Icon, jq.IconColour, jq.Name);
return sb.ToString();
}
else
{
return System.Web.HttpUtility.HtmlEncode(jst.Description);
}
}
}
}
@@ -27,7 +27,7 @@ namespace Disco.Web.Extensions
return jobTypes.Select(jt => new SelectListItem { Value = jt.Id, Text = jt.Description, Selected = (SelectedId == jt.Id) }).ToList();
}
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobType> jobTypes, List<JobType> SelectedItems)
public static List<SelectListItem> ToSelectListItems(this IEnumerable<JobType> jobTypes, IEnumerable<JobType> SelectedItems)
{
List<string> selectedIds = default(List<string>);
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.1128.1503")]
[assembly: AssemblyFileVersion("1.2.1128.1503")]
[assembly: AssemblyVersion("1.2.1229.1537")]
[assembly: AssemblyFileVersion("1.2.1229.1537")]
+21 -18
View File
@@ -6,19 +6,19 @@
@using System.Web.Mvc
@using System.Web.Mvc.Html;
@using Disco.Services.Web;
@helper FriendlyDate(DateTime d, string ElementId = null)
{<span @(ElementId == null ? null : new HtmlString(string.Format("id=\"{0}\" ", ElementId)))title="@d.ToFullDateTime()" data-discodatetime="@d.ToSortable()" data-datetimeformatted="@d.ToJavaScript()" class="date nowrap">@d.FromNow()</span>}
@helper FriendlyDate(DateTime? d, string NullValue = "n/a", string ElementId = null)
{<span @(ElementId == null ? null : new HtmlString(string.Format("id=\"{0}\" ", ElementId)))title="@d.ToFullDateTime(NullValue)" data-discodatetime="@d.ToSortable()" data-datetimeformatted="@d.ToJavaScript()" class="date nowrap">@d.FromNow(NullValue)</span>}
@helper FriendlyDate(DateTime d, string ElementId = null, bool WithoutSuffix = false)
{<span @(ElementId == null ? null : new HtmlString(string.Format("id=\"{0}\" ", ElementId)))title="@d.ToFullDateTime()" data-discodatetime="@d.ToSortable()" data-datetimeformatted="@d.ToJavaScript()" class="date nowrap">@d.FromNow(WithoutSuffix)</span>}
@helper FriendlyDate(DateTime? d, string NullValue = "n/a", string ElementId = null, bool WithoutSuffix = false)
{<span @(ElementId == null ? null : new HtmlString(string.Format("id=\"{0}\" ", ElementId)))title="@d.ToFullDateTime(NullValue)" data-discodatetime="@d.ToSortable()" data-datetimeformatted="@d.ToJavaScript()" class="date nowrap">@d.FromNow(WithoutSuffix, NullValue)</span>}
@helper RadioButtonList(string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1)
{
@ItemList("radio", id, items, columns)
}
@helper CheckBoxList(string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1, bool alignEven = true, int? forceUniqueIds = null)
@helper CheckBoxList(string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1, bool alignEven = true, int? forceUniqueIds = null, bool htmlEncodeText = true)
{
@ItemList("checkbox", id, items, columns, alignEven, forceUniqueIds)
@ItemList("checkbox", id, items, columns, alignEven, forceUniqueIds, htmlEncodeText)
}
@helper ItemList(string inputType, string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1, bool alignEven = true, int? forceUniqueIds = null)
@helper ItemList(string inputType, string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1, bool alignEven = true, int? forceUniqueIds = null, bool htmlEncodeText = true)
{
int itemsPerColumn = items.Count / columns;
int columnWidth = (100 / columns);
@@ -37,7 +37,10 @@
itemNextId++;
var itemId = forceUniqueIds.HasValue ? string.Format("{0}_{1}_{2}", id, item.Value, forceUniqueIds++) : string.Format("{0}_{1}", id, item.Value);
<li>
<input id="@itemId" name="@id" value="@item.Value" type="@inputType" @(item.Selected ? new HtmlString("checked=\"checked\" ") : null)/><label for="@itemId">@item.Text</label></li>
<input id="@itemId" name="@id" value="@item.Value" type="@inputType" @(item.Selected ? new HtmlString("checked=\"checked\" ") : null)/><label for="@itemId">@if (htmlEncodeText)
{ @item.Text }
else
{ @(new HtmlString(item.Text)) }</label></li>
}
}
</ul>
@@ -46,23 +49,23 @@
</tr>
</table>
}
@helper FriendlyDateAndUser(DateTime? d, User u, string DateNullValue = "n/a")
@helper FriendlyDateAndUser(DateTime? d, User u, string DateNullValue = "n/a", bool WithoutSuffix = false)
{
@FriendlyDate(d, DateNullValue);
@FriendlyUser(u, null, "by");
@FriendlyDate(d, DateNullValue, WithoutSuffix: WithoutSuffix);
@FriendlyUser(u, null, " by");
}
@helper FriendlyDateAndUser(DateTime d, User u)
@helper FriendlyDateAndUser(DateTime d, User u, bool WithoutSuffix = false)
{
@FriendlyDate(d);
@FriendlyUser(u, null, "by");
@FriendlyDate(d, WithoutSuffix: WithoutSuffix);
@FriendlyUser(u, null, " by");
}
@helper FriendlyDateAndTitleUser(DateTime? d, User u, string DateNullValue = "n/a")
@helper FriendlyDateAndTitleUser(DateTime? d, User u, string DateNullValue = "n/a", bool WithoutSuffix = false)
{
<span title="@d.ToFullDateTime(DateNullValue) by @u" data-discodatetime="@d.ToSortable()" class="date nowrap">@d.FromNow(DateNullValue)</span>
<span title="@d.ToFullDateTime(DateNullValue) by @u" data-discodatetime="@d.ToSortable()" class="date nowrap">@d.FromNow(WithoutSuffix, DateNullValue)</span>
}
@helper FriendlyDateAndTitleUser(DateTime d, User u)
@helper FriendlyDateAndTitleUser(DateTime d, User u, bool WithoutSuffix = false)
{
<span title="@d.ToFullDateTime() by @u" data-discodatetime="@d.ToSortable()" class="date nowrap">@d.FromNow()</span>
<span title="@d.ToFullDateTime() by @u" data-discodatetime="@d.ToSortable()" class="date nowrap">@d.FromNow(WithoutSuffix)</span>
}
@helper FriendlyUser(User u, string nullValue = null, string prepend = null)
{
+153 -120
View File
@@ -70,7 +70,7 @@ namespace Disco.Web
public class CommonHelpers : System.Web.WebPages.HelperPage
{
public static System.Web.WebPages.HelperResult FriendlyDate(DateTime d, string ElementId = null)
public static System.Web.WebPages.HelperResult FriendlyDate(DateTime d, string ElementId = null, bool WithoutSuffix = false)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
@@ -121,7 +121,7 @@ WriteLiteralTo(@__razor_helper_writer, "\" class=\"date nowrap\">");
#line 10 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, d.FromNow());
WriteTo(@__razor_helper_writer, d.FromNow(WithoutSuffix));
#line default
#line hidden
@@ -131,16 +131,16 @@ WriteLiteralTo(@__razor_helper_writer, "</span>");
#line 10 "..\..\App_Code\CommonHelpers.cshtml"
#line default
#line hidden
});
}
}
public static System.Web.WebPages.HelperResult FriendlyDate(DateTime? d, string NullValue = "n/a", string ElementId = null)
public static System.Web.WebPages.HelperResult FriendlyDate(DateTime? d, string NullValue = "n/a", string ElementId = null, bool WithoutSuffix = false)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
@@ -191,7 +191,7 @@ WriteLiteralTo(@__razor_helper_writer, "\" class=\"date nowrap\">");
#line 12 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, d.FromNow(NullValue));
WriteTo(@__razor_helper_writer, d.FromNow(WithoutSuffix, NullValue));
#line default
#line hidden
@@ -201,13 +201,13 @@ WriteLiteralTo(@__razor_helper_writer, "</span>");
#line 12 "..\..\App_Code\CommonHelpers.cshtml"
#line default
#line hidden
});
}
}
public static System.Web.WebPages.HelperResult RadioButtonList(string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1)
@@ -241,7 +241,7 @@ WriteTo(@__razor_helper_writer, ItemList("radio", id, items, columns));
}
public static System.Web.WebPages.HelperResult CheckBoxList(string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1, bool alignEven = true, int? forceUniqueIds = null)
public static System.Web.WebPages.HelperResult CheckBoxList(string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1, bool alignEven = true, int? forceUniqueIds = null, bool htmlEncodeText = true)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
@@ -255,14 +255,14 @@ return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
#line 19 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, ItemList("checkbox", id, items, columns, alignEven, forceUniqueIds));
WriteTo(@__razor_helper_writer, ItemList("checkbox", id, items, columns, alignEven, forceUniqueIds, htmlEncodeText));
#line default
#line hidden
#line 19 "..\..\App_Code\CommonHelpers.cshtml"
#line default
#line hidden
@@ -272,7 +272,7 @@ WriteTo(@__razor_helper_writer, ItemList("checkbox", id, items, columns, alignEv
}
public static System.Web.WebPages.HelperResult ItemList(string inputType, string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1, bool alignEven = true, int? forceUniqueIds = null)
public static System.Web.WebPages.HelperResult ItemList(string inputType, string id, List<System.Web.Mvc.SelectListItem> items, int columns = 1, bool alignEven = true, int? forceUniqueIds = null, bool htmlEncodeText = true)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
@@ -384,21 +384,54 @@ WriteLiteralTo(@__razor_helper_writer, "/><label for=\"");
#line default
#line hidden
WriteLiteralTo(@__razor_helper_writer, "\">");
#line 40 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, item.Text);
WriteLiteralTo(@__razor_helper_writer, "\">");
#line default
#line hidden
#line 40 "..\..\App_Code\CommonHelpers.cshtml"
if (htmlEncodeText)
{
#line default
#line hidden
#line 41 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, item.Text);
#line default
#line hidden
#line 41 "..\..\App_Code\CommonHelpers.cshtml"
}
else
{
#line default
#line hidden
#line 43 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, new HtmlString(item.Text));
#line default
#line hidden
#line 43 "..\..\App_Code\CommonHelpers.cshtml"
}
#line default
#line hidden
WriteLiteralTo(@__razor_helper_writer, "</label></li>\r\n");
#line 41 "..\..\App_Code\CommonHelpers.cshtml"
#line 44 "..\..\App_Code\CommonHelpers.cshtml"
}
@@ -409,7 +442,7 @@ WriteLiteralTo(@__razor_helper_writer, " </ul>\r\n
#line 45 "..\..\App_Code\CommonHelpers.cshtml"
#line 48 "..\..\App_Code\CommonHelpers.cshtml"
}
#line default
@@ -419,7 +452,7 @@ WriteLiteralTo(@__razor_helper_writer, " </tr>\r\n </table>\r\n");
#line 48 "..\..\App_Code\CommonHelpers.cshtml"
#line 51 "..\..\App_Code\CommonHelpers.cshtml"
#line default
#line hidden
@@ -429,87 +462,42 @@ WriteLiteralTo(@__razor_helper_writer, " </tr>\r\n </table>\r\n");
}
public static System.Web.WebPages.HelperResult FriendlyDateAndUser(DateTime? d, User u, string DateNullValue = "n/a")
public static System.Web.WebPages.HelperResult FriendlyDateAndUser(DateTime? d, User u, string DateNullValue = "n/a", bool WithoutSuffix = false)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
#line 50 "..\..\App_Code\CommonHelpers.cshtml"
#line 53 "..\..\App_Code\CommonHelpers.cshtml"
#line default
#line hidden
#line 51 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, FriendlyDate(d, DateNullValue));
#line 54 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, FriendlyDate(d, DateNullValue, WithoutSuffix: WithoutSuffix));
#line default
#line hidden
#line 51 "..\..\App_Code\CommonHelpers.cshtml"
;
#line 54 "..\..\App_Code\CommonHelpers.cshtml"
;
#line default
#line hidden
#line 52 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, FriendlyUser(u, null, "by"));
#line default
#line hidden
#line 52 "..\..\App_Code\CommonHelpers.cshtml"
;
#line default
#line hidden
});
}
public static System.Web.WebPages.HelperResult FriendlyDateAndUser(DateTime d, User u)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
#line 55 "..\..\App_Code\CommonHelpers.cshtml"
#line default
#line hidden
#line 56 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, FriendlyDate(d));
WriteTo(@__razor_helper_writer, FriendlyUser(u, null, " by"));
#line default
#line hidden
#line 56 "..\..\App_Code\CommonHelpers.cshtml"
;
#line default
#line hidden
#line 57 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, FriendlyUser(u, null, "by"));
#line default
#line hidden
#line 57 "..\..\App_Code\CommonHelpers.cshtml"
;
#line 55 "..\..\App_Code\CommonHelpers.cshtml"
;
#line default
#line hidden
@@ -519,13 +507,58 @@ WriteTo(@__razor_helper_writer, FriendlyUser(u, null, "by"));
}
public static System.Web.WebPages.HelperResult FriendlyDateAndTitleUser(DateTime? d, User u, string DateNullValue = "n/a")
public static System.Web.WebPages.HelperResult FriendlyDateAndUser(DateTime d, User u, bool WithoutSuffix = false)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
#line 58 "..\..\App_Code\CommonHelpers.cshtml"
#line default
#line hidden
#line 59 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, FriendlyDate(d, WithoutSuffix: WithoutSuffix));
#line default
#line hidden
#line 59 "..\..\App_Code\CommonHelpers.cshtml"
;
#line default
#line hidden
#line 60 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, FriendlyUser(u, null, " by"));
#line default
#line hidden
#line 60 "..\..\App_Code\CommonHelpers.cshtml"
;
#line default
#line hidden
});
}
public static System.Web.WebPages.HelperResult FriendlyDateAndTitleUser(DateTime? d, User u, string DateNullValue = "n/a", bool WithoutSuffix = false)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
#line 63 "..\..\App_Code\CommonHelpers.cshtml"
#line default
@@ -535,7 +568,7 @@ WriteLiteralTo(@__razor_helper_writer, " <span title=\"");
#line 61 "..\..\App_Code\CommonHelpers.cshtml"
#line 64 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, d.ToFullDateTime(DateNullValue));
#line default
@@ -545,7 +578,7 @@ WriteLiteralTo(@__razor_helper_writer, " by ");
#line 61 "..\..\App_Code\CommonHelpers.cshtml"
#line 64 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, u);
#line default
@@ -555,7 +588,7 @@ WriteLiteralTo(@__razor_helper_writer, "\" data-discodatetime=\"");
#line 61 "..\..\App_Code\CommonHelpers.cshtml"
#line 64 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, d.ToSortable());
#line default
@@ -565,8 +598,8 @@ WriteLiteralTo(@__razor_helper_writer, "\" class=\"date nowrap\">");
#line 61 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, d.FromNow(DateNullValue));
#line 64 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, d.FromNow(WithoutSuffix, DateNullValue));
#line default
#line hidden
@@ -575,7 +608,7 @@ WriteLiteralTo(@__razor_helper_writer, "</span>\r\n");
#line 62 "..\..\App_Code\CommonHelpers.cshtml"
#line 65 "..\..\App_Code\CommonHelpers.cshtml"
#line default
#line hidden
@@ -585,13 +618,13 @@ WriteLiteralTo(@__razor_helper_writer, "</span>\r\n");
}
public static System.Web.WebPages.HelperResult FriendlyDateAndTitleUser(DateTime d, User u)
public static System.Web.WebPages.HelperResult FriendlyDateAndTitleUser(DateTime d, User u, bool WithoutSuffix = false)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
#line 64 "..\..\App_Code\CommonHelpers.cshtml"
#line 67 "..\..\App_Code\CommonHelpers.cshtml"
#line default
@@ -601,7 +634,7 @@ WriteLiteralTo(@__razor_helper_writer, " <span title=\"");
#line 65 "..\..\App_Code\CommonHelpers.cshtml"
#line 68 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, d.ToFullDateTime());
#line default
@@ -611,7 +644,7 @@ WriteLiteralTo(@__razor_helper_writer, " by ");
#line 65 "..\..\App_Code\CommonHelpers.cshtml"
#line 68 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, u);
#line default
@@ -621,7 +654,7 @@ WriteLiteralTo(@__razor_helper_writer, "\" data-discodatetime=\"");
#line 65 "..\..\App_Code\CommonHelpers.cshtml"
#line 68 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, d.ToSortable());
#line default
@@ -631,8 +664,8 @@ WriteLiteralTo(@__razor_helper_writer, "\" class=\"date nowrap\">");
#line 65 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, d.FromNow());
#line 68 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, d.FromNow(WithoutSuffix));
#line default
#line hidden
@@ -641,7 +674,7 @@ WriteLiteralTo(@__razor_helper_writer, "</span>\r\n");
#line 66 "..\..\App_Code\CommonHelpers.cshtml"
#line 69 "..\..\App_Code\CommonHelpers.cshtml"
#line default
#line hidden
@@ -657,7 +690,7 @@ return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
#line 68 "..\..\App_Code\CommonHelpers.cshtml"
#line 71 "..\..\App_Code\CommonHelpers.cshtml"
if (u != null)
{
@@ -666,7 +699,7 @@ return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
#line hidden
#line 71 "..\..\App_Code\CommonHelpers.cshtml"
#line 74 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, prepend);
#line default
@@ -677,7 +710,7 @@ WriteLiteralTo(@__razor_helper_writer, " <span title=\"");
#line 71 "..\..\App_Code\CommonHelpers.cshtml"
#line 74 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, u);
#line default
@@ -687,7 +720,7 @@ WriteLiteralTo(@__razor_helper_writer, "\">");
#line 71 "..\..\App_Code\CommonHelpers.cshtml"
#line 74 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, u.Id);
#line default
@@ -697,7 +730,7 @@ WriteLiteralTo(@__razor_helper_writer, "</span>\r\n");
#line 72 "..\..\App_Code\CommonHelpers.cshtml"
#line 75 "..\..\App_Code\CommonHelpers.cshtml"
}
else
{
@@ -709,7 +742,7 @@ WriteLiteralTo(@__razor_helper_writer, " <span>");
#line 75 "..\..\App_Code\CommonHelpers.cshtml"
#line 78 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, nullValue);
#line default
@@ -719,7 +752,7 @@ WriteLiteralTo(@__razor_helper_writer, "</span>\r\n");
#line 76 "..\..\App_Code\CommonHelpers.cshtml"
#line 79 "..\..\App_Code\CommonHelpers.cshtml"
}
#line default
@@ -736,7 +769,7 @@ return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
#line 79 "..\..\App_Code\CommonHelpers.cshtml"
#line 82 "..\..\App_Code\CommonHelpers.cshtml"
for (int index = 0; index < BreadCrumbs.Count; index++)
{
@@ -751,7 +784,7 @@ WriteLiteralTo(@__razor_helper_writer, " <span>&gt;</span>\r\n");
#line 86 "..\..\App_Code\CommonHelpers.cshtml"
#line 89 "..\..\App_Code\CommonHelpers.cshtml"
}
if (breadCrumb.Item2 == null)
{
@@ -760,14 +793,14 @@ WriteLiteralTo(@__razor_helper_writer, " <span>&gt;</span>\r\n");
#line hidden
#line 89 "..\..\App_Code\CommonHelpers.cshtml"
#line 92 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, breadCrumb.Item1);
#line default
#line hidden
#line 89 "..\..\App_Code\CommonHelpers.cshtml"
#line 92 "..\..\App_Code\CommonHelpers.cshtml"
}
else
@@ -777,14 +810,14 @@ WriteTo(@__razor_helper_writer, breadCrumb.Item1);
#line hidden
#line 93 "..\..\App_Code\CommonHelpers.cshtml"
#line 96 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, Html.GetPageHelper().ActionLink(breadCrumb.Item1, breadCrumb.Item2));
#line default
#line hidden
#line 93 "..\..\App_Code\CommonHelpers.cshtml"
#line 96 "..\..\App_Code\CommonHelpers.cshtml"
}
}
@@ -803,21 +836,21 @@ return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
#line 98 "..\..\App_Code\CommonHelpers.cshtml"
#line 101 "..\..\App_Code\CommonHelpers.cshtml"
#line default
#line hidden
#line 99 "..\..\App_Code\CommonHelpers.cshtml"
#line 102 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, Title);
#line default
#line hidden
#line 99 "..\..\App_Code\CommonHelpers.cshtml"
#line 102 "..\..\App_Code\CommonHelpers.cshtml"
#line default
@@ -834,7 +867,7 @@ return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
#line 102 "..\..\App_Code\CommonHelpers.cshtml"
#line 105 "..\..\App_Code\CommonHelpers.cshtml"
for (int index = 0; index < BreadCrumbs.Count; index++)
{
@@ -846,14 +879,14 @@ return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
#line hidden
#line 108 "..\..\App_Code\CommonHelpers.cshtml"
#line 111 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, new HtmlString(" > "));
#line default
#line hidden
#line 108 "..\..\App_Code\CommonHelpers.cshtml"
#line 111 "..\..\App_Code\CommonHelpers.cshtml"
}
@@ -861,14 +894,14 @@ WriteTo(@__razor_helper_writer, new HtmlString(" > "));
#line hidden
#line 110 "..\..\App_Code\CommonHelpers.cshtml"
#line 113 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, breadCrumb.Item1);
#line default
#line hidden
#line 110 "..\..\App_Code\CommonHelpers.cshtml"
#line 113 "..\..\App_Code\CommonHelpers.cshtml"
}
@@ -886,21 +919,21 @@ return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
#line 114 "..\..\App_Code\CommonHelpers.cshtml"
#line 117 "..\..\App_Code\CommonHelpers.cshtml"
#line default
#line hidden
#line 115 "..\..\App_Code\CommonHelpers.cshtml"
#line 118 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, Title);
#line default
#line hidden
#line 115 "..\..\App_Code\CommonHelpers.cshtml"
#line 118 "..\..\App_Code\CommonHelpers.cshtml"
#line default
@@ -917,7 +950,7 @@ return new System.Web.WebPages.HelperResult(__razor_helper_writer => {
#line 118 "..\..\App_Code\CommonHelpers.cshtml"
#line 121 "..\..\App_Code\CommonHelpers.cshtml"
Html.GetPageHelper().BundleDeferred("~/ClientScripts/Modules/Disco-jQueryExtensions");
#line default
@@ -927,7 +960,7 @@ WriteLiteralTo(@__razor_helper_writer, " <span id=\"");
#line 119 "..\..\App_Code\CommonHelpers.cshtml"
#line 122 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, BulkSelectContainerId);
#line default
@@ -937,7 +970,7 @@ WriteLiteralTo(@__razor_helper_writer, "\" class=\"checkboxBulkSelectContainer\"
#line 120 "..\..\App_Code\CommonHelpers.cshtml"
#line 123 "..\..\App_Code\CommonHelpers.cshtml"
if (string.IsNullOrWhiteSpace(ParentJQuerySelector))
{
@@ -948,7 +981,7 @@ WriteLiteralTo(@__razor_helper_writer, " <script type=\"text/javascri
#line 122 "..\..\App_Code\CommonHelpers.cshtml"
#line 125 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, BulkSelectContainerId);
#line default
@@ -958,7 +991,7 @@ WriteLiteralTo(@__razor_helper_writer, "\').checkboxBulkSelect(); });</script>\r
#line 123 "..\..\App_Code\CommonHelpers.cshtml"
#line 126 "..\..\App_Code\CommonHelpers.cshtml"
}
else
{
@@ -970,7 +1003,7 @@ WriteLiteralTo(@__razor_helper_writer, " <script type=\"text/javascri
#line 126 "..\..\App_Code\CommonHelpers.cshtml"
#line 129 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, BulkSelectContainerId);
#line default
@@ -980,7 +1013,7 @@ WriteLiteralTo(@__razor_helper_writer, "\').checkboxBulkSelect({ parentSelector:
#line 126 "..\..\App_Code\CommonHelpers.cshtml"
#line 129 "..\..\App_Code\CommonHelpers.cshtml"
WriteTo(@__razor_helper_writer, ParentJQuerySelector);
#line default
@@ -990,7 +1023,7 @@ WriteLiteralTo(@__razor_helper_writer, "\' }); });</script>\r\n");
#line 127 "..\..\App_Code\CommonHelpers.cshtml"
#line 130 "..\..\App_Code\CommonHelpers.cshtml"
}
#line default
@@ -1000,7 +1033,7 @@ WriteLiteralTo(@__razor_helper_writer, " </span>\r\n");
#line 129 "..\..\App_Code\CommonHelpers.cshtml"
#line 132 "..\..\App_Code\CommonHelpers.cshtml"
#line default
#line hidden
+4 -1
View File
@@ -56,7 +56,10 @@ namespace Disco.Web
// Initialize Expressions
BI.Expressions.Expression.InitializeExpressions();
// Initialize Warranty Providers Plugins
// Initialize Job Queues
Disco.Services.Jobs.JobQueues.JobQueueService.Initialize(Database);
// Initialize Plugins
Disco.Services.Plugins.Plugins.InitalizePlugins(Database);
// Initialize Scheduled Tasks
@@ -138,7 +138,7 @@ namespace Disco.Web.Areas.API.Controllers
return Update(id, pScope, Scope, redirect);
}
[DiscoAuthorize(Claims.Config.DocumentTemplate.Configure)]
public virtual ActionResult UpdateSubTypes(string id, List<string> SubTypes = null)
public virtual ActionResult UpdateJobSubTypes(string id, List<string> JobSubTypes = null, bool redirect = false)
{
try
{
@@ -146,13 +146,19 @@ namespace Disco.Web.Areas.API.Controllers
throw new ArgumentNullException("id");
var documentTemplate = Database.DocumentTemplates.Find(id);
UpdateSubTypes(documentTemplate, SubTypes);
UpdateJobSubTypes(documentTemplate, JobSubTypes);
return Json("OK", JsonRequestBehavior.AllowGet);
if (redirect)
return RedirectToAction(MVC.Config.DocumentTemplate.Index(documentTemplate.Id));
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
}
}
@@ -224,7 +230,7 @@ namespace Disco.Web.Areas.API.Controllers
Database.SaveChanges();
}
private void UpdateSubTypes(Disco.Models.Repository.DocumentTemplate documentTemplate, List<string> SubTypes)
private void UpdateJobSubTypes(Disco.Models.Repository.DocumentTemplate documentTemplate, List<string> JobSubTypes)
{
Database.Configuration.LazyLoadingEnabled = true;
@@ -236,10 +242,10 @@ namespace Disco.Web.Areas.API.Controllers
}
// Add New
if (SubTypes != null && SubTypes.Count > 0)
if (JobSubTypes != null && JobSubTypes.Count > 0)
{
var subTypes = new List<Disco.Models.Repository.JobSubType>();
foreach (var stId in SubTypes)
foreach (var stId in JobSubTypes)
{
var typeId = stId.Substring(0, stId.IndexOf("_"));
var subTypeId = stId.Substring(stId.IndexOf("_") + 1);
@@ -1690,9 +1690,9 @@ namespace Disco.Web.Areas.API.Controllers
Database.Configuration.LazyLoadingEnabled = true;
if (j != null)
{
if (j.CanForceClose())
if (j.CanCloseForced())
{
j.OnForceClose(Database, CurrentUser, Reason);
j.OnCloseForced(Database, CurrentUser, Reason);
Database.SaveChanges();
if (redirect.HasValue && redirect.Value)
@@ -1715,9 +1715,9 @@ namespace Disco.Web.Areas.API.Controllers
Database.Configuration.LazyLoadingEnabled = true;
if (j != null)
{
if (j.CanClose())
if (j.CanCloseNormally())
{
j.OnClose(CurrentUser);
j.OnCloseNormally(CurrentUser);
Database.SaveChanges();
if (redirect)
@@ -18,8 +18,6 @@ namespace Disco.Web.Areas.API.Controllers
Database.DiscoConfiguration.JobPreferences.LongRunningJobDaysThreshold = LongRunningJobDaysThreshold;
Database.SaveChanges();
Disco.Web.Controllers.JobController.ReInitializeLongRunningJobList(Database);
if (redirect)
return RedirectToAction(MVC.Config.JobPreferences.Index());
else
@@ -0,0 +1,393 @@
using Disco.BI.Interop.ActiveDirectory;
using Disco.Models.Interop.ActiveDirectory;
using Disco.Models.Repository;
using Disco.Services.Authorization;
using Disco.Services.Jobs.JobQueues;
using Disco.Services.Web;
using Disco.BI.Extensions;
using System;
using System.Linq;
using System.Web.Mvc;
using System.Collections.Generic;
namespace Disco.Web.Areas.API.Controllers
{
public partial class JobQueueController : AuthorizedDatabaseController
{
const string pName = "name";
const string pDescription = "description";
const string pIcon = "icon";
const string pIconColour = "iconcolour";
const string pPriority = "priority";
const string pDefaultSLAExpiry = "defaultslaexpiry";
[DiscoAuthorize(Claims.Config.JobQueue.Configure)]
public virtual ActionResult Update(int id, string key, string value = null, Nullable<bool> redirect = null)
{
Authorization.Require(Claims.Config.JobQueue.Configure);
try
{
if (id < 0)
throw new ArgumentOutOfRangeException("id");
if (string.IsNullOrEmpty(key))
throw new ArgumentNullException("key");
var jobQueue = Database.JobQueues.Find(id);
if (jobQueue != null)
{
switch (key.ToLower())
{
case pName:
UpdateName(jobQueue, value);
break;
case pDescription:
UpdateDescription(jobQueue, value);
break;
case pPriority:
UpdatePriority(jobQueue, value);
break;
case pIcon:
UpdateIcon(jobQueue, value);
break;
case pIconColour:
UpdateIconColour(jobQueue, value);
break;
case pDefaultSLAExpiry:
UpdateDefaultSLAExpiry(jobQueue, value);
break;
default:
throw new Exception("Invalid Update Key");
}
}
else
{
throw new Exception("Invalid Job Queue Id");
}
if (redirect.HasValue && redirect.Value)
return RedirectToAction(MVC.Config.JobQueue.Index(jobQueue.Id));
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
}
}
#region Update Shortcut Methods
[DiscoAuthorize(Claims.Config.JobQueue.Configure)]
public virtual ActionResult UpdateName(int id, string QueueName = null, Nullable<bool> redirect = null)
{
return Update(id, pName, QueueName, redirect);
}
[DiscoAuthorize(Claims.Config.JobQueue.Configure)]
public virtual ActionResult UpdateDescription(int id, string Description = null, Nullable<bool> redirect = null)
{
return Update(id, pDescription, Description, redirect);
}
[DiscoAuthorize(Claims.Config.JobQueue.Configure)]
public virtual ActionResult UpdatePriority(int id, string Priority = null, Nullable<bool> redirect = null)
{
return Update(id, pPriority, Priority, redirect);
}
[DiscoAuthorize(Claims.Config.JobQueue.Configure)]
public virtual ActionResult UpdateDefaultSLAExpiry(int id, string DefaultSLAExpiry = null, Nullable<bool> redirect = null)
{
return Update(id, pDefaultSLAExpiry, DefaultSLAExpiry, redirect);
}
[DiscoAuthorize(Claims.Config.JobQueue.Configure)]
public virtual ActionResult UpdateIcon(int id, string Icon = null, Nullable<bool> redirect = null)
{
return Update(id, pIcon, Icon, redirect);
}
[DiscoAuthorize(Claims.Config.JobQueue.Configure)]
public virtual ActionResult UpdateIconColour(int id, string IconColour = null, Nullable<bool> redirect = null)
{
return Update(id, pIconColour, IconColour, redirect);
}
[DiscoAuthorize(Claims.Config.JobQueue.Configure)]
public virtual ActionResult UpdateIconAndColour(int id, string Icon = null, string IconColour = null, bool redirect = false)
{
try
{
if (id < 0)
throw new ArgumentOutOfRangeException("id");
var jobQueue = Database.JobQueues.Find(id);
if (jobQueue != null)
{
UpdateIconAndColour(jobQueue, Icon, IconColour);
}
else
{
return Json("Invalid Job Queue Id", JsonRequestBehavior.AllowGet);
}
if (redirect)
return RedirectToAction(MVC.Config.JobQueue.Index(jobQueue.Id));
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
}
}
[DiscoAuthorize(Claims.Config.JobQueue.Configure)]
public virtual ActionResult UpdateSubjects(int id, string[] Subjects = null, bool redirect = false)
{
try
{
if (id < 0)
throw new ArgumentOutOfRangeException("id");
var jobQueue = Database.JobQueues.Find(id);
if (jobQueue != null)
{
UpdateSubjects(jobQueue, Subjects);
}
else
{
return Json("Invalid Job Queue Id", JsonRequestBehavior.AllowGet);
}
if (redirect)
return RedirectToAction(MVC.Config.JobQueue.Index(jobQueue.Id));
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
}
}
[DiscoAuthorize(Claims.Config.JobQueue.Configure)]
public virtual ActionResult UpdateJobSubTypes(int id, List<string> JobSubTypes = null, bool redirect = false)
{
try
{
var jobQueue = Database.JobQueues.Find(id);
if (jobQueue != null)
{
UpdateJobSubTypes(jobQueue, JobSubTypes);
}
else
{
return Json("Invalid Job Queue Id", JsonRequestBehavior.AllowGet);
}
if (redirect)
return RedirectToAction(MVC.Config.JobQueue.Index(jobQueue.Id));
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
if (redirect)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
}
}
#endregion
#region Update Properties
private void UpdateIconAndColour(JobQueue jobQueue, string Icon, string IconColour)
{
if (string.IsNullOrWhiteSpace(Icon))
throw new ArgumentNullException("Icon");
if (string.IsNullOrWhiteSpace(IconColour))
throw new ArgumentNullException("IconColour");
jobQueue.Icon = Icon;
jobQueue.IconColour = IconColour;
JobQueueService.UpdateJobQueue(Database, jobQueue);
}
private void UpdateIcon(JobQueue jobQueue, string Icon)
{
if (string.IsNullOrWhiteSpace(Icon))
throw new ArgumentNullException("Icon");
jobQueue.Icon = Icon;
JobQueueService.UpdateJobQueue(Database, jobQueue);
}
private void UpdateIconColour(JobQueue jobQueue, string IconColour)
{
if (string.IsNullOrWhiteSpace(IconColour))
throw new ArgumentNullException("IconColour");
jobQueue.IconColour = IconColour;
JobQueueService.UpdateJobQueue(Database, jobQueue);
}
private void UpdateName(JobQueue jobQueue, string Name)
{
jobQueue.Name = Name;
JobQueueService.UpdateJobQueue(Database, jobQueue);
}
private void UpdateDescription(JobQueue jobQueue, string Description)
{
jobQueue.Description = Description;
JobQueueService.UpdateJobQueue(Database, jobQueue);
}
private void UpdatePriority(JobQueue jobQueue, string Priority)
{
JobQueuePriority priority;
if (!Enum.TryParse<JobQueuePriority>(Priority, out priority))
throw new ArgumentException("Invalid Priority Value", "Priority");
jobQueue.Priority = priority;
JobQueueService.UpdateJobQueue(Database, jobQueue);
}
private void UpdateDefaultSLAExpiry(JobQueue jobQueue, string DefaultSLAExpiry)
{
int? defaultSLAExpiry = null;
if (!string.IsNullOrEmpty(DefaultSLAExpiry))
{
int intValue;
if (!int.TryParse(DefaultSLAExpiry, out intValue))
throw new ArgumentException("Invalid Default SLA Expiry Value", "DefaultSLAPriority");
if (intValue < 0)
throw new ArgumentException("Default SLA Expiry Value must be greater than zero", "DefaultSLAPriority");
// if intValue == 0, then no SLA.
if (intValue > 0)
defaultSLAExpiry = intValue;
}
jobQueue.DefaultSLAExpiry = defaultSLAExpiry;
JobQueueService.UpdateJobQueue(Database, jobQueue);
}
private void UpdateSubjects(JobQueue jobQueue, string[] Subjects)
{
string subjectIds = null;
// Validate Subjects
if (Subjects != null && Subjects.Length > 0)
{
var subjects = Subjects.Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => s.Trim()).Select(s => new Tuple<string, IActiveDirectoryObject>(s, ActiveDirectory.GetObject(s))).ToList();
var invalidSubjects = subjects.Where(s => s.Item2 == null).ToList();
if (invalidSubjects.Count > 0)
throw new ArgumentException(string.Format("Subjects not found: {0}", string.Join(", ", invalidSubjects)), "Subjects");
var proposedSubjects = subjects.Select(s => s.Item2.SamAccountName).OrderBy(s => s).ToArray();
subjectIds = string.Join(",", proposedSubjects);
if (string.IsNullOrEmpty(subjectIds))
subjectIds = null;
}
if (jobQueue.SubjectIds != subjectIds)
{
jobQueue.SubjectIds = subjectIds;
JobQueueService.UpdateJobQueue(Database, jobQueue);
}
}
private void UpdateJobSubTypes(Disco.Models.Repository.JobQueue jobQueue, List<string> JobSubTypes)
{
Database.Configuration.LazyLoadingEnabled = true;
// Remove All Existing
if (jobQueue.JobSubTypes != null)
{
foreach (var st in jobQueue.JobSubTypes.ToArray())
jobQueue.JobSubTypes.Remove(st);
}
// Add New
if (JobSubTypes != null && JobSubTypes.Count > 0)
{
var subTypes = new List<Disco.Models.Repository.JobSubType>();
foreach (var stId in JobSubTypes)
{
var typeId = stId.Substring(0, stId.IndexOf("_"));
var subTypeId = stId.Substring(stId.IndexOf("_") + 1);
var subType = Database.JobSubTypes.FirstOrDefault(jst => jst.JobTypeId == typeId && jst.Id == subTypeId);
subTypes.Add(subType);
}
jobQueue.JobSubTypes = subTypes;
}
Database.SaveChanges();
}
#endregion
#region Actions
[DiscoAuthorize(Claims.Config.JobQueue.Delete)]
public virtual ActionResult Delete(int id, Nullable<bool> redirect = false)
{
try
{
var jq = Database.JobQueues.Find(id);
if (jq != null)
{
var status = JobQueueDeleteTask.ScheduleNow(id);
status.SetFinishedUrl(Url.Action(MVC.Config.JobQueue.Index(null)));
if (redirect.HasValue && redirect.Value)
return RedirectToAction(MVC.Config.Logging.TaskStatus(status.SessionId));
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
throw new Exception("Invalid Job Queue Id");
}
catch (Exception ex)
{
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
}
}
#endregion
[DiscoAuthorize(Claims.Config.JobQueue.Configure)]
public virtual ActionResult SearchSubjects(string term)
{
var groupResults = BI.Interop.ActiveDirectory.ActiveDirectory.SearchGroups(term).Cast<IActiveDirectoryObject>();
var userResults = BI.Interop.ActiveDirectory.ActiveDirectory.SearchUsers(term).Cast<IActiveDirectoryObject>();
var results = groupResults.Concat(userResults).OrderBy(r => r.SamAccountName)
.Select(r => Models.JobQueue.SubjectItem.FromActiveDirectoryObject(r)).ToList();
return Json(results, JsonRequestBehavior.AllowGet);
}
[DiscoAuthorize(Claims.Config.JobQueue.Configure)]
public virtual ActionResult Subject(string Id)
{
var subject = ActiveDirectory.GetObject(Id);
if (subject == null || !(subject is ActiveDirectoryUserAccount || subject is ActiveDirectoryGroup))
return Json(null, JsonRequestBehavior.AllowGet);
else
return Json(Models.JobQueue.SubjectItem.FromActiveDirectoryObject(subject), JsonRequestBehavior.AllowGet);
}
}
}
@@ -0,0 +1,234 @@
using Disco.Models.Repository;
using Disco.Services.Authorization;
using Disco.Services.Jobs.JobQueues;
using Disco.BI.Extensions;
using Disco.Services.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Disco.Web.Areas.API.Controllers
{
public partial class JobQueueJobController : AuthorizedDatabaseController
{
const string pAddedComment = "addedcomment";
const string pRemovedComment = "removedcomment";
const string pSla = "sla";
const string pPriority = "priority";
public virtual ActionResult Update(int id, string key, string value = null, Nullable<bool> redirect = null)
{
try
{
if (id < 0)
throw new ArgumentOutOfRangeException("id");
if (string.IsNullOrEmpty(key))
throw new ArgumentNullException("key");
var jobQueueJob = Database.JobQueueJobs.Include("Job").FirstOrDefault(jqj => jqj.Id == id);
if (jobQueueJob != null)
{
switch (key.ToLower())
{
case pAddedComment:
UpdateAddedComment(jobQueueJob, value);
break;
case pRemovedComment:
UpdateRemovedComment(jobQueueJob, value);
break;
case pSla:
UpdateSla(jobQueueJob, value);
break;
case pPriority:
UpdatePriority(jobQueueJob, value);
break;
default:
throw new Exception("Invalid Update Key");
}
}
else
{
throw new Exception("Invalid Job Queue Job Id");
}
if (redirect.HasValue && redirect.Value)
return Redirect(string.Format("{0}#jobDetailTab-Queues", Url.Action(MVC.Job.Show(jobQueueJob.JobId))));
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
}
}
#region Update Shortcut Methods
[DiscoAuthorizeAny(Claims.Job.Properties.JobQueueProperties.EditAnyComments, Claims.Job.Properties.JobQueueProperties.EditOwnComments)]
public virtual ActionResult UpdateAddedComment(int id, string AddedComment = null, Nullable<bool> redirect = null)
{
return Update(id, pAddedComment, AddedComment, redirect);
}
[DiscoAuthorizeAny(Claims.Job.Properties.JobQueueProperties.EditAnyComments, Claims.Job.Properties.JobQueueProperties.EditOwnComments)]
public virtual ActionResult UpdateRemovedComment(int id, string RemovedComment = null, Nullable<bool> redirect = null)
{
return Update(id, pRemovedComment, RemovedComment, redirect);
}
[DiscoAuthorizeAny(Claims.Job.Properties.JobQueueProperties.EditAnySLA, Claims.Job.Properties.JobQueueProperties.EditOwnSLA)]
public virtual ActionResult UpdateSla(int id, string SLA = null, Nullable<bool> redirect = null)
{
return Update(id, pSla, SLA, redirect);
}
[DiscoAuthorizeAny(Claims.Job.Properties.JobQueueProperties.EditAnyPriority, Claims.Job.Properties.JobQueueProperties.EditOwnPriority)]
public virtual ActionResult UpdatePriority(int id, string Priority = null, Nullable<bool> redirect = null)
{
return Update(id, pPriority, Priority, redirect);
}
[DiscoAuthorizeAny(Claims.Job.Properties.JobQueueProperties.EditAnySLA, Claims.Job.Properties.JobQueueProperties.EditOwnSLA,
Claims.Job.Properties.JobQueueProperties.EditAnyPriority, Claims.Job.Properties.JobQueueProperties.EditOwnPriority)]
public virtual ActionResult UpdateSlaAndPriority(int id, string Sla = null, string Priority = null, Nullable<bool> redirect = null)
{
try
{
if (id < 0)
throw new ArgumentOutOfRangeException("id");
var jobQueueJob = Database.JobQueueJobs.Include("Job").FirstOrDefault(jqj => jqj.Id == id);
if (jobQueueJob != null)
{
UpdateSla(jobQueueJob, Sla);
UpdatePriority(jobQueueJob, Priority);
}
else
{
throw new Exception("Invalid Job Queue Job Id");
}
if (redirect.HasValue && redirect.Value)
return Redirect(string.Format("{0}#jobDetailTab-Queues", Url.Action(MVC.Job.Show(jobQueueJob.JobId))));
else
return Json("OK", JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
if (redirect.HasValue && redirect.Value)
throw;
else
return Json(string.Format("Error: {0}", ex.Message), JsonRequestBehavior.AllowGet);
}
}
#endregion
#region Update Properties
private void UpdateAddedComment(JobQueueJob jobQueueJob, string AddedComment)
{
if (!jobQueueJob.CanEditAddedComment())
throw new InvalidOperationException("Editing added comment for job queue job is Denied");
jobQueueJob.OnEditAddedComment(AddedComment);
Database.SaveChanges();
}
private void UpdateRemovedComment(JobQueueJob jobQueueJob, string RemovedComment)
{
if (!jobQueueJob.CanEditRemovedComment())
throw new InvalidOperationException("Editing removed comment for job queue job is Denied");
jobQueueJob.OnEditRemovedComment(RemovedComment);
Database.SaveChanges();
}
private void UpdateSla(JobQueueJob jobQueueJob, string Sla)
{
if (!jobQueueJob.CanEditSla())
throw new InvalidOperationException("Editing SLA for job queue job is Denied");
if (!string.IsNullOrEmpty(Sla))
{
DateTime SLADate;
if (DateTime.TryParse(Sla, out SLADate))
{
jobQueueJob.OnEditSla(SLADate);
Database.SaveChanges();
}
else
{
throw new ArgumentException("Unable to Parse SLA Date", "SLA");
}
}
else
{
jobQueueJob.OnEditSla(null);
Database.SaveChanges();
}
}
private void UpdatePriority(JobQueueJob jobQueueJob, string Priority)
{
if (!jobQueueJob.CanEditPriority())
throw new InvalidOperationException("Editing Priority for job queue job is Denied");
JobQueuePriority priority;
if (!Enum.TryParse<JobQueuePriority>(Priority, out priority))
throw new ArgumentException("Invalid Priority Value", "Priority");
jobQueueJob.OnEditPriority(priority);
Database.SaveChanges();
}
#endregion
#region Actions
[DiscoAuthorizeAny(Claims.Job.Actions.AddAnyQueues, Claims.Job.Actions.AddOwnQueues)]
public virtual ActionResult AddJob(int id, int JobId, string Comment, int? SLAExpiresMinutes, JobQueuePriority Priority)
{
DateTime? SLAExpires = (SLAExpiresMinutes.HasValue && SLAExpiresMinutes.Value > 0) ? DateTime.Now.AddMinutes(SLAExpiresMinutes.Value) : (DateTime?)null;
var jobQueueToken = JobQueueService.GetQueue(id);
if (jobQueueToken == null)
throw new ArgumentException("Invalid Job Queue Id", "id");
var job = Database.Jobs.Include("JobQueues").FirstOrDefault(j => j.Id == JobId);
if (job == null)
throw new ArgumentException("Invalid Job Id", "JobId");
if (!job.CanAddQueue(jobQueueToken.JobQueue))
throw new InvalidOperationException("Adding job to queue is Denied");
var jobQueueJob = job.OnAddQueue(Database, jobQueueToken.JobQueue, CurrentUser, Comment, SLAExpires, Priority);
Database.SaveChanges();
return Redirect(string.Format("{0}#jobDetailTab-Queues", Url.Action(MVC.Job.Show(job.Id))));
}
[DiscoAuthorizeAny(Claims.Job.Actions.RemoveAnyQueues, Claims.Job.Actions.RemoveOwnQueues)]
public virtual ActionResult RemoveJob(int id, string Comment, bool? CloseJob = null)
{
Database.Configuration.LazyLoadingEnabled = true;
var jobQueueJob = Database.JobQueueJobs.Find(id);
if (jobQueueJob == null)
throw new ArgumentException("Invalid Job Queue Job Id", "id");
if (!jobQueueJob.CanRemove())
throw new InvalidOperationException("Removing job from queue is Denied");
var job = Database.Jobs.Find(jobQueueJob.JobId);
if (job == null)
throw new ArgumentException("Invalid Job Id", "JobId");
jobQueueJob.OnRemove(CurrentUser, Comment);
Database.SaveChanges();
if (CloseJob.HasValue && CloseJob.Value && job.CanCloseNormally())
{
job.OnCloseNormally(CurrentUser);
Database.SaveChanges();
}
return Redirect(string.Format("{0}#jobDetailTab-Queues", Url.Action(MVC.Job.Show(job.Id))));
}
#endregion
}
}
@@ -1,4 +1,6 @@
using System;
using Disco.Models.BI.Search;
using Disco.Models.Services.Jobs.JobLists;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
@@ -18,7 +20,7 @@ namespace Disco.Web.Areas.API.Models.DocumentTemplate
label = string.Format("{0} - {1} - {2}", item.SerialNumber, item.ComputerName, item.DeviceModelDescription)
};
}
public static ImporterUndetectedDataIdLookupModel FromSearchResultItem(Disco.Models.BI.Job.JobTableModel.JobTableItemModel item)
public static ImporterUndetectedDataIdLookupModel FromSearchResultItem(JobTableItemModel item)
{
return new ImporterUndetectedDataIdLookupModel
{
@@ -26,7 +28,7 @@ namespace Disco.Web.Areas.API.Models.DocumentTemplate
label = string.Format("{0} ({1}; {2})", item.Id, item.DeviceSerialNumber, item.UserDisplayName)
};
}
public static ImporterUndetectedDataIdLookupModel FromSearchResultItem(Disco.Models.BI.Search.UserSearchResultItem item)
public static ImporterUndetectedDataIdLookupModel FromSearchResultItem(UserSearchResultItem item)
{
return new ImporterUndetectedDataIdLookupModel
{
@@ -0,0 +1,25 @@
using Disco.Models.Interop.ActiveDirectory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Disco.Web.Areas.API.Models.JobQueue
{
public class SubjectItem
{
public string Id { get; set; }
public string Name { get; set; }
public string Type { get; set; }
public static SubjectItem FromActiveDirectoryObject(IActiveDirectoryObject ADObject)
{
return new Models.JobQueue.SubjectItem()
{
Id = ADObject.SamAccountName,
Name = ADObject.Name,
Type = ADObject is ActiveDirectoryGroup ? "group" : "user"
};
}
}
}
@@ -104,6 +104,16 @@ namespace Disco.Web.Areas.Config
"Config/AuthorizationRole/{id}",
new { controller = "AuthorizationRole", action = "Index", id = UrlParameter.Optional }
);
context.MapRoute(
"Config_JobQueue_Create",
"Config/JobQueue/Create",
new { controller = "JobQueue", action = "Create", id = UrlParameter.Optional }
);
context.MapRoute(
"Config_JobQueue",
"Config/JobQueue/{id}",
new { controller = "JobQueue", action = "Index", id = UrlParameter.Optional }
);
context.MapRoute(
"Config_Plugins",
@@ -1,4 +1,4 @@
using Disco.Models.Authorization;
using Disco.Models.Services.Authorization;
using Disco.Models.UI.Config.AuthorizationRole;
using Disco.Services.Authorization;
using Disco.Services.Authorization.Roles;
@@ -92,7 +92,7 @@ namespace Disco.Web.Areas.Config.Controllers
}
else
{
ModelState.AddModelError("Name", "Am Authorization Role with this name already exists.");
ModelState.AddModelError("Name", "An Authorization Role with this name already exists.");
}
}
@@ -28,7 +28,7 @@ namespace Disco.Web.Areas.Config.Controllers
{
var m = new Models.DocumentTemplate.ShowModel()
{
DocumentTemplate = Database.DocumentTemplates.Include("JobSubTypes").Where(at => at.Id == id).FirstOrDefault()
DocumentTemplate = Database.DocumentTemplates.Include("JobSubTypes").FirstOrDefault(at => at.Id == id)
};
m.TemplateExpressions = m.DocumentTemplate.ExtractPdfExpressions(Database);
m.UpdateModel(Database);
@@ -0,0 +1,121 @@
using Disco.Models.Repository;
using Disco.Models.Services.Jobs.JobQueues;
using Disco.Models.UI.Config.JobQueue;
using Disco.Services.Authorization;
using Disco.Services.Jobs.JobQueues;
using Disco.Services.Plugins.Features.UIExtension;
using Disco.Services.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Disco.Web.Areas.Config.Controllers
{
public partial class JobQueueController : AuthorizedDatabaseController
{
[DiscoAuthorize(Claims.Config.JobQueue.Show)]
public virtual ActionResult Index(int? id)
{
if (id.HasValue)
{
// Show
var jq = Database.JobQueues.Include("JobSubTypes").FirstOrDefault(q => q.Id == id.Value);
if (jq == null)
throw new ArgumentException("Invalid Job Queue Id");
var token = JobQueueToken.FromJobQueue(jq);
var subjects = token.SubjectIds == null ? new List<Models.JobQueue.ShowModel.SubjectDescriptor>() :
token.SubjectIds.Select(subjectId => Disco.BI.Interop.ActiveDirectory.ActiveDirectory.GetObject(subjectId))
.Where(item => item != null)
.Select(item => Models.JobQueue.ShowModel.SubjectDescriptor.FromActiveDirectoryObject(item))
.OrderBy(item => item.Name).ToList();
var totalJobCount = Database.JobQueueJobs.Where(jqj => jqj.JobQueueId == id.Value).Select(jqj => jqj.Job).Distinct().Count();
var openJobCount = Database.JobQueueJobs.Count(jqj => jqj.JobQueueId == id.Value && !jqj.RemovedDate.HasValue);
var m = new Models.JobQueue.ShowModel()
{
Token = token,
Subjects = subjects,
TotalJobCount = totalJobCount,
OpenJobCount = openJobCount,
CanDelete = openJobCount == 0
};
if (Authorization.Has(Claims.Config.JobQueue.Configure))
{
m.JobTypes = Database.JobTypes.Include("JobSubTypes").ToList();
}
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigJobQueueShowModel>(this.ControllerContext, m);
return View(MVC.Config.JobQueue.Views.Show, m);
}
else
{
// List Index
var jqs = Database.JobQueues.ToList()
.Select(jq => JobQueueToken.FromJobQueue(jq)).Cast<IJobQueueToken>().ToList();
var m = new Models.JobQueue.IndexModel()
{
Tokens = jqs
};
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigJobQueueIndexModel>(this.ControllerContext, m);
return View(m);
}
}
[DiscoAuthorizeAll(Claims.Config.JobQueue.Create, Claims.Config.JobQueue.Configure)]
public virtual ActionResult Create()
{
// Default Queue
var m = new Models.JobQueue.CreateModel()
{
JobQueue = new Disco.Models.Repository.JobQueue()
{
Icon = JobQueueService.RandomIcon(),
IconColour = JobQueueService.RandomIconColour(),
Priority = JobQueuePriority.Normal
}
};
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigJobQueueCreateModel>(this.ControllerContext, m);
return View(m);
}
[DiscoAuthorizeAll(Claims.Config.JobQueue.Create, Claims.Config.JobQueue.Configure), HttpPost]
public virtual ActionResult Create(Models.JobQueue.CreateModel model)
{
if (ModelState.IsValid)
{
// Check for Existing
var existing = Database.JobQueues.Where(m => m.Name == model.JobQueue.Name).FirstOrDefault();
if (existing == null)
{
var token = JobQueueService.CreateJobQueue(Database, model.JobQueue);
return RedirectToAction(MVC.Config.JobQueue.Index(token.JobQueue.Id));
}
else
{
ModelState.AddModelError("Name", "A Job Queue with this name already exists.");
}
}
// UI Extensions
UIExtensions.ExecuteExtensions<ConfigJobQueueCreateModel>(this.ControllerContext, model);
return View(model);
}
}
}
@@ -4,7 +4,7 @@ using System.Linq;
using System.Web;
using Disco.Data.Repository;
using Disco.Models.UI.Config.AuthorizationRole;
using Disco.Models.Authorization;
using Disco.Models.Services.Authorization;
namespace Disco.Web.Areas.Config.Models.AuthorizationRole
{
@@ -1,4 +1,4 @@
using Disco.Models.Authorization;
using Disco.Models.Services.Authorization;
using Disco.Models.Interop.ActiveDirectory;
using Disco.Models.UI.Config.AuthorizationRole;
using Disco.Web.Models.Shared;

Some files were not shown because too many files have changed in this diff Show More