qol: simplify calls
This commit is contained in:
@@ -199,7 +199,7 @@ namespace Disco.Services.Authorization.Roles
|
||||
claims.User.ShowDetails = true;
|
||||
}
|
||||
|
||||
role.ClaimsJson = Newtonsoft.Json.JsonConvert.SerializeObject(claims);
|
||||
role.ClaimsJson = JsonConvert.SerializeObject(claims);
|
||||
}
|
||||
|
||||
Database.SaveChanges();
|
||||
@@ -217,7 +217,7 @@ namespace Disco.Services.Authorization.Roles
|
||||
claims.Job.Properties.NonWarrantyProperties.RepairProviderDetails = true;
|
||||
}
|
||||
|
||||
role.ClaimsJson = Newtonsoft.Json.JsonConvert.SerializeObject(claims);
|
||||
role.ClaimsJson = JsonConvert.SerializeObject(claims);
|
||||
}
|
||||
|
||||
Database.SaveChanges();
|
||||
|
||||
@@ -19,9 +19,9 @@ namespace Disco.Services
|
||||
if (SubSubLocationTimestamp.HasValue)
|
||||
SubSubLocation = SubSubLocationTimestamp.Value.ToString(@"yyyy\\MM");
|
||||
|
||||
string storeDirectory = System.IO.Path.Combine(DiscoConfiguration.DataStoreLocation, SubLocation, SubSubLocation);
|
||||
if (!System.IO.Directory.Exists(storeDirectory))
|
||||
System.IO.Directory.CreateDirectory(storeDirectory);
|
||||
string storeDirectory = Path.Combine(DiscoConfiguration.DataStoreLocation, SubLocation, SubSubLocation);
|
||||
if (!Directory.Exists(storeDirectory))
|
||||
Directory.CreateDirectory(storeDirectory);
|
||||
|
||||
return storeDirectory;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace Disco.Services.Devices.Enrolment
|
||||
}
|
||||
private static void Log(EventTypeIds EventTypeId, params object[] Args)
|
||||
{
|
||||
EnrolmentLog.Current.Log((int)EventTypeId, Args);
|
||||
Current.Log((int)EventTypeId, Args);
|
||||
}
|
||||
public static void LogSessionStarting(string SessionId, string HostId, EnrolmentTypes EnrolmentType)
|
||||
{
|
||||
@@ -147,11 +147,11 @@ namespace Disco.Services.Devices.Enrolment
|
||||
}
|
||||
public static void LogSessionDeviceInfo(string SessionId, MacEnrol Request)
|
||||
{
|
||||
EnrolmentLog.LogSessionDeviceInfo(SessionId, Request.DeviceSerialNumber, Request.DeviceUUID, Request.DeviceComputerName, Request.DeviceLanMacAddress, Request.DeviceWlanMacAddress, Request.DeviceManufacturer, Request.DeviceModel, Request.DeviceModelType);
|
||||
LogSessionDeviceInfo(SessionId, Request.DeviceSerialNumber, Request.DeviceUUID, Request.DeviceComputerName, Request.DeviceLanMacAddress, Request.DeviceWlanMacAddress, Request.DeviceManufacturer, Request.DeviceModel, Request.DeviceModelType);
|
||||
}
|
||||
public static void LogSessionDeviceInfo(string SessionId, Enrol Request)
|
||||
{
|
||||
EnrolmentLog.LogSessionDeviceInfo(
|
||||
LogSessionDeviceInfo(
|
||||
SessionId,
|
||||
Request.SerialNumber,
|
||||
Request.Hardware.UUID,
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Disco.Services.Devices.Importing
|
||||
public string GetString(int ColumnIndex)
|
||||
{
|
||||
if (currentRow == null)
|
||||
throw new InvalidOperationException($"{nameof(CsvDeviceImportDataReader.Read)} must be called before retrieving values");
|
||||
throw new InvalidOperationException($"{nameof(Read)} must be called before retrieving values");
|
||||
|
||||
var value = currentRow[ColumnIndex];
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Disco.Services.Devices.Importing
|
||||
public bool TryGetNullableInt(int ColumnIndex, out int? value)
|
||||
{
|
||||
if (currentRow == null)
|
||||
throw new InvalidOperationException($"{nameof(CsvDeviceImportDataReader.Read)} must be called before retrieving values");
|
||||
throw new InvalidOperationException($"{nameof(Read)} must be called before retrieving values");
|
||||
|
||||
return TryGetNullableInt(currentRow[ColumnIndex], out value);
|
||||
}
|
||||
@@ -79,7 +79,7 @@ namespace Disco.Services.Devices.Importing
|
||||
public bool TryGetNullableBool(int ColumnIndex, out bool? value)
|
||||
{
|
||||
if (currentRow == null)
|
||||
throw new InvalidOperationException($"{nameof(CsvDeviceImportDataReader.Read)} must be called before retrieving values");
|
||||
throw new InvalidOperationException($"{nameof(Read)} must be called before retrieving values");
|
||||
|
||||
return TryGetNullableBool(currentRow[ColumnIndex], out value);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ namespace Disco.Services.Devices.Importing
|
||||
public bool TryGetNullableDateTime(int ColumnIndex, out DateTime? value)
|
||||
{
|
||||
if (currentRow == null)
|
||||
throw new InvalidOperationException($"{nameof(CsvDeviceImportDataReader.Read)} must be called before retrieving values");
|
||||
throw new InvalidOperationException($"{nameof(Read)} must be called before retrieving values");
|
||||
|
||||
return TryGetNullableDateTime(currentRow[ColumnIndex], out value);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Disco.Services.Devices.Importing
|
||||
public string GetString(int ColumnIndex)
|
||||
{
|
||||
if (currentRow == null)
|
||||
throw new InvalidOperationException($"{nameof(XlsxDeviceImportDataReader.Read)} must be called before retrieving values");
|
||||
throw new InvalidOperationException($"{nameof(Read)} must be called before retrieving values");
|
||||
|
||||
var cell = currentRow[ColumnIndex];
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Disco.Services.Devices.Importing
|
||||
public bool TryGetNullableInt(int ColumnIndex, out int? value)
|
||||
{
|
||||
if (currentRow == null)
|
||||
throw new InvalidOperationException($"{nameof(XlsxDeviceImportDataReader.Read)} must be called before retrieving values");
|
||||
throw new InvalidOperationException($"{nameof(Read)} must be called before retrieving values");
|
||||
|
||||
return TryGetNullableInt(currentRow[ColumnIndex], out value);
|
||||
}
|
||||
@@ -79,7 +79,7 @@ namespace Disco.Services.Devices.Importing
|
||||
public bool TryGetNullableBool(int ColumnIndex, out bool? value)
|
||||
{
|
||||
if (currentRow == null)
|
||||
throw new InvalidOperationException($"{nameof(XlsxDeviceImportDataReader.Read)} must be called before retrieving values");
|
||||
throw new InvalidOperationException($"{nameof(Read)} must be called before retrieving values");
|
||||
|
||||
return TryGetNullableBool(currentRow[ColumnIndex], out value);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ namespace Disco.Services.Devices.Importing
|
||||
public bool TryGetNullableDateTime(int ColumnIndex, out DateTime? value)
|
||||
{
|
||||
if (currentRow == null)
|
||||
throw new InvalidOperationException($"{nameof(XlsxDeviceImportDataReader.Read)} must be called before retrieving values");
|
||||
throw new InvalidOperationException($"{nameof(Read)} must be called before retrieving values");
|
||||
|
||||
return TryGetNullableDateTime(currentRow[ColumnIndex], out value);
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
|
||||
if (!string.IsNullOrEmpty(DeviceBatch.AssignedUsersLinkedGroup))
|
||||
{
|
||||
var config = ADManagedGroup.ConfigurationFromJson(DeviceBatch.AssignedUsersLinkedGroup);
|
||||
var config = ConfigurationFromJson(DeviceBatch.AssignedUsersLinkedGroup);
|
||||
|
||||
if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
|
||||
{
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
|
||||
if (!string.IsNullOrEmpty(DeviceBatch.DevicesLinkedGroup))
|
||||
{
|
||||
var config = ADManagedGroup.ConfigurationFromJson(DeviceBatch.DevicesLinkedGroup);
|
||||
var config = ConfigurationFromJson(DeviceBatch.DevicesLinkedGroup);
|
||||
|
||||
if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
|
||||
{
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
|
||||
if (!string.IsNullOrEmpty(DeviceProfile.AssignedUsersLinkedGroup))
|
||||
{
|
||||
var config = ADManagedGroup.ConfigurationFromJson(DeviceProfile.AssignedUsersLinkedGroup);
|
||||
var config = ConfigurationFromJson(DeviceProfile.AssignedUsersLinkedGroup);
|
||||
|
||||
if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
|
||||
{
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Disco.Services.Devices.ManagedGroups
|
||||
|
||||
if (!string.IsNullOrEmpty(DeviceProfile.DevicesLinkedGroup))
|
||||
{
|
||||
var config = ADManagedGroup.ConfigurationFromJson(DeviceProfile.DevicesLinkedGroup);
|
||||
var config = ConfigurationFromJson(DeviceProfile.DevicesLinkedGroup);
|
||||
|
||||
if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
|
||||
{
|
||||
|
||||
@@ -270,7 +270,7 @@ namespace Disco.Services.Documents.AttachmentImport
|
||||
}
|
||||
|
||||
// Add PDF Icon overlay
|
||||
using (Image mimeTypeIcon = Disco.Services.Properties.Resources.MimeType_pdf16)
|
||||
using (Image mimeTypeIcon = Properties.Resources.MimeType_pdf16)
|
||||
{
|
||||
thumbnail.EmbedIconOverlay(mimeTypeIcon);
|
||||
}
|
||||
|
||||
@@ -62,11 +62,11 @@ namespace Disco.Services.Documents
|
||||
}
|
||||
private static void Log(EventTypeIds EventTypeId, params object[] Args)
|
||||
{
|
||||
DocumentsLog.Current.Log((int)EventTypeId, Args);
|
||||
Current.Log((int)EventTypeId, Args);
|
||||
}
|
||||
public static void LogImportStarting(string SessionId, string DocumentName)
|
||||
{
|
||||
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportStarting, new object[]
|
||||
Log(EventTypeIds.ImportStarting, new object[]
|
||||
{
|
||||
SessionId,
|
||||
DocumentName
|
||||
@@ -74,7 +74,7 @@ namespace Disco.Services.Documents
|
||||
}
|
||||
public static void LogImportProgress(string SessionId, int? Progress, string Status)
|
||||
{
|
||||
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportProgress, new object[]
|
||||
Log(EventTypeIds.ImportProgress, new object[]
|
||||
{
|
||||
SessionId,
|
||||
Progress,
|
||||
@@ -83,14 +83,14 @@ namespace Disco.Services.Documents
|
||||
}
|
||||
public static void LogImportFinished(string SessionId)
|
||||
{
|
||||
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportFinished, new object[]
|
||||
Log(EventTypeIds.ImportFinished, new object[]
|
||||
{
|
||||
SessionId
|
||||
});
|
||||
}
|
||||
public static void LogImportWarning(string SessionId, string Message)
|
||||
{
|
||||
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportWarning, new object[]
|
||||
Log(EventTypeIds.ImportWarning, new object[]
|
||||
{
|
||||
SessionId,
|
||||
Message
|
||||
@@ -98,7 +98,7 @@ namespace Disco.Services.Documents
|
||||
}
|
||||
public static void LogImportError(string SessionId, string Message)
|
||||
{
|
||||
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportError, new object[]
|
||||
Log(EventTypeIds.ImportError, new object[]
|
||||
{
|
||||
SessionId,
|
||||
Message
|
||||
@@ -106,7 +106,7 @@ namespace Disco.Services.Documents
|
||||
}
|
||||
public static void LogImportAttachmentExpressionEvaluated(DocumentTemplate template, IAttachmentTarget target, IAttachment attachment, string Result)
|
||||
{
|
||||
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportAttachmentExpressionEvaluated, new object[]
|
||||
Log(EventTypeIds.ImportAttachmentExpressionEvaluated, new object[]
|
||||
{
|
||||
template.Id,
|
||||
target.AttachmentReferenceId,
|
||||
@@ -116,7 +116,7 @@ namespace Disco.Services.Documents
|
||||
}
|
||||
public static void LogImportPageStarting(string SessionId, int PageNumber)
|
||||
{
|
||||
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageStarting, new object[]
|
||||
Log(EventTypeIds.ImportPageStarting, new object[]
|
||||
{
|
||||
SessionId,
|
||||
PageNumber
|
||||
@@ -124,7 +124,7 @@ namespace Disco.Services.Documents
|
||||
}
|
||||
public static void LogImportPageImageUpdate(string SessionId, int PageNumber)
|
||||
{
|
||||
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageImageUpdate, new object[]
|
||||
Log(EventTypeIds.ImportPageImageUpdate, new object[]
|
||||
{
|
||||
SessionId,
|
||||
PageNumber
|
||||
@@ -132,7 +132,7 @@ namespace Disco.Services.Documents
|
||||
}
|
||||
public static void LogImportPageProgress(string SessionId, int PageNumber, int? Progress, string Status)
|
||||
{
|
||||
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageProgress, new object[]
|
||||
Log(EventTypeIds.ImportPageProgress, new object[]
|
||||
{
|
||||
SessionId,
|
||||
PageNumber,
|
||||
@@ -142,7 +142,7 @@ namespace Disco.Services.Documents
|
||||
}
|
||||
public static void LogImportPageDetected(string SessionId, int PageNumber, string DocumentTypeId, string DocumentTypeName, string TargetType, string AssignedId, string AssignedName)
|
||||
{
|
||||
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageDetected, new object[]
|
||||
Log(EventTypeIds.ImportPageDetected, new object[]
|
||||
{
|
||||
SessionId,
|
||||
PageNumber,
|
||||
@@ -155,7 +155,7 @@ namespace Disco.Services.Documents
|
||||
}
|
||||
public static void LogImportPageUndetected(string SessionId, int PageNumber)
|
||||
{
|
||||
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageUndetected, new object[]
|
||||
Log(EventTypeIds.ImportPageUndetected, new object[]
|
||||
{
|
||||
SessionId,
|
||||
PageNumber
|
||||
@@ -163,7 +163,7 @@ namespace Disco.Services.Documents
|
||||
}
|
||||
public static void LogImportPageError(string SessionId, int PageNumber, string Message)
|
||||
{
|
||||
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageError, new object[]
|
||||
Log(EventTypeIds.ImportPageError, new object[]
|
||||
{
|
||||
SessionId,
|
||||
PageNumber,
|
||||
@@ -172,7 +172,7 @@ namespace Disco.Services.Documents
|
||||
}
|
||||
public static void LogImportPageUndetectedStored(string SessionId, int PageNumber)
|
||||
{
|
||||
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageUndetectedStored, new object[]
|
||||
Log(EventTypeIds.ImportPageUndetectedStored, new object[]
|
||||
{
|
||||
SessionId,
|
||||
PageNumber
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace Disco.Services.Documents.ManagedGroups
|
||||
|
||||
if (!string.IsNullOrEmpty(Template.DevicesLinkedGroup))
|
||||
{
|
||||
var config = ADManagedGroup.ConfigurationFromJson(Template.DevicesLinkedGroup);
|
||||
var config = ConfigurationFromJson(Template.DevicesLinkedGroup);
|
||||
|
||||
if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
|
||||
{
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace Disco.Services.Documents.ManagedGroups
|
||||
|
||||
if (!string.IsNullOrEmpty(Template.UsersLinkedGroup))
|
||||
{
|
||||
var config = ADManagedGroup.ConfigurationFromJson(Template.UsersLinkedGroup);
|
||||
var config = ConfigurationFromJson(Template.UsersLinkedGroup);
|
||||
|
||||
if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
|
||||
{
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Disco.Services.Expressions.Extensions
|
||||
{
|
||||
var configCache = new Data.Configuration.SystemConfiguration(null);
|
||||
string DataStoreLocation = configCache.DataStoreLocation;
|
||||
string AbsoluteFilePath = System.IO.Path.Combine(DataStoreLocation, RelativeFilePath);
|
||||
string AbsoluteFilePath = Path.Combine(DataStoreLocation, RelativeFilePath);
|
||||
return new FileImageExpressionResult(AbsoluteFilePath);
|
||||
}
|
||||
public static FileImageExpressionResult JobAttachmentFirstImage(Job Job, DiscoDataContext Database)
|
||||
@@ -94,14 +94,14 @@ namespace Disco.Services.Expressions.Extensions
|
||||
if (ImageStream == null)
|
||||
throw new ArgumentNullException("ImageStream");
|
||||
|
||||
return new BitmapImageExpressionResult(Bitmap.FromStream(ImageStream));
|
||||
return new BitmapImageExpressionResult(Image.FromStream(ImageStream));
|
||||
}
|
||||
public static BitmapImageExpressionResult ImageFromByteArray(byte[] ImageByteArray)
|
||||
{
|
||||
if (ImageByteArray == null)
|
||||
throw new ArgumentNullException("ImageByteArray");
|
||||
|
||||
return new BitmapImageExpressionResult(Bitmap.FromStream(new MemoryStream(ImageByteArray)));
|
||||
return new BitmapImageExpressionResult(Image.FromStream(new MemoryStream(ImageByteArray)));
|
||||
}
|
||||
public static BitmapImageExpressionResult DeviceModelImage(DeviceModel DeviceModel)
|
||||
{
|
||||
|
||||
@@ -36,11 +36,11 @@ namespace Disco.Services.Extensions
|
||||
var rnd = new Random();
|
||||
if (Except != null)
|
||||
{
|
||||
var availableIcons = UIHelpers.Icons.Select(i => i.Key).Except(Except).ToList();
|
||||
var availableIcons = Icons.Select(i => i.Key).Except(Except).ToList();
|
||||
if (availableIcons.Count > 0)
|
||||
return availableIcons[rnd.Next(availableIcons.Count - 1)];
|
||||
}
|
||||
return UIHelpers.Icons[rnd.Next(UIHelpers.Icons.Count - 1)].Key;
|
||||
return Icons[rnd.Next(Icons.Count - 1)].Key;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -59,11 +59,11 @@ namespace Disco.Services.Extensions
|
||||
var rnd = new Random();
|
||||
if (Except != null)
|
||||
{
|
||||
var availableColours = UIHelpers.ThemeColours.Select(i => i.Key).Except(Except).ToList();
|
||||
var availableColours = ThemeColours.Select(i => i.Key).Except(Except).ToList();
|
||||
if (availableColours.Count > 0)
|
||||
return availableColours[rnd.Next(availableColours.Count - 1)];
|
||||
}
|
||||
return UIHelpers.ThemeColours[rnd.Next(UIHelpers.ThemeColours.Count - 1)].Key;
|
||||
return ThemeColours[rnd.Next(ThemeColours.Count - 1)].Key;
|
||||
}
|
||||
|
||||
static UIHelpers()
|
||||
|
||||
@@ -414,7 +414,7 @@ namespace Disco.Services.Interop.ActiveDirectory
|
||||
|
||||
if (System.IO.File.Exists(tempFileName))
|
||||
{
|
||||
DJoinResult = System.Convert.ToBase64String(System.IO.File.ReadAllBytes(tempFileName));
|
||||
DJoinResult = Convert.ToBase64String(System.IO.File.ReadAllBytes(tempFileName));
|
||||
System.IO.File.Delete(tempFileName);
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(DJoinResult))
|
||||
|
||||
@@ -388,7 +388,7 @@ namespace Disco.Services.Interop.ActiveDirectory
|
||||
netbootGUID = NetbootGUIDFromMACAddress(MACAddress);
|
||||
}
|
||||
|
||||
if (netbootGUID != System.Guid.Empty && netbootGUID != NetbootGUID)
|
||||
if (netbootGUID != Guid.Empty && netbootGUID != NetbootGUID)
|
||||
{
|
||||
SetNetbootGUID(WritableDomainController, netbootGUID);
|
||||
return true;
|
||||
@@ -418,7 +418,7 @@ namespace Disco.Services.Interop.ActiveDirectory
|
||||
}
|
||||
else
|
||||
{
|
||||
NetbootGUIDFromMACAddress = System.Guid.Empty;
|
||||
NetbootGUIDFromMACAddress = Guid.Empty;
|
||||
}
|
||||
return NetbootGUIDFromMACAddress;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Disco.Services.Interop.ActiveDirectory
|
||||
return domain.GetAvailableDomainController().RetrieveADUserAccount(User.UserId, AdditionalProperties);
|
||||
}
|
||||
|
||||
public static IEnumerable<ADUserAccount> SearchADUserAccounts(string Term, bool Quick, int? ResultLimit = ActiveDirectory.DefaultSearchResultLimit, params string[] AdditionalProperties)
|
||||
public static IEnumerable<ADUserAccount> SearchADUserAccounts(string Term, bool Quick, int? ResultLimit = DefaultSearchResultLimit, params string[] AdditionalProperties)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Term))
|
||||
throw new ArgumentNullException("Term");
|
||||
@@ -133,7 +133,7 @@ namespace Disco.Services.Interop.ActiveDirectory
|
||||
return domain.GetAvailableDomainController().RetrieveADGroupWithSecurityIdentifier(SecurityIdentifier, AdditionalProperties);
|
||||
}
|
||||
|
||||
public static IEnumerable<ADGroup> SearchADGroups(string Term, int? ResultLimit = ActiveDirectory.DefaultSearchResultLimit, params string[] AdditionalProperties)
|
||||
public static IEnumerable<ADGroup> SearchADGroups(string Term, int? ResultLimit = DefaultSearchResultLimit, params string[] AdditionalProperties)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Term))
|
||||
throw new ArgumentNullException("Term");
|
||||
@@ -279,7 +279,7 @@ namespace Disco.Services.Interop.ActiveDirectory
|
||||
else
|
||||
{
|
||||
AccountUsername = AccountId.Substring(slashIndex + 1);
|
||||
return ActiveDirectory.Context.TryGetDomainByNetBiosName(AccountId.Substring(0, slashIndex), out Domain);
|
||||
return Context.TryGetDomainByNetBiosName(AccountId.Substring(0, slashIndex), out Domain);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ namespace Disco.Services.Interop.ActiveDirectory
|
||||
{
|
||||
var slashIndex = AccountId.IndexOf('\\');
|
||||
|
||||
if (slashIndex > 0 && AccountId.Substring(0, slashIndex).Equals(ActiveDirectory.Context.PrimaryDomain.NetBiosName, StringComparison.OrdinalIgnoreCase))
|
||||
if (slashIndex > 0 && AccountId.Substring(0, slashIndex).Equals(Context.PrimaryDomain.NetBiosName, StringComparison.OrdinalIgnoreCase))
|
||||
return AccountId.Substring(slashIndex + 1);
|
||||
else
|
||||
return AccountId;
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace Disco.Services.Interop.DiscoServices
|
||||
};
|
||||
var requestJson = JsonConvert.SerializeObject(body);
|
||||
|
||||
using (var request = new ByteArrayContent(System.Text.Encoding.UTF8.GetBytes(requestJson)))
|
||||
using (var request = new ByteArrayContent(Encoding.UTF8.GetBytes(requestJson)))
|
||||
{
|
||||
request.Headers.ContentType = new MediaTypeHeaderValue("application/json");
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Disco.Services.Interop.DiscoServices
|
||||
{
|
||||
Attachments
|
||||
.Select(a => new { Attachment = a, Filename = AttachmentFilenameRetriever(a, Database) })
|
||||
.Where(a => System.IO.File.Exists(a.Filename))
|
||||
.Where(a => File.Exists(a.Filename))
|
||||
.Select((a, i) => new { Attachment = a.Attachment, Filename = a.Filename, Index = i })
|
||||
.ToList()
|
||||
.ForEach(a =>
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace Disco.Services.Interop.DiscoServices
|
||||
var appVersion = typeof(LicenseValidationTask).Assembly.GetName().Version.ToString(4);
|
||||
var updateUrl = $"{DiscoServiceHelpers.ServicesUrl}API/License/V1";
|
||||
|
||||
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(updateUrl);
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(updateUrl);
|
||||
|
||||
// Fix for Proxy Servers which don't support KeepAlive
|
||||
request.KeepAlive = false;
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Disco.Services.Interop.DiscoServices
|
||||
|
||||
var manifestJson = JsonConvert.SerializeObject(result, Formatting.Indented);
|
||||
|
||||
var manifestFile = PluginLibrary.ManifestFilename(Database);
|
||||
var manifestFile = ManifestFilename(Database);
|
||||
|
||||
if (!Directory.Exists(Path.GetDirectoryName(manifestFile)))
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(manifestFile));
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Disco.Services.Interop.DiscoServices
|
||||
|
||||
var discoVersion = CurrentDiscoVersionFormatted();
|
||||
|
||||
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(UpdateUrl());
|
||||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(UpdateUrl());
|
||||
|
||||
// Fix for Proxy Servers which don't support KeepAlive
|
||||
request.KeepAlive = false;
|
||||
@@ -223,7 +223,7 @@ namespace Disco.Services.Interop.DiscoServices
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
m.InstalledPlugins = Disco.Services.Plugins.Plugins.GetPlugins().Select(manifest => new StatisticString() { Key = manifest.Id, Value = manifest.VersionFormatted }).ToList();
|
||||
m.InstalledPlugins = Plugins.Plugins.GetPlugins().Select(manifest => new StatisticString() { Key = manifest.Id, Value = manifest.VersionFormatted }).ToList();
|
||||
|
||||
return m;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Disco.Services.Interop.VicEduDept
|
||||
{
|
||||
var DiscoBIVersion = UpdateQuery.CurrentDiscoVersionFormatted();
|
||||
|
||||
HttpWebRequest wReq = (HttpWebRequest)HttpWebRequest.Create("http://broadband.doe.wan/ipsearch/showresult.php");
|
||||
HttpWebRequest wReq = (HttpWebRequest)WebRequest.Create("http://broadband.doe.wan/ipsearch/showresult.php");
|
||||
|
||||
// Fix for Proxy Servers which don't support KeepAlive
|
||||
wReq.KeepAlive = false;
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace Disco.Services.Jobs.Noticeboards
|
||||
|
||||
|
||||
// Notify Held Devices
|
||||
HeldDevices.BroadcastUpdates(Database, deviceSerialNumbers);
|
||||
BroadcastUpdates(Database, deviceSerialNumbers);
|
||||
|
||||
// Notify Held Devices for Users
|
||||
HeldDevicesForUsers.BroadcastUpdates(Database, userIds);
|
||||
@@ -203,7 +203,7 @@ namespace Disco.Services.Jobs.Noticeboards
|
||||
});
|
||||
|
||||
NoticeboardUpdatesHub.HubContext.Clients
|
||||
.Group(HeldDevices.Name)
|
||||
.Group(Name)
|
||||
.updateHeldDevice(updates);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Disco.Services.Jobs.Noticeboards
|
||||
});
|
||||
|
||||
NoticeboardUpdatesHub.HubContext.Clients
|
||||
.Group(HeldDevicesForUsers.Name)
|
||||
.Group(Name)
|
||||
.updateHeldDeviceForUser(updates);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Disco.Services.Logging
|
||||
{
|
||||
var query = BuildQuery(context, logFile.Item2, results.Count);
|
||||
IEnumerable<LogEvent> queryResults = query; // Run the Query
|
||||
results.AddRange(queryResults.Select(le => Models.LogLiveEvent.Create(logModules[le.ModuleId], logModules[le.ModuleId].EventTypes[le.EventTypeId], le.Timestamp, le.Arguments)));
|
||||
results.AddRange(queryResults.Select(le => LogLiveEvent.Create(logModules[le.ModuleId], logModules[le.ModuleId].EventTypes[le.EventTypeId], le.Timestamp, le.Arguments)));
|
||||
}
|
||||
if (Take.HasValue && Take.Value < results.Count)
|
||||
break;
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Disco.Services.Plugins.Features.CertificateProvider
|
||||
{
|
||||
get
|
||||
{
|
||||
return CertificateProvidersLog._IsCertificateRetrievalProcessing;
|
||||
return _IsCertificateRetrievalProcessing;
|
||||
}
|
||||
}
|
||||
public override string ModuleDescription
|
||||
@@ -69,11 +69,11 @@ namespace Disco.Services.Plugins.Features.CertificateProvider
|
||||
}
|
||||
private static void Log(EventTypeIds EventTypeId, params object[] Args)
|
||||
{
|
||||
CertificateProvidersLog.Current.Log((int)EventTypeId, Args);
|
||||
Current.Log((int)EventTypeId, Args);
|
||||
}
|
||||
public static void LogRetrievalStarting(int CertificateCount, int CertificateIdFrom, int CertificateIdTo)
|
||||
{
|
||||
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalStarting, new object[]
|
||||
Log(EventTypeIds.RetrievalStarting, new object[]
|
||||
{
|
||||
CertificateCount,
|
||||
CertificateIdFrom,
|
||||
@@ -82,61 +82,61 @@ namespace Disco.Services.Plugins.Features.CertificateProvider
|
||||
}
|
||||
public static void LogRetrievalFinished()
|
||||
{
|
||||
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalFinished, new object[0]);
|
||||
Log(EventTypeIds.RetrievalFinished, new object[0]);
|
||||
}
|
||||
public static void LogRetrievalWarning(string Message)
|
||||
{
|
||||
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalWarning, new object[]
|
||||
Log(EventTypeIds.RetrievalWarning, new object[]
|
||||
{
|
||||
Message
|
||||
});
|
||||
}
|
||||
public static void LogRetrievalError(string Message)
|
||||
{
|
||||
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalError, new object[]
|
||||
Log(EventTypeIds.RetrievalError, new object[]
|
||||
{
|
||||
Message
|
||||
});
|
||||
}
|
||||
public static void LogRetrievalCertificateStarting(string CertificateId)
|
||||
{
|
||||
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalCertificateStarting, CertificateId);
|
||||
Log(EventTypeIds.RetrievalCertificateStarting, CertificateId);
|
||||
}
|
||||
public static void LogRetrievalCertificateFinished(string CertificateId)
|
||||
{
|
||||
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalCertificateFinished, CertificateId);
|
||||
Log(EventTypeIds.RetrievalCertificateFinished, CertificateId);
|
||||
}
|
||||
public static void LogRetrievalCertificateWarning(string CertificateId, string Message)
|
||||
{
|
||||
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalCertificateWarning, CertificateId, Message);
|
||||
Log(EventTypeIds.RetrievalCertificateWarning, CertificateId, Message);
|
||||
}
|
||||
public static void LogRetrievalCertificateError(string CertificateId, string Message)
|
||||
{
|
||||
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalCertificateError, CertificateId, Message);
|
||||
Log(EventTypeIds.RetrievalCertificateError, CertificateId, Message);
|
||||
}
|
||||
public static void LogAllocated(string CertificateId, string DeviceSerialNumber)
|
||||
{
|
||||
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.Allocated, CertificateId, DeviceSerialNumber);
|
||||
Log(EventTypeIds.Allocated, CertificateId, DeviceSerialNumber);
|
||||
}
|
||||
public static void LogAllocationFailed(string DeviceSerialNumber)
|
||||
{
|
||||
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.AllocationFailed, DeviceSerialNumber);
|
||||
Log(EventTypeIds.AllocationFailed, DeviceSerialNumber);
|
||||
}
|
||||
public static void LogDisabledCertificate(DeviceCertificate Certificate, string Reason)
|
||||
{
|
||||
CertificateProvidersLog.Log(EventTypeIds.DisabledCertificate, Certificate.Name, Certificate.Id, Reason);
|
||||
Log(EventTypeIds.DisabledCertificate, Certificate.Name, Certificate.Id, Reason);
|
||||
}
|
||||
public static void LogEnabledCertificate(DeviceCertificate Certificate, string Reason)
|
||||
{
|
||||
CertificateProvidersLog.Log(EventTypeIds.EnabledCertificate, Certificate.Name, Certificate.Id, Reason);
|
||||
Log(EventTypeIds.EnabledCertificate, Certificate.Name, Certificate.Id, Reason);
|
||||
}
|
||||
public static void LogDeletedCertificate(DeviceCertificate Certificate, string Reason)
|
||||
{
|
||||
CertificateProvidersLog.Log(EventTypeIds.DeletedCertificate, Certificate.Name, Certificate.Id, Reason);
|
||||
Log(EventTypeIds.DeletedCertificate, Certificate.Name, Certificate.Id, Reason);
|
||||
}
|
||||
public static void LogUpdatedCertificate(DeviceCertificate Certificate, string Reason)
|
||||
{
|
||||
CertificateProvidersLog.Log(EventTypeIds.UpdatedCertificate, Certificate.Name, Certificate.Id, Reason);
|
||||
Log(EventTypeIds.UpdatedCertificate, Certificate.Name, Certificate.Id, Reason);
|
||||
}
|
||||
|
||||
public static void LogCertificateRetrievalProgress(bool? IsProcessing, int? Progress, string Status)
|
||||
@@ -144,32 +144,32 @@ namespace Disco.Services.Plugins.Features.CertificateProvider
|
||||
bool flag = IsProcessing.HasValue;
|
||||
if (flag)
|
||||
{
|
||||
CertificateProvidersLog._IsCertificateRetrievalProcessing = IsProcessing.Value;
|
||||
_IsCertificateRetrievalProcessing = IsProcessing.Value;
|
||||
}
|
||||
flag = CertificateProvidersLog._IsCertificateRetrievalProcessing;
|
||||
flag = _IsCertificateRetrievalProcessing;
|
||||
if (flag)
|
||||
{
|
||||
bool flag2 = Status != null;
|
||||
if (flag2)
|
||||
{
|
||||
CertificateProvidersLog._CertificateRetrievalStatus = Status;
|
||||
_CertificateRetrievalStatus = Status;
|
||||
}
|
||||
flag2 = Progress.HasValue;
|
||||
if (flag2)
|
||||
{
|
||||
CertificateProvidersLog._CertificateRetrievalProgress = Progress.Value;
|
||||
_CertificateRetrievalProgress = Progress.Value;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CertificateProvidersLog._CertificateRetrievalStatus = null;
|
||||
CertificateProvidersLog._CertificateRetrievalProgress = 0;
|
||||
_CertificateRetrievalStatus = null;
|
||||
_CertificateRetrievalProgress = 0;
|
||||
}
|
||||
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalProgress, new object[]
|
||||
Log(EventTypeIds.RetrievalProgress, new object[]
|
||||
{
|
||||
CertificateProvidersLog._IsCertificateRetrievalProcessing,
|
||||
CertificateProvidersLog._CertificateRetrievalProgress,
|
||||
CertificateProvidersLog._CertificateRetrievalStatus
|
||||
_IsCertificateRetrievalProcessing,
|
||||
_CertificateRetrievalProgress,
|
||||
_CertificateRetrievalStatus
|
||||
});
|
||||
}
|
||||
protected override System.Collections.Generic.List<LogEventType> LoadEventTypes()
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Disco.Services.Plugins.Features.UIExtension
|
||||
|
||||
public static void ExecuteExtensions<UIModel>(ControllerContext context, UIModel model) where UIModel : BaseUIModel
|
||||
{
|
||||
var uiExts = UIExtensions.GetRegisteredExtensions<UIModel>();
|
||||
var uiExts = GetRegisteredExtensions<UIModel>();
|
||||
Queue<UIExtensionResult> uiExtResults = new Queue<UIExtensionResult>();
|
||||
foreach (var uiExt in uiExts)
|
||||
{
|
||||
|
||||
@@ -516,7 +516,7 @@ namespace Disco.Services.Plugins
|
||||
if (WebResourceHashes.TryGetValue(resourceKey, out var resourceHash))
|
||||
{
|
||||
#if DEBUG
|
||||
var fileDateCheck = System.IO.File.GetLastWriteTime(resourcePath);
|
||||
var fileDateCheck = File.GetLastWriteTime(resourcePath);
|
||||
if (fileDateCheck == resourceHash.Item2)
|
||||
#endif
|
||||
return new Tuple<string, string>(resourcePath, resourceHash.Item1);
|
||||
@@ -525,8 +525,8 @@ namespace Disco.Services.Plugins
|
||||
if (!File.Exists(resourcePath))
|
||||
throw new FileNotFoundException($"Resource [{Resource}] not found", resourcePath);
|
||||
|
||||
var fileDate = System.IO.File.GetLastWriteTime(resourcePath);
|
||||
var fileBytes = System.IO.File.ReadAllBytes(resourcePath);
|
||||
var fileDate = File.GetLastWriteTime(resourcePath);
|
||||
var fileBytes = File.ReadAllBytes(resourcePath);
|
||||
if (fileBytes.Length > 0)
|
||||
{
|
||||
using (SHA256 sha = SHA256.Create())
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace Disco.Services.Plugins
|
||||
_PluginManifests[Manifest.Id] = Manifest;
|
||||
|
||||
// Reinitialize Plugin Host Environment
|
||||
Plugins.ReinitializePluginHostEnvironment();
|
||||
ReinitializePluginHostEnvironment();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ namespace Disco.Services.Plugins
|
||||
catch (UnauthorizedAccessException ex) { lastAccessException = ex; }
|
||||
if (removeRetryTime < DateTime.Now)
|
||||
throw lastAccessException;
|
||||
System.Threading.Thread.Sleep(2000);
|
||||
Thread.Sleep(2000);
|
||||
}
|
||||
|
||||
// Check for Data Removal
|
||||
|
||||
@@ -194,18 +194,18 @@ namespace Disco.Services.Tasks
|
||||
{
|
||||
public void Execute(IJobExecutionContext context)
|
||||
{
|
||||
lock (ScheduledTasks._RunningTasksLock)
|
||||
lock (_RunningTasksLock)
|
||||
{
|
||||
// Lifetime = 5mins
|
||||
var expiredTime = DateTime.Now.AddMinutes(-1);
|
||||
var expiredTasks = ScheduledTasks._RunningTasks.Where(
|
||||
var expiredTasks = _RunningTasks.Where(
|
||||
t => !t.IsRunning &&
|
||||
!t.NextScheduledTimestamp.HasValue &&
|
||||
t.FinishedTimestamp < expiredTime
|
||||
).ToArray();
|
||||
|
||||
foreach (var expiredTask in expiredTasks)
|
||||
ScheduledTasks._RunningTasks.Remove(expiredTask);
|
||||
_RunningTasks.Remove(expiredTask);
|
||||
}
|
||||
}
|
||||
public static void Schedule(IScheduler TaskScheduler)
|
||||
@@ -219,11 +219,11 @@ namespace Disco.Services.Tasks
|
||||
ITrigger trigger = TriggerBuilder.Create()
|
||||
.StartAt(startAt)
|
||||
.WithSchedule(SimpleScheduleBuilder.RepeatMinutelyForever(10))
|
||||
.WithIdentity("ScheduledTaskCleanupTrigger", ScheduledTasks.SchedulerGroupName + "_System")
|
||||
.WithIdentity("ScheduledTaskCleanupTrigger", SchedulerGroupName + "_System")
|
||||
.Build();
|
||||
|
||||
IJobDetail job = JobBuilder.Create<ScheduledTaskCleanup>()
|
||||
.WithIdentity("ScheduledTaskCleanupJob", ScheduledTasks.SchedulerGroupName + "_System")
|
||||
.WithIdentity("ScheduledTaskCleanupJob", SchedulerGroupName + "_System")
|
||||
.Build();
|
||||
|
||||
_TaskScheduler.ScheduleJob(job, trigger);
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Disco.Services.Users.UserFlags
|
||||
|
||||
if (!string.IsNullOrEmpty(UserFlag.UserDevicesLinkedGroup))
|
||||
{
|
||||
var config = ADManagedGroup.ConfigurationFromJson(UserFlag.UserDevicesLinkedGroup);
|
||||
var config = ConfigurationFromJson(UserFlag.UserDevicesLinkedGroup);
|
||||
|
||||
if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Disco.Services.Users.UserFlags
|
||||
|
||||
if (!string.IsNullOrEmpty(UserFlag.UsersLinkedGroup))
|
||||
{
|
||||
var config = ADManagedGroup.ConfigurationFromJson(UserFlag.UsersLinkedGroup);
|
||||
var config = ConfigurationFromJson(UserFlag.UsersLinkedGroup);
|
||||
|
||||
if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
|
||||
{
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Disco.Services.Users
|
||||
|
||||
public static void Initialize(DiscoDataContext Database)
|
||||
{
|
||||
Authorization.Roles.RoleCache.Initialize(Database);
|
||||
RoleCache.Initialize(Database);
|
||||
}
|
||||
|
||||
public static string CurrentUserId
|
||||
@@ -221,7 +221,7 @@ namespace Disco.Services.Users
|
||||
else
|
||||
Database.Users.Add(adU);
|
||||
Database.SaveChanges();
|
||||
UserService.InvalidateCachedUser(adU.UserId);
|
||||
InvalidateCachedUser(adU.UserId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Disco.Services.Web
|
||||
}
|
||||
else
|
||||
{
|
||||
Disco.Services.Logging.SystemLog.LogException("Global Application Exception Caught", Exception);
|
||||
Logging.SystemLog.LogException("Global Application Exception Caught", Exception);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
Reference in New Issue
Block a user