Created ECN# autocomplete for PCR3 docs
This commit is contained in:
@ -53,4 +53,36 @@ public class ECNController : ControllerBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
[Route("ecn/allNumbers")]
|
||||||
|
public async Task<IActionResult> GetAllECNNumbers() {
|
||||||
|
DateTime start = DateTime.Now;
|
||||||
|
bool isInternalError = false;
|
||||||
|
string errorMessage = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
_logger.LogInformation($"Attempting to get all ECN#s");
|
||||||
|
|
||||||
|
IEnumerable<int> allEcnNumbers = await _ecnService.GetAllECNNumbers();
|
||||||
|
|
||||||
|
return Ok(allEcnNumbers);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
isInternalError = true;
|
||||||
|
errorMessage = $"Cannot get all ECN#s, because {ex.Message}";
|
||||||
|
return Problem(errorMessage);
|
||||||
|
} finally {
|
||||||
|
string metricName = "GetAllECNNumbers";
|
||||||
|
DateTime end = DateTime.Now;
|
||||||
|
double millisecondsDiff = (end - start).TotalMilliseconds;
|
||||||
|
_monInClient.PostAverage(metricName + "Latency", millisecondsDiff);
|
||||||
|
|
||||||
|
if (isInternalError) {
|
||||||
|
_logger.LogError(errorMessage);
|
||||||
|
_monInClient.PostStatus(metricName, StatusValue.Critical);
|
||||||
|
} else {
|
||||||
|
_monInClient.PostStatus(metricName, StatusValue.Ok);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -265,6 +265,7 @@ public class PCRBController : ControllerBase {
|
|||||||
|
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("pcrb/attachment")]
|
[Route("pcrb/attachment")]
|
||||||
|
[ApiExplorerSettings(IgnoreApi = true)]
|
||||||
public async Task<IActionResult> UploadAttachment([FromForm] IFormFile file, [FromForm] PCRBAttachment attachment) {
|
public async Task<IActionResult> UploadAttachment([FromForm] IFormFile file, [FromForm] PCRBAttachment attachment) {
|
||||||
DateTime start = DateTime.Now;
|
DateTime start = DateTime.Now;
|
||||||
bool isArgumentError = false;
|
bool isArgumentError = false;
|
||||||
|
@ -132,9 +132,6 @@ builder.Services.AddSwaggerGen(c => {
|
|||||||
|
|
||||||
WebApplication app = builder.Build();
|
WebApplication app = builder.Build();
|
||||||
|
|
||||||
if (Debugger.IsAttached)
|
|
||||||
app.Services.GetRequiredService<IApprovalService>();
|
|
||||||
|
|
||||||
app.UseCors();
|
app.UseCors();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
|
@ -4,6 +4,7 @@ namespace MesaFabApproval.API.Services;
|
|||||||
|
|
||||||
public interface IECNService {
|
public interface IECNService {
|
||||||
Task<bool> IsValidECNNumber(int number);
|
Task<bool> IsValidECNNumber(int number);
|
||||||
|
Task<IEnumerable<int>> GetAllECNNumbers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ECNService : IECNService {
|
public class ECNService : IECNService {
|
||||||
@ -43,4 +44,19 @@ public class ECNService : IECNService {
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<int>> GetAllECNNumbers() {
|
||||||
|
try {
|
||||||
|
_logger.LogInformation("Attempting to get all ECN#s");
|
||||||
|
|
||||||
|
string sql = "select ECNNumber from ECN where Deleted=0 and Cancelled=0";
|
||||||
|
|
||||||
|
IEnumerable<int> allEcnNumbers = await _dalService.QueryAsync<int>(sql);
|
||||||
|
|
||||||
|
return allEcnNumbers;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
_logger.LogError($"Unable to get all ECN#s, because {ex.Message}");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -31,16 +31,16 @@
|
|||||||
Immediate
|
Immediate
|
||||||
AutoGrow />
|
AutoGrow />
|
||||||
} else {
|
} else {
|
||||||
<MudTextField @bind-Value="@document.ECNNumber"
|
<MudAutocomplete @bind-Value="@document.ECNNumber"
|
||||||
Required
|
T="int"
|
||||||
RequiredError="You must provide a valid ECN#"
|
SearchFunc="Search"
|
||||||
Clearable
|
Required
|
||||||
Variant="Variant.Outlined"
|
Clearable
|
||||||
InputType="@InputType.Number"
|
RequiredError="You must provide a valid ECN#"
|
||||||
Validation="@(new Func<int, Task<string>>(ECNNoIsValid))"
|
Variant="Variant.Outlined"
|
||||||
Label="ECN#"
|
Validation="@(new Func<int, Task<string>>(ECNNoIsValid))"
|
||||||
Immediate
|
Label="ECN#"
|
||||||
AutoGrow />
|
Immediate />
|
||||||
}
|
}
|
||||||
<MudCheckBox Label="Complete"
|
<MudCheckBox Label="Complete"
|
||||||
Color="Color.Tertiary"
|
Color="Color.Tertiary"
|
||||||
@ -79,6 +79,8 @@
|
|||||||
[Parameter]
|
[Parameter]
|
||||||
public required PCR3Document document { get; set; }
|
public required PCR3Document document { get; set; }
|
||||||
|
|
||||||
|
private IEnumerable<int> allEcnNumbers = new List<int>();
|
||||||
|
|
||||||
private string[] errors = { };
|
private string[] errors = { };
|
||||||
|
|
||||||
private bool complete = false;
|
private bool complete = false;
|
||||||
@ -89,6 +91,8 @@
|
|||||||
|
|
||||||
protected override async Task OnParametersSetAsync() {
|
protected override async Task OnParametersSetAsync() {
|
||||||
complete = document.CompletedByID > 0;
|
complete = document.CompletedByID > 0;
|
||||||
|
|
||||||
|
allEcnNumbers = await ecnService.GetAllECNNumbers();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Save() {
|
private async Task Save() {
|
||||||
@ -155,4 +159,13 @@
|
|||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task<IEnumerable<int>> Search(string searchValue, CancellationToken token) {
|
||||||
|
if (string.IsNullOrWhiteSpace(searchValue))
|
||||||
|
return allEcnNumbers;
|
||||||
|
|
||||||
|
return allEcnNumbers
|
||||||
|
.Where(x => x.ToString().StartsWith(searchValue, StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
.Order();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ namespace MesaFabApproval.Client.Services;
|
|||||||
public interface IECNService {
|
public interface IECNService {
|
||||||
Task<string> ECNNumberIsValidStr(int ecnNumber);
|
Task<string> ECNNumberIsValidStr(int ecnNumber);
|
||||||
Task<bool> ECNNumberIsValid(int number);
|
Task<bool> ECNNumberIsValid(int number);
|
||||||
|
Task<IEnumerable<int>> GetAllECNNumbers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ECNService : IECNService {
|
public class ECNService : IECNService {
|
||||||
@ -49,4 +50,32 @@ public class ECNService : IECNService {
|
|||||||
throw new Exception($"Unable to determine if {number} is a valid ECN#, because {ex.Message}");
|
throw new Exception($"Unable to determine if {number} is a valid ECN#, because {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<IEnumerable<int>> GetAllECNNumbers() {
|
||||||
|
try {
|
||||||
|
HttpClient httpClient = _httpClientFactory.CreateClient("API");
|
||||||
|
|
||||||
|
HttpRequestMessage requestMessage = new(HttpMethod.Get, $"ecn/allNumbers");
|
||||||
|
|
||||||
|
HttpResponseMessage responseMessage = await httpClient.SendAsync(requestMessage);
|
||||||
|
|
||||||
|
if (responseMessage.IsSuccessStatusCode) {
|
||||||
|
string responseContent = await responseMessage.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
|
JsonSerializerOptions jsonSerializerOptions = new() {
|
||||||
|
PropertyNameCaseInsensitive = true
|
||||||
|
};
|
||||||
|
|
||||||
|
IEnumerable<int> allEcnNumbers =
|
||||||
|
JsonSerializer.Deserialize<IEnumerable<int>>(responseContent, jsonSerializerOptions) ??
|
||||||
|
new List<int>();
|
||||||
|
|
||||||
|
return allEcnNumbers;
|
||||||
|
} else {
|
||||||
|
throw new Exception(responseMessage.ReasonPhrase);
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw new Exception($"Unable to get all ECN#s, because {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user