public async Task <bool> Handle(Request request, CancellationToken cancellationToken) { await _jobScheduler.ClearAsync(cancellationToken); _context.Session = new Session { IsDirty = true, Widget = new Root() }; return(true); }
public async Task <bool> Handle(Request request, CancellationToken cancellationToken) { if (_context.Session is null) { throw new Exception("Session not found"); } if (string.IsNullOrEmpty(request.FileName)) { var dialog = new OpenFileDialog("JSON|*.json"); var result = _dialogService.ShowFileDialog(dialog); if (result != DialogResult.OK) { return(false); } request.FileName = dialog.FileName; } if (string.IsNullOrEmpty(request.FileName) || !File.Exists(request.FileName)) { throw new FileNotFoundException(request.FileName); } _context.Session.IsDirty = false; _context.Session.FileName = request.FileName; _context.Session.Widget = GetWidget(request.FileName); await _jobScheduler.ClearAsync(cancellationToken); await Schedule(_context.Session.Widget, cancellationToken); return(true); }