SEBWIN-320: Implemented version step for reset utility.

This commit is contained in:
dbuechel 2019-07-16 16:09:12 +02:00
parent a27723dc35
commit fbe6f45d78
6 changed files with 53 additions and 5 deletions

View file

@ -22,7 +22,7 @@ namespace SafeExamBrowser.ResetUtility.Procedure
internal override ProcedureStepResult Execute() internal override ProcedureStepResult Execute()
{ {
Initialize(); InitializeConsole();
if (IsSingleInstance() && HasAdminPrivileges() && SebNotRunning()) if (IsSingleInstance() && HasAdminPrivileges() && SebNotRunning())
{ {

View file

@ -22,6 +22,7 @@ namespace SafeExamBrowser.ResetUtility.Procedure
{ {
new Option { IsSelected = true, NextStep = new Restore(Context), Result = ProcedureStepResult.Continue, Text = "Restore system configuration via backup mechanism" }, new Option { IsSelected = true, NextStep = new Restore(Context), Result = ProcedureStepResult.Continue, Text = "Restore system configuration via backup mechanism" },
new Option { NextStep = new Reset(Context), Result = ProcedureStepResult.Continue, Text = "Reset system configuration to default values" }, new Option { NextStep = new Reset(Context), Result = ProcedureStepResult.Continue, Text = "Reset system configuration to default values" },
new Option { NextStep = new ShowVersion(Context), Result = ProcedureStepResult.Continue, Text = "Show version information" },
new Option { NextStep = new ShowLog(Context), Result = ProcedureStepResult.Continue, Text = "Show application log" }, new Option { NextStep = new ShowLog(Context), Result = ProcedureStepResult.Continue, Text = "Show application log" },
new Option { Result = ProcedureStepResult.Terminate, Text = "Exit" } new Option { Result = ProcedureStepResult.Terminate, Text = "Exit" }
}; };
@ -50,7 +51,7 @@ namespace SafeExamBrowser.ResetUtility.Procedure
private void PrintMenu() private void PrintMenu()
{ {
Initialize(); InitializeConsole();
Console.WriteLine("Please choose one of the following options:"); Console.WriteLine("Please choose one of the following options:");
Console.WriteLine(); Console.WriteLine();

View file

@ -26,7 +26,7 @@ namespace SafeExamBrowser.ResetUtility.Procedure
internal abstract ProcedureStepResult Execute(); internal abstract ProcedureStepResult Execute();
internal abstract ProcedureStep GetNextStep(); internal abstract ProcedureStep GetNextStep();
protected void Initialize() protected void InitializeConsole()
{ {
var title = "SEB Reset Utility"; var title = "SEB Reset Utility";

View file

@ -27,7 +27,7 @@ namespace SafeExamBrowser.ResetUtility.Procedure
{ {
offset = UpdateOffset(key, offset, log.Count); offset = UpdateOffset(key, offset, log.Count);
Initialize(); InitializeConsole();
PrintInstructions(); PrintInstructions();
PrintLogSection(log, offset); PrintLogSection(log, offset);
} }
@ -135,7 +135,7 @@ namespace SafeExamBrowser.ResetUtility.Procedure
case LogLevel.Warning: case LogLevel.Warning:
return ConsoleColor.DarkYellow; return ConsoleColor.DarkYellow;
default: default:
return ForegroundColor; return ConsoleColor.DarkBlue;
} }
} }
} }

View file

@ -0,0 +1,46 @@
/*
* 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 System;
using System.Reflection;
namespace SafeExamBrowser.ResetUtility.Procedure
{
internal class ShowVersion : ProcedureStep
{
public ShowVersion(Context context) : base(context)
{
}
internal override ProcedureStepResult Execute()
{
var executable = Assembly.GetExecutingAssembly();
var build = executable.GetCustomAttribute<AssemblyFileVersionAttribute>().Version;
var copyright = executable.GetCustomAttribute<AssemblyCopyrightAttribute>().Copyright;
var version = executable.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
InitializeConsole();
Console.ForegroundColor = ConsoleColor.DarkBlue;
Console.WriteLine($"Safe Exam Browser, Version {version}");
Console.WriteLine($"Build Version {build}");
Console.WriteLine(copyright.Replace("©", "(c)"));
Console.WriteLine();
Console.ForegroundColor = ForegroundColor;
Console.WriteLine("Press any key to return to the main menu.");
Console.ReadKey();
return ProcedureStepResult.Continue;
}
internal override ProcedureStep GetNextStep()
{
return new MainMenu(Context);
}
}
}

View file

@ -70,6 +70,7 @@
<Compile Include="Procedure\Reset.cs" /> <Compile Include="Procedure\Reset.cs" />
<Compile Include="Procedure\Restore.cs" /> <Compile Include="Procedure\Restore.cs" />
<Compile Include="Procedure\ShowLog.cs" /> <Compile Include="Procedure\ShowLog.cs" />
<Compile Include="Procedure\ShowVersion.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup> </ItemGroup>