public async Task <IActionResult> GetF340_ProcessPpd([FromQuery] SF340PPDSchedule sF340PPDSchedule) { _logger.LogInformation(String.Format(@"****** DKSController GetF340_ProcessPpd fired!! ******")); if (sF340PPDSchedule.cwaDateS == "" || sF340PPDSchedule.cwaDateS == null) { sF340PPDSchedule.cwaDateS = _config.GetSection("LogicSettings:MinDate").Value; } if (sF340PPDSchedule.cwaDateE == "" || sF340PPDSchedule.cwaDateE == null) { sF340PPDSchedule.cwaDateE = _config.GetSection("LogicSettings:MaxDate").Value; } sF340PPDSchedule.cwaDateS = sF340PPDSchedule.cwaDateS.Replace("-", "/"); sF340PPDSchedule.cwaDateE = sF340PPDSchedule.cwaDateE.Replace("-", "/"); var data = await _dksDao.GetF340PPDView(sF340PPDSchedule); if (sF340PPDSchedule.ubType == "U") { data = data.Where(x => x.HpPartNo != "2016").ToList(); } if (sF340PPDSchedule.ubType == "B") { data = data.Where(x => x.HpPartNo == "2016").ToList(); } PagedList <F340_PpdDto> result = PagedList <F340_PpdDto> .Create(data, sF340PPDSchedule.PageNumber, sF340PPDSchedule.PageSize, sF340PPDSchedule.IsPaging); Response.AddPagination(result.CurrentPage, result.PageSize, result.TotalCount, result.TotalPages); return(Ok(result)); }
public async Task <List <F340_PpdDto> > GetF340PPDView(SF340PPDSchedule sF340PPDSchedule) { List <SqlParameter> pc = new List <SqlParameter> { new SqlParameter("@FactoryId", sF340PPDSchedule.factory), new SqlParameter("@Season", sF340PPDSchedule.season.Trim().ToUpper()), new SqlParameter("@BuyPlanVer", sF340PPDSchedule.bpVer == null || sF340PPDSchedule.bpVer == "" ? (object)DBNull.Value : sF340PPDSchedule.bpVer.Trim()), new SqlParameter("@CwaDateS", sF340PPDSchedule.cwaDateS), new SqlParameter("@CwaDateE", sF340PPDSchedule.cwaDateE), new SqlParameter("@ModelNo", (sF340PPDSchedule.modelNo == null || sF340PPDSchedule.modelNo == "") ? (object)DBNull.Value : sF340PPDSchedule.modelNo.Trim()), new SqlParameter("@ModelName", (sF340PPDSchedule.modelName == null || sF340PPDSchedule.modelName == "") ? (object)DBNull.Value : sF340PPDSchedule.modelName.Trim()), new SqlParameter("@Article", (sF340PPDSchedule.article == null || sF340PPDSchedule.article == "") ? (object)DBNull.Value : sF340PPDSchedule.article.Trim()), }; var data = await _context.GetF340PpdView .FromSqlRaw(string.Format("EXECUTE dbo.GetF340_BuyPlan_PPD_FGT @FactoryId,@Season,@BuyPlanVer,@CwaDateS,@CwaDateE,@ModelNo,@ModelName,@Article"), pc.ToArray()) .ToListAsync(); //tranfer minDate to '' string minDate = _config.GetSection("LogicSettings:MinDate").Value; data.ForEach(m => { if (m.CwaDeadline == minDate) { m.CwaDeadline = ""; } }); return(data); }
public async Task <IActionResult> SentMailF340PpdByArticle(SF340PPDSchedule sF340PPDSchedule) { _logger.LogInformation(String.Format(@"******DKSController SentMailF340PpdByArticle fired!! ******")); //var dksSignature = _config.GetSection("DksSignatureLine").Value; var dksSignature = ""; var content = string.Format(@"The Article : {0} Added Memo please check it in F340-PPD of the below website.{1}", sF340PPDSchedule.article, dksSignature); var toMails = new List <string>(); var users = await _dksDao.GetUsersByRole("GM0000000038"); users.ForEach(x => { toMails.Add(x.EMAIL); }); await _sendMailService.SendListMailAsync(toMails, null, "This Article Add Memo Please check it in F340-PPD !", content, null); return(Ok()); }
public async Task <IActionResult> ExportF340_ProcessPpd(SF340PPDSchedule sF340PPDSchedule) { _logger.LogInformation(String.Format(@"****** DKSController ExportF340_ProcessPpd fired!! ******")); var dksSignature = _config.GetSection("AppSettings:encodeStr").Value; if (sF340PPDSchedule.cwaDateS == "" || sF340PPDSchedule.cwaDateS == null) { sF340PPDSchedule.cwaDateS = _config.GetSection("LogicSettings:MinDate").Value; } if (sF340PPDSchedule.cwaDateE == "" || sF340PPDSchedule.cwaDateE == null) { sF340PPDSchedule.cwaDateE = _config.GetSection("LogicSettings:MaxDate").Value; } sF340PPDSchedule.cwaDateS = sF340PPDSchedule.cwaDateS.Replace("-", "/"); sF340PPDSchedule.cwaDateE = sF340PPDSchedule.cwaDateE.Replace("-", "/"); // query data from database var data = await _dksDao.GetF340PPDView(sF340PPDSchedule); // data.ForEach(x => { if (x.Photo.Length > 1) { var factoryApi = ""; var apiUrl = _config.GetSection("AppSettings:ApiUrl").Value; switch (sF340PPDSchedule.factory) { case "C": //SHC factoryApi = apiUrl + "dks/getF340PpdPic?isStanHandsome="; break; case "E": //CB factoryApi = "http://10.9.0.35/material/WatermarkAPI/GetF340PpdPic?param="; break; case "D": //SPC factoryApi = "http://10.10.0.21/material/WatermarkAPI/GetF340PpdPic?param="; break; case "U": //TSH factoryApi = "http://10.11.0.22/material/WatermarkAPI/GetF340PpdPic?param="; break; default: { factoryApi = apiUrl + "dks/getF340PpdPic?isStanHandsome="; break; } } var param = dksSignature + x.DevSeason + "$" + x.Article + "$" + x.Photo + "$" + sF340PPDSchedule.factory + "$" + sF340PPDSchedule.loginUser; var encodeStr = CSharpLab.Btoa(param); var dataUrl = string.Format(@"{0}{1}", factoryApi, encodeStr); //let dataUrl = environment.apiUrl + "dks/getF340PpdPdf?isStanHandsome=" + window.btoa(param); //x.Photo = "=HYPERLINK(\"" + dataUrl + "\",\"jpg\")"; x.Photo = dataUrl; //x.Photo = "http://" + serverIp + "/assets/F340PpdPic/" + x.DevSeason + "/" + x.Article + "/" + x.Photo; } if (x.Pdf.Length > 1) { //encoding version var factoryApi = ""; var apiUrl = _config.GetSection("AppSettings:ApiUrl").Value; switch (sF340PPDSchedule.factory) { case "C": //SHC factoryApi = apiUrl + "dks/getF340PpdPdf?isStanHandsome="; break; case "E": //CB factoryApi = "http://10.9.0.35/material/WatermarkAPI/GetF340PpdPdf?param="; break; case "D": //SPC factoryApi = "http://10.10.0.21/material/WatermarkAPI/GetF340PpdPdf?param="; break; case "U": //TSH factoryApi = "http://10.11.0.22/material/WatermarkAPI/GetF340PpdPdf?param="; break; default: { factoryApi = apiUrl + "dks/getF340PpdPdf?isStanHandsome="; break; } } var param = dksSignature + x.DevSeason + "$" + x.Article + "$" + x.Pdf + "$" + sF340PPDSchedule.factory + "$" + sF340PPDSchedule.loginUser; var encodeStr = CSharpLab.Btoa(param); var dataUrl = string.Format(@"{0}{1}", factoryApi, encodeStr); // no encoding version //var dataUrl = string.Format(@"{0}:{1}{2}{3}/{4}/{5}",ip,spaPort,"/assets/F340PpdPic/",x.DevSeason,x.Article,x.Pdf); x.Pdf = dataUrl; } if (x.FgtFileName.Length > 1) { var factoryApi = ""; switch (sF340PPDSchedule.factory) { case "C": //SHC factoryApi = "http://10.4.0.39:6970/assets/F340PpdPic/QCTestResult/"; break; case "E": //CB factoryApi = "http://10.9.0.35/material/Upload/F340CmptMatPic/QCTestResult/"; break; case "D": //SPC factoryApi = "http://10.10.0.21/material/Upload/F340CmptMatPic/QCTestResult/"; break; case "U": //TSH factoryApi = "http://10.11.0.22/material/Upload/F340CmptMatPic/QCTestResult/"; break; default: factoryApi = "http://10.4.0.39:6970/assets/F340PpdPic/QCTestResult/"; break; } var dataUrl = string.Format(@"{0}{1}/{2}", factoryApi, x.Article, x.FgtFileName); x.FgtFileName = dataUrl; } }); var upper = data.Where(x => x.HpPartNo != "2016").ToList(); var bottom = data.Where(x => x.HpPartNo == "2016").ToList(); List <List <F340_PpdDto> > dataList = new List <List <F340_PpdDto> >() { upper, bottom }; byte[] result = _excelService.CommonExportReportTabs4F340PPD(dataList, "TempF340PPDProcessTabs.xlsx"); return(File(result, "application/xlsx")); }