コード例 #1
0
        public async Task <IActionResult> GetF340_Process([FromQuery] SF340Schedule sF340Schedule)
        {
            _logger.LogInformation(String.Format(@"****** DKSController GetF340_Process fired!! ******"));

            if (sF340Schedule.cwaDateS == "" || sF340Schedule.cwaDateS == null)
            {
                sF340Schedule.cwaDateS = _config.GetSection("LogicSettings:MinDate").Value;
            }
            if (sF340Schedule.cwaDateE == "" || sF340Schedule.cwaDateE == null)
            {
                sF340Schedule.cwaDateE = _config.GetSection("LogicSettings:MaxDate").Value;
            }
            sF340Schedule.cwaDateS = sF340Schedule.cwaDateS.Replace("-", "/");
            sF340Schedule.cwaDateE = sF340Schedule.cwaDateE.Replace("-", "/");
            var data = await _dksDao.GetF340ProcessView(sF340Schedule);

            //Response.AddPagination(result.CurrentPage, result.PageSize,
            //result.TotalCount, result.TotalPages);


            PagedList <F340_ProcessDto> result = PagedList <F340_ProcessDto> .Create(data, sF340Schedule.PageNumber, sF340Schedule.PageSize, sF340Schedule.IsPaging);

            Response.AddPagination(result.CurrentPage, result.PageSize,
                                   result.TotalCount, result.TotalPages);
            return(Ok(result));
        }
コード例 #2
0
        public async Task <IActionResult> ExportF340_Process(SF340Schedule sF340Schedule)
        {
            _logger.LogInformation(String.Format(@"****** DKSController ExportF340_Process fired!! ******"));
            if (sF340Schedule.cwaDateS == "" || sF340Schedule.cwaDateS == null)
            {
                sF340Schedule.cwaDateS = _config.GetSection("LogicSettings:MinDate").Value;
            }
            if (sF340Schedule.cwaDateE == "" || sF340Schedule.cwaDateE == null)
            {
                sF340Schedule.cwaDateE = _config.GetSection("LogicSettings:MaxDate").Value;
            }
            sF340Schedule.cwaDateS = sF340Schedule.cwaDateS.Replace("-", "/");
            sF340Schedule.cwaDateE = sF340Schedule.cwaDateE.Replace("-", "/");
            // query data from database
            var data = await _dksDao.GetF340ProcessView(sF340Schedule);

            byte[] result = _excelService.CommonExportReport(data, "TempF340Process.xlsx");

            return(File(result, "application/xlsx"));
        }
コード例 #3
0
        public async Task <List <F340_ProcessDto> > GetF340ProcessView(SF340Schedule sF340Schedule)
        {
            //Stored Procedure A、B、C共用
            List <SqlParameter> pc = new List <SqlParameter> {
                new SqlParameter("@Season", sF340Schedule.season.Trim().ToUpper()),
                new SqlParameter("@CwaDateS", sF340Schedule.cwaDateS),
                new SqlParameter("@CwaDateE", sF340Schedule.cwaDateE)
            };
            string SQL = "";

            if (sF340Schedule.dataType == "DHO")
            {
                SQL = string.Format("EXECUTE dbo.GetF340Process_BuyPlan_C{0} @Season,@CwaDateS,@CwaDateE", spCode);
            }
            else if (sF340Schedule.dataType == "FHO")
            {
                pc.Add(new SqlParameter("@FactoryId", sF340Schedule.factory != null ? sF340Schedule.factory.Trim().ToUpper() : (object)DBNull.Value));
                pc.Add(new SqlParameter("@BuyPlanVer", sF340Schedule.bpVer.Trim()));
                SQL = string.Format("EXECUTE dbo.GetF340Process_BuyPlan_B{0} @FactoryId,@Season,@BuyPlanVer,@CwaDateS,@CwaDateE", spCode);
            }
            else if (sF340Schedule.dataType == "DEV")
            {
                SQL = string.Format("EXECUTE dbo.GetF340Process_BuyPlan_A{0} @Season,@CwaDateS,@CwaDateE", spCode);
            }

            var data = await _context.GetF340ProcessView
                       .FromSqlRaw(SQL, pc.ToArray())
                       .ToListAsync();

            //tranfer minDate to ''
            string minDate = _config.GetSection("LogicSettings:MinDate").Value;

            data.ForEach(m => {
                if (m.ActivationDate == minDate)
                {
                    m.ActivationDate = "";
                }
            });
            return(data);
        }