public async Task Handle(ResumeGeneration message, CancellationToken token = default(CancellationToken)) { if (this.isStarted) { throw new InvalidOperationException("Graph is already being generated."); } await this.notificationLogClient.ResumeGeneration(); this.isStarted = true; }
public GraphModule(ICommandSender commandSender) : base("/cortex/graph") { this.Post("/regenerate", async(parameters) => { Response result = null; try { var command = new Regenerate(); await commandSender.Send(command); result = new Response { StatusCode = HttpStatusCode.OK }; } catch (Exception ex) { var error = $"An error occurred during graph regeneration: {ex.Message}; Stack Trace: {ex.StackTrace}"; GraphModule.logger.Error(ex, error); result = new Response { StatusCode = HttpStatusCode.InternalServerError }; } return(result); } ); this.Post("/resumegeneration", async(parameters) => { Response result = null; try { var command = new ResumeGeneration(); await commandSender.Send(command); result = new Response { StatusCode = HttpStatusCode.OK }; } catch (Exception ex) { GraphModule.logger.Error(ex, $"An error occurred while resuming graph generation: {ex.Message}; Stack Trace: {ex.StackTrace}"); result = new Response { StatusCode = HttpStatusCode.InternalServerError }; } return(result); } ); }