fix: simplify document template managed groups
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using Disco.Data.Repository;
|
||||
using Disco.Data.Repository.Monitor;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Models.Services.Documents;
|
||||
using Disco.Models.Services.Interop.ActiveDirectory;
|
||||
using Disco.Services.Expressions;
|
||||
using Disco.Services.Interop.ActiveDirectory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -157,128 +159,73 @@ namespace Disco.Services.Documents.ManagedGroups
|
||||
switch (DocumentTemplateScope)
|
||||
{
|
||||
case DocumentTemplate.DocumentTemplateScopes.Device:
|
||||
var deviceFilter = Database.DeviceAttachments.Include("Device").Where(a => a.DocumentTemplateId == DocumentTemplateId);
|
||||
|
||||
if (Configuration.FilterBeginDate.HasValue)
|
||||
{
|
||||
return Database.Devices
|
||||
.Where(d => d.DeviceDomainId != null && d.DeviceAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate))
|
||||
.Select(d => d.DeviceDomainId)
|
||||
deviceFilter = deviceFilter.Where(a => a.Timestamp >= Configuration.FilterBeginDate);
|
||||
}
|
||||
|
||||
return deviceFilter.Select(a => a.Device.DeviceDomainId)
|
||||
.Distinct()
|
||||
.ToList()
|
||||
.Where(ActiveDirectory.IsValidDomainAccountId)
|
||||
.Select(id => id + "$");
|
||||
}
|
||||
else
|
||||
{
|
||||
return Database.Devices
|
||||
.Where(d => d.DeviceDomainId != null && d.DeviceAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId))
|
||||
.Select(d => d.DeviceDomainId)
|
||||
.ToList()
|
||||
.Where(ActiveDirectory.IsValidDomainAccountId)
|
||||
.Select(id => id + "$");
|
||||
}
|
||||
case DocumentTemplate.DocumentTemplateScopes.Job:
|
||||
var jobFilter = Database.JobAttachments.Include("Job.Device").Where(a => a.DocumentTemplateId == DocumentTemplateId && a.Job.Device.DeviceDomainId != null);
|
||||
|
||||
if (Configuration.FilterBeginDate.HasValue)
|
||||
{
|
||||
return Database.Jobs
|
||||
.Where(j => j.Device.DeviceDomainId != null && j.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate))
|
||||
.Select(j => j.Device.DeviceDomainId)
|
||||
jobFilter = jobFilter.Where(a => a.Timestamp >= Configuration.FilterBeginDate);
|
||||
}
|
||||
|
||||
return jobFilter.Select(a => a.Job.Device.DeviceDomainId)
|
||||
.Distinct()
|
||||
.ToList()
|
||||
.Where(ActiveDirectory.IsValidDomainAccountId)
|
||||
.Select(id => id + "$");
|
||||
}
|
||||
else
|
||||
{
|
||||
return Database.Jobs
|
||||
.Where(j => j.Device.DeviceDomainId != null && j.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId))
|
||||
.Select(j => j.Device.DeviceDomainId)
|
||||
.Distinct()
|
||||
.ToList()
|
||||
.Where(ActiveDirectory.IsValidDomainAccountId)
|
||||
.Select(id => id + "$");
|
||||
}
|
||||
case DocumentTemplate.DocumentTemplateScopes.User:
|
||||
var userFilter = Database.UserAttachments.Include("User.Device.DeviceUserAssignments.Device").Where(a => a.DocumentTemplateId == DocumentTemplateId && a.User.DeviceUserAssignments.Where(ua => ua.UnassignedDate == null && ua.Device.DeviceDomainId != null).Any());
|
||||
|
||||
if (Configuration.FilterBeginDate.HasValue)
|
||||
{
|
||||
return Database.Users
|
||||
.Where(u => u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate))
|
||||
.SelectMany(u => u.DeviceUserAssignments.Where(dua => !dua.UnassignedDate.HasValue && dua.Device.DeviceDomainId != null), (u, dua) => dua.Device.DeviceDomainId)
|
||||
userFilter = userFilter.Where(a => a.Timestamp >= Configuration.FilterBeginDate);
|
||||
}
|
||||
|
||||
return userFilter.SelectMany(a => a.User.DeviceUserAssignments)
|
||||
.Where(a => a.UnassignedDate == null)
|
||||
.Select(a => a.Device.DeviceDomainId)
|
||||
.Distinct()
|
||||
.ToList()
|
||||
.Where(ActiveDirectory.IsValidDomainAccountId)
|
||||
.Select(id => id + "$");
|
||||
}
|
||||
else
|
||||
{
|
||||
return Database.Users
|
||||
.Where(u => u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId))
|
||||
.SelectMany(u => u.DeviceUserAssignments.Where(dua => !dua.UnassignedDate.HasValue && dua.Device.DeviceDomainId != null), (u, dua) => dua.Device.DeviceDomainId)
|
||||
.ToList()
|
||||
.Where(ActiveDirectory.IsValidDomainAccountId)
|
||||
.Select(id => id + "$");
|
||||
}
|
||||
default:
|
||||
return Enumerable.Empty<string>();
|
||||
}
|
||||
}
|
||||
|
||||
#region Device Scope
|
||||
private class ContainsAttachmentResult
|
||||
{
|
||||
public string Id;
|
||||
public bool HasAttachment;
|
||||
public string SerialNumber;
|
||||
public IEnumerable<ContainsAttachmentDeviceResult> Devices;
|
||||
}
|
||||
private class ContainsAttachmentDeviceResult
|
||||
{
|
||||
public string Id;
|
||||
public string SerialNumber;
|
||||
}
|
||||
|
||||
private bool DeviceContainsAttachment(DiscoDataContext Database, string DeviceSerialNumber, out string DeviceAccountId)
|
||||
{
|
||||
ContainsAttachmentResult result;
|
||||
var query = Database.DeviceAttachments.Include("Device")
|
||||
.Where(a => a.DocumentTemplateId == DocumentTemplateId && a.DeviceSerialNumber == DeviceSerialNumber && a.Device.DeviceDomainId != null);
|
||||
|
||||
if (Configuration.FilterBeginDate.HasValue)
|
||||
{
|
||||
result = Database.Devices
|
||||
.Where(d => d.SerialNumber == DeviceSerialNumber && d.DeviceDomainId != null)
|
||||
.Select(d => new ContainsAttachmentResult()
|
||||
{
|
||||
Id = d.DeviceDomainId,
|
||||
HasAttachment = d.DeviceAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)
|
||||
})
|
||||
.FirstOrDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = Database.Devices
|
||||
.Where(d => d.SerialNumber == DeviceSerialNumber && d.DeviceDomainId != null)
|
||||
.Select(d => new ContainsAttachmentResult()
|
||||
{
|
||||
Id = d.DeviceDomainId,
|
||||
HasAttachment = d.DeviceAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId)
|
||||
})
|
||||
.FirstOrDefault();
|
||||
query = query.Where(a => a.Timestamp >= Configuration.FilterBeginDate);
|
||||
}
|
||||
|
||||
if (result == null)
|
||||
var deviceDomainId = query.Select(a => a.Device.DeviceDomainId).FirstOrDefault();
|
||||
if (ActiveDirectory.IsValidDomainAccountId(deviceDomainId))
|
||||
{
|
||||
DeviceAccountId = deviceDomainId + "$";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
DeviceAccountId = null;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ActiveDirectory.IsValidDomainAccountId(result.Id))
|
||||
{
|
||||
DeviceAccountId = result.Id + "$";
|
||||
return result.HasAttachment;
|
||||
}
|
||||
else
|
||||
{
|
||||
DeviceAccountId = result.Id + "$";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessDeviceAttachmentAddEvent(RepositoryMonitorEvent e)
|
||||
@@ -307,55 +254,27 @@ namespace Disco.Services.Documents.ManagedGroups
|
||||
#region Job Scope
|
||||
private bool JobsContainAttachment(DiscoDataContext Database, int JobId, out string DeviceAccountId, out string DeviceSerialNumber)
|
||||
{
|
||||
ContainsAttachmentResult result;
|
||||
var query = Database.JobAttachments.Include("Job.Device")
|
||||
.Where(a => a.DocumentTemplateId == DocumentTemplateId && a.JobId == JobId && a.Job.Device.DeviceDomainId != null);
|
||||
|
||||
if (Configuration.FilterBeginDate.HasValue)
|
||||
{
|
||||
result = Database.Jobs
|
||||
.Where(j => j.Id == JobId && j.Device.DeviceDomainId != null)
|
||||
.Select(j => new ContainsAttachmentResult()
|
||||
{
|
||||
Id = j.Device.DeviceDomainId,
|
||||
SerialNumber = j.Device.SerialNumber,
|
||||
HasAttachment = j.Device.Jobs.Any(dj => dj.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate))
|
||||
})
|
||||
.FirstOrDefault();
|
||||
query = query.Where(a => a.Timestamp >= Configuration.FilterBeginDate);
|
||||
}
|
||||
|
||||
var deviceRecord = query.Select(a => Tuple.Create(a.Job.DeviceSerialNumber, a.Job.Device.DeviceDomainId)).FirstOrDefault();
|
||||
if (ActiveDirectory.IsValidDomainAccountId(deviceRecord.Item2))
|
||||
{
|
||||
DeviceSerialNumber = deviceRecord.Item1;
|
||||
DeviceAccountId = deviceRecord.Item2 + "$";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = Database.Jobs
|
||||
.Where(j => j.Id == JobId && j.Device.DeviceDomainId != null)
|
||||
.Select(j => new ContainsAttachmentResult()
|
||||
{
|
||||
Id = j.Device.DeviceDomainId,
|
||||
SerialNumber = j.Device.SerialNumber,
|
||||
HasAttachment = j.Device.Jobs.Any(dj => dj.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId))
|
||||
})
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
DeviceAccountId = null;
|
||||
DeviceSerialNumber = null;
|
||||
DeviceAccountId = null;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ActiveDirectory.IsValidDomainAccountId(result.Id))
|
||||
{
|
||||
DeviceAccountId = result.Id + "$";
|
||||
DeviceSerialNumber = result.SerialNumber;
|
||||
return result.HasAttachment;
|
||||
}
|
||||
else
|
||||
{
|
||||
DeviceAccountId = result.Id + "$";
|
||||
DeviceSerialNumber = result.SerialNumber;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessJobAttachmentAddEvent(RepositoryMonitorEvent e)
|
||||
@@ -390,48 +309,28 @@ namespace Disco.Services.Documents.ManagedGroups
|
||||
#region User Scope
|
||||
private bool DeviceUserContainAttachment(DiscoDataContext Database, string UserId, out List<Tuple<string, string>> Devices)
|
||||
{
|
||||
ContainsAttachmentResult result;
|
||||
var query = Database.UserAttachments.Include("User.DeviceUserAssignments.Device")
|
||||
.Where(a => a.DocumentTemplateId == DocumentTemplateId && a.UserId == UserId && a.User.DeviceUserAssignments.Any(d => d.UnassignedDate == null && d.Device.DeviceDomainId != null));
|
||||
|
||||
if (Configuration.FilterBeginDate.HasValue)
|
||||
{
|
||||
result = Database.Users
|
||||
.Where(u => u.UserId == UserId)
|
||||
.Select(u => new ContainsAttachmentResult()
|
||||
{
|
||||
HasAttachment = u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate),
|
||||
Devices = u.DeviceUserAssignments
|
||||
.Where(dua => !dua.UnassignedDate.HasValue && dua.Device.DeviceDomainId != null)
|
||||
.Select(dua => new ContainsAttachmentDeviceResult() { Id = dua.Device.DeviceDomainId, SerialNumber = dua.Device.SerialNumber })
|
||||
})
|
||||
.FirstOrDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
result = Database.Users
|
||||
.Where(u => u.UserId == UserId)
|
||||
.Select(u => new ContainsAttachmentResult()
|
||||
{
|
||||
HasAttachment = u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId),
|
||||
Devices = u.DeviceUserAssignments
|
||||
.Where(dua => !dua.UnassignedDate.HasValue && dua.Device.DeviceDomainId != null)
|
||||
.Select(dua => new ContainsAttachmentDeviceResult() { Id = dua.Device.DeviceDomainId, SerialNumber = dua.Device.SerialNumber })
|
||||
})
|
||||
.FirstOrDefault();
|
||||
query = query.Where(a => a.Timestamp >= Configuration.FilterBeginDate);
|
||||
}
|
||||
|
||||
if (result == null)
|
||||
var deviceRecords = query.Take(1).SelectMany(a => a.User.DeviceUserAssignments)
|
||||
.Where(a => a.UnassignedDate == null && a.Device.DeviceDomainId != null)
|
||||
.Select(a => new { a.Device.SerialNumber, a.Device.DeviceDomainId }).ToList()
|
||||
.Where(r => ActiveDirectory.IsValidDomainAccountId(r.DeviceDomainId)).ToList();
|
||||
if (deviceRecords.Count > 0)
|
||||
{
|
||||
Devices = deviceRecords.Select(r => Tuple.Create(r.DeviceDomainId + "$", r.SerialNumber)).ToList();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Devices = null;
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Devices = result.Devices
|
||||
.Where(d => ActiveDirectory.IsValidDomainAccountId(d.Id))
|
||||
.Select(d => new Tuple<string, string>(d.Id + "$", d.SerialNumber))
|
||||
.ToList();
|
||||
return result.HasAttachment;
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessUserAttachmentAddEvent(RepositoryMonitorEvent e)
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Disco.Data.Repository;
|
||||
using Disco.Data.Repository.Monitor;
|
||||
using Disco.Models.Repository;
|
||||
using Disco.Models.Services.Documents;
|
||||
using Disco.Models.Services.Interop.ActiveDirectory;
|
||||
using Disco.Services.Expressions;
|
||||
using Disco.Services.Interop.ActiveDirectory;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -152,84 +154,54 @@ namespace Disco.Services.Documents.ManagedGroups
|
||||
switch (DocumentTemplateScope)
|
||||
{
|
||||
case DocumentTemplate.DocumentTemplateScopes.Device:
|
||||
var deviceFilter = Database.DeviceAttachments.Include("Device").Where(a => a.DocumentTemplateId == DocumentTemplateId && a.Device.AssignedUserId != null);
|
||||
|
||||
if (Configuration.FilterBeginDate.HasValue)
|
||||
{
|
||||
return Database.Devices
|
||||
.Where(d => d.AssignedUserId != null && d.DeviceAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate))
|
||||
.Select(d => d.AssignedUserId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Database.Devices
|
||||
.Where(d => d.AssignedUserId != null && d.DeviceAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId))
|
||||
.Select(d => d.AssignedUserId);
|
||||
deviceFilter = deviceFilter.Where(a => a.Timestamp >= Configuration.FilterBeginDate);
|
||||
}
|
||||
|
||||
return deviceFilter.Select(a => a.Device.AssignedUserId).Distinct();
|
||||
case DocumentTemplate.DocumentTemplateScopes.Job:
|
||||
var jobFilter = Database.JobAttachments.Include("Job").Where(a => a.DocumentTemplateId == DocumentTemplateId && a.Job.UserId != null);
|
||||
|
||||
if (Configuration.FilterBeginDate.HasValue)
|
||||
{
|
||||
return Database.Jobs
|
||||
.Where(j => j.UserId != null && j.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate))
|
||||
.Select(j => j.UserId)
|
||||
.Distinct();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Database.Jobs
|
||||
.Where(j => j.UserId != null && j.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId))
|
||||
.Select(j => j.UserId)
|
||||
.Distinct();
|
||||
jobFilter = jobFilter.Where(a => a.Timestamp >= Configuration.FilterBeginDate);
|
||||
}
|
||||
|
||||
return jobFilter.Select(a => a.Job.UserId).Distinct();
|
||||
case DocumentTemplate.DocumentTemplateScopes.User:
|
||||
var userFilter = Database.UserAttachments.Include("User").Where(a => a.DocumentTemplateId == DocumentTemplateId && a.User.UserId != null);
|
||||
|
||||
if (Configuration.FilterBeginDate.HasValue)
|
||||
{
|
||||
return Database.Users
|
||||
.Where(u => u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate))
|
||||
.Select(u => u.UserId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Database.Users
|
||||
.Where(u => u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId))
|
||||
.Select(u => u.UserId);
|
||||
userFilter = userFilter.Where(a => a.Timestamp >= Configuration.FilterBeginDate);
|
||||
}
|
||||
|
||||
return userFilter.Select(a => a.UserId).Distinct();
|
||||
default:
|
||||
return Enumerable.Empty<string>();
|
||||
}
|
||||
}
|
||||
|
||||
#region Device Scope
|
||||
private class ContainsAttachmentResult
|
||||
{
|
||||
public string Id;
|
||||
public bool HasAttachment;
|
||||
}
|
||||
|
||||
private bool DeviceContainsAttachment(DiscoDataContext Database, string DeviceSerialNumber, out string UserId)
|
||||
{
|
||||
ContainsAttachmentResult result;
|
||||
var query = Database.DeviceAttachments
|
||||
.Include("Device")
|
||||
.Where(da => da.DocumentTemplateId == DocumentTemplateId && da.DeviceSerialNumber == DeviceSerialNumber && da.Device.AssignedUserId != null);
|
||||
|
||||
if (Configuration.FilterBeginDate.HasValue)
|
||||
{
|
||||
result = Database.Devices
|
||||
.Where(d => d.SerialNumber == DeviceSerialNumber && d.AssignedUser != null)
|
||||
.Select(d => new ContainsAttachmentResult()
|
||||
{
|
||||
Id = d.AssignedUserId,
|
||||
HasAttachment = d.DeviceAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate)
|
||||
})
|
||||
.FirstOrDefault();
|
||||
query = query.Where(da => da.Timestamp >= Configuration.FilterBeginDate);
|
||||
}
|
||||
else
|
||||
|
||||
var result = query.Select(da => new
|
||||
{
|
||||
result = Database.Devices
|
||||
.Where(d => d.SerialNumber == DeviceSerialNumber && d.AssignedUser != null)
|
||||
.Select(d => new ContainsAttachmentResult()
|
||||
{
|
||||
Id = d.AssignedUserId,
|
||||
HasAttachment = d.DeviceAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId)
|
||||
})
|
||||
.FirstOrDefault();
|
||||
}
|
||||
da.Id,
|
||||
da.Device.AssignedUserId,
|
||||
}).FirstOrDefault();
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -238,8 +210,8 @@ namespace Disco.Services.Documents.ManagedGroups
|
||||
}
|
||||
else
|
||||
{
|
||||
UserId = result.Id;
|
||||
return result.HasAttachment;
|
||||
UserId = result.AssignedUserId;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,30 +244,20 @@ namespace Disco.Services.Documents.ManagedGroups
|
||||
#region Job Scope
|
||||
private bool JobsContainAttachment(DiscoDataContext Database, int JobId, out string UserId)
|
||||
{
|
||||
ContainsAttachmentResult result;
|
||||
var query = Database.JobAttachments
|
||||
.Include("Job")
|
||||
.Where(da => da.DocumentTemplateId == DocumentTemplateId && da.JobId == JobId && da.Job.UserId != null);
|
||||
|
||||
if (Configuration.FilterBeginDate.HasValue)
|
||||
{
|
||||
result = Database.Jobs
|
||||
.Where(j => j.Id == JobId && j.UserId != null)
|
||||
.Select(j => new ContainsAttachmentResult()
|
||||
{
|
||||
Id = j.UserId,
|
||||
HasAttachment = j.User.Jobs.Any(uj => uj.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate))
|
||||
})
|
||||
.FirstOrDefault();
|
||||
query = query.Where(da => da.Timestamp >= Configuration.FilterBeginDate);
|
||||
}
|
||||
else
|
||||
|
||||
var result = query.Select(da => new
|
||||
{
|
||||
result = Database.Jobs
|
||||
.Where(j => j.Id == JobId && j.UserId != null)
|
||||
.Select(j => new ContainsAttachmentResult()
|
||||
{
|
||||
Id = j.UserId,
|
||||
HasAttachment = j.User.Jobs.Any(uj => uj.JobAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId))
|
||||
})
|
||||
.FirstOrDefault();
|
||||
}
|
||||
da.Id,
|
||||
da.Job.UserId,
|
||||
}).FirstOrDefault();
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -304,8 +266,8 @@ namespace Disco.Services.Documents.ManagedGroups
|
||||
}
|
||||
else
|
||||
{
|
||||
UserId = result.Id;
|
||||
return result.HasAttachment;
|
||||
UserId = result.UserId;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,18 +300,16 @@ namespace Disco.Services.Documents.ManagedGroups
|
||||
#region User Scope
|
||||
private bool UserContainAttachment(DiscoDataContext Database, string UserId)
|
||||
{
|
||||
var query = Database.UserAttachments
|
||||
.Include("User")
|
||||
.Where(da => da.DocumentTemplateId == DocumentTemplateId && da.UserId == UserId);
|
||||
|
||||
if (Configuration.FilterBeginDate.HasValue)
|
||||
{
|
||||
return Database.Users
|
||||
.Where(u => u.UserId == UserId)
|
||||
.Any(u => u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId && a.Timestamp >= Configuration.FilterBeginDate));
|
||||
}
|
||||
else
|
||||
{
|
||||
return Database.Users
|
||||
.Where(u => u.UserId == UserId)
|
||||
.Any(u => u.UserAttachments.Any(a => a.DocumentTemplateId == DocumentTemplateId));
|
||||
query = query.Where(da => da.Timestamp >= Configuration.FilterBeginDate);
|
||||
}
|
||||
|
||||
return query.Any();
|
||||
}
|
||||
|
||||
private void ProcessUserAttachmentAddEvent(RepositoryMonitorEvent e)
|
||||
@@ -380,19 +340,16 @@ namespace Disco.Services.Documents.ManagedGroups
|
||||
var deviceSerialNumber = device.SerialNumber;
|
||||
bool relevantDevice;
|
||||
|
||||
var query = Event.Database.DeviceAttachments.Include("Device")
|
||||
.Where(da => da.DocumentTemplateId == DocumentTemplateId && da.DeviceSerialNumber == deviceSerialNumber);
|
||||
|
||||
if (Configuration.FilterBeginDate.HasValue)
|
||||
{
|
||||
relevantDevice = Event.Database.Devices
|
||||
.Where(d => d.SerialNumber == deviceSerialNumber && d.DeviceAttachments.Any(ja => ja.DocumentTemplateId == DocumentTemplateId && ja.Timestamp >= Configuration.FilterBeginDate))
|
||||
.Any();
|
||||
}
|
||||
else
|
||||
{
|
||||
relevantDevice = Event.Database.Devices
|
||||
.Where(d => d.SerialNumber == deviceSerialNumber && d.DeviceAttachments.Any(ja => ja.DocumentTemplateId == DocumentTemplateId))
|
||||
.Any();
|
||||
query = query.Where(da => da.Timestamp >= Configuration.FilterBeginDate);
|
||||
}
|
||||
|
||||
relevantDevice = query.Any();
|
||||
|
||||
if (relevantDevice)
|
||||
{
|
||||
var deviceCurrentAssignedUserId = device.AssignedUserId;
|
||||
|
||||
@@ -19,23 +19,23 @@
|
||||
{
|
||||
if (group != null)
|
||||
{
|
||||
<div class="code" title="@group.Id">
|
||||
<i class="fa fa-fw fa-lg fa-link success"></i>@group.Domain.FriendlyDistinguishedNamePath(group.DistinguishedName)
|
||||
</div>
|
||||
<button class="button small Config_LinkedGroup_LinkButton" data-linkedgroupid="@(Model.ManagedGroup.Configuration.GroupId)" data-linkedgroupfilterdateoption="@(Model.ManagedGroup.IncludeFilterBeginDate)" data-linkedgroupfilterdate="@(Model.ManagedGroup.Configuration.FilterBeginDate)" data-linkedroupdescription="@(Model.CategoryDescription)" data-linkedroupupdateurl="@(Model.UpdateUrl)">Change Link</button>
|
||||
<a href="@(Url.Action(MVC.API.System.SyncActiveDirectoryManagedGroup(Model.ManagedGroup.Key, Context.Request.Path)))" class="button small">Synchronize Now</a>
|
||||
<div class="code" title="@group.Id">
|
||||
<i class="fa fa-fw fa-lg fa-link success"></i>@group.Domain.FriendlyDistinguishedNamePath(group.DistinguishedName)
|
||||
</div>
|
||||
<button class="button small Config_LinkedGroup_LinkButton" data-linkedgroupid="@(Model.ManagedGroup.Configuration.GroupId)" data-linkedgroupfilterdateoption="@(Model.ManagedGroup.IncludeFilterBeginDate)" data-linkedgroupfilterdate="@(Model.ManagedGroup.Configuration.FilterBeginDate)" data-linkedroupdescription="@(Model.CategoryDescription)" data-linkedroupupdateurl="@(Model.UpdateUrl)">Change Link</button>
|
||||
<a href="@(Url.Action(MVC.API.System.SyncActiveDirectoryManagedGroup(Model.ManagedGroup.Key, Context.Request.Path)))" class="button small">Synchronize Now</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="code error">
|
||||
<i class="fa fa-fw fa-lg fa-unlink error"></i>Group Not Found: <strong class="code">@Model.ManagedGroup.Configuration.GroupId</strong>
|
||||
</div>
|
||||
<button class="button small Config_LinkedGroup_LinkButton" data-linkedgroupid="@(Model.ManagedGroup.Configuration.GroupId)" data-linkedgroupfilterdateoption="@(Model.ManagedGroup.IncludeFilterBeginDate)" data-linkedgroupfilterdate="@(Model.ManagedGroup.Configuration.FilterBeginDate)" data-linkedroupdescription="@(Model.CategoryDescription)" data-linkedroupupdateurl="@(Model.UpdateUrl)">Change Link</button>
|
||||
<div class="code error">
|
||||
<i class="fa fa-fw fa-lg fa-unlink error"></i>Group Not Found: <strong class="code">@Model.ManagedGroup.Configuration.GroupId</strong>
|
||||
</div>
|
||||
<button class="button small Config_LinkedGroup_LinkButton" data-linkedgroupid="@(Model.ManagedGroup.Configuration.GroupId)" data-linkedgroupfilterdateoption="@(Model.ManagedGroup.IncludeFilterBeginDate)" data-linkedgroupfilterdate="@(Model.ManagedGroup.Configuration.FilterBeginDate)" data-linkedroupdescription="@(Model.CategoryDescription)" data-linkedroupupdateurl="@(Model.UpdateUrl)">Change Link</button>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<button class="button small Config_LinkedGroup_LinkButton" data-linkedgroupid="" data-linkedgroupfilterdateoption="@(Model.IncludeFilterBeginDate)" data-linkedroupdescription="@(Model.CategoryDescription)" data-linkedroupupdateurl="@(Model.UpdateUrl)">Link Group</button>
|
||||
<button class="button small Config_LinkedGroup_LinkButton" data-linkedgroupid="" data-linkedgroupfilterdateoption="@(Model.IncludeFilterBeginDate)" data-linkedroupdescription="@(Model.CategoryDescription)" data-linkedroupupdateurl="@(Model.UpdateUrl)">Link Group</button>
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -44,21 +44,21 @@
|
||||
{
|
||||
if (group != null)
|
||||
{
|
||||
<div class="code" title="@group.Id">
|
||||
<i class="fa fa-fw fa-lg fa-link success"></i>@group.Domain.FriendlyDistinguishedNamePath(group.DistinguishedName)
|
||||
</div>
|
||||
<div class="code" title="@group.Id">
|
||||
<i class="fa fa-fw fa-lg fa-link success"></i>@group.Domain.FriendlyDistinguishedNamePath(group.DistinguishedName)
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="code error">
|
||||
<i class="fa fa-fw fa-lg fa-unlink error"></i>Group Not Found: <strong class="code">@Model.ManagedGroup.Configuration.GroupId</strong>
|
||||
</div>
|
||||
<div class="code error">
|
||||
<i class="fa fa-fw fa-lg fa-unlink error"></i>Group Not Found: <strong class="code">@Model.ManagedGroup.Configuration.GroupId</strong>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="smallMessage"><i class="fa fa-fw fa-lg fa-unlink information"></i>No Group Linked</div>
|
||||
<div class="smallMessage"><i class="fa fa-fw fa-lg fa-unlink information"></i>No Group Linked</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -109,21 +109,21 @@ WriteLiteral("\r\n </p>\r\n </div>\r\n");
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div");
|
||||
WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" class=\"code\"");
|
||||
|
||||
WriteAttribute("title", Tuple.Create(" title=\"", 681), Tuple.Create("\"", 698)
|
||||
WriteAttribute("title", Tuple.Create(" title=\"", 693), Tuple.Create("\"", 710)
|
||||
|
||||
#line 22 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 689), Tuple.Create<System.Object, System.Int32>(group.Id
|
||||
, Tuple.Create(Tuple.Create("", 701), Tuple.Create<System.Object, System.Int32>(group.Id
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 689), false)
|
||||
, 701), false)
|
||||
);
|
||||
|
||||
WriteLiteral(">\r\n <i");
|
||||
WriteLiteral(">\r\n <i");
|
||||
|
||||
WriteLiteral(" class=\"fa fa-fw fa-lg fa-link success\"");
|
||||
|
||||
@@ -131,14 +131,14 @@ WriteLiteral("></i>");
|
||||
|
||||
|
||||
#line 23 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
Write(group.Domain.FriendlyDistinguishedNamePath(group.DistinguishedName));
|
||||
Write(group.Domain.FriendlyDistinguishedNamePath(group.DistinguishedName));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </div>\r\n");
|
||||
WriteLiteral("\r\n </div>\r\n");
|
||||
|
||||
WriteLiteral(" <button");
|
||||
WriteLiteral(" <button");
|
||||
|
||||
WriteLiteral(" class=\"button small Config_LinkedGroup_LinkButton\"");
|
||||
|
||||
@@ -146,7 +146,7 @@ WriteLiteral(" data-linkedgroupid=\"");
|
||||
|
||||
|
||||
#line 25 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
Write(Model.ManagedGroup.Configuration.GroupId);
|
||||
Write(Model.ManagedGroup.Configuration.GroupId);
|
||||
|
||||
|
||||
#line default
|
||||
@@ -157,7 +157,7 @@ WriteLiteral(" data-linkedgroupfilterdateoption=\"");
|
||||
|
||||
|
||||
#line 25 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
Write(Model.ManagedGroup.IncludeFilterBeginDate);
|
||||
Write(Model.ManagedGroup.IncludeFilterBeginDate);
|
||||
|
||||
|
||||
#line default
|
||||
@@ -168,7 +168,7 @@ WriteLiteral(" data-linkedgroupfilterdate=\"");
|
||||
|
||||
|
||||
#line 25 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
Write(Model.ManagedGroup.Configuration.FilterBeginDate);
|
||||
Write(Model.ManagedGroup.Configuration.FilterBeginDate);
|
||||
|
||||
|
||||
#line default
|
||||
@@ -179,7 +179,7 @@ WriteLiteral(" data-linkedroupdescription=\"");
|
||||
|
||||
|
||||
#line 25 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
Write(Model.CategoryDescription);
|
||||
Write(Model.CategoryDescription);
|
||||
|
||||
|
||||
#line default
|
||||
@@ -190,7 +190,7 @@ WriteLiteral(" data-linkedroupupdateurl=\"");
|
||||
|
||||
|
||||
#line 25 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
Write(Model.UpdateUrl);
|
||||
Write(Model.UpdateUrl);
|
||||
|
||||
|
||||
#line default
|
||||
@@ -199,16 +199,16 @@ WriteLiteral("\"");
|
||||
|
||||
WriteLiteral(">Change Link</button>\r\n");
|
||||
|
||||
WriteLiteral(" <a");
|
||||
WriteLiteral(" <a");
|
||||
|
||||
WriteAttribute("href", Tuple.Create(" href=\"", 1275), Tuple.Create("\"", 1389)
|
||||
WriteAttribute("href", Tuple.Create(" href=\"", 1335), Tuple.Create("\"", 1449)
|
||||
|
||||
#line 26 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 1282), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.System.SyncActiveDirectoryManagedGroup(Model.ManagedGroup.Key, Context.Request.Path))
|
||||
, Tuple.Create(Tuple.Create("", 1342), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.System.SyncActiveDirectoryManagedGroup(Model.ManagedGroup.Key, Context.Request.Path))
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 1282), false)
|
||||
, 1342), false)
|
||||
);
|
||||
|
||||
WriteLiteral(" class=\"button small\"");
|
||||
@@ -224,11 +224,11 @@ WriteLiteral(">Synchronize Now</a>\r\n");
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div");
|
||||
WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" class=\"code error\"");
|
||||
|
||||
WriteLiteral(">\r\n <i");
|
||||
WriteLiteral(">\r\n <i");
|
||||
|
||||
WriteLiteral(" class=\"fa fa-fw fa-lg fa-unlink error\"");
|
||||
|
||||
@@ -240,14 +240,14 @@ WriteLiteral(">");
|
||||
|
||||
|
||||
#line 31 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
Write(Model.ManagedGroup.Configuration.GroupId);
|
||||
Write(Model.ManagedGroup.Configuration.GroupId);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</strong>\r\n </div> \r\n");
|
||||
WriteLiteral("</strong>\r\n </div>\r\n");
|
||||
|
||||
WriteLiteral(" <button");
|
||||
WriteLiteral(" <button");
|
||||
|
||||
WriteLiteral(" class=\"button small Config_LinkedGroup_LinkButton\"");
|
||||
|
||||
@@ -255,7 +255,7 @@ WriteLiteral(" data-linkedgroupid=\"");
|
||||
|
||||
|
||||
#line 33 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
Write(Model.ManagedGroup.Configuration.GroupId);
|
||||
Write(Model.ManagedGroup.Configuration.GroupId);
|
||||
|
||||
|
||||
#line default
|
||||
@@ -266,7 +266,7 @@ WriteLiteral(" data-linkedgroupfilterdateoption=\"");
|
||||
|
||||
|
||||
#line 33 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
Write(Model.ManagedGroup.IncludeFilterBeginDate);
|
||||
Write(Model.ManagedGroup.IncludeFilterBeginDate);
|
||||
|
||||
|
||||
#line default
|
||||
@@ -277,7 +277,7 @@ WriteLiteral(" data-linkedgroupfilterdate=\"");
|
||||
|
||||
|
||||
#line 33 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
Write(Model.ManagedGroup.Configuration.FilterBeginDate);
|
||||
Write(Model.ManagedGroup.Configuration.FilterBeginDate);
|
||||
|
||||
|
||||
#line default
|
||||
@@ -288,7 +288,7 @@ WriteLiteral(" data-linkedroupdescription=\"");
|
||||
|
||||
|
||||
#line 33 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
Write(Model.CategoryDescription);
|
||||
Write(Model.CategoryDescription);
|
||||
|
||||
|
||||
#line default
|
||||
@@ -299,7 +299,7 @@ WriteLiteral(" data-linkedroupupdateurl=\"");
|
||||
|
||||
|
||||
#line 33 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
Write(Model.UpdateUrl);
|
||||
Write(Model.UpdateUrl);
|
||||
|
||||
|
||||
#line default
|
||||
@@ -318,7 +318,7 @@ WriteLiteral(">Change Link</button>\r\n");
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <button");
|
||||
WriteLiteral(" <button");
|
||||
|
||||
WriteLiteral(" class=\"button small Config_LinkedGroup_LinkButton\"");
|
||||
|
||||
@@ -328,7 +328,7 @@ WriteLiteral(" data-linkedgroupfilterdateoption=\"");
|
||||
|
||||
|
||||
#line 38 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
Write(Model.IncludeFilterBeginDate);
|
||||
Write(Model.IncludeFilterBeginDate);
|
||||
|
||||
|
||||
#line default
|
||||
@@ -339,7 +339,7 @@ WriteLiteral(" data-linkedroupdescription=\"");
|
||||
|
||||
|
||||
#line 38 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
Write(Model.CategoryDescription);
|
||||
Write(Model.CategoryDescription);
|
||||
|
||||
|
||||
#line default
|
||||
@@ -350,7 +350,7 @@ WriteLiteral(" data-linkedroupupdateurl=\"");
|
||||
|
||||
|
||||
#line 38 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
Write(Model.UpdateUrl);
|
||||
Write(Model.UpdateUrl);
|
||||
|
||||
|
||||
#line default
|
||||
@@ -373,21 +373,21 @@ WriteLiteral(">Link Group</button>\r\n");
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div");
|
||||
WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" class=\"code\"");
|
||||
|
||||
WriteAttribute("title", Tuple.Create(" title=\"", 2661), Tuple.Create("\"", 2678)
|
||||
WriteAttribute("title", Tuple.Create(" title=\"", 2777), Tuple.Create("\"", 2794)
|
||||
|
||||
#line 47 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 2669), Tuple.Create<System.Object, System.Int32>(group.Id
|
||||
, Tuple.Create(Tuple.Create("", 2785), Tuple.Create<System.Object, System.Int32>(group.Id
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 2669), false)
|
||||
, 2785), false)
|
||||
);
|
||||
|
||||
WriteLiteral(">\r\n <i");
|
||||
WriteLiteral(">\r\n <i");
|
||||
|
||||
WriteLiteral(" class=\"fa fa-fw fa-lg fa-link success\"");
|
||||
|
||||
@@ -395,12 +395,12 @@ WriteLiteral("></i>");
|
||||
|
||||
|
||||
#line 48 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
Write(group.Domain.FriendlyDistinguishedNamePath(group.DistinguishedName));
|
||||
Write(group.Domain.FriendlyDistinguishedNamePath(group.DistinguishedName));
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("\r\n </div>\r\n");
|
||||
WriteLiteral("\r\n </div>\r\n");
|
||||
|
||||
|
||||
#line 50 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
@@ -411,11 +411,11 @@ WriteLiteral("\r\n </div>\r\n");
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div");
|
||||
WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" class=\"code error\"");
|
||||
|
||||
WriteLiteral(">\r\n <i");
|
||||
WriteLiteral(">\r\n <i");
|
||||
|
||||
WriteLiteral(" class=\"fa fa-fw fa-lg fa-unlink error\"");
|
||||
|
||||
@@ -427,12 +427,12 @@ WriteLiteral(">");
|
||||
|
||||
|
||||
#line 54 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
Write(Model.ManagedGroup.Configuration.GroupId);
|
||||
Write(Model.ManagedGroup.Configuration.GroupId);
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral("</strong>\r\n </div> \r\n");
|
||||
WriteLiteral("</strong>\r\n </div>\r\n");
|
||||
|
||||
|
||||
#line 56 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
@@ -444,7 +444,7 @@ WriteLiteral("</strong>\r\n </div> \r\n");
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
WriteLiteral(" <div");
|
||||
WriteLiteral(" <div");
|
||||
|
||||
WriteLiteral(" class=\"smallMessage\"");
|
||||
|
||||
@@ -457,7 +457,7 @@ WriteLiteral("></i>No Group Linked</div>\r\n");
|
||||
|
||||
#line 61 "..\..\Areas\Config\Views\Shared\LinkedGroupInstance.cshtml"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#line default
|
||||
|
||||
@@ -34,10 +34,10 @@
|
||||
</div>
|
||||
<script>
|
||||
$(function () {
|
||||
var dialog;
|
||||
var dialogGroupId;
|
||||
var dialogFilterDate;
|
||||
var dialogTitle;
|
||||
let dialog;
|
||||
let dialogGroupId;
|
||||
let dialogFilterDate;
|
||||
let dialogTitle;
|
||||
|
||||
function showDialog(groupId, filterDateOption, filterDateValue, updateUrl, title) {
|
||||
if (dialog == null) {
|
||||
|
||||
@@ -125,10 +125,10 @@ WriteLiteral(@"></i><strong>Warning:</strong> This group will be managed by Disc
|
||||
</div>
|
||||
<script>
|
||||
$(function () {
|
||||
var dialog;
|
||||
var dialogGroupId;
|
||||
var dialogFilterDate;
|
||||
var dialogTitle;
|
||||
let dialog;
|
||||
let dialogGroupId;
|
||||
let dialogFilterDate;
|
||||
let dialogTitle;
|
||||
|
||||
function showDialog(groupId, filterDateOption, filterDateValue, updateUrl, title) {
|
||||
if (dialog == null) {
|
||||
|
||||
Reference in New Issue
Block a user