public async Task <IActionResult> SendEosReport( string dept, DateTime shiftDate, string shift ) { if (dept == null) { throw new ArgumentNullException(nameof(dept)); } try { dept = dept.ToLower(); if (dept != "anodize" && dept != "skirt coat" && dept != "assembly") { return(Ok( await _kpiService .SendEosReport(dept, shiftDate, shift) .ConfigureAwait(false) )); } //var anodize = await _kpiService.GetEndOfShiftListDto("Anodize", shiftDate, shift).ConfigureAwait(false); //var sc = await _kpiService.GetEndOfShiftListDto("Skirt Coat", shiftDate, shift).ConfigureAwait(false); var assembly = await _kpiService .GetEndOfShiftListDto("Assembly", shiftDate, shift) .ConfigureAwait(false); //if (!anodize.Any()) throw new OperationCanceledException(EosErrorMsg("Anodize")); //if (!sc.Any()) throw new OperationCanceledException(EosErrorMsg("Skirt Coat")); if (!assembly.Any()) { throw new OperationCanceledException(EosErrorMsg("Assembly")); } //if (anodize.Any()) //{ // await _kpiService.SendEosReport(anodize, "Anodize", shiftDate, shift).ConfigureAwait(false); //} //if (sc.Any()) //{ // await _kpiService.SendEosReport(sc, "Skirt Coat", shiftDate, shift).ConfigureAwait(false); //} if (assembly.Any()) { await _kpiService .SendEosReport(assembly, "Assembly", shiftDate, shift) .ConfigureAwait(false); } return(Ok(true)); } catch (Exception e) { return(BadRequest(_env.IsDevelopment() ? e.StackTrace : e.Message)); } }
public async Task <IActionResult> GetEos(string dept, DateTime shiftDate, string shift) { try { var data = await _kpiService .GetEndOfShiftListDto(dept, shiftDate, shift) .ConfigureAwait(false); var total = await _kpiService .GetOverallEosTotal(data, dept, shiftDate, shift) .ConfigureAwait(false); return(Ok(new { data, total })); } catch (OperationCanceledException e) { return(BadRequest(e.Message)); } catch (Exception e) { return(BadRequest(e.Message)); } }