qol: simplify calls

This commit is contained in:
Gary Sharp
2025-07-20 15:20:22 +10:00
parent 1add4ee0f5
commit 9656c15c4b
61 changed files with 214 additions and 214 deletions
+2 -2
View File
@@ -85,7 +85,7 @@ namespace Disco.Client
string reportJson = JsonConvert.SerializeObject(report); string reportJson = JsonConvert.SerializeObject(report);
string reportResponse; string reportResponse;
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(ServicePathTemplate); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(ServicePathTemplate);
request.UserAgent = $"Disco-Client/{Assembly.GetExecutingAssembly().GetName().Version.ToString(3)}"; request.UserAgent = $"Disco-Client/{Assembly.GetExecutingAssembly().GetName().Version.ToString(3)}";
request.ContentType = "application/json"; request.ContentType = "application/json";
request.Method = WebRequestMethods.Http.Post; request.Method = WebRequestMethods.Http.Post;
@@ -105,7 +105,7 @@ namespace Disco.Client
} }
} }
System.Diagnostics.Debug.WriteLine("Error Report Logged to Server; Response: {0}", reportResponse); Debug.WriteLine("Error Report Logged to Server; Response: {0}", reportResponse);
} }
#endregion #endregion
@@ -26,7 +26,7 @@ namespace Disco.Client.Extensions
else else
serviceUrl = string.Format(ServicePathUnauthenticatedTemplate, Service.Feature); serviceUrl = string.Format(ServicePathUnauthenticatedTemplate, Service.Feature);
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(serviceUrl); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(serviceUrl);
request.UserAgent = $"Disco-Client/{Assembly.GetExecutingAssembly().GetName().Version.ToString(3)}"; request.UserAgent = $"Disco-Client/{Assembly.GetExecutingAssembly().GetName().Version.ToString(3)}";
request.ContentType = "application/json"; request.ContentType = "application/json";
request.Method = WebRequestMethods.Http.Post; request.Method = WebRequestMethods.Http.Post;
+1 -1
View File
@@ -133,7 +133,7 @@ namespace Disco.Client.Extensions
Presentation.UpdateStatus("Enrolling Device", $"Configuring the device owner:\r\n{enrolResponse.AssignedUserDescription} ({enrolResponse.AssignedUserDomain}\\{enrolResponse.AssignedUserUsername})", true, -1, 3000); Presentation.UpdateStatus("Enrolling Device", $"Configuring the device owner:\r\n{enrolResponse.AssignedUserDescription} ({enrolResponse.AssignedUserDomain}\\{enrolResponse.AssignedUserUsername})", true, -1, 3000);
if (enrolResponse.AssignedUserIsLocalAdmin) if (enrolResponse.AssignedUserIsLocalAdmin)
Interop.LocalAuthentication.AddLocalGroupMembership("Administrators", enrolResponse.AssignedUserSID, enrolResponse.AssignedUserUsername, enrolResponse.AssignedUserDomain); LocalAuthentication.AddLocalGroupMembership("Administrators", enrolResponse.AssignedUserSID, enrolResponse.AssignedUserUsername, enrolResponse.AssignedUserDomain);
// Make Windows think this user was the last to logon // Make Windows think this user was the last to logon
using (RegistryKey regWinlogon = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true)) using (RegistryKey regWinlogon = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true))
+1 -1
View File
@@ -20,7 +20,7 @@ namespace Disco.Client
} }
public static void UpdateStatus(string SubHeading, string Message, bool ShowProgress, int Progress, int TryDelay) public static void UpdateStatus(string SubHeading, string Message, bool ShowProgress, int Progress, int TryDelay)
{ {
Presentation.UpdateStatus(SubHeading, Message, ShowProgress, Progress); UpdateStatus(SubHeading, Message, ShowProgress, Progress);
if (TryDelay > 0) if (TryDelay > 0)
Presentation.TryDelay(TryDelay); Presentation.TryDelay(TryDelay);
} }
+4 -4
View File
@@ -35,14 +35,14 @@ namespace Disco.Client
Presentation.WriteBanner(); Presentation.WriteBanner();
// WhoAmI Phase // WhoAmI Phase
keepProcessing = Program.WhoAmI(); keepProcessing = WhoAmI();
// Enrol Phase // Enrol Phase
if (keepProcessing) if (keepProcessing)
keepProcessing = Program.Enrol(); keepProcessing = Enrol();
// End conversation with Bootstrapper // End conversation with Bootstrapper
Presentation.WriteFooter(Program.RebootRequired, Program.AllowUninstall, !keepProcessing); Presentation.WriteFooter(RebootRequired, AllowUninstall, !keepProcessing);
} }
public static void SetupEnvironment() public static void SetupEnvironment()
@@ -128,7 +128,7 @@ namespace Disco.Client
{ {
// Send Request // Send Request
Presentation.UpdateStatus("Enrolling Device", "Sending the enrolment request to the server.", true, -1); Presentation.UpdateStatus("Enrolling Device", "Sending the enrolment request to the server.", true, -1);
response = request.Post(Program.IsAuthenticated); response = request.Post(IsAuthenticated);
// Process Response // Process Response
Presentation.UpdateStatus("Enrolling Device", "Processing the enrolment response from the server.", true, -1); Presentation.UpdateStatus("Enrolling Device", "Processing the enrolment response from the server.", true, -1);
+1 -1
View File
@@ -232,7 +232,7 @@ namespace Disco.ClientBootstrapper
{ {
if (!string.IsNullOrWhiteSpace(e.Data)) if (!string.IsNullOrWhiteSpace(e.Data))
{ {
System.Diagnostics.Debug.WriteLine($"OUTPUT: {e.Data}"); Debug.WriteLine($"OUTPUT: {e.Data}");
var data = e.Data.Substring(1).Split(new char[] { ',' }); var data = e.Data.Substring(1).Split(new char[] { ',' });
switch (e.Data[0]) switch (e.Data[0])
{ {
@@ -248,9 +248,9 @@ namespace Disco.ClientBootstrapper.Interop
Program.Status.UpdateStatus(null, "Mounting WIM", $"Mounting WIM Image to '{wimMountPath}'"); Program.Status.UpdateStatus(null, "Mounting WIM", $"Mounting WIM Image to '{wimMountPath}'");
Program.SleepThread(500, false); Program.SleepThread(500, false);
m_MessageCallback = new WIMInterop.WindowsImageContainer.NativeMethods.MessageCallback(WimImageEventMessagePump); m_MessageCallback = new WIMInterop.WindowsImageContainer.NativeMethods.MessageCallback(WimImageEventMessagePump);
Interop.WIMInterop.WindowsImageContainer.NativeMethods.RegisterCallback(m_MessageCallback); WIMInterop.WindowsImageContainer.NativeMethods.RegisterCallback(m_MessageCallback);
Interop.WIMInterop.WindowsImageContainer.NativeMethods.MountImage(wimMountPath, InstallLocation, wimImageIndex, wimTempMountPath); WIMInterop.WindowsImageContainer.NativeMethods.MountImage(wimMountPath, InstallLocation, wimImageIndex, wimTempMountPath);
// Load Local Machine Registry // Load Local Machine Registry
var wimHivePath = Path.Combine(wimMountPath, "Windows\\System32\\config\\SOFTWARE"); var wimHivePath = Path.Combine(wimMountPath, "Windows\\System32\\config\\SOFTWARE");
@@ -283,11 +283,11 @@ namespace Disco.ClientBootstrapper.Interop
// Unmount WIM // Unmount WIM
Program.Status.UpdateStatus(null, "Unmounting WIM", $"Unmounting WIM Image at '{wimMountPath}'"); Program.Status.UpdateStatus(null, "Unmounting WIM", $"Unmounting WIM Image at '{wimMountPath}'");
Program.SleepThread(500, false); Program.SleepThread(500, false);
Interop.WIMInterop.WindowsImageContainer.NativeMethods.DismountImage(wimMountPath, InstallLocation, wimImageIndex, wimCommitChanges); WIMInterop.WindowsImageContainer.NativeMethods.DismountImage(wimMountPath, InstallLocation, wimImageIndex, wimCommitChanges);
if (m_MessageCallback != null) if (m_MessageCallback != null)
{ {
Interop.WIMInterop.WindowsImageContainer.NativeMethods.UnregisterMessageCallback(m_MessageCallback); WIMInterop.WindowsImageContainer.NativeMethods.UnregisterMessageCallback(m_MessageCallback);
m_MessageCallback = null; m_MessageCallback = null;
} }
@@ -321,7 +321,7 @@ namespace Disco.ClientBootstrapper.Interop
IntPtr UserData IntPtr UserData
) )
{ {
uint status = (uint)Interop.WIMInterop.WindowsImageContainer.NativeMethods.WIMMessage.WIM_MSG_SUCCESS; uint status = (uint)WIMInterop.WindowsImageContainer.NativeMethods.WIMMessage.WIM_MSG_SUCCESS;
WIMInterop.DefaultImageEventArgs eventArgs = new WIMInterop.DefaultImageEventArgs(wParam, lParam, UserData); WIMInterop.DefaultImageEventArgs eventArgs = new WIMInterop.DefaultImageEventArgs(wParam, lParam, UserData);
//System.Diagnostics.Debug.WriteLine(MessageId); //System.Diagnostics.Debug.WriteLine(MessageId);
@@ -329,8 +329,8 @@ namespace Disco.ClientBootstrapper.Interop
switch ((WIMInterop.WindowsImageContainer.ImageEventMessage)MessageId) switch ((WIMInterop.WindowsImageContainer.ImageEventMessage)MessageId)
{ {
case Interop.WIMInterop.WindowsImageContainer.ImageEventMessage.Progress: case WIMInterop.WindowsImageContainer.ImageEventMessage.Progress:
case Interop.WIMInterop.WindowsImageContainer.ImageEventMessage.MountCleanupProgress: case WIMInterop.WindowsImageContainer.ImageEventMessage.MountCleanupProgress:
var timeRemainingMil = eventArgs.LeftParameter.ToInt32(); var timeRemainingMil = eventArgs.LeftParameter.ToInt32();
string timeRemainingMessage; string timeRemainingMessage;
if (timeRemainingMil > 0) if (timeRemainingMil > 0)
@@ -224,7 +224,7 @@ namespace Disco.ClientBootstrapper.Interop
finally finally
{ {
if (wlanHandle != IntPtr.Zero) if (wlanHandle != IntPtr.Zero)
NetworkInterop.WlanCloseHandle(wlanHandle, IntPtr.Zero); WlanCloseHandle(wlanHandle, IntPtr.Zero);
} }
} }
@@ -277,7 +277,7 @@ namespace Disco.ClientBootstrapper.Interop
WlanGetProfileList(WlanHandle, ref pInterfaceGuid, new IntPtr(), ref ppProfileList); WlanGetProfileList(WlanHandle, ref pInterfaceGuid, new IntPtr(), ref ppProfileList);
WLAN_PROFILE_INFO_LIST wlanProfileInfoList = new WLAN_PROFILE_INFO_LIST(ppProfileList); WLAN_PROFILE_INFO_LIST wlanProfileInfoList = new WLAN_PROFILE_INFO_LIST(ppProfileList);
NetworkInterop.WlanFreeMemory(ppProfileList); WlanFreeMemory(ppProfileList);
return wlanProfileInfoList; return wlanProfileInfoList;
} }
+15 -15
View File
@@ -163,7 +163,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
//Set the temporary path so that we can write to an image. This //Set the temporary path so that we can write to an image. This
//cannot be %TEMP% as it does not exist on Windows PE //cannot be %TEMP% as it does not exist on Windows PE
// //
string tempDirectory = System.Environment.GetEnvironmentVariable("systemdrive"); string tempDirectory = Environment.GetEnvironmentVariable("systemdrive");
NativeMethods.SetTemporaryPath(m_ImageContainerHandle, tempDirectory); NativeMethods.SetTemporaryPath(m_ImageContainerHandle, tempDirectory);
} }
@@ -596,7 +596,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
//Mount the image //Mount the image
// //
m_MountedPath = pathToMountTo; m_MountedPath = pathToMountTo;
NativeMethods.MountImage(pathToMountTo, m_ParentWindowsImageFilePath, m_Index, System.IO.Path.GetTempPath()); NativeMethods.MountImage(pathToMountTo, m_ParentWindowsImageFilePath, m_Index, Path.GetTempPath());
m_Mounted = true; m_Mounted = true;
} }
@@ -684,7 +684,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
IntPtr windowsImageHandle = IntPtr.Zero; IntPtr windowsImageHandle = IntPtr.Zero;
int rc = -1; int rc = -1;
windowsImageHandle = NativeMethods.WimCreateFile(imageFile, access, mode, 0, 0, out _); windowsImageHandle = WimCreateFile(imageFile, access, mode, 0, 0, out _);
rc = Marshal.GetLastWin32Error(); rc = Marshal.GetLastWin32Error();
if (windowsImageHandle == IntPtr.Zero) if (windowsImageHandle == IntPtr.Zero)
{ {
@@ -721,7 +721,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
void void
CloseHandle(IntPtr handle) CloseHandle(IntPtr handle)
{ {
bool status = NativeMethods.WimCloseHandle(handle); bool status = WimCloseHandle(handle);
int rc = Marshal.GetLastWin32Error(); int rc = Marshal.GetLastWin32Error();
if (status == false) if (status == false)
{ {
@@ -757,7 +757,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
void void
SetTemporaryPath(IntPtr handle, string temporaryPath) SetTemporaryPath(IntPtr handle, string temporaryPath)
{ {
bool status = NativeMethods.WimSetTemporaryPath(handle, temporaryPath); bool status = WimSetTemporaryPath(handle, temporaryPath);
int rc = Marshal.GetLastWin32Error(); int rc = Marshal.GetLastWin32Error();
if (status == false) if (status == false)
{ {
@@ -794,7 +794,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
{ {
//Load the image data based on the .wim handle //Load the image data based on the .wim handle
// //
IntPtr hWim = NativeMethods.WimLoadImage(handle, (uint)imageIndex); IntPtr hWim = WimLoadImage(handle, (uint)imageIndex);
int rc = Marshal.GetLastWin32Error(); int rc = Marshal.GetLastWin32Error();
if (hWim == IntPtr.Zero) if (hWim == IntPtr.Zero)
{ {
@@ -832,7 +832,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
IntPtr IntPtr
CaptureImage(IntPtr handle, string path) CaptureImage(IntPtr handle, string path)
{ {
IntPtr hImage = NativeMethods.WimCaptureImage(handle, path, 0); IntPtr hImage = WimCaptureImage(handle, path, 0);
int rc = Marshal.GetLastWin32Error(); int rc = Marshal.GetLastWin32Error();
if (hImage == IntPtr.Zero) if (hImage == IntPtr.Zero)
{ {
@@ -873,7 +873,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
int int
GetImageCount(IntPtr windowsImageHandle) GetImageCount(IntPtr windowsImageHandle)
{ {
int count = NativeMethods.WimGetImageCount(windowsImageHandle); int count = WimGetImageCount(windowsImageHandle);
int rc = Marshal.GetLastWin32Error(); int rc = Marshal.GetLastWin32Error();
if (count == -1) if (count == -1)
{ {
@@ -971,7 +971,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
try try
{ {
status = NativeMethods.WimMountImage(mountPath, status = WimMountImage(mountPath,
windowsImageFileName, windowsImageFileName,
(uint)imageIndex, (uint)imageIndex,
temporaryPath); temporaryPath);
@@ -1022,7 +1022,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
// //
//Call WimApplyImage always with the Index flag for performance reasons. //Call WimApplyImage always with the Index flag for performance reasons.
// //
bool status = NativeMethods.WimApplyImage(imageHandle, applicationPath, NativeMethods.WIM_FLAG_INDEX); bool status = WimApplyImage(imageHandle, applicationPath, WIM_FLAG_INDEX);
int rc = Marshal.GetLastWin32Error(); int rc = Marshal.GetLastWin32Error();
if (status == false) if (status == false)
{ {
@@ -1062,7 +1062,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
IntPtr info = IntPtr.Zero, sizeOfInfo = IntPtr.Zero; IntPtr info = IntPtr.Zero, sizeOfInfo = IntPtr.Zero;
bool status; bool status;
status = NativeMethods.WimGetImageInformation(handle, out info, out _); status = WimGetImageInformation(handle, out info, out _);
int rc = Marshal.GetLastWin32Error(); int rc = Marshal.GetLastWin32Error();
if (status == false) if (status == false)
@@ -1112,7 +1112,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
IntPtr xmlBuffer = Marshal.AllocHGlobal(byteBufferSize); IntPtr xmlBuffer = Marshal.AllocHGlobal(byteBufferSize);
Marshal.Copy(byteBuffer, 0, xmlBuffer, byteBufferSize); Marshal.Copy(byteBuffer, 0, xmlBuffer, byteBufferSize);
bool status = NativeMethods.WimSetImageInformation(handle, xmlBuffer, (uint)byteBufferSize); bool status = WimSetImageInformation(handle, xmlBuffer, (uint)byteBufferSize);
int rc = Marshal.GetLastWin32Error(); int rc = Marshal.GetLastWin32Error();
if (status == false) if (status == false)
{ {
@@ -1153,7 +1153,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
try try
{ {
status = NativeMethods.WimUnmountImage(mountPath, wimdowsImageFileName, (uint)imageIndex, commitChanges); status = WimUnmountImage(mountPath, wimdowsImageFileName, (uint)imageIndex, commitChanges);
rc = Marshal.GetLastWin32Error(); rc = Marshal.GetLastWin32Error();
} }
catch (System.StackOverflowException ex) catch (System.StackOverflowException ex)
@@ -1221,7 +1221,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
void void
RegisterCallback(MessageCallback callback) RegisterCallback(MessageCallback callback)
{ {
NativeMethods.WimRegisterMessageCallback(IntPtr.Zero, callback, IntPtr.Zero); WimRegisterMessageCallback(IntPtr.Zero, callback, IntPtr.Zero);
int rc = Marshal.GetLastWin32Error(); int rc = Marshal.GetLastWin32Error();
if (rc != 0) if (rc != 0)
{ {
@@ -1253,7 +1253,7 @@ namespace Disco.ClientBootstrapper.Interop.WIMInterop
void void
UnregisterMessageCallback(MessageCallback registeredCallback) UnregisterMessageCallback(MessageCallback registeredCallback)
{ {
bool status = NativeMethods.WimUnregisterMessageCallback(IntPtr.Zero, registeredCallback); bool status = WimUnregisterMessageCallback(IntPtr.Zero, registeredCallback);
_ = Marshal.GetLastWin32Error(); _ = Marshal.GetLastWin32Error();
if (status != true) if (status != true)
{ {
+2 -2
View File
@@ -153,11 +153,11 @@ namespace Disco.ClientBootstrapper
{ {
if (BootstrapperLoop.LoopThread != null) if (BootstrapperLoop.LoopThread != null)
{ {
if (BootstrapperLoop.LoopThread.ThreadState == System.Threading.ThreadState.WaitSleepJoin) if (BootstrapperLoop.LoopThread.ThreadState == ThreadState.WaitSleepJoin)
{ {
BootstrapperLoop.LoopThread.Interrupt(); BootstrapperLoop.LoopThread.Interrupt();
} }
if (BootstrapperLoop.LoopThread.ThreadState == System.Threading.ThreadState.Running) if (BootstrapperLoop.LoopThread.ThreadState == ThreadState.Running)
{ {
BootstrapperLoop.LoopThread.Abort(); BootstrapperLoop.LoopThread.Abort();
} }
@@ -22,11 +22,11 @@ namespace Disco.Data.Configuration
private static ConfigurationCacheType Cache(DiscoDataContext Database) private static ConfigurationCacheType Cache(DiscoDataContext Database)
{ {
if (ConfigurationCache.cacheStore == null) if (cacheStore == null)
{ {
lock (configChangeLock) lock (configChangeLock)
{ {
if (ConfigurationCache.cacheStore == null) if (cacheStore == null)
{ {
if (Database == null) if (Database == null)
throw new InvalidOperationException("The Configuration must be loaded at least once before a Cache-Only Configuration Context is used"); throw new InvalidOperationException("The Configuration must be loaded at least once before a Cache-Only Configuration Context is used");
@@ -46,7 +46,7 @@ namespace Disco.Data.Configuration
} }
} }
return ConfigurationCache.cacheStore; return cacheStore;
} }
private static ConfigurationCacheItemType CacheGetItem(DiscoDataContext Database, string Scope, string Key) private static ConfigurationCacheItemType CacheGetItem(DiscoDataContext Database, string Scope, string Key)
@@ -160,7 +160,7 @@ namespace Disco.Data.Configuration
} }
private static ConfigurationCacheItemType SetItemTypeValue(ConfigurationCacheItemType ExistingItem, object Value) private static ConfigurationCacheItemType SetItemTypeValue(ConfigurationCacheItemType ExistingItem, object Value)
{ {
var cache = ConfigurationCache.cacheStore; var cache = cacheStore;
if (cache.TryGetValue(ExistingItem.Item1.Scope, out var scopeCache)) if (cache.TryGetValue(ExistingItem.Item1.Scope, out var scopeCache))
{ {
@@ -113,7 +113,7 @@ namespace Disco.Data.Configuration
{ {
get get
{ {
return System.IO.Path.Combine(DataStoreLocation, "OrganisationLogo.png"); return Path.Combine(DataStoreLocation, "OrganisationLogo.png");
} }
} }
public string OrganisationLogoHash public string OrganisationLogoHash
@@ -135,15 +135,15 @@ namespace Disco.Data.Configuration
if (File.Exists(path)) if (File.Exists(path))
return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read); return new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
else else
return new MemoryStream(Disco.Data.Properties.Resources.EmptyLogo); return new MemoryStream(Properties.Resources.EmptyLogo);
} }
set set
{ {
string organisationLogoPath = OrganisationLogoPath; string organisationLogoPath = OrganisationLogoPath;
if (value == null) if (value == null)
{ {
if (System.IO.File.Exists(organisationLogoPath)) if (File.Exists(organisationLogoPath))
System.IO.File.Delete(organisationLogoPath); File.Delete(organisationLogoPath);
} }
else else
{ {
@@ -199,7 +199,7 @@ namespace Disco.Services.Authorization.Roles
claims.User.ShowDetails = true; claims.User.ShowDetails = true;
} }
role.ClaimsJson = Newtonsoft.Json.JsonConvert.SerializeObject(claims); role.ClaimsJson = JsonConvert.SerializeObject(claims);
} }
Database.SaveChanges(); Database.SaveChanges();
@@ -217,7 +217,7 @@ namespace Disco.Services.Authorization.Roles
claims.Job.Properties.NonWarrantyProperties.RepairProviderDetails = true; claims.Job.Properties.NonWarrantyProperties.RepairProviderDetails = true;
} }
role.ClaimsJson = Newtonsoft.Json.JsonConvert.SerializeObject(claims); role.ClaimsJson = JsonConvert.SerializeObject(claims);
} }
Database.SaveChanges(); Database.SaveChanges();
+3 -3
View File
@@ -19,9 +19,9 @@ namespace Disco.Services
if (SubSubLocationTimestamp.HasValue) if (SubSubLocationTimestamp.HasValue)
SubSubLocation = SubSubLocationTimestamp.Value.ToString(@"yyyy\\MM"); SubSubLocation = SubSubLocationTimestamp.Value.ToString(@"yyyy\\MM");
string storeDirectory = System.IO.Path.Combine(DiscoConfiguration.DataStoreLocation, SubLocation, SubSubLocation); string storeDirectory = Path.Combine(DiscoConfiguration.DataStoreLocation, SubLocation, SubSubLocation);
if (!System.IO.Directory.Exists(storeDirectory)) if (!Directory.Exists(storeDirectory))
System.IO.Directory.CreateDirectory(storeDirectory); Directory.CreateDirectory(storeDirectory);
return storeDirectory; return storeDirectory;
} }
@@ -70,7 +70,7 @@ namespace Disco.Services.Devices.Enrolment
} }
private static void Log(EventTypeIds EventTypeId, params object[] Args) 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) 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) 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) public static void LogSessionDeviceInfo(string SessionId, Enrol Request)
{ {
EnrolmentLog.LogSessionDeviceInfo( LogSessionDeviceInfo(
SessionId, SessionId,
Request.SerialNumber, Request.SerialNumber,
Request.Hardware.UUID, Request.Hardware.UUID,
@@ -53,7 +53,7 @@ namespace Disco.Services.Devices.Importing
public string GetString(int ColumnIndex) public string GetString(int ColumnIndex)
{ {
if (currentRow == null) 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]; var value = currentRow[ColumnIndex];
@@ -71,7 +71,7 @@ namespace Disco.Services.Devices.Importing
public bool TryGetNullableInt(int ColumnIndex, out int? value) public bool TryGetNullableInt(int ColumnIndex, out int? value)
{ {
if (currentRow == null) 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); return TryGetNullableInt(currentRow[ColumnIndex], out value);
} }
@@ -79,7 +79,7 @@ namespace Disco.Services.Devices.Importing
public bool TryGetNullableBool(int ColumnIndex, out bool? value) public bool TryGetNullableBool(int ColumnIndex, out bool? value)
{ {
if (currentRow == null) 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); return TryGetNullableBool(currentRow[ColumnIndex], out value);
} }
@@ -87,7 +87,7 @@ namespace Disco.Services.Devices.Importing
public bool TryGetNullableDateTime(int ColumnIndex, out DateTime? value) public bool TryGetNullableDateTime(int ColumnIndex, out DateTime? value)
{ {
if (currentRow == null) 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); return TryGetNullableDateTime(currentRow[ColumnIndex], out value);
} }
@@ -53,7 +53,7 @@ namespace Disco.Services.Devices.Importing
public string GetString(int ColumnIndex) public string GetString(int ColumnIndex)
{ {
if (currentRow == null) 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]; var cell = currentRow[ColumnIndex];
@@ -71,7 +71,7 @@ namespace Disco.Services.Devices.Importing
public bool TryGetNullableInt(int ColumnIndex, out int? value) public bool TryGetNullableInt(int ColumnIndex, out int? value)
{ {
if (currentRow == null) 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); return TryGetNullableInt(currentRow[ColumnIndex], out value);
} }
@@ -79,7 +79,7 @@ namespace Disco.Services.Devices.Importing
public bool TryGetNullableBool(int ColumnIndex, out bool? value) public bool TryGetNullableBool(int ColumnIndex, out bool? value)
{ {
if (currentRow == null) 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); return TryGetNullableBool(currentRow[ColumnIndex], out value);
} }
@@ -87,7 +87,7 @@ namespace Disco.Services.Devices.Importing
public bool TryGetNullableDateTime(int ColumnIndex, out DateTime? value) public bool TryGetNullableDateTime(int ColumnIndex, out DateTime? value)
{ {
if (currentRow == null) 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); return TryGetNullableDateTime(currentRow[ColumnIndex], out value);
} }
@@ -98,7 +98,7 @@ namespace Disco.Services.Devices.ManagedGroups
if (!string.IsNullOrEmpty(DeviceBatch.AssignedUsersLinkedGroup)) if (!string.IsNullOrEmpty(DeviceBatch.AssignedUsersLinkedGroup))
{ {
var config = ADManagedGroup.ConfigurationFromJson(DeviceBatch.AssignedUsersLinkedGroup); var config = ConfigurationFromJson(DeviceBatch.AssignedUsersLinkedGroup);
if (config != null && !string.IsNullOrWhiteSpace(config.GroupId)) if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
{ {
@@ -96,7 +96,7 @@ namespace Disco.Services.Devices.ManagedGroups
if (!string.IsNullOrEmpty(DeviceBatch.DevicesLinkedGroup)) if (!string.IsNullOrEmpty(DeviceBatch.DevicesLinkedGroup))
{ {
var config = ADManagedGroup.ConfigurationFromJson(DeviceBatch.DevicesLinkedGroup); var config = ConfigurationFromJson(DeviceBatch.DevicesLinkedGroup);
if (config != null && !string.IsNullOrWhiteSpace(config.GroupId)) if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
{ {
@@ -98,7 +98,7 @@ namespace Disco.Services.Devices.ManagedGroups
if (!string.IsNullOrEmpty(DeviceProfile.AssignedUsersLinkedGroup)) if (!string.IsNullOrEmpty(DeviceProfile.AssignedUsersLinkedGroup))
{ {
var config = ADManagedGroup.ConfigurationFromJson(DeviceProfile.AssignedUsersLinkedGroup); var config = ConfigurationFromJson(DeviceProfile.AssignedUsersLinkedGroup);
if (config != null && !string.IsNullOrWhiteSpace(config.GroupId)) if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
{ {
@@ -97,7 +97,7 @@ namespace Disco.Services.Devices.ManagedGroups
if (!string.IsNullOrEmpty(DeviceProfile.DevicesLinkedGroup)) if (!string.IsNullOrEmpty(DeviceProfile.DevicesLinkedGroup))
{ {
var config = ADManagedGroup.ConfigurationFromJson(DeviceProfile.DevicesLinkedGroup); var config = ConfigurationFromJson(DeviceProfile.DevicesLinkedGroup);
if (config != null && !string.IsNullOrWhiteSpace(config.GroupId)) if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
{ {
@@ -270,7 +270,7 @@ namespace Disco.Services.Documents.AttachmentImport
} }
// Add PDF Icon overlay // Add PDF Icon overlay
using (Image mimeTypeIcon = Disco.Services.Properties.Resources.MimeType_pdf16) using (Image mimeTypeIcon = Properties.Resources.MimeType_pdf16)
{ {
thumbnail.EmbedIconOverlay(mimeTypeIcon); thumbnail.EmbedIconOverlay(mimeTypeIcon);
} }
+14 -14
View File
@@ -62,11 +62,11 @@ namespace Disco.Services.Documents
} }
private static void Log(EventTypeIds EventTypeId, params object[] Args) 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) public static void LogImportStarting(string SessionId, string DocumentName)
{ {
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportStarting, new object[] Log(EventTypeIds.ImportStarting, new object[]
{ {
SessionId, SessionId,
DocumentName DocumentName
@@ -74,7 +74,7 @@ namespace Disco.Services.Documents
} }
public static void LogImportProgress(string SessionId, int? Progress, string Status) public static void LogImportProgress(string SessionId, int? Progress, string Status)
{ {
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportProgress, new object[] Log(EventTypeIds.ImportProgress, new object[]
{ {
SessionId, SessionId,
Progress, Progress,
@@ -83,14 +83,14 @@ namespace Disco.Services.Documents
} }
public static void LogImportFinished(string SessionId) public static void LogImportFinished(string SessionId)
{ {
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportFinished, new object[] Log(EventTypeIds.ImportFinished, new object[]
{ {
SessionId SessionId
}); });
} }
public static void LogImportWarning(string SessionId, string Message) public static void LogImportWarning(string SessionId, string Message)
{ {
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportWarning, new object[] Log(EventTypeIds.ImportWarning, new object[]
{ {
SessionId, SessionId,
Message Message
@@ -98,7 +98,7 @@ namespace Disco.Services.Documents
} }
public static void LogImportError(string SessionId, string Message) public static void LogImportError(string SessionId, string Message)
{ {
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportError, new object[] Log(EventTypeIds.ImportError, new object[]
{ {
SessionId, SessionId,
Message Message
@@ -106,7 +106,7 @@ namespace Disco.Services.Documents
} }
public static void LogImportAttachmentExpressionEvaluated(DocumentTemplate template, IAttachmentTarget target, IAttachment attachment, string Result) 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, template.Id,
target.AttachmentReferenceId, target.AttachmentReferenceId,
@@ -116,7 +116,7 @@ namespace Disco.Services.Documents
} }
public static void LogImportPageStarting(string SessionId, int PageNumber) public static void LogImportPageStarting(string SessionId, int PageNumber)
{ {
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageStarting, new object[] Log(EventTypeIds.ImportPageStarting, new object[]
{ {
SessionId, SessionId,
PageNumber PageNumber
@@ -124,7 +124,7 @@ namespace Disco.Services.Documents
} }
public static void LogImportPageImageUpdate(string SessionId, int PageNumber) public static void LogImportPageImageUpdate(string SessionId, int PageNumber)
{ {
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageImageUpdate, new object[] Log(EventTypeIds.ImportPageImageUpdate, new object[]
{ {
SessionId, SessionId,
PageNumber PageNumber
@@ -132,7 +132,7 @@ namespace Disco.Services.Documents
} }
public static void LogImportPageProgress(string SessionId, int PageNumber, int? Progress, string Status) 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, SessionId,
PageNumber, 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) 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, SessionId,
PageNumber, PageNumber,
@@ -155,7 +155,7 @@ namespace Disco.Services.Documents
} }
public static void LogImportPageUndetected(string SessionId, int PageNumber) public static void LogImportPageUndetected(string SessionId, int PageNumber)
{ {
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageUndetected, new object[] Log(EventTypeIds.ImportPageUndetected, new object[]
{ {
SessionId, SessionId,
PageNumber PageNumber
@@ -163,7 +163,7 @@ namespace Disco.Services.Documents
} }
public static void LogImportPageError(string SessionId, int PageNumber, string Message) public static void LogImportPageError(string SessionId, int PageNumber, string Message)
{ {
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageError, new object[] Log(EventTypeIds.ImportPageError, new object[]
{ {
SessionId, SessionId,
PageNumber, PageNumber,
@@ -172,7 +172,7 @@ namespace Disco.Services.Documents
} }
public static void LogImportPageUndetectedStored(string SessionId, int PageNumber) public static void LogImportPageUndetectedStored(string SessionId, int PageNumber)
{ {
DocumentsLog.Log(DocumentsLog.EventTypeIds.ImportPageUndetectedStored, new object[] Log(EventTypeIds.ImportPageUndetectedStored, new object[]
{ {
SessionId, SessionId,
PageNumber PageNumber
@@ -129,7 +129,7 @@ namespace Disco.Services.Documents.ManagedGroups
if (!string.IsNullOrEmpty(Template.DevicesLinkedGroup)) if (!string.IsNullOrEmpty(Template.DevicesLinkedGroup))
{ {
var config = ADManagedGroup.ConfigurationFromJson(Template.DevicesLinkedGroup); var config = ConfigurationFromJson(Template.DevicesLinkedGroup);
if (config != null && !string.IsNullOrWhiteSpace(config.GroupId)) if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
{ {
@@ -124,7 +124,7 @@ namespace Disco.Services.Documents.ManagedGroups
if (!string.IsNullOrEmpty(Template.UsersLinkedGroup)) if (!string.IsNullOrEmpty(Template.UsersLinkedGroup))
{ {
var config = ADManagedGroup.ConfigurationFromJson(Template.UsersLinkedGroup); var config = ConfigurationFromJson(Template.UsersLinkedGroup);
if (config != null && !string.IsNullOrWhiteSpace(config.GroupId)) if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
{ {
@@ -19,7 +19,7 @@ namespace Disco.Services.Expressions.Extensions
{ {
var configCache = new Data.Configuration.SystemConfiguration(null); var configCache = new Data.Configuration.SystemConfiguration(null);
string DataStoreLocation = configCache.DataStoreLocation; string DataStoreLocation = configCache.DataStoreLocation;
string AbsoluteFilePath = System.IO.Path.Combine(DataStoreLocation, RelativeFilePath); string AbsoluteFilePath = Path.Combine(DataStoreLocation, RelativeFilePath);
return new FileImageExpressionResult(AbsoluteFilePath); return new FileImageExpressionResult(AbsoluteFilePath);
} }
public static FileImageExpressionResult JobAttachmentFirstImage(Job Job, DiscoDataContext Database) public static FileImageExpressionResult JobAttachmentFirstImage(Job Job, DiscoDataContext Database)
@@ -94,14 +94,14 @@ namespace Disco.Services.Expressions.Extensions
if (ImageStream == null) if (ImageStream == null)
throw new ArgumentNullException("ImageStream"); throw new ArgumentNullException("ImageStream");
return new BitmapImageExpressionResult(Bitmap.FromStream(ImageStream)); return new BitmapImageExpressionResult(Image.FromStream(ImageStream));
} }
public static BitmapImageExpressionResult ImageFromByteArray(byte[] ImageByteArray) public static BitmapImageExpressionResult ImageFromByteArray(byte[] ImageByteArray)
{ {
if (ImageByteArray == null) if (ImageByteArray == null)
throw new ArgumentNullException("ImageByteArray"); 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) public static BitmapImageExpressionResult DeviceModelImage(DeviceModel DeviceModel)
{ {
+4 -4
View File
@@ -36,11 +36,11 @@ namespace Disco.Services.Extensions
var rnd = new Random(); var rnd = new Random();
if (Except != null) 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) if (availableIcons.Count > 0)
return availableIcons[rnd.Next(availableIcons.Count - 1)]; 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> /// <summary>
@@ -59,11 +59,11 @@ namespace Disco.Services.Extensions
var rnd = new Random(); var rnd = new Random();
if (Except != null) 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) if (availableColours.Count > 0)
return availableColours[rnd.Next(availableColours.Count - 1)]; 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() static UIHelpers()
@@ -414,7 +414,7 @@ namespace Disco.Services.Interop.ActiveDirectory
if (System.IO.File.Exists(tempFileName)) 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); System.IO.File.Delete(tempFileName);
} }
if (string.IsNullOrWhiteSpace(DJoinResult)) if (string.IsNullOrWhiteSpace(DJoinResult))
@@ -388,7 +388,7 @@ namespace Disco.Services.Interop.ActiveDirectory
netbootGUID = NetbootGUIDFromMACAddress(MACAddress); netbootGUID = NetbootGUIDFromMACAddress(MACAddress);
} }
if (netbootGUID != System.Guid.Empty && netbootGUID != NetbootGUID) if (netbootGUID != Guid.Empty && netbootGUID != NetbootGUID)
{ {
SetNetbootGUID(WritableDomainController, netbootGUID); SetNetbootGUID(WritableDomainController, netbootGUID);
return true; return true;
@@ -418,7 +418,7 @@ namespace Disco.Services.Interop.ActiveDirectory
} }
else else
{ {
NetbootGUIDFromMACAddress = System.Guid.Empty; NetbootGUIDFromMACAddress = Guid.Empty;
} }
return NetbootGUIDFromMACAddress; return NetbootGUIDFromMACAddress;
} }
@@ -74,7 +74,7 @@ namespace Disco.Services.Interop.ActiveDirectory
return domain.GetAvailableDomainController().RetrieveADUserAccount(User.UserId, AdditionalProperties); 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)) if (string.IsNullOrWhiteSpace(Term))
throw new ArgumentNullException("Term"); throw new ArgumentNullException("Term");
@@ -133,7 +133,7 @@ namespace Disco.Services.Interop.ActiveDirectory
return domain.GetAvailableDomainController().RetrieveADGroupWithSecurityIdentifier(SecurityIdentifier, AdditionalProperties); 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)) if (string.IsNullOrWhiteSpace(Term))
throw new ArgumentNullException("Term"); throw new ArgumentNullException("Term");
@@ -279,7 +279,7 @@ namespace Disco.Services.Interop.ActiveDirectory
else else
{ {
AccountUsername = AccountId.Substring(slashIndex + 1); 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('\\'); 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); return AccountId.Substring(slashIndex + 1);
else else
return AccountId; return AccountId;
@@ -82,7 +82,7 @@ namespace Disco.Services.Interop.DiscoServices
}; };
var requestJson = JsonConvert.SerializeObject(body); 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"); request.Headers.ContentType = new MediaTypeHeaderValue("application/json");
+1 -1
View File
@@ -46,7 +46,7 @@ namespace Disco.Services.Interop.DiscoServices
{ {
Attachments Attachments
.Select(a => new { Attachment = a, Filename = AttachmentFilenameRetriever(a, Database) }) .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 }) .Select((a, i) => new { Attachment = a.Attachment, Filename = a.Filename, Index = i })
.ToList() .ToList()
.ForEach(a => .ForEach(a =>
@@ -104,7 +104,7 @@ namespace Disco.Services.Interop.DiscoServices
var appVersion = typeof(LicenseValidationTask).Assembly.GetName().Version.ToString(4); var appVersion = typeof(LicenseValidationTask).Assembly.GetName().Version.ToString(4);
var updateUrl = $"{DiscoServiceHelpers.ServicesUrl}API/License/V1"; 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 // Fix for Proxy Servers which don't support KeepAlive
request.KeepAlive = false; request.KeepAlive = false;
@@ -105,7 +105,7 @@ namespace Disco.Services.Interop.DiscoServices
var manifestJson = JsonConvert.SerializeObject(result, Formatting.Indented); var manifestJson = JsonConvert.SerializeObject(result, Formatting.Indented);
var manifestFile = PluginLibrary.ManifestFilename(Database); var manifestFile = ManifestFilename(Database);
if (!Directory.Exists(Path.GetDirectoryName(manifestFile))) if (!Directory.Exists(Path.GetDirectoryName(manifestFile)))
Directory.CreateDirectory(Path.GetDirectoryName(manifestFile)); Directory.CreateDirectory(Path.GetDirectoryName(manifestFile));
@@ -69,7 +69,7 @@ namespace Disco.Services.Interop.DiscoServices
var discoVersion = CurrentDiscoVersionFormatted(); var discoVersion = CurrentDiscoVersionFormatted();
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(UpdateUrl()); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(UpdateUrl());
// Fix for Proxy Servers which don't support KeepAlive // Fix for Proxy Servers which don't support KeepAlive
request.KeepAlive = false; request.KeepAlive = false;
@@ -223,7 +223,7 @@ namespace Disco.Services.Interop.DiscoServices
}).ToList(); }).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; return m;
} }
@@ -50,7 +50,7 @@ namespace Disco.Services.Interop.VicEduDept
{ {
var DiscoBIVersion = UpdateQuery.CurrentDiscoVersionFormatted(); 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 // Fix for Proxy Servers which don't support KeepAlive
wReq.KeepAlive = false; wReq.KeepAlive = false;
@@ -178,7 +178,7 @@ namespace Disco.Services.Jobs.Noticeboards
// Notify Held Devices // Notify Held Devices
HeldDevices.BroadcastUpdates(Database, deviceSerialNumbers); BroadcastUpdates(Database, deviceSerialNumbers);
// Notify Held Devices for Users // Notify Held Devices for Users
HeldDevicesForUsers.BroadcastUpdates(Database, userIds); HeldDevicesForUsers.BroadcastUpdates(Database, userIds);
@@ -203,7 +203,7 @@ namespace Disco.Services.Jobs.Noticeboards
}); });
NoticeboardUpdatesHub.HubContext.Clients NoticeboardUpdatesHub.HubContext.Clients
.Group(HeldDevices.Name) .Group(Name)
.updateHeldDevice(updates); .updateHeldDevice(updates);
} }
} }
@@ -32,7 +32,7 @@ namespace Disco.Services.Jobs.Noticeboards
}); });
NoticeboardUpdatesHub.HubContext.Clients NoticeboardUpdatesHub.HubContext.Clients
.Group(HeldDevicesForUsers.Name) .Group(Name)
.updateHeldDeviceForUser(updates); .updateHeldDeviceForUser(updates);
} }
} }
+1 -1
View File
@@ -48,7 +48,7 @@ namespace Disco.Services.Logging
{ {
var query = BuildQuery(context, logFile.Item2, results.Count); var query = BuildQuery(context, logFile.Item2, results.Count);
IEnumerable<LogEvent> queryResults = query; // Run the Query 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) if (Take.HasValue && Take.Value < results.Count)
break; break;
@@ -39,7 +39,7 @@ namespace Disco.Services.Plugins.Features.CertificateProvider
{ {
get get
{ {
return CertificateProvidersLog._IsCertificateRetrievalProcessing; return _IsCertificateRetrievalProcessing;
} }
} }
public override string ModuleDescription public override string ModuleDescription
@@ -69,11 +69,11 @@ namespace Disco.Services.Plugins.Features.CertificateProvider
} }
private static void Log(EventTypeIds EventTypeId, params object[] Args) 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) public static void LogRetrievalStarting(int CertificateCount, int CertificateIdFrom, int CertificateIdTo)
{ {
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalStarting, new object[] Log(EventTypeIds.RetrievalStarting, new object[]
{ {
CertificateCount, CertificateCount,
CertificateIdFrom, CertificateIdFrom,
@@ -82,61 +82,61 @@ namespace Disco.Services.Plugins.Features.CertificateProvider
} }
public static void LogRetrievalFinished() public static void LogRetrievalFinished()
{ {
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalFinished, new object[0]); Log(EventTypeIds.RetrievalFinished, new object[0]);
} }
public static void LogRetrievalWarning(string Message) public static void LogRetrievalWarning(string Message)
{ {
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalWarning, new object[] Log(EventTypeIds.RetrievalWarning, new object[]
{ {
Message Message
}); });
} }
public static void LogRetrievalError(string Message) public static void LogRetrievalError(string Message)
{ {
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalError, new object[] Log(EventTypeIds.RetrievalError, new object[]
{ {
Message Message
}); });
} }
public static void LogRetrievalCertificateStarting(string CertificateId) public static void LogRetrievalCertificateStarting(string CertificateId)
{ {
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalCertificateStarting, CertificateId); Log(EventTypeIds.RetrievalCertificateStarting, CertificateId);
} }
public static void LogRetrievalCertificateFinished(string 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) 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) 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) 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) public static void LogAllocationFailed(string DeviceSerialNumber)
{ {
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.AllocationFailed, DeviceSerialNumber); Log(EventTypeIds.AllocationFailed, DeviceSerialNumber);
} }
public static void LogDisabledCertificate(DeviceCertificate Certificate, string Reason) 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) 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) 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) 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) public static void LogCertificateRetrievalProgress(bool? IsProcessing, int? Progress, string Status)
@@ -144,32 +144,32 @@ namespace Disco.Services.Plugins.Features.CertificateProvider
bool flag = IsProcessing.HasValue; bool flag = IsProcessing.HasValue;
if (flag) if (flag)
{ {
CertificateProvidersLog._IsCertificateRetrievalProcessing = IsProcessing.Value; _IsCertificateRetrievalProcessing = IsProcessing.Value;
} }
flag = CertificateProvidersLog._IsCertificateRetrievalProcessing; flag = _IsCertificateRetrievalProcessing;
if (flag) if (flag)
{ {
bool flag2 = Status != null; bool flag2 = Status != null;
if (flag2) if (flag2)
{ {
CertificateProvidersLog._CertificateRetrievalStatus = Status; _CertificateRetrievalStatus = Status;
} }
flag2 = Progress.HasValue; flag2 = Progress.HasValue;
if (flag2) if (flag2)
{ {
CertificateProvidersLog._CertificateRetrievalProgress = Progress.Value; _CertificateRetrievalProgress = Progress.Value;
} }
} }
else else
{ {
CertificateProvidersLog._CertificateRetrievalStatus = null; _CertificateRetrievalStatus = null;
CertificateProvidersLog._CertificateRetrievalProgress = 0; _CertificateRetrievalProgress = 0;
} }
CertificateProvidersLog.Log(CertificateProvidersLog.EventTypeIds.RetrievalProgress, new object[] Log(EventTypeIds.RetrievalProgress, new object[]
{ {
CertificateProvidersLog._IsCertificateRetrievalProcessing, _IsCertificateRetrievalProcessing,
CertificateProvidersLog._CertificateRetrievalProgress, _CertificateRetrievalProgress,
CertificateProvidersLog._CertificateRetrievalStatus _CertificateRetrievalStatus
}); });
} }
protected override System.Collections.Generic.List<LogEventType> LoadEventTypes() 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 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>(); Queue<UIExtensionResult> uiExtResults = new Queue<UIExtensionResult>();
foreach (var uiExt in uiExts) foreach (var uiExt in uiExts)
{ {
+3 -3
View File
@@ -516,7 +516,7 @@ namespace Disco.Services.Plugins
if (WebResourceHashes.TryGetValue(resourceKey, out var resourceHash)) if (WebResourceHashes.TryGetValue(resourceKey, out var resourceHash))
{ {
#if DEBUG #if DEBUG
var fileDateCheck = System.IO.File.GetLastWriteTime(resourcePath); var fileDateCheck = File.GetLastWriteTime(resourcePath);
if (fileDateCheck == resourceHash.Item2) if (fileDateCheck == resourceHash.Item2)
#endif #endif
return new Tuple<string, string>(resourcePath, resourceHash.Item1); return new Tuple<string, string>(resourcePath, resourceHash.Item1);
@@ -525,8 +525,8 @@ namespace Disco.Services.Plugins
if (!File.Exists(resourcePath)) if (!File.Exists(resourcePath))
throw new FileNotFoundException($"Resource [{Resource}] not found", resourcePath); throw new FileNotFoundException($"Resource [{Resource}] not found", resourcePath);
var fileDate = System.IO.File.GetLastWriteTime(resourcePath); var fileDate = File.GetLastWriteTime(resourcePath);
var fileBytes = System.IO.File.ReadAllBytes(resourcePath); var fileBytes = File.ReadAllBytes(resourcePath);
if (fileBytes.Length > 0) if (fileBytes.Length > 0)
{ {
using (SHA256 sha = SHA256.Create()) using (SHA256 sha = SHA256.Create())
+2 -2
View File
@@ -41,7 +41,7 @@ namespace Disco.Services.Plugins
_PluginManifests[Manifest.Id] = Manifest; _PluginManifests[Manifest.Id] = Manifest;
// Reinitialize Plugin Host Environment // Reinitialize Plugin Host Environment
Plugins.ReinitializePluginHostEnvironment(); ReinitializePluginHostEnvironment();
} }
} }
@@ -335,7 +335,7 @@ namespace Disco.Services.Plugins
catch (UnauthorizedAccessException ex) { lastAccessException = ex; } catch (UnauthorizedAccessException ex) { lastAccessException = ex; }
if (removeRetryTime < DateTime.Now) if (removeRetryTime < DateTime.Now)
throw lastAccessException; throw lastAccessException;
System.Threading.Thread.Sleep(2000); Thread.Sleep(2000);
} }
// Check for Data Removal // Check for Data Removal
+5 -5
View File
@@ -194,18 +194,18 @@ namespace Disco.Services.Tasks
{ {
public void Execute(IJobExecutionContext context) public void Execute(IJobExecutionContext context)
{ {
lock (ScheduledTasks._RunningTasksLock) lock (_RunningTasksLock)
{ {
// Lifetime = 5mins // Lifetime = 5mins
var expiredTime = DateTime.Now.AddMinutes(-1); var expiredTime = DateTime.Now.AddMinutes(-1);
var expiredTasks = ScheduledTasks._RunningTasks.Where( var expiredTasks = _RunningTasks.Where(
t => !t.IsRunning && t => !t.IsRunning &&
!t.NextScheduledTimestamp.HasValue && !t.NextScheduledTimestamp.HasValue &&
t.FinishedTimestamp < expiredTime t.FinishedTimestamp < expiredTime
).ToArray(); ).ToArray();
foreach (var expiredTask in expiredTasks) foreach (var expiredTask in expiredTasks)
ScheduledTasks._RunningTasks.Remove(expiredTask); _RunningTasks.Remove(expiredTask);
} }
} }
public static void Schedule(IScheduler TaskScheduler) public static void Schedule(IScheduler TaskScheduler)
@@ -219,11 +219,11 @@ namespace Disco.Services.Tasks
ITrigger trigger = TriggerBuilder.Create() ITrigger trigger = TriggerBuilder.Create()
.StartAt(startAt) .StartAt(startAt)
.WithSchedule(SimpleScheduleBuilder.RepeatMinutelyForever(10)) .WithSchedule(SimpleScheduleBuilder.RepeatMinutelyForever(10))
.WithIdentity("ScheduledTaskCleanupTrigger", ScheduledTasks.SchedulerGroupName + "_System") .WithIdentity("ScheduledTaskCleanupTrigger", SchedulerGroupName + "_System")
.Build(); .Build();
IJobDetail job = JobBuilder.Create<ScheduledTaskCleanup>() IJobDetail job = JobBuilder.Create<ScheduledTaskCleanup>()
.WithIdentity("ScheduledTaskCleanupJob", ScheduledTasks.SchedulerGroupName + "_System") .WithIdentity("ScheduledTaskCleanupJob", SchedulerGroupName + "_System")
.Build(); .Build();
_TaskScheduler.ScheduleJob(job, trigger); _TaskScheduler.ScheduleJob(job, trigger);
@@ -79,7 +79,7 @@ namespace Disco.Services.Users.UserFlags
if (!string.IsNullOrEmpty(UserFlag.UserDevicesLinkedGroup)) if (!string.IsNullOrEmpty(UserFlag.UserDevicesLinkedGroup))
{ {
var config = ADManagedGroup.ConfigurationFromJson(UserFlag.UserDevicesLinkedGroup); var config = ConfigurationFromJson(UserFlag.UserDevicesLinkedGroup);
if (config != null && !string.IsNullOrWhiteSpace(config.GroupId)) if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
{ {
@@ -79,7 +79,7 @@ namespace Disco.Services.Users.UserFlags
if (!string.IsNullOrEmpty(UserFlag.UsersLinkedGroup)) if (!string.IsNullOrEmpty(UserFlag.UsersLinkedGroup))
{ {
var config = ADManagedGroup.ConfigurationFromJson(UserFlag.UsersLinkedGroup); var config = ConfigurationFromJson(UserFlag.UsersLinkedGroup);
if (config != null && !string.IsNullOrWhiteSpace(config.GroupId)) if (config != null && !string.IsNullOrWhiteSpace(config.GroupId))
{ {
+2 -2
View File
@@ -20,7 +20,7 @@ namespace Disco.Services.Users
public static void Initialize(DiscoDataContext Database) public static void Initialize(DiscoDataContext Database)
{ {
Authorization.Roles.RoleCache.Initialize(Database); RoleCache.Initialize(Database);
} }
public static string CurrentUserId public static string CurrentUserId
@@ -221,7 +221,7 @@ namespace Disco.Services.Users
else else
Database.Users.Add(adU); Database.Users.Add(adU);
Database.SaveChanges(); Database.SaveChanges();
UserService.InvalidateCachedUser(adU.UserId); InvalidateCachedUser(adU.UserId);
} }
} }
+1 -1
View File
@@ -59,7 +59,7 @@ namespace Disco.Services.Web
} }
else else
{ {
Disco.Services.Logging.SystemLog.LogException("Global Application Exception Caught", Exception); Logging.SystemLog.LogException("Global Application Exception Caught", Exception);
} }
} }
catch (Exception) catch (Exception)
+16 -16
View File
@@ -14,14 +14,14 @@ namespace Disco.Web
// Modified Connection Factory // Modified Connection Factory
System.Data.Entity.Database.DefaultConnectionFactory = new DiscoDatabaseConnectionFactory(System.Data.Entity.Database.DefaultConnectionFactory); System.Data.Entity.Database.DefaultConnectionFactory = new DiscoDatabaseConnectionFactory(System.Data.Entity.Database.DefaultConnectionFactory);
if (Disco.Data.Repository.DiscoDatabaseConnectionFactory.DiscoDataContextConnectionString == null) if (DiscoDatabaseConnectionFactory.DiscoDataContextConnectionString == null)
{ {
// Database Connection String not configured - Trigger 'Install' // Database Connection String not configured - Trigger 'Install'
return false; return false;
} }
// Migrate Database // Migrate Database
Disco.Data.Migrations.DiscoDataMigrator.MigrateLatest(true); Data.Migrations.DiscoDataMigrator.MigrateLatest(true);
return true; return true;
} }
@@ -29,7 +29,7 @@ namespace Disco.Web
public static void InitalizeCoreEnvironment(DiscoDataContext Database) public static void InitalizeCoreEnvironment(DiscoDataContext Database)
{ {
// Initialize Logging // Initialize Logging
Disco.Services.Logging.LogContext.Initalize(Database, DiscoApplication.SchedulerFactory); Services.Logging.LogContext.Initalize(Database, DiscoApplication.SchedulerFactory);
// Load Organisation Name // Load Organisation Name
DiscoApplication.DeploymentId = Database.DiscoConfiguration.DeploymentId; DiscoApplication.DeploymentId = Database.DiscoConfiguration.DeploymentId;
@@ -37,7 +37,7 @@ namespace Disco.Web
DiscoApplication.MultiSiteMode = Database.DiscoConfiguration.MultiSiteMode; DiscoApplication.MultiSiteMode = Database.DiscoConfiguration.MultiSiteMode;
// Initialize Active Directory Interop // Initialize Active Directory Interop
Disco.Services.Interop.ActiveDirectory.ActiveDirectory.Initialize(Database); Services.Interop.ActiveDirectory.ActiveDirectory.Initialize(Database);
// Setup Global Proxy // Setup Global Proxy
DiscoApplication.SetGlobalProxy(Database.DiscoConfiguration.ProxyAddress, DiscoApplication.SetGlobalProxy(Database.DiscoConfiguration.ProxyAddress,
@@ -46,7 +46,7 @@ namespace Disco.Web
Database.DiscoConfiguration.ProxyPassword); Database.DiscoConfiguration.ProxyPassword);
// Initialize User Service Interop // Initialize User Service Interop
Disco.Services.Users.UserService.Initialize(Database); Services.Users.UserService.Initialize(Database);
} }
public static void InitalizeNormalEnvironment(DiscoDataContext Database) public static void InitalizeNormalEnvironment(DiscoDataContext Database)
@@ -54,25 +54,25 @@ namespace Disco.Web
InitalizeCoreEnvironment(Database); InitalizeCoreEnvironment(Database);
// Initialize Expressions // Initialize Expressions
Disco.Services.Expressions.Extensions.ImageResultImplementations.QrCodeImageExpressionResult.CCITTG4EncoderCompressDelegate = Disco.BI.Interop.Pdf.Utilities.GetCCITTG4EncoderCompressDelegate(); Services.Expressions.Extensions.ImageResultImplementations.QrCodeImageExpressionResult.CCITTG4EncoderCompressDelegate = BI.Interop.Pdf.Utilities.GetCCITTG4EncoderCompressDelegate();
Disco.Services.Expressions.Expression.InitializeExpressions(); Services.Expressions.Expression.InitializeExpressions();
// Initialize Job Queues // Initialize Job Queues
Disco.Services.Jobs.JobQueues.JobQueueService.Initialize(Database); Services.Jobs.JobQueues.JobQueueService.Initialize(Database);
// Initialize Flags // Initialize Flags
Disco.Services.Users.UserFlags.UserFlagService.Initialize(Database); Services.Users.UserFlags.UserFlagService.Initialize(Database);
Disco.Services.Devices.DeviceFlags.DeviceFlagService.Initialize(Database); Services.Devices.DeviceFlags.DeviceFlagService.Initialize(Database);
// Initialize Satellite Managed Groups (which don't belong to any other component) // Initialize Satellite Managed Groups (which don't belong to any other component)
Disco.Services.Devices.ManagedGroups.DeviceManagedGroups.Initialize(Database); Services.Devices.ManagedGroups.DeviceManagedGroups.Initialize(Database);
Disco.Services.Documents.ManagedGroups.DocumentTemplateManagedGroups.Initialize(Database); Services.Documents.ManagedGroups.DocumentTemplateManagedGroups.Initialize(Database);
// Initialize Plugins // Initialize Plugins
Disco.Services.Plugins.Plugins.InitalizePlugins(Database); Services.Plugins.Plugins.InitalizePlugins(Database);
// Initialize Scheduled Tasks // Initialize Scheduled Tasks
Disco.Services.Tasks.ScheduledTasks.InitializeScheduledTasks(Database, DiscoApplication.SchedulerFactory, true); Services.Tasks.ScheduledTasks.InitializeScheduledTasks(Database, DiscoApplication.SchedulerFactory, true);
// Schedule Immediate Check for Update (if never updated, or last updated over 2 days ago) // Schedule Immediate Check for Update (if never updated, or last updated over 2 days ago)
if (Database.DiscoConfiguration.UpdateLastCheckResponse == null || if (Database.DiscoConfiguration.UpdateLastCheckResponse == null ||
@@ -98,7 +98,7 @@ namespace Disco.Web
InitalizeCoreEnvironment(Database); InitalizeCoreEnvironment(Database);
// Initialize Scheduled Tasks // Initialize Scheduled Tasks
Disco.Services.Tasks.ScheduledTasks.InitializeScheduledTasks(Database, DiscoApplication.SchedulerFactory, false); Services.Tasks.ScheduledTasks.InitializeScheduledTasks(Database, DiscoApplication.SchedulerFactory, false);
// Import MAC Address Migration // Import MAC Address Migration
if (PreviousVersion != null && PreviousVersion < new Version(1, 2, 910, 0)) if (PreviousVersion != null && PreviousVersion < new Version(1, 2, 910, 0))
@@ -128,7 +128,7 @@ namespace Disco.Web
} }
} }
Disco.Services.Logging.SystemLog.LogUninitialized(); Services.Logging.SystemLog.LogUninitialized();
} }
} }
} }
@@ -496,7 +496,7 @@ namespace Disco.Web.Areas.API.Controllers
public virtual ActionResult ImporterThumbnail(string SessionId, int PageNumber) public virtual ActionResult ImporterThumbnail(string SessionId, int PageNumber)
{ {
var dataStoreSessionPagesCacheLocation = DataStore.CreateLocation(Database, "Cache\\DocumentDropBox_SessionPages"); var dataStoreSessionPagesCacheLocation = DataStore.CreateLocation(Database, "Cache\\DocumentDropBox_SessionPages");
var filename = System.IO.Path.Combine(dataStoreSessionPagesCacheLocation, $"{SessionId}-{PageNumber}"); var filename = Path.Combine(dataStoreSessionPagesCacheLocation, $"{SessionId}-{PageNumber}");
if (System.IO.File.Exists(filename)) if (System.IO.File.Exists(filename))
return File(filename, "image/png"); return File(filename, "image/png");
else else
@@ -510,7 +510,7 @@ namespace Disco.Web.Areas.API.Controllers
var undetectedDirectory = new DirectoryInfo(undetectedLocation); var undetectedDirectory = new DirectoryInfo(undetectedLocation);
var m = undetectedDirectory.GetFiles("*.pdf").Select(f => new ImporterUndetectedFilesModel() var m = undetectedDirectory.GetFiles("*.pdf").Select(f => new ImporterUndetectedFilesModel()
{ {
Id = System.IO.Path.GetFileNameWithoutExtension(f.Name), Id = Path.GetFileNameWithoutExtension(f.Name),
Timestamp = f.CreationTime.ToFullDateTime(), Timestamp = f.CreationTime.ToFullDateTime(),
TimestampUnixEpoc = f.CreationTime.ToUnixEpoc() TimestampUnixEpoc = f.CreationTime.ToUnixEpoc()
}).ToArray(); }).ToArray();
@@ -556,13 +556,13 @@ namespace Disco.Web.Areas.API.Controllers
switch (searchScope) switch (searchScope)
{ {
case DocumentTemplate.DocumentTemplateScopes.Device: case DocumentTemplate.DocumentTemplateScopes.Device:
results = Disco.Services.Searching.Search.SearchDevices(Database, term, limitCount).Select(sr => Models.DocumentTemplate.ImporterUndetectedDataIdLookupModel.FromSearchResultItem(sr)).ToArray(); results = Disco.Services.Searching.Search.SearchDevices(Database, term, limitCount).Select(sr => ImporterUndetectedDataIdLookupModel.FromSearchResultItem(sr)).ToArray();
break; break;
case DocumentTemplate.DocumentTemplateScopes.Job: case DocumentTemplate.DocumentTemplateScopes.Job:
results = Disco.Services.Searching.Search.SearchJobsTable(Database, term, limitCount, false).Items.Select(sr => Models.DocumentTemplate.ImporterUndetectedDataIdLookupModel.FromSearchResultItem(sr)).ToArray(); results = Disco.Services.Searching.Search.SearchJobsTable(Database, term, limitCount, false).Items.Select(sr => ImporterUndetectedDataIdLookupModel.FromSearchResultItem(sr)).ToArray();
break; break;
case DocumentTemplate.DocumentTemplateScopes.User: case DocumentTemplate.DocumentTemplateScopes.User:
results = Disco.Services.Searching.Search.SearchUsers(Database, term, false, limitCount).Select(sr => Models.DocumentTemplate.ImporterUndetectedDataIdLookupModel.FromSearchResultItem(sr)).ToArray(); results = Disco.Services.Searching.Search.SearchUsers(Database, term, false, limitCount).Select(sr => ImporterUndetectedDataIdLookupModel.FromSearchResultItem(sr)).ToArray();
break; break;
default: default:
results = null; results = null;
@@ -584,7 +584,7 @@ namespace Disco.Web.Areas.API.Controllers
var undetectedLocation = DataStore.CreateLocation(Database, "DocumentDropBox_Unassigned"); var undetectedLocation = DataStore.CreateLocation(Database, "DocumentDropBox_Unassigned");
if (Source.HasValue && Source.Value) if (Source.HasValue && Source.Value)
{ {
var filename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, ".pdf")); var filename = Path.Combine(undetectedLocation, string.Concat(id, ".pdf"));
if (System.IO.File.Exists(filename)) if (System.IO.File.Exists(filename))
return File(filename, DocumentTemplate.PdfMimeType); return File(filename, DocumentTemplate.PdfMimeType);
else else
@@ -594,7 +594,7 @@ namespace Disco.Web.Areas.API.Controllers
{ {
if (Thumbnail.HasValue && Thumbnail.Value) if (Thumbnail.HasValue && Thumbnail.Value)
{ {
var filename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, "_thumbnail.png")); var filename = Path.Combine(undetectedLocation, string.Concat(id, "_thumbnail.png"));
if (System.IO.File.Exists(filename)) if (System.IO.File.Exists(filename))
return File(filename, "image/png"); return File(filename, "image/png");
else else
@@ -602,7 +602,7 @@ namespace Disco.Web.Areas.API.Controllers
} }
else else
{ {
var filename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, ".jpg")); var filename = Path.Combine(undetectedLocation, string.Concat(id, ".jpg"));
if (System.IO.File.Exists(filename)) if (System.IO.File.Exists(filename))
return File(filename, "image/jpeg"); return File(filename, "image/jpeg");
else else
@@ -617,7 +617,7 @@ namespace Disco.Web.Areas.API.Controllers
public virtual ActionResult ImporterUndetectedAssign(string id, string DocumentTemplateId, string DataId) public virtual ActionResult ImporterUndetectedAssign(string id, string DocumentTemplateId, string DataId)
{ {
var undetectedLocation = DataStore.CreateLocation(Database, "DocumentDropBox_Unassigned"); var undetectedLocation = DataStore.CreateLocation(Database, "DocumentDropBox_Unassigned");
var filename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, ".pdf")); var filename = Path.Combine(undetectedLocation, string.Concat(id, ".pdf"));
var identifier = DocumentUniqueIdentifier.Create(Database, DocumentTemplateId, DataId, UserService.CurrentUser.UserId, DateTime.Now, 0); var identifier = DocumentUniqueIdentifier.Create(Database, DocumentTemplateId, DataId, UserService.CurrentUser.UserId, DateTime.Now, 0);
if (Disco.Services.Documents.AttachmentImport.Importer.ImportPdfAttachment(identifier, Database, filename) != null) if (Disco.Services.Documents.AttachmentImport.Importer.ImportPdfAttachment(identifier, Database, filename) != null)
@@ -626,10 +626,10 @@ namespace Disco.Web.Areas.API.Controllers
System.IO.File.Delete(filename); System.IO.File.Delete(filename);
// Delete Thumbnail/Preview // Delete Thumbnail/Preview
var thumbnailFilename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, "_thumbnail.png")); var thumbnailFilename = Path.Combine(undetectedLocation, string.Concat(id, "_thumbnail.png"));
if (System.IO.File.Exists(thumbnailFilename)) if (System.IO.File.Exists(thumbnailFilename))
System.IO.File.Delete(thumbnailFilename); System.IO.File.Delete(thumbnailFilename);
var previewFilename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, ".jpg")); var previewFilename = Path.Combine(undetectedLocation, string.Concat(id, ".jpg"));
if (System.IO.File.Exists(previewFilename)) if (System.IO.File.Exists(previewFilename))
System.IO.File.Delete(previewFilename); System.IO.File.Delete(previewFilename);
@@ -645,17 +645,17 @@ namespace Disco.Web.Areas.API.Controllers
public virtual ActionResult ImporterUndetectedDelete(string id) public virtual ActionResult ImporterUndetectedDelete(string id)
{ {
var undetectedLocation = DataStore.CreateLocation(Database, "DocumentDropBox_Unassigned"); var undetectedLocation = DataStore.CreateLocation(Database, "DocumentDropBox_Unassigned");
var filename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, ".pdf")); var filename = Path.Combine(undetectedLocation, string.Concat(id, ".pdf"));
if (System.IO.File.Exists(filename)) if (System.IO.File.Exists(filename))
{ {
// Delete File // Delete File
System.IO.File.Delete(filename); System.IO.File.Delete(filename);
// Delete Thumbnail/Preview // Delete Thumbnail/Preview
var thumbnailFilename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, "_thumbnail.png")); var thumbnailFilename = Path.Combine(undetectedLocation, string.Concat(id, "_thumbnail.png"));
if (System.IO.File.Exists(thumbnailFilename)) if (System.IO.File.Exists(thumbnailFilename))
System.IO.File.Delete(thumbnailFilename); System.IO.File.Delete(thumbnailFilename);
var previewFilename = System.IO.Path.Combine(undetectedLocation, string.Concat(id, ".jpg")); var previewFilename = Path.Combine(undetectedLocation, string.Concat(id, ".jpg"));
if (System.IO.File.Exists(previewFilename)) if (System.IO.File.Exists(previewFilename))
System.IO.File.Delete(previewFilename); System.IO.File.Delete(previewFilename);
@@ -820,7 +820,7 @@ namespace Disco.Web.Areas.API.Controllers
public virtual ActionResult BulkGenerateAddUsers(string userIds) public virtual ActionResult BulkGenerateAddUsers(string userIds)
{ {
if (string.IsNullOrWhiteSpace(userIds)) if (string.IsNullOrWhiteSpace(userIds))
return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest); return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
var dataIds = userIds.Split(new string[] { Environment.NewLine, ",", ";" }, StringSplitOptions.RemoveEmptyEntries).Select(d => d.Trim()).Where(d => !string.IsNullOrEmpty(d)).ToList(); var dataIds = userIds.Split(new string[] { Environment.NewLine, ",", ";" }, StringSplitOptions.RemoveEmptyEntries).Select(d => d.Trim()).Where(d => !string.IsNullOrEmpty(d)).ToList();
var results = new List<BulkGenerateUserModel>(dataIds.Count); var results = new List<BulkGenerateUserModel>(dataIds.Count);
@@ -893,7 +893,7 @@ namespace Disco.Web.Areas.API.Controllers
public virtual ActionResult BulkGenerateAddGroupMembers(string groupId) public virtual ActionResult BulkGenerateAddGroupMembers(string groupId)
{ {
if (string.IsNullOrWhiteSpace(groupId)) if (string.IsNullOrWhiteSpace(groupId))
return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest); return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
var results = new List<BulkGenerateUserModel>(); var results = new List<BulkGenerateUserModel>();
var accountId = ActiveDirectory.ParseDomainAccountId(groupId); var accountId = ActiveDirectory.ParseDomainAccountId(groupId);
@@ -954,7 +954,7 @@ namespace Disco.Web.Areas.API.Controllers
public virtual ActionResult BulkGenerateAddUserFlag(int flagId) public virtual ActionResult BulkGenerateAddUserFlag(int flagId)
{ {
if (flagId <= 0) if (flagId <= 0)
return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest); return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
var results = new List<BulkGenerateUserModel>(); var results = new List<BulkGenerateUserModel>();
@@ -1008,7 +1008,7 @@ namespace Disco.Web.Areas.API.Controllers
public virtual ActionResult BulkGenerateAddDeviceProfile(int deviceProfileId) public virtual ActionResult BulkGenerateAddDeviceProfile(int deviceProfileId)
{ {
if (deviceProfileId <= 0) if (deviceProfileId <= 0)
return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest); return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
var results = new List<BulkGenerateUserModel>(); var results = new List<BulkGenerateUserModel>();
@@ -1062,7 +1062,7 @@ namespace Disco.Web.Areas.API.Controllers
public virtual ActionResult BulkGenerateAddDeviceBatch(int deviceBatchId) public virtual ActionResult BulkGenerateAddDeviceBatch(int deviceBatchId)
{ {
if (deviceBatchId <= 0) if (deviceBatchId <= 0)
return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest); return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
var results = new List<BulkGenerateUserModel>(); var results = new List<BulkGenerateUserModel>();
@@ -1116,7 +1116,7 @@ namespace Disco.Web.Areas.API.Controllers
public virtual ActionResult BulkGenerateAddDocumentAttachment(string documentTemplateId, DateTime? threshold) public virtual ActionResult BulkGenerateAddDocumentAttachment(string documentTemplateId, DateTime? threshold)
{ {
if (string.IsNullOrWhiteSpace(documentTemplateId)) if (string.IsNullOrWhiteSpace(documentTemplateId))
return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest); return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
var results = new List<BulkGenerateUserModel>(); var results = new List<BulkGenerateUserModel>();
@@ -1229,7 +1229,7 @@ namespace Disco.Web.Areas.API.Controllers
public virtual ActionResult BulkGenerateGetUserDetailValues(string key) public virtual ActionResult BulkGenerateGetUserDetailValues(string key)
{ {
if (string.IsNullOrWhiteSpace(key)) if (string.IsNullOrWhiteSpace(key))
return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest); return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
var results = Database.UserDetails.Where(d => d.Scope == "Details" && d.Key == key).Select(d => d.Value).Distinct().ToList(); var results = Database.UserDetails.Where(d => d.Scope == "Details" && d.Key == key).Select(d => d.Value).Distinct().ToList();
@@ -1241,7 +1241,7 @@ namespace Disco.Web.Areas.API.Controllers
public virtual ActionResult BulkGenerateAddUserDetail(string key, string value) public virtual ActionResult BulkGenerateAddUserDetail(string key, string value)
{ {
if (string.IsNullOrWhiteSpace(key)) if (string.IsNullOrWhiteSpace(key))
return new HttpStatusCodeResult(System.Net.HttpStatusCode.BadRequest); return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
var results = new List<BulkGenerateUserModel>(); var results = new List<BulkGenerateUserModel>();
@@ -21,7 +21,7 @@ namespace Disco.Web.Areas.API.Controllers
[DiscoAuthorize(Claims.Config.System.Show)] [DiscoAuthorize(Claims.Config.System.Show)]
public virtual ActionResult UpdateLastNetworkLogonDates() public virtual ActionResult UpdateLastNetworkLogonDates()
{ {
var taskStatus = Disco.Services.Interop.ActiveDirectory.ADNetworkLogonDatesUpdateTask.ScheduleImmediately(); var taskStatus = ADNetworkLogonDatesUpdateTask.ScheduleImmediately();
return RedirectToAction(MVC.Config.Logging.TaskStatus(taskStatus.SessionId)); return RedirectToAction(MVC.Config.Logging.TaskStatus(taskStatus.SessionId));
} }
@@ -37,7 +37,7 @@ namespace Disco.Web.Areas.API.Controllers
[DiscoAuthorize(Claims.DiscoAdminAccount)] [DiscoAuthorize(Claims.DiscoAdminAccount)]
public virtual ActionResult UpdateADDeviceDescriptions() public virtual ActionResult UpdateADDeviceDescriptions()
{ {
var ts = Disco.Services.Interop.ActiveDirectory.ADDeviceDescriptionUpdateTask.ScheduleImmediately(); var ts = ADDeviceDescriptionUpdateTask.ScheduleImmediately();
ts.SetFinishedUrl(Url.Action(MVC.Config.SystemConfig.Index())); ts.SetFinishedUrl(Url.Action(MVC.Config.SystemConfig.Index()));
return RedirectToAction(MVC.Config.Logging.TaskStatus(ts.SessionId)); return RedirectToAction(MVC.Config.Logging.TaskStatus(ts.SessionId));
} }
@@ -56,7 +56,7 @@ namespace Disco.Web.Areas.API.Controllers
} }
else else
{ {
var ts = Disco.Services.Interop.DiscoServices.LicenseValidationTask.ScheduleNow(license); var ts = LicenseValidationTask.ScheduleNow(license);
ts.SetFinishedUrl(Url.Action(MVC.Config.SystemConfig.Index())); ts.SetFinishedUrl(Url.Action(MVC.Config.SystemConfig.Index()));
return RedirectToAction(MVC.Config.Logging.TaskStatus(ts.SessionId)); return RedirectToAction(MVC.Config.Logging.TaskStatus(ts.SessionId));
} }
@@ -65,7 +65,7 @@ namespace Disco.Web.Areas.API.Controllers
[DiscoAuthorize(Claims.Config.System.Show)] [DiscoAuthorize(Claims.Config.System.Show)]
public virtual ActionResult UpdateCheck() public virtual ActionResult UpdateCheck()
{ {
var ts = Disco.Services.Interop.DiscoServices.UpdateQueryTask.ScheduleNow(); var ts = UpdateQueryTask.ScheduleNow();
ts.SetFinishedUrl(Url.Action(MVC.Config.SystemConfig.Index())); ts.SetFinishedUrl(Url.Action(MVC.Config.SystemConfig.Index()));
return RedirectToAction(MVC.Config.Logging.TaskStatus(ts.SessionId)); return RedirectToAction(MVC.Config.Logging.TaskStatus(ts.SessionId));
} }
@@ -111,7 +111,7 @@ namespace Disco.Web.Areas.API.Controllers
using (Stream logoStream = Database.DiscoConfiguration.OrganisationLogo) using (Stream logoStream = Database.DiscoConfiguration.OrganisationLogo)
{ {
using (Image logoBitmap = Bitmap.FromStream(logoStream)) using (Image logoBitmap = Image.FromStream(logoStream))
{ {
return File(logoBitmap.ResizeImage(Width, Height).SavePng(), "image/png"); return File(logoBitmap.ResizeImage(Width, Height).SavePng(), "image/png");
} }
@@ -43,7 +43,7 @@ namespace Disco.Web.Areas.Config.Models.SystemConfig
#region Database Connection #region Database Connection
private Lazy<SqlConnectionStringBuilder> DatabaseConnectionString = new Lazy<SqlConnectionStringBuilder>(() => private Lazy<SqlConnectionStringBuilder> DatabaseConnectionString = new Lazy<SqlConnectionStringBuilder>(() =>
{ {
return new SqlConnectionStringBuilder(Disco.Data.Repository.DiscoDatabaseConnectionFactory.DiscoDataContextConnectionString); return new SqlConnectionStringBuilder(Data.Repository.DiscoDatabaseConnectionFactory.DiscoDataContextConnectionString);
}); });
public string DatabaseServer public string DatabaseServer
{ {
@@ -29,28 +29,28 @@ namespace Disco.Web.Areas.Public.Controllers
query = query.Where(j => j.Device.DeviceProfile.DefaultOrganisationAddress == null || !addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress)); query = query.Where(j => j.Device.DeviceProfile.DefaultOrganisationAddress == null || !addressIds.Contains(j.Device.DeviceProfile.DefaultOrganisationAddress));
} }
var m = Disco.Services.Jobs.Noticeboards.HeldDevicesForUsers.GetHeldDevicesForUsers(query); var m = HeldDevicesForUsers.GetHeldDevicesForUsers(query);
return View(m); return View(m);
} }
public virtual ActionResult ReadyForReturnXml() public virtual ActionResult ReadyForReturnXml()
{ {
var readyForReturn = Disco.Services.Jobs.Noticeboards.HeldDevicesForUsers.GetHeldDevicesForUsers(Database) var readyForReturn = HeldDevicesForUsers.GetHeldDevicesForUsers(Database)
.Where(j => j.ReadyForReturn && !j.WaitingForUserAction).Cast<HeldDeviceItem>().ToArray(); .Where(j => j.ReadyForReturn && !j.WaitingForUserAction).Cast<HeldDeviceItem>().ToArray();
return new Extensions.XmlResult(readyForReturn); return new Extensions.XmlResult(readyForReturn);
} }
public virtual ActionResult WaitingForUserActionXml() public virtual ActionResult WaitingForUserActionXml()
{ {
var userHeldDevices = Disco.Services.Jobs.Noticeboards.HeldDevicesForUsers.GetHeldDevicesForUsers(Database) var userHeldDevices = HeldDevicesForUsers.GetHeldDevicesForUsers(Database)
.Where(j => j.WaitingForUserAction).Cast<HeldDeviceItem>().ToArray(); .Where(j => j.WaitingForUserAction).Cast<HeldDeviceItem>().ToArray();
return new Extensions.XmlResult(userHeldDevices); return new Extensions.XmlResult(userHeldDevices);
} }
public virtual ActionResult UserHeldDevicesXml() public virtual ActionResult UserHeldDevicesXml()
{ {
var userHeldDevices = Disco.Services.Jobs.Noticeboards.HeldDevicesForUsers.GetHeldDevicesForUsers(Database) var userHeldDevices = HeldDevicesForUsers.GetHeldDevicesForUsers(Database)
.Where(j => !j.ReadyForReturn && !j.WaitingForUserAction).Cast<HeldDeviceItem>().ToArray(); .Where(j => !j.ReadyForReturn && !j.WaitingForUserAction).Cast<HeldDeviceItem>().ToArray();
return new Extensions.XmlResult(userHeldDevices); return new Extensions.XmlResult(userHeldDevices);
@@ -68,13 +68,13 @@ namespace Disco.Web.Areas.Public.Controllers
public virtual ActionResult UserHeldDevice(string id) public virtual ActionResult UserHeldDevice(string id)
{ {
var m = Disco.Services.Jobs.Noticeboards.HeldDevicesForUsers.GetHeldDeviceForUsers(Database, id); var m = HeldDevicesForUsers.GetHeldDeviceForUsers(Database, id);
return Json(m, JsonRequestBehavior.AllowGet); return Json(m, JsonRequestBehavior.AllowGet);
} }
public virtual ActionResult UserHeldDevices() public virtual ActionResult UserHeldDevices()
{ {
var m = Disco.Services.Jobs.Noticeboards.HeldDevicesForUsers.GetHeldDevicesForUsers(Database); var m = HeldDevicesForUsers.GetHeldDevicesForUsers(Database);
return Json(m, JsonRequestBehavior.AllowGet); return Json(m, JsonRequestBehavior.AllowGet);
} }
+1 -1
View File
@@ -288,7 +288,7 @@ namespace Disco.Web.Controllers
HideClosedJobs = true, HideClosedJobs = true,
EnablePaging = false EnablePaging = false
}; };
m.Jobs.Fill(Database, Disco.Services.Searching.Search.BuildJobTableModel(Database).Where(j => j.DeviceSerialNumber == m.Device.SerialNumber).OrderByDescending(j => j.Id), true); m.Jobs.Fill(Database, Services.Searching.Search.BuildJobTableModel(Database).Where(j => j.DeviceSerialNumber == m.Device.SerialNumber).OrderByDescending(j => j.Id), true);
} }
if (Authorization.Has(Claims.Device.ShowCertificates)) if (Authorization.Has(Claims.Device.ShowCertificates))
@@ -107,7 +107,7 @@ namespace Disco.Web.Controllers
#region Database #region Database
public virtual ActionResult Database() public virtual ActionResult Database()
{ {
var cs = Disco.Data.Repository.DiscoDatabaseConnectionFactory.DiscoDataContextConnectionString; var cs = DiscoDatabaseConnectionFactory.DiscoDataContextConnectionString;
DatabaseModel m; DatabaseModel m;
@@ -128,11 +128,11 @@ namespace Disco.Web.Controllers
// Try Creating/Migrating // Try Creating/Migrating
connectionString.ConnectTimeout = 5; connectionString.ConnectTimeout = 5;
Disco.Data.Repository.DiscoDatabaseConnectionFactory.SetDiscoDataContextConnectionString(connectionString.ToString(), false); DiscoDatabaseConnectionFactory.SetDiscoDataContextConnectionString(connectionString.ToString(), false);
try try
{ {
Disco.Data.Migrations.DiscoDataMigrator.MigrateLatest(true); Data.Migrations.DiscoDataMigrator.MigrateLatest(true);
} }
catch (Exception ex) catch (Exception ex)
{ {
+1 -1
View File
@@ -238,7 +238,7 @@ namespace Disco.Web.Controllers
closedThreshold = closedThreshold.AddDays(-2); closedThreshold = closedThreshold.AddDays(-2);
if (dateTimeNow.DayOfWeek == DayOfWeek.Tuesday) if (dateTimeNow.DayOfWeek == DayOfWeek.Tuesday)
closedThreshold = closedThreshold.AddDays(-1); closedThreshold = closedThreshold.AddDays(-1);
m.JobTable.Fill(Database, Disco.Services.Searching.Search.BuildJobTableModel(Database).Where(j => j.ClosedDate > closedThreshold).OrderBy(j => j.Id), true); m.JobTable.Fill(Database, Services.Searching.Search.BuildJobTableModel(Database).Where(j => j.ClosedDate > closedThreshold).OrderBy(j => j.Id), true);
// UI Extensions // UI Extensions
UIExtensions.ExecuteExtensions<JobListModel>(ControllerContext, m); UIExtensions.ExecuteExtensions<JobListModel>(ControllerContext, m);
+3 -3
View File
@@ -16,8 +16,8 @@ namespace Disco.Web
{ {
public DiscoApplication() public DiscoApplication()
{ {
base.BeginRequest += new EventHandler(DiscoApplication_BeginRequest); BeginRequest += new EventHandler(DiscoApplication_BeginRequest);
base.Error += new EventHandler(DiscoApplication_Error); Error += new EventHandler(DiscoApplication_Error);
} }
protected void Application_Start() protected void Application_Start()
@@ -45,7 +45,7 @@ namespace Disco.Web
bool.TryParse(ConfigurationManager.AppSettings["DiscoIgnoreVersionUpdate"], out ignoreVersionUpdate); bool.TryParse(ConfigurationManager.AppSettings["DiscoIgnoreVersionUpdate"], out ignoreVersionUpdate);
// Only Update if Plugins are installed // Only Update if Plugins are installed
if (!ignoreVersionUpdate) if (!ignoreVersionUpdate)
ignoreVersionUpdate = (Disco.Services.Plugins.UpdatePluginTask.OfflineInstalledPlugins(database).Count == 0); ignoreVersionUpdate = (Services.Plugins.UpdatePluginTask.OfflineInstalledPlugins(database).Count == 0);
} }
if (!isVersionUpdate || ignoreVersionUpdate) if (!isVersionUpdate || ignoreVersionUpdate)
@@ -36,8 +36,8 @@ namespace Disco.Web.Models.InitialConfig
try try
{ {
// Make Connection String Persistent // Make Connection String Persistent
Disco.Data.Repository.DiscoDatabaseConnectionFactory.SetDiscoDataContextConnectionString( Data.Repository.DiscoDatabaseConnectionFactory.SetDiscoDataContextConnectionString(
Disco.Data.Repository.DiscoDatabaseConnectionFactory.DiscoDataContextConnectionString, true); Data.Repository.DiscoDatabaseConnectionFactory.DiscoDataContextConnectionString, true);
RegistryDatabaseResult = null; RegistryDatabaseResult = null;
} }
catch (Exception ex) catch (Exception ex)
@@ -52,7 +52,7 @@ namespace Disco.Web.Models.InitialConfig
Dns.GetHostEntry("discoict.com.au"); Dns.GetHostEntry("discoict.com.au");
try try
{ {
HttpWebRequest wReq = (HttpWebRequest)HttpWebRequest.Create("https://discoict.com.au/"); HttpWebRequest wReq = (HttpWebRequest)WebRequest.Create("https://discoict.com.au/");
// Added: 2013-02-08 G# // Added: 2013-02-08 G#
// Fix for Proxy Servers which dont support KeepAlive // Fix for Proxy Servers which dont support KeepAlive
wReq.KeepAlive = false; wReq.KeepAlive = false;
@@ -9,7 +9,7 @@ namespace Disco.Web.Models.InitialConfig
{ {
public FileStoreModel() public FileStoreModel()
{ {
DirectoryModel = FileStoreModel.FileStoreDirectoryModel.DirectoryRoots(); DirectoryModel = FileStoreDirectoryModel.DirectoryRoots();
} }
[Required(), CustomValidation(typeof(FileStoreModel), "DirectoryPermissionRequired")] [Required(), CustomValidation(typeof(FileStoreModel), "DirectoryPermissionRequired")]
@@ -145,7 +145,7 @@ namespace Disco.Web.Models.InitialConfig
foreach (var driveInfo in DriveInfo.GetDrives()) foreach (var driveInfo in DriveInfo.GetDrives())
{ {
if (driveInfo.DriveType == DriveType.Fixed) if (driveInfo.DriveType == DriveType.Fixed)
root.SubDirectories.Add(driveInfo.Name.Substring(0, 2).ToUpper(), FileStoreDirectoryModel.FromInfo(driveInfo)); root.SubDirectories.Add(driveInfo.Name.Substring(0, 2).ToUpper(), FromInfo(driveInfo));
} }
return root; return root;
@@ -166,7 +166,7 @@ namespace Disco.Web.Models.InitialConfig
if (((subDir.Attributes & FileAttributes.System) != FileAttributes.System) && if (((subDir.Attributes & FileAttributes.System) != FileAttributes.System) &&
((subDir.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden)) ((subDir.Attributes & FileAttributes.Hidden) != FileAttributes.Hidden))
{ {
SubDirectories.Add(subDir.Name.ToUpper(), FileStoreDirectoryModel.FromInfo(subDir)); SubDirectories.Add(subDir.Name.ToUpper(), FromInfo(subDir));
} }
} }
} }
+1 -1
View File
@@ -29,7 +29,7 @@ namespace Disco.Web.Models.Job
public int? OrganisationAddressId { get; set; } public int? OrganisationAddressId { get; set; }
[Required(ErrorMessage = "Please specify a Repair Provider")] [Required(ErrorMessage = "Please specify a Repair Provider")]
public string RepairProviderId { get; set; } public string RepairProviderId { get; set; }
[Required(ErrorMessage = "A fault description is required"), DataType(System.ComponentModel.DataAnnotations.DataType.MultilineText)] [Required(ErrorMessage = "A fault description is required"), DataType(DataType.MultilineText)]
public string RepairDescription { get; set; } public string RepairDescription { get; set; }
public List<int> PublishAttachmentIds { get; set; } public List<int> PublishAttachmentIds { get; set; }
[Required] [Required]
+1 -1
View File
@@ -29,7 +29,7 @@ namespace Disco.Web.Models.Job
public int? OrganisationAddressId { get; set; } public int? OrganisationAddressId { get; set; }
[Required(ErrorMessage = "Please specify a Warranty Provider")] [Required(ErrorMessage = "Please specify a Warranty Provider")]
public string WarrantyProviderId { get; set; } public string WarrantyProviderId { get; set; }
[Required(ErrorMessage = "A fault description is required"), DataType(System.ComponentModel.DataAnnotations.DataType.MultilineText)] [Required(ErrorMessage = "A fault description is required"), DataType(DataType.MultilineText)]
public string FaultDescription { get; set; } public string FaultDescription { get; set; }
public List<int> PublishAttachmentIds { get; set; } public List<int> PublishAttachmentIds { get; set; }
[Required] [Required]