public IActionResult GetAFgtByLabNo(string labNo) { _logger.LogInformation(String.Format(@"****** DTRController GetAFgtByLabNo fired!! ******")); DevDtrFgtResult model = _devDtrFgtResultDAO.FindSingle( x => x.LABNO.Trim() == labNo); return(Ok(model)); }
public async Task <IActionResult> CheckFgtIsValid(string article, string stage, string kind, string factoryId) { _logger.LogInformation(String.Format(@"******DTRController CheckFgtIsValid fired!! ******")); var isValid = false; DevDtrFgtResult model = await _devDtrFgtResultDAO.FindAll(x => x.ARTICLE == article && x.STAGE == stage && x.KIND == kind && x.LABNO.Substring(0, 1) == factoryId) .FirstOrDefaultAsync(); if (model == null) { isValid = true; } return(Ok(isValid)); }
public async Task <IActionResult> UpdateDevDtrFgtResult(AddDevDtrFgtResultDto updateDevDtrFgtResultDto) { _logger.LogInformation(String.Format(@"****** DTRController UpdateDevDtrFgtResult fired!! ******")); DevDtrFgtResult model = _devDtrFgtResultDAO.FindSingle( x => x.ARTICLE.Trim() == updateDevDtrFgtResultDto.Article && x.MODELNO.Trim() == updateDevDtrFgtResultDto.ModelNo && x.MODELNAME.Trim() == updateDevDtrFgtResultDto.ModelName && x.LABNO.Trim() == updateDevDtrFgtResultDto.LabNo && x.STAGE.Trim() == updateDevDtrFgtResultDto.Stage && x.KIND.Trim() == updateDevDtrFgtResultDto.Kind); if (model != null) { model.RESULT = updateDevDtrFgtResultDto.Result; model.REMARK = updateDevDtrFgtResultDto.Remark; model.UPUSR = updateDevDtrFgtResultDto.Upusr; model.UPDAY = DateTime.Now; _devDtrFgtResultDAO.Update(model); await _devDtrFgtResultDAO.SaveAll(); return(Ok(true)); } return(Ok(false)); }
public async Task <IActionResult> EditPdfDevDtrFgtResult() { _logger.LogInformation(String.Format(@"******DTRController EditPdfDevDtrFgtResult fired!! ******")); var article = HttpContext.Request.Form["article"].ToString().Trim(); var modelNo = HttpContext.Request.Form["modelNo"].ToString().Trim(); var modelName = HttpContext.Request.Form["modelName"].ToString().Trim(); var labNo = HttpContext.Request.Form["labNo"].ToString().Trim(); var stage = HttpContext.Request.Form["stage"].ToString().Trim(); var kind = HttpContext.Request.Form["kind"].ToString().Trim(); var loginUser = HttpContext.Request.Form["loginUser"].ToString().Trim(); DevDtrFgtResult model = _devDtrFgtResultDAO.FindSingle( x => x.ARTICLE.Trim() == article && x.MODELNO.Trim() == modelNo && x.MODELNAME.Trim() == modelName && x.LABNO.Trim() == labNo && x.STAGE.Trim() == stage && x.KIND.Trim() == kind); if (model == null) { return(NoContent()); } if (HttpContext.Request.Form.Files.Count == 0) { return(NoContent()); } var file = HttpContext.Request.Form.Files[0]; var fileType = Extensions.GenerateExtension(file.ContentType.ToString()); var elderFileName = model.FILENAME; //Article + Stage + Kind + Test Result + LAB No .pdf var fileName = string.Format("{0}_{1}_{2}_{3}.{4}", model.ARTICLE, model.STAGE, model.KIND, model.LABNO, fileType); // save or delete file to server List <string> nastFileName = new List <string>(); nastFileName.Add("QCTestResult"); nastFileName.Add(article); nastFileName.Add(fileName); //save to server if (await _fileService.SaveFiletoServer(file, "F340PpdPic", nastFileName)) { _logger.LogInformation(String.Format(@"******DTRController EditPdfDevDtrFgtResult Add a File: {0}!! ******", fileName)); model.FILENAME = fileName; //Cancel FgtStats 2021/09/14 Aven /* * model.FILENAME = fileName; * model.UPUSR = loginUser; * model.UPDAY = DateTime.Now; * * //add DTR FGT STATUS start * //find the status by article stage kind * var dtrFgtStats = _devDtrFgtStatsDAO.FindSingle( * x => x.ARTICLE.Trim() == model.ARTICLE && * x.STAGE.Trim() == model.STAGE && * x.KIND.Trim() == model.KIND); * * if (dtrFgtStats == null) * { //add status * dtrFgtStats = new DevDtrFgtStats(); * dtrFgtStats.ARTICLE = model.ARTICLE; * dtrFgtStats.STAGE = model.STAGE; * dtrFgtStats.KIND = model.KIND; * dtrFgtStats.LABNO = model.LABNO; * dtrFgtStats.FILENAME = ""; * if (model.RESULT == "PASS") dtrFgtStats.PASS = 1; * if (model.RESULT == "FAIL") dtrFgtStats.FAIL = 1; * _devDtrFgtStatsDAO.Add(dtrFgtStats); * _logger.LogInformation(String.Format(@"******DTRController EditPdfDevDtrFgtResult Add a NEW DevDtrFgtStats: {0}!! ******", dtrFgtStats)); * } * else * { * if (isUpdate) * { //overwrite pdf * //won't update status * _logger.LogInformation(String.Format(@"******DTRController EditPdfDevDtrFgtResult Overwrite a PDF: {0}!! ******", dtrFgtStats)); * } * else * { //same status but NEW LabNo => update status * if (model.RESULT == "PASS") dtrFgtStats.PASS += 1; * if (model.RESULT == "FAIL") dtrFgtStats.FAIL += 1; * dtrFgtStats.LABNO = model.LABNO; * _devDtrFgtStatsDAO.Update(dtrFgtStats); * _logger.LogInformation(String.Format(@"******DTRController EditPdfDevDtrFgtResult ReCount result and update LabNo: {0}!! ******", dtrFgtStats)); * * } * _logger.LogInformation(String.Format(@"******DTRController EditPdfDevDtrFgtResult Update a Pdf BUT won't update DevDtrFgtStats: {0}!! ******", dtrFgtStats)); * } * await _devDtrFgtStatsDAO.SaveAll(); * //add DTR FGT STATUS end */ } _devDtrFgtResultDAO.Update(model); await _devDtrFgtResultDAO.SaveAll(); return(Ok(model)); }