2018-02-12 12:21:55 +01:00
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018 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 SafeExamBrowser.Contracts.Behaviour.Operations;
|
|
|
|
|
using SafeExamBrowser.Contracts.Communication;
|
|
|
|
|
using SafeExamBrowser.Contracts.Configuration;
|
|
|
|
|
using SafeExamBrowser.Contracts.I18n;
|
|
|
|
|
using SafeExamBrowser.Contracts.Logging;
|
|
|
|
|
using SafeExamBrowser.Contracts.UserInterface;
|
|
|
|
|
|
|
|
|
|
namespace SafeExamBrowser.Client.Behaviour.Operations
|
|
|
|
|
{
|
|
|
|
|
internal class ConfigurationOperation : IOperation
|
|
|
|
|
{
|
2018-02-15 15:42:54 +01:00
|
|
|
|
private ClientConfiguration configuration;
|
2018-02-12 12:21:55 +01:00
|
|
|
|
private ILogger logger;
|
|
|
|
|
private IRuntimeProxy runtime;
|
|
|
|
|
|
|
|
|
|
public bool Abort { get; private set; }
|
|
|
|
|
public IProgressIndicator ProgressIndicator { private get; set; }
|
|
|
|
|
|
2018-02-15 15:42:54 +01:00
|
|
|
|
public ConfigurationOperation(ClientConfiguration configuration, ILogger logger, IRuntimeProxy runtime)
|
2018-02-12 12:21:55 +01:00
|
|
|
|
{
|
|
|
|
|
this.configuration = configuration;
|
|
|
|
|
this.logger = logger;
|
|
|
|
|
this.runtime = runtime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Perform()
|
|
|
|
|
{
|
|
|
|
|
logger.Info("Initializing application configuration...");
|
|
|
|
|
ProgressIndicator?.UpdateText(TextKey.ProgressIndicator_InitializeConfiguration);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var config = runtime.GetConfiguration();
|
|
|
|
|
|
|
|
|
|
configuration.RuntimeInfo = config.RuntimeInfo;
|
2018-02-14 15:26:05 +01:00
|
|
|
|
configuration.SessionId = config.SessionId;
|
2018-02-12 12:21:55 +01:00
|
|
|
|
configuration.Settings = config.Settings;
|
|
|
|
|
|
|
|
|
|
logger.Info("Successfully retrieved the application configuration from the runtime.");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
logger.Error("An unexpected error occurred while trying to retrieve the application configuration!", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Repeat()
|
|
|
|
|
{
|
|
|
|
|
// Nothing to do here...
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Revert()
|
|
|
|
|
{
|
|
|
|
|
// Nothing to do here...
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|