This commit is contained in:
@@ -70,6 +70,26 @@ namespace AyaNova.Api.Controllers
|
|||||||
return Ok(ApiOkResponse.Response(ret));
|
return Ok(ApiOkResponse.Response(ret));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get DB Emptiness
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Checks if there is any data in critical tables only</returns>
|
||||||
|
[HttpGet("database-empty")]
|
||||||
|
public async Task<IActionResult> GetDbEmpty()
|
||||||
|
{
|
||||||
|
if (serverState.IsClosed)
|
||||||
|
{
|
||||||
|
//Exception for SuperUser account to handle licensing issues
|
||||||
|
if (UserIdFromContext.Id(HttpContext.Items) != 1)
|
||||||
|
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||||
|
}
|
||||||
|
if (!Authorized.HasReadFullRole(HttpContext.Items, AyaType.License))
|
||||||
|
{
|
||||||
|
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||||
|
}
|
||||||
|
return Ok(ApiOkResponse.Response(await AyaNova.Util.DbUtil.DBIsEmptyAsync(ct, log)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -111,7 +131,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.License, AyaEvent.LicenseFetch), ct);
|
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserIdFromContext.Id(HttpContext.Items), 0, AyaType.License, AyaEvent.LicenseFetch), ct);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log.LogError($"LicenseController::FetchLicense - failed: {ret}");
|
log.LogError($"LicenseController::FetchLicense - failed: {ret}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -401,7 +401,13 @@ namespace AyaNova.Util
|
|||||||
if (await ct.WorkOrder.AnyAsync()) return false;
|
if (await ct.WorkOrder.AnyAsync()) return false;
|
||||||
if (await ct.Quote.AnyAsync()) return false;
|
if (await ct.Quote.AnyAsync()) return false;
|
||||||
if (await ct.PM.AnyAsync()) return false;
|
if (await ct.PM.AnyAsync()) return false;
|
||||||
|
if (await ct.Unit.AnyAsync()) return false;
|
||||||
|
if (await ct.HeadOffice.AnyAsync()) return false;
|
||||||
|
if (await ct.LoanUnit.AnyAsync()) return false;
|
||||||
|
if (await ct.Part.AnyAsync()) return false;
|
||||||
|
if (await ct.Project.AnyAsync()) return false;
|
||||||
|
if (await ct.PurchaseOrder.AnyAsync()) return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user