public IHttpActionResult Post([FromBody] List<ExecuteRequest> requests) { ContextSwitch.Go(); using (var session = new Session()) { foreach (var r in requests) { var mappedPath = PathProvider.Translate(r.Path); session.Load(new Command(mappedPath, r.Args, r.Type)); } session.RunAsync(); return Ok(ExecuteResult.Ok(requests, session.Result)); } }
public IHttpActionResult Get([FromUri] string path, [FromUri] string[] args, [FromUri] CommandType type = CommandType.Cmd) { ContextSwitch.Go(); try { var mappedPath = PathProvider.Translate(path); using (var session = new Session()) { session.Load(new Command(mappedPath, args, type)).RunAsync(); return Ok(ExecuteResult.Ok(new ExecuteRequest(path, args), session.Result)); } } catch (Exception e) { return BadRequest(e.ToString()); } }