This commit is contained in:
2020-01-27 22:50:10 +00:00
parent 76e7d98319
commit dafdaac654
3 changed files with 9 additions and 7 deletions

View File

@@ -66,7 +66,7 @@ namespace AyaNova.Api.Controllers
string sResult = await GetTheMetrics("plain"); string sResult = await GetTheMetrics("plain");
//Log //Log
EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.Metrics, AyaEvent.Retrieved), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.Metrics, AyaEvent.Retrieved), ct);
return Content(sResult); return Content(sResult);
} }
@@ -94,7 +94,7 @@ namespace AyaNova.Api.Controllers
JObject json = JObject.Parse(sResult); JObject json = JObject.Parse(sResult);
//Log //Log
EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.Metrics, AyaEvent.Retrieved), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.Metrics, AyaEvent.Retrieved), ct);
return Ok(ApiOkResponse.Response(json, true)); return Ok(ApiOkResponse.Response(json, true));
} }

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
@@ -59,7 +60,7 @@ namespace AyaNova.Api.Controllers
/// <returns>NoContent 204</returns> /// <returns>NoContent 204</returns>
[HttpPost] [HttpPost]
[Authorize] [Authorize]
public ActionResult PostServerState([FromBody] ServerStateModel state) public async Task<IActionResult> PostServerState([FromBody] ServerStateModel state)
{ {
if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.ServerState)) if (!Authorized.HasModifyRole(HttpContext.Items, AyaType.ServerState))
{ {
@@ -88,7 +89,7 @@ namespace AyaNova.Api.Controllers
serverState.SetState(desiredState, state.Reason); serverState.SetState(desiredState, state.Reason);
//Log //Log
EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.ServerState, AyaEvent.ServerStateChange, $"{state.ServerState}-{state.Reason}"), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.ServerState, AyaEvent.ServerStateChange, $"{state.ServerState}-{state.Reason}"), ct);
return NoContent(); return NoContent();
} }

View File

@@ -1,3 +1,4 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@@ -51,7 +52,7 @@ namespace AyaNova.Api.Controllers
/// <param name="timeZoneOffset">Value in hours of local time zone offset from UTC / GMT. This ensures that data is generated relative to the desired time zone</param> /// <param name="timeZoneOffset">Value in hours of local time zone offset from UTC / GMT. This ensures that data is generated relative to the desired time zone</param>
/// <returns></returns> /// <returns></returns>
[HttpPost("seed/{size}/{timeZoneOffset}")] [HttpPost("seed/{size}/{timeZoneOffset}")]
public ActionResult SeedTrialDatabase([FromRoute] string size,[FromRoute] decimal timeZoneOffset ) public async Task<IActionResult> SeedTrialDatabase([FromRoute] string size,[FromRoute] decimal timeZoneOffset )
{ {
if (!serverState.IsOpen) if (!serverState.IsOpen)
{ {
@@ -101,10 +102,10 @@ namespace AyaNova.Api.Controllers
j.JobType = JobType.SeedTestData; j.JobType = JobType.SeedTestData;
j.Exclusive = true;//don't run other jobs, this will erase the db j.Exclusive = true;//don't run other jobs, this will erase the db
j.JobInfo = o.ToString(); j.JobInfo = o.ToString();
JobsBiz.AddJobAsync(j, ct); await JobsBiz.AddJobAsync(j, ct);
//Log //Log
EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.TrialSeeder, AyaEvent.Created, size), ct); await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.TrialSeeder, AyaEvent.Created, size), ct);
return Accepted(new { JobId = j.GId });//202 accepted return Accepted(new { JobId = j.GId });//202 accepted
} }