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()
|
||||
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))
|
||||
{
|
||||
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();
|
||||
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;
|
||||
|
||||
@@ -113,14 +113,14 @@ 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");
|
||||
@@ -201,14 +201,14 @@ WriteLiteral(">Change Link</button>\r\n");
|
||||
|
||||
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\"");
|
||||
@@ -377,14 +377,14 @@ 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");
|
||||
|
||||
@@ -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