public async Task HandleAsync(DomainCommandContext context, GenerateTexturePreviewCommand command) { var settings = new TextureConversionSettings { ColorSpace = command.ColorSpace, FileType = FileType.WIC, MaxHeight = command.MaxSize, MaxWidth = command.MaxSize, OutputFormat = command.OutputFormat, KeepMipmaps = false }; var metadata = _textureService.GetMetadata(command.FilePath); if (metadata == null) { await context.EmitAsync(new ErrorOccuredNotification()); } var texture = _textureService.Convert(command.FilePath, settings); if (texture?.Metadata == null) { await context.EmitAsync(new ErrorOccuredNotification()); } await context.EmitAsync(new GeneratedTexturePreviewNotification(texture, metadata)); }
public async Task HandleAsync(DomainCommandContext context, ConvertTextureCommand command) { Texture texture = null; try { texture = _textureService.Convert( Path.Combine(command.SourceDirectoryPath, command.FileName), command.Settings); } catch (Exception exception) { _logger.Log(LogLevel.Error, $"texture conversion failed; exception: {exception}"); } if (texture?.Metadata == null) { await context.EmitAsync(new ErrorOccuredNotification()); return; } var directory = await _directoryRepository.LoadAsync(command.DestinationDirectoryPath); directory.AddFile(command.FileName, texture.Buffer); await _directoryRepository.SaveAsync(directory); await context.EmitAsync(new ActionSucceededNotification()); }
public async Task HandleAsync(DomainCommandContext context, InitializeCommand command) { var applicationSettings = await _applicationSettingsRepository.LoadAsync(); var games = await _gameRepository.LoadAllAsync(); var gameProfileId = await _gameRepository.LoadGameProfileIdAsync(); var textureManagementSettings = await _textureManagementSettingsRepository.LoadAsync(); var usageStatistics = await _usageStatisticsRepository.LoadAsync(); var @event = new InitializeEvent( applicationSettings.Map <ApplicationSettings>(), games.Map <IEnumerable <Game> >(), gameProfileId?.Value, textureManagementSettings.Map <TextureManagementSettings>(), usageStatistics.Map <SharedModel.UsageStatistics>()); foreach (var settings in games) { await _processWatcher.WatchAsync(settings.Id); } await context.PublishAsync(@event); }
public async Task HandleAsync(DomainCommandContext context, LoadTextureFilesCommand command) { IEnumerable <TextureFile> files; try { files = _textureService.GetTextureFiles(command.DirectoryPath); } catch (DirectoryNotFoundException) { await context.EmitAsync(new ErrorOccuredNotification()); return; } catch (PathTooLongException) { await context.EmitAsync(new ErrorOccuredNotification()); return; } catch (SecurityException) { await context.EmitAsync(new ErrorOccuredNotification()); return; } catch (UnauthorizedAccessException) { await context.EmitAsync(new ErrorOccuredNotification()); return; } await context.EmitAsync(new TextureFilesLoadedNotification(files)); }
public async Task HandleAsync(DomainCommandContext context, UpdateTextureManagementSettingsCommand command) { var settings = command.Settings.Map <TextureManagementSettings>(); await _textureManagementSettingsRepository.SaveAsync(settings); await context.PublishAsync(new TextureManagementSettingsUpdatedEvent(command.Settings)); }
public async Task HandleAsync(DomainCommandContext context, TCommand command) { using (var transaction = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled)) { await _domainCommandHandler.HandleAsync(context, command); transaction.Complete(); } }
public async Task HandleAsync(DomainCommandContext context, IndicateFirstLaunchCommand command) { var usageStatistics = await _usageStatisticsRepository.LoadAsync(); usageStatistics.FirstLaunchTime = command.Time; await _usageStatisticsRepository.SaveAsync(usageStatistics); await context.PublishAsync(new FirstLaunchIndicatedEvent(command.Time)); }
public async Task HandleAsync(DomainCommandContext context, UpdateApplicationSettingsCommand command) { var applicationSettings = await _applicationSettingsRepository.LoadAsync(); applicationSettings.ApplicationCommunicationPort = command.ApplicationCommunicationPort; applicationSettings.ProxyCommunicationPort = command.ProxyCommunicationPort; await _applicationSettingsRepository.SaveAsync(applicationSettings); await context.PublishAsync(new ApplicationSettingsUpdatedEvent(command.ApplicationCommunicationPort, command.ProxyCommunicationPort)); }
public async Task HandleAsync(DomainCommandContext context, RemoveGameProfileCommand command) { var game = await _gameRepository.LoadByGameProfileId(command.Id); game.RemoveGameProfile(command.Id); await _gameRepository.SaveAsync(game); await _processWatcher.UnwatchAsync(command.Id); await context.PublishAsync(new GameProfileRemovedEvent(game.ProfileId, command.Id)); }
public async Task HandleAsync(DomainCommandContext context, UpdateGameCommand command) { var game = await _gameRepository.LoadAsync(command.Id); game.ChangeName(command.Name); game.ChangeFilePath(command.FilePath); await _gameRepository.SaveAsync(game); await _processWatcher.WatchAsync(game.Id); await context.PublishAsync(new GameUpdatedEvent(game.Id, game.Name, game.FilePath)); }
public async Task HandleAsync(DomainCommandContext context, UpdateProxySettingsCommand command) { if (await UpdateAsync(command.ProxyPluginSettings)) { var settings = await GetProxySettingsAsync(); if (settings != null) { await context.PublishAsync(new SharedEvent.ProxySettingsLoadedEvent(settings)); return; } } await context.EmitAsync(new ErrorOccuredNotification()); }
public async Task HandleAsync(DomainCommandContext context, LoadProxySettingsCommand command) { using (var communicator = _communicatorFactory.Create()) { var result = await communicator.GetProxySettingsAsync(); if (result.IsCompleted) { await context.PublishAsync(new ProxySettingsLoadedEvent(result.Response.Map <ProxySettings>())); return; } await context.EmitAsync(new ErrorOccuredNotification()); } }
public async Task HandleAsync(DomainCommandContext context, UpdateGameProfileCommand command) { var gameProfile = command.GameProfile.Map <GameProfile>(); var game = await _gameRepository.LoadByGameProfileId(gameProfile.Id); var profile = game.AddGameProfile( command.GameProfile.Id, command.GameProfile.Name, command.GameProfile.ProxyDirectoryPath, command.GameProfile.LogsDirectoryPath, command.GameProfile.PluginType, command.GameProfile.Direct3D11Settings.Map <Direct3D11Settings>()); await _gameRepository.SaveAsync(game); await _processWatcher.WatchAsync(game.Id); await context.PublishAsync(new GameProfileUpdatedEvent(profile.Map <Shared.Model.GameSettings.GameProfile>())); }
public async Task HandleAsync(DomainCommandContext context, StarGameCommand command) { var game = await _gameRepository.LoadAsync(command.GameId); if (_injectionService.IsProxyLoaded(game.FilePath, _plugins.Proxy)) { await context.PublishAsync( new SharedEvent.GameStartedEvent( game.FilePath, GameLaunchingStatus.PluginAlreadyLoaded)); return; } var result = _injectionService.Start(game.FilePath) ? GameLaunchingStatus.Completed : GameLaunchingStatus.Failed; await context.PublishAsync(new SharedEvent.GameStartedEvent(game.FilePath, result)); }
public async Task HandleAsync(DomainCommandContext context, AddGameProfileCommand command) { var game = await _gameRepository.LoadAsync(command.GameId); if (game == null) { await context.EmitAsync(new ErrorOccuredNotification()); return; } var gameProfileTemplate = game.Profiles.SingleOrDefault(entity => entity.Id == (AggregateId)command.BasedOnGameProfileId); if (gameProfileTemplate == null) { await context.EmitAsync(new ErrorOccuredNotification()); return; } var gameProfile = game.AddGameProfile( AggregateId.Generate(), command.Name, gameProfileTemplate.ProxyDirectoryPath, gameProfileTemplate.LogsDirectoryPath, gameProfileTemplate.PluginType, gameProfileTemplate.Direct3D11Settings); await _gameRepository.SaveAsync(game); await _processWatcher.WatchAsync(game.Id); var @event = new GameProfileAddedEvent( game.Id, game.ProfileId, gameProfile.Map <GameProfile>()); await context.PublishAsync(@event); }
public async Task HandleAsync(DomainCommandContext context, UpdateLastEditedGameProfileCommand command) { await _gameRepository.ChangeGameProfileAsync(command.Id); await context.PublishAsync(new LastEditedGameProfileUpdatedEvent(command.Id)); }
public async Task HandleAsync(DomainCommandContext context, LoadProxyActivationStatusCommand command) { var status = GetActivationStatus(command.ApplicationFilePath); await context.PublishAsync(new ProxyActivationStatusLoadedEvent(command.ApplicationFilePath, status)); }