public static string GetMessage(FailMessages failMessages) { switch (failMessages) { case FailMessages.VehicleWentOffRoute: return("OH NO !! The Vehicle Went Off Route .. We Lost It .. "); default: return(""); } }
public async Task GivenCommand_WhenIngredientDoesNotExist_ReturnFailure() { var result = await _systemUnderTests.Handle(_command); using (new AssertionScope()) { result.IsFailure.Should().BeTrue(); result.Message.Should().Be(FailMessages.DoesNotExist(nameof(Ingredient), nameof(UpdateIngredientCommand.Id), _command.Id.ToString())); } }
public static void Initialize(StartupEventArgs e) { var isMaintenanceMode = e.Args.Select(a => a.ToLower()).Contains("-maintenance"); var postUpdate = e.Args.Select(a => a.ToLower()).Contains("-postupdate"); // determine mode and rescue/maintenance self if (!CheckRescueMaintenance(isMaintenanceMode)) { Environment.Exit(-1); } if (postUpdate || AutoUpdateService.IsPostUpdateFileExisted()) { // remove update binary AutoUpdateService.PostUpdate(); } else if (AutoUpdateService.IsUpdateBinaryExisted()) { // execute auto-update AutoUpdateService.StartUpdate(App.Version); Environment.Exit(0); } try { // create lock file using (File.Create(App.LockFilePath)) { // do nothing } } catch (Exception ex) { FailMessages.InitLockFailed(ex); Environment.Exit(-1); } // initialze web parameters InitializeWebConnectionParameters(); // load subsystems, load settings InitializeSubsystemsBeforeSettingsLoaded(); if (!Setting.LoadSettings()) { // failed loading settings Environment.Exit(-1); } // prepare user anonymous id InitializeSubsystemsAfterSettingsLoaded(); }
private static void PrepareConfigurationDirectory() { // create data-store directory try { Directory.CreateDirectory(App.ConfigurationDirectoryPath); } catch (Exception ex) { FailMessages.InitConfDirFailed(ex); Environment.Exit(-1); } }
public async Task GivenProperData_WhenIngredientExist_ShouldReturnResultFailure() { _ingredientRepositoryMock.Setup(x => x.ExistByName(It.IsAny <string>())) .Returns(true); var result = await _systemUnderTest.Handle(_command); using (new AssertionScope()) { result.IsFailure.Should().BeTrue(); result.Message.Should().Be(FailMessages.AlreadyExist(nameof(Ingredient), nameof(CreateIngredientCommand.Name), _command.Name)); } }
public static void PreInitialize(StartupEventArgs e) { var isMaintenanceMode = e.Args.Select(a => a.ToLower()).Contains("-maintenance"); PrepareConfigurationDirectory(); SetSystemParameters(App.IsMulticoreJitEnabled && !isMaintenanceMode, App.IsHardwareRenderingEnabled); if (!isMaintenanceMode && !CheckInitializeMutex()) { FailMessages.LaunchDuplicated(); Environment.Exit(-1); } }
public async Task <Result> Handle(UpdateIngredientCommand command) { foreach (var validator in _validators) { var validationResult = validator.Validate(command); if (validationResult.IsFailure) { return(validationResult); } } var ingredient = _ingredientRepository.GetById(command.Id); if (ingredient == null) { return(Result.Fail(ResultCode.NotFound, FailMessages.DoesNotExist(nameof(Ingredient), nameof(UpdateIngredientCommand.Id), command.Id.ToString()))); } ingredient.Update(command.Name, command.Allergens, command.Requirements, command.Shares); _eventPublisher.Rise(); return(Result.Ok()); }
/// <summary> /// Show maintenance option dialog (TaskDialog) /// </summary> /// <returns>when returning false, should abort execution</returns> private static bool ShowMaintenanceDialog() { var resp = ConfirmationMassages.ConfirmMaintenance(); if (!resp.CommandButtonResult.HasValue || resp.CommandButtonResult.Value == 5) { return(false); } try { switch (resp.CommandButtonResult.Value) { case 1: // optimize database ScheduleDatabaseOptimization(); break; case 2: // remove database if (File.Exists(App.DatabaseFilePath)) { File.Delete(App.DatabaseFilePath); } break; case 3: case 4: case 5: // remove all if (App.ExecutionMode == ExecutionMode.Standalone) { // remove each var files = new[] { App.DatabaseFilePath, App.DatabaseFilePath, App.HashtagTempFilePath, App.ListUserTempFilePath, Path.Combine(App.ConfigurationDirectoryPath, App.ProfileFileName) }; var dirs = new[] { App.KeyAssignProfilesDirectory }; files.Where(File.Exists).ForEach(File.Delete); dirs.Where(Directory.Exists).ForEach(d => Directory.Delete(d, true)); } else { // remove whole directory if (Directory.Exists(App.ConfigurationDirectoryPath)) { Directory.Delete(App.ConfigurationDirectoryPath, true); } } break; } } catch (Exception ex) { FailMessages.GeneralProcessFailed(ex); } if (resp.CommandButtonResult.Value == 5) { // force update var w = new AwaitDownloadingUpdateWindow(); w.ShowDialog(); } return(resp.CommandButtonResult.Value < 4); }