Exemplo n.º 1
0
        public async Task <bool> ImportExcel(string filePath)
        {
            using (var package = new ExcelPackage(new FileInfo(filePath)))
            {
                ExcelWorksheet workSheet    = package.Workbook.Worksheets[0];
                AuditRecMDto   auditRecMDto = new AuditRecMDto();
                for (int i = workSheet.Dimension.Start.Row + 1; i <= workSheet.Dimension.End.Row; i++)
                {
                    auditRecMDto.Record_ID   = "REC" + DateTime.Now.Year.ToString().Substring(2) + DateTime.Now.Month.ToString() + i.ToString();
                    auditRecMDto.Record_Time = Convert.ToDateTime(workSheet.Cells[i, 1].Value.ToString());
                    auditRecMDto.PDC         = workSheet.Cells[i, 2].Value.ToString();
                    auditRecMDto.Building    = workSheet.Cells[i, 3].Value.ToString();
                    auditRecMDto.Line        = workSheet.Cells[i, 4].Value.ToString();
                    auditRecMDto.Model_No    = workSheet.Cells[i, 5].Value.ToString();
                    auditRecMDto.Model_Name  = "Test";
                    var auditRecM = _mapper.Map <MES_Audit_Rec_M>(auditRecMDto);
                    _repoAuditRecM.Add(auditRecM);
                }
                try
                {
                    await _repoAuditRecM.SaveAll();

                    return(true);
                }
                catch (System.Exception)
                {
                    return(false);

                    throw;
                }
            }
        }
Exemplo n.º 2
0
 public async Task <IActionResult> UpdateRecM([FromBody] AuditRecMDto model)
 {
     if (await _service.Update(model))
     {
         return(NoContent());
     }
     return(BadRequest("Updating Failed"));
 }
Exemplo n.º 3
0
        public async Task <bool> Update(AuditRecMDto model)
        {
            var auditRecM = _mapper.Map <MES_Audit_Rec_M>(model);

            auditRecM.Updated_Time = DateTime.Now;
            _repoAuditRecM.Update(auditRecM);
            return(await _repoAuditRecM.SaveAll());
        }
Exemplo n.º 4
0
 public async Task <IActionResult> UpdateRecM([FromBody] AuditRecMDto model)
 {
     if (await _service.Update(model))
     {
         return(NoContent());
     }
     return(BadRequest($"Updating AuditRecM {model.Record_ID} failed on save"));
 }
Exemplo n.º 5
0
        public async Task <bool> ImportExcel(string filePath, string userName)
        {
            string record_Id = await GetRecordIdRate();

            using (var package = new ExcelPackage(new FileInfo(filePath)))
            {
                ExcelWorksheet workSheet  = package.Workbook.Worksheets[0];
                ExcelWorksheet workSheet2 = package.Workbook.Worksheets[1];


                AuditRecMDto auditRecMDto = new AuditRecMDto();
                for (int i = workSheet.Dimension.Start.Row + 1; i <= workSheet.Dimension.End.Row; i++)
                {
                    auditRecMDto.Record_ID   = record_Id;
                    auditRecMDto.Record_Time = Convert.ToDateTime(workSheet.Cells[i, 1].Value.ToString());
                    auditRecMDto.Updated_By  = userName;
                    auditRecMDto.PDC         = workSheet.Cells[i, 2].Value.ToString();
                    auditRecMDto.Building    = workSheet.Cells[i, 3].Value.ToString();
                    auditRecMDto.Line        = workSheet.Cells[i, 4].Value.ToString();
                    auditRecMDto.Model_No    = workSheet.Cells[i, 5].Value.ToString();
                    auditRecMDto.Model_Name  = _mesMo.FindAll().Where(x => x.Style_No.Trim()
                                                                      == (workSheet.Cells[i, 5].Value.ToString()).Trim()).Count() == 0 ? "" :
                                               _mesMo.FindAll().Where(x => x.Style_No.Trim()
                                                                      == (workSheet.Cells[i, 5].Value.ToString()).Trim()).FirstOrDefault().Style_Name;
                    var auditRecM = _mapper.Map <MES_Audit_Rec_M>(auditRecMDto);
                    _repoAuditRecM.Add(auditRecM);
                }

                AuditRecDDto auditRecDDto = new AuditRecDDto();
                for (int i = workSheet2.Dimension.Start.Row + 1; i <= workSheet2.Dimension.End.Row; i++)
                {
                    auditRecDDto.Record_ID  = record_Id;
                    auditRecDDto.Updated_By = userName;
                    auditRecDDto.Status     = "Ongoing";
                    auditRecDDto.Item_no    = workSheet2.Cells[i, 1].Value.ToInt();
                    auditRecDDto.Issue_LL   = workSheet2.Cells[i, 2].Value.ToString();
                    var auditRecD = _mapper.Map <MES_Audit_Rec_D>(auditRecDDto);
                    _repoAuditRecD.Add(auditRecD);
                }
                try
                {
                    await _repoAuditRecD.SaveAll();

                    return(true);
                }
                catch (System.Exception)
                {
                    return(false);

                    throw;
                }
            }
        }
Exemplo n.º 6
0
        public async Task <bool> AddAuditRecM(AuditRecMViewModel model)
        {
            var          recored_Time = DateTime.Parse(model.Record_Time.ToString());
            AuditRecMDto data         = new AuditRecMDto();

            data.Record_ID = await this.GetRecordIdRate();

            data.Record_Time = recored_Time;
            data.PDC         = model.PDC.Trim();
            data.Building    = model.Building.Trim();
            data.Line        = model.Line.Trim();
            data.Model_Name  = model.Model_Name.Trim();
            data.Model_No    = model.Model_No.Trim();
            data.Chief       = model.Chief.Trim();
            data.Recorder    = model.Recorder.Trim();
            data.Attendees   = model.Attendees.Trim();
            data.Updated_By  = model.Updated_By.Trim();
            var auditRecMAdd = _mapper.Map <MES_Audit_Rec_M>(data);

            _repoAuditRecM.Add(auditRecMAdd);
            return(await _repoAuditRecM.SaveAll());
        }
Exemplo n.º 7
0
 public Task <bool> Add(AuditRecMDto model)
 {
     throw new System.NotImplementedException();
 }