Beispiel #1
0
        public IHttpActionResult DownloadExcel(string code, long feeNo = 0, DateTime?startDate = null, DateTime?endDate = null)
        {
            string mapPath = HttpContext.Current.Server.MapPath(VirtualPathUtility.GetDirectory("~"));
            IReportManageService reportManageService = IOCContainer.Instance.Resolve <IReportManageService>();
            string path = string.Empty;

            switch (code)
            {
            case "H20":
                if (startDate.HasValue)
                {
                    path = string.Format(@"{0}Templates\{1}.xls", mapPath, "H20");
                    reportManageService.DownloadUnPlanedIpdStatisticsFile(startDate.Value.Year, path);
                }
                break;

            case "H49":
                if (startDate.HasValue)
                {
                    path = string.Format(@"{0}Templates\{1}.xls", mapPath, "H49");
                    reportManageService.DownloadInfectionStatisticsFile(startDate.Value.Year, path);
                }
                break;

            case "H50":
                if (startDate.HasValue)
                {
                    path = string.Format(@"{0}Templates\{1}.xls", mapPath, "H50");
                    reportManageService.DownloadH50(startDate.Value.Year, path);
                }
                break;

            case "H76":
                if (startDate.HasValue && endDate.HasValue)
                {
                    path = string.Format(@"{0}Templates\{1}.xls", mapPath, "H76");
                    reportManageService.DownloadPrsSoreRisk(path, feeNo, startDate, endDate);
                }
                break;

            case "H77":
                path = string.Format(@"{0}Templates\{1}.xls", mapPath, "H77");
                reportManageService.DownloadH77(feeNo, path, startDate, endDate);
                break;

            case "H79":
                path = string.Format(@"{0}Templates\{1}.xls", mapPath, "H79");
                reportManageService.DownloadH79(feeNo, path);
                break;

            case "P19":
                path = string.Format(@"{0}Templates\{1}.xls", mapPath, "P19");
                int seqNo = 0;
                if (int.TryParse(HttpContext.Current.Request["seqNo"], out seqNo))
                {
                    reportManageService.DownloadP19(seqNo, path);
                }
                break;

            case "View":
                this.View();
                break;
            }
            //HttpContext.Current.Response.AddHeader("Content-type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
            //HttpContext.Current.Response.AddHeader("Accept-Ranges", "bytes");
            //HttpContext.Current.Response.AddHeader("Content-Length", new System.IO.FileInfo(swfFilePath).Length.ToString());
            //HttpContext.Current.Response.WriteFile(swfFilePath);

            //HttpContext.Current.Response.End();
            return(Ok());
        }