SEBWIN-316: Added manufacturer, model and name to system info.
This commit is contained in:
parent
175a2e8cf7
commit
bf69a64e15
8 changed files with 115 additions and 13 deletions
|
@ -12,7 +12,7 @@ using SafeExamBrowser.Settings;
|
|||
|
||||
namespace SafeExamBrowser.Configuration.ConfigurationData
|
||||
{
|
||||
internal partial class DataMapper
|
||||
internal class DataMapper
|
||||
{
|
||||
private BaseDataMapper[] mappers =
|
||||
{
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.UnitTests.Operations
|
||||
{
|
||||
[TestClass]
|
||||
public class VirtualMachineOperationTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void TODO()
|
||||
{
|
||||
Assert.Fail();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -90,6 +90,7 @@
|
|||
<Compile Include="Operations\ClientOperationTests.cs" />
|
||||
<Compile Include="Operations\SessionActivationOperationTests.cs" />
|
||||
<Compile Include="Operations\SessionInitializationOperationTests.cs" />
|
||||
<Compile Include="Operations\VirtualMachineOperationTests.cs" />
|
||||
<Compile Include="RuntimeControllerTests.cs" />
|
||||
<Compile Include="Communication\RuntimeHostTests.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
|
|
@ -11,30 +11,30 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using SafeExamBrowser.Communication.Contracts;
|
||||
using SafeExamBrowser.Communication.Hosts;
|
||||
using SafeExamBrowser.Communication.Proxies;
|
||||
using SafeExamBrowser.Configuration;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Configuration.Cryptography;
|
||||
using SafeExamBrowser.Configuration.DataCompression;
|
||||
using SafeExamBrowser.Configuration.DataFormats;
|
||||
using SafeExamBrowser.Configuration.DataResources;
|
||||
using SafeExamBrowser.Communication.Contracts;
|
||||
using SafeExamBrowser.Configuration.Contracts;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Runtime.Contracts;
|
||||
using SafeExamBrowser.SystemComponents.Contracts;
|
||||
using SafeExamBrowser.Core.OperationModel;
|
||||
using SafeExamBrowser.Core.Operations;
|
||||
using SafeExamBrowser.I18n;
|
||||
using SafeExamBrowser.I18n.Contracts;
|
||||
using SafeExamBrowser.Logging;
|
||||
using SafeExamBrowser.Logging.Contracts;
|
||||
using SafeExamBrowser.Runtime.Communication;
|
||||
using SafeExamBrowser.Runtime.Contracts;
|
||||
using SafeExamBrowser.Runtime.Operations;
|
||||
using SafeExamBrowser.Settings.Logging;
|
||||
using SafeExamBrowser.SystemComponents;
|
||||
using SafeExamBrowser.SystemComponents.Contracts;
|
||||
using SafeExamBrowser.UserInterface.Desktop;
|
||||
using SafeExamBrowser.WindowsApi;
|
||||
using SafeExamBrowser.Settings.Logging;
|
||||
|
||||
namespace SafeExamBrowser.Runtime
|
||||
{
|
||||
|
@ -83,6 +83,7 @@ namespace SafeExamBrowser.Runtime
|
|||
|
||||
sessionOperations.Enqueue(new SessionInitializationOperation(configuration, logger, runtimeHost, sessionContext));
|
||||
sessionOperations.Enqueue(new ConfigurationOperation(args, configuration, new HashAlgorithm(), logger, sessionContext));
|
||||
sessionOperations.Enqueue(new VirtualMachineOperation(sessionContext));
|
||||
sessionOperations.Enqueue(new ServiceOperation(logger, runtimeHost, serviceProxy, sessionContext, THIRTY_SECONDS, userInfo));
|
||||
sessionOperations.Enqueue(new ClientTerminationOperation(logger, processFactory, proxyFactory, runtimeHost, sessionContext, THIRTY_SECONDS));
|
||||
sessionOperations.Enqueue(new KioskModeOperation(desktopFactory, explorerShell, logger, processFactory, sessionContext));
|
||||
|
@ -115,6 +116,7 @@ namespace SafeExamBrowser.Runtime
|
|||
logger.Log(string.Empty);
|
||||
logger.Log($"# Application started at {appConfig.ApplicationStartTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}");
|
||||
logger.Log($"# Running on {systemInfo.OperatingSystemInfo}");
|
||||
logger.Log($"# Computer '{systemInfo.Name}' is a {systemInfo.Model} manufactured by {systemInfo.Manufacturer}");
|
||||
logger.Log($"# Runtime-ID: {appConfig.RuntimeId}");
|
||||
logger.Log(string.Empty);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2019 ETH Zürich, Educational Development and Technology (LET)
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel;
|
||||
using SafeExamBrowser.Core.Contracts.OperationModel.Events;
|
||||
|
||||
namespace SafeExamBrowser.Runtime.Operations
|
||||
{
|
||||
internal class VirtualMachineOperation : SessionOperation
|
||||
{
|
||||
//private IVirtualMachineDetector detector;
|
||||
|
||||
public VirtualMachineOperation(/*IVirtualMachineDetector detector, */SessionContext context) : base(context)
|
||||
{
|
||||
//this.detector = detector;
|
||||
}
|
||||
|
||||
public override event ActionRequiredEventHandler ActionRequired { add { } remove { } }
|
||||
public override event StatusChangedEventHandler StatusChanged { add { } remove { } }
|
||||
|
||||
public override OperationResult Perform()
|
||||
{
|
||||
return OperationResult.Success;
|
||||
}
|
||||
|
||||
public override OperationResult Repeat()
|
||||
{
|
||||
return OperationResult.Success;
|
||||
}
|
||||
|
||||
public override OperationResult Revert()
|
||||
{
|
||||
return OperationResult.Success;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -106,6 +106,7 @@
|
|||
<Compile Include="Operations\SessionInitializationOperation.cs" />
|
||||
<Compile Include="Communication\RuntimeHost.cs" />
|
||||
<Compile Include="CompositionRoot.cs" />
|
||||
<Compile Include="Operations\VirtualMachineOperation.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
namespace SafeExamBrowser.SystemComponents.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides access to information about the operating system.
|
||||
/// Provides access to information about the computer system.
|
||||
/// </summary>
|
||||
public interface ISystemInfo
|
||||
{
|
||||
|
@ -18,6 +18,21 @@ namespace SafeExamBrowser.SystemComponents.Contracts
|
|||
/// </summary>
|
||||
bool HasBattery { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The manufacturer name of the computer system.
|
||||
/// </summary>
|
||||
string Manufacturer { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The model name of the computer system.
|
||||
/// </summary>
|
||||
string Model { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The machine name of the computer system.
|
||||
/// </summary>
|
||||
string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Reveals the version of the currently running operating system.
|
||||
/// </summary>
|
||||
|
|
|
@ -6,25 +6,33 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Management;
|
||||
using System.Windows.Forms;
|
||||
using SafeExamBrowser.SystemComponents.Contracts;
|
||||
using BatteryChargeStatus = System.Windows.Forms.BatteryChargeStatus;
|
||||
using OperatingSystem = SafeExamBrowser.SystemComponents.Contracts.OperatingSystem;
|
||||
|
||||
namespace SafeExamBrowser.SystemComponents
|
||||
{
|
||||
public class SystemInfo : ISystemInfo
|
||||
{
|
||||
public bool HasBattery { get; private set; }
|
||||
public string Manufacturer { get; private set; }
|
||||
public string Model { get; private set; }
|
||||
public string Name { get; private set; }
|
||||
public OperatingSystem OperatingSystem { get; private set; }
|
||||
|
||||
public string OperatingSystemInfo
|
||||
{
|
||||
get { return $"{OperatingSystemName()}, {System.Environment.OSVersion.VersionString} ({Architecture()})"; }
|
||||
get { return $"{OperatingSystemName()}, {Environment.OSVersion.VersionString} ({Architecture()})"; }
|
||||
}
|
||||
|
||||
public SystemInfo()
|
||||
{
|
||||
InitializeBattery();
|
||||
InitializeMachineInfo();
|
||||
InitializeOperatingSystem();
|
||||
}
|
||||
|
||||
|
@ -35,13 +43,25 @@ namespace SafeExamBrowser.SystemComponents
|
|||
HasBattery = !status.HasFlag(BatteryChargeStatus.NoSystemBattery) && !status.HasFlag(BatteryChargeStatus.Unknown);
|
||||
}
|
||||
|
||||
private void InitializeMachineInfo()
|
||||
{
|
||||
using (var searcher = new ManagementObjectSearcher("Select * from Win32_ComputerSystem"))
|
||||
using (var results = searcher.Get())
|
||||
using (var system = results.Cast<ManagementObject>().FirstOrDefault())
|
||||
{
|
||||
Manufacturer = Convert.ToString(system["Manufacturer"]);
|
||||
Model = string.Join(" ", Convert.ToString(system["SystemFamily"]), Convert.ToString(system["Model"]));
|
||||
Name = Convert.ToString(system["Name"]);
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeOperatingSystem()
|
||||
{
|
||||
// IMPORTANT:
|
||||
// In order to be able to retrieve the correct operating system version via System.Environment.OSVersion, the executing
|
||||
// assembly needs to define an application manifest where the supported Windows versions are specified!
|
||||
var major = System.Environment.OSVersion.Version.Major;
|
||||
var minor = System.Environment.OSVersion.Version.Minor;
|
||||
var major = Environment.OSVersion.Version.Major;
|
||||
var minor = Environment.OSVersion.Version.Minor;
|
||||
|
||||
// See https://en.wikipedia.org/wiki/List_of_Microsoft_Windows_versions for mapping source...
|
||||
if (major == 6)
|
||||
|
@ -84,7 +104,7 @@ namespace SafeExamBrowser.SystemComponents
|
|||
|
||||
private string Architecture()
|
||||
{
|
||||
return System.Environment.Is64BitOperatingSystem ? "x64" : "x86";
|
||||
return Environment.Is64BitOperatingSystem ? "x64" : "x86";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue