private bool TryEstablishConnection() { var mandatory = Context.Next.Settings.Service.Policy == ServicePolicy.Mandatory; var warn = Context.Next.Settings.Service.Policy == ServicePolicy.Warn; var connected = service.Connect(); var success = connected || !mandatory; if (success) { service.Ignore = !connected; logger.Info($"The service is {(mandatory ? "mandatory" : "optional")} and {(connected ? "connected." : "not connected. All service-related operations will be ignored!")}"); if (!connected && warn) { ActionRequired?.Invoke(new MessageEventArgs { Icon = MessageBoxIcon.Warning, Message = TextKey.MessageBox_ServiceUnavailableWarning, Title = TextKey.MessageBox_ServiceUnavailableWarningTitle }); } } else { logger.Error("The service is mandatory but no connection could be established!"); ActionRequired?.Invoke(new MessageEventArgs { Icon = MessageBoxIcon.Error, Message = TextKey.MessageBox_ServiceUnavailableError, Title = TextKey.MessageBox_ServiceUnavailableErrorTitle }); } return(success); }
private void Initialize(WhitelistApplication settings) { var result = factory.TryCreate(settings, out var application); while (result == FactoryResult.NotFound && settings.AllowCustomPath) { var args = new ApplicationNotFoundEventArgs(settings.DisplayName, settings.ExecutableName); ActionRequired?.Invoke(args); if (args.Success) { settings.ExecutablePath = args.CustomPath; result = factory.TryCreate(settings, out application); } else { break; } } if (result == FactoryResult.Success) { Context.Applications.Add(application); } else { logger.Error($"Failed to initialize application '{settings.DisplayName}' ({settings.ExecutableName}). Reason: {result}."); ActionRequired?.Invoke(new ApplicationInitializationFailedEventArgs(settings.DisplayName, settings.ExecutableName, result)); } }
private OperationResult ShowDisclaimer() { var args = new MessageEventArgs { Action = MessageBoxAction.OkCancel, Icon = MessageBoxIcon.Information, Message = TextKey.MessageBox_ProctoringDisclaimer, Title = TextKey.MessageBox_ProctoringDisclaimerTitle }; StatusChanged?.Invoke(TextKey.OperationStatus_WaitDisclaimerConfirmation); ActionRequired?.Invoke(args); if (args.Result == MessageBoxResult.Ok) { logger.Info("The user confirmed the remote proctoring disclaimer."); return(OperationResult.Success); } else { logger.Warn("The user did not confirm the remote proctoring disclaimer! Aborting session initialization..."); return(OperationResult.Aborted); } }
private OperationResult HandleAutoTerminationFailure(IList <RunningApplication> applications) { logger.Error($"{applications.Count} application(s) could not be automatically terminated: {string.Join(", ", applications.Select(a => a.Name))}"); ActionRequired?.Invoke(new ApplicationTerminationFailedEventArgs(applications)); return(OperationResult.Failed); }
public void Run(string[] args) { ActionRequired actionRequired = ActionRequired.None; foreach (string cmd in args) { if (cmd.StartsWith("/")) { switch (cmd.Substring(1)) { case "c": actionRequired = ActionRequired.CalculateCharge; break; default: break; } } } switch (actionRequired) { case ActionRequired.CalculateCharge: chargeCalculator.Action(); break; default: break; } }
private bool AbortAfterClientConfiguration() { var args = new ConfigurationCompletedEventArgs(); ActionRequired?.Invoke(args); logger.Info($"The user chose to {(args.AbortStartup ? "abort" : "continue")} startup after successful client configuration."); return(args.AbortStartup); }
public HttpResponseMessage actionRequiredCSV(Guid orgId, Guid projId, Guid? locId) { DateTime? startDate = grabStartDate(DateTime.Now.AddDays(-14)); var response = csvStream("actionrequired.csv", new PushStreamContent((stream, Content, context) => { var writer = new StreamWriter(stream); ActionRequired.buildCSV(writer, orgId, projId, locId, startDate.Value); })); return response; } // actionRequiredcsv
private bool TryGetPassword(PasswordRequestPurpose purpose, out string password) { var args = new PasswordRequiredEventArgs { Purpose = purpose }; ActionRequired?.Invoke(args); password = args.Password; return(args.Success); }
private bool?TryConfigureClient(Uri uri, PasswordParameters passwordParams, string currentPassword = default(string)) { var mustAuthenticate = IsRequiredToAuthenticateForClientConfiguration(passwordParams, currentPassword); logger.Info("Starting client configuration..."); if (mustAuthenticate) { var authenticated = AuthenticateForClientConfiguration(currentPassword); if (authenticated == true) { logger.Info("Authentication was successful."); } if (authenticated == false) { logger.Info("Authentication has failed!"); ActionRequired?.Invoke(new InvalidPasswordMessageArgs()); return(false); } if (!authenticated.HasValue) { logger.Info("Authentication was aborted."); return(null); } } else { logger.Info("Authentication is not required."); } var status = configuration.ConfigureClientWith(uri, passwordParams); var success = status == SaveStatus.Success; if (success) { logger.Info("Client configuration was successful."); } else { logger.Error($"Client configuration failed with status '{status}'!"); ActionRequired?.Invoke(new ClientConfigurationErrorMessageArgs()); } return(success); }
private OperationResult TryTerminate(IEnumerable <RunningApplication> runningApplications) { var args = new ApplicationTerminationEventArgs(runningApplications); var failed = new List <RunningApplication>(); var result = OperationResult.Success; logger.Info($"The following applications need to be terminated: {string.Join(", ", runningApplications.Select(a => a.Name))}."); ActionRequired?.Invoke(args); if (args.TerminateProcesses) { logger.Info($"The user chose to automatically terminate all running applications."); foreach (var application in runningApplications) { var success = monitor.TryTerminate(application); if (success) { logger.Info($"Successfully terminated application '{application.Name}'."); } else { result = OperationResult.Failed; failed.Add(application); logger.Error($"Failed to automatically terminate application '{application.Name}'!"); } } } else { logger.Info("The user chose not to automatically terminate all running applications. Aborting..."); result = OperationResult.Aborted; } if (failed.Any()) { ActionRequired?.Invoke(new ApplicationTerminationFailedEventArgs(failed)); } return(result); }
private void ShowFailureMessage(LoadStatus status, Uri uri) { switch (status) { case LoadStatus.PasswordNeeded: ActionRequired?.Invoke(new InvalidPasswordMessageArgs()); break; case LoadStatus.InvalidData: ActionRequired?.Invoke(new InvalidDataMessageArgs(uri.ToString())); break; case LoadStatus.NotSupported: ActionRequired?.Invoke(new NotSupportedMessageArgs(uri.ToString())); break; case LoadStatus.UnexpectedError: ActionRequired?.Invoke(new UnexpectedErrorMessageArgs(uri.ToString())); break; } }
private OperationResult ValidatePolicy() { logger.Info($"Validating remote session policy..."); StatusChanged?.Invoke(TextKey.OperationStatus_ValidateRemoteSessionPolicy); if (Context.Next.Settings.Service.DisableRemoteConnections && detector.IsRemoteSession()) { var args = new MessageEventArgs { Icon = MessageBoxIcon.Error, Message = TextKey.MessageBox_RemoteSessionNotAllowed, Title = TextKey.MessageBox_RemoteSessionNotAllowedTitle }; logger.Error("Detected remote session while SEB is not allowed to be run in a remote session! Aborting..."); ActionRequired?.Invoke(args); return(OperationResult.Aborted); } return(OperationResult.Success); }
private OperationResult ValidatePolicy() { logger.Info($"Validating virtual machine policy..."); StatusChanged?.Invoke(TextKey.OperationStatus_ValidateVirtualMachinePolicy); if (Context.Next.Settings.Security.VirtualMachinePolicy == VirtualMachinePolicy.Deny && detector.IsVirtualMachine()) { var args = new MessageEventArgs { Icon = MessageBoxIcon.Error, Message = TextKey.MessageBox_VirtualMachineNotAllowed, Title = TextKey.MessageBox_VirtualMachineNotAllowedTitle }; logger.Error("Detected virtual machine while SEB is not allowed to be run in a virtual machine! Aborting..."); ActionRequired?.Invoke(args); return(OperationResult.Aborted); } return(OperationResult.Success); }
protected override void InvokeActionRequired(ActionRequiredEventArgs args) { ActionRequired?.Invoke(args); }
public Message(ActionRequired actionRequired, string messageString) : base(7, 1) { ActionRequired = actionRequired; MessageString = messageString; }
public IHttpActionResult actionRequired(Guid orgId, Guid projId, Guid? locId) { DateTime? startDate = grabStartDate(DateTime.Now.AddDays(-14)); ReportData<ActionRequired.Row> reportData = ActionRequired.build(orgId, projId, locId, startDate.Value); return Ok(reportData); } // actionRequired