Esempio n. 1
0
        public void ProcessRequest(HttpContext context)
        {
            Int32  userid        = SessionData.UserID;
            String uploadFileDir = ConfigurationManager.AppSettings["UploadFolderPath"];

            System.Web.HttpRequest request = System.Web.HttpContext.Current.Request;
            string startDate      = request.QueryString["startDate"];
            string endDate        = request.QueryString["endDate"];
            string uploadfilepath = MppUtility.GetFilelocation(userid, uploadFileDir, "bulk");
            string fileName       = ConfigurationManager.AppSettings["filename"];
            string fileName1      = fileName.PadRight(29) + MppUtility.DateFormat(Convert.ToDateTime(startDate), 2) + "-" + MppUtility.DateFormat(Convert.ToDateTime(endDate), 2) + ".csv";
            string filePath       = Path.Combine(uploadfilepath, fileName1);
            bool   test           = System.IO.File.Exists(filePath);

            System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
            if (System.IO.File.Exists(filePath))
            {
                response.ClearContent();
                response.Clear();
                byte[] Content = System.IO.File.ReadAllBytes(filePath);
                response.ContentType = "text/csv";
                response.AddHeader("content-disposition", "attachment; filename=" + fileName1 + ".csv");
                response.BufferOutput = true;
                response.Cache.SetCacheability(HttpCacheability.NoCache);
                response.OutputStream.Write(Content, 0, Content.Length);
                response.Flush();
                response.End();
            }
            else
            {
                response.Redirect("ShowStatus.html");
            }
        }
        public void DownloadFileData(DateTime startDate, DateTime endDate)
        {
            String msg = "";

            try
            {
                Int32  userid         = SessionData.UserID;
                String downloaddir    = ConfigurationManager.AppSettings["DownloadFolderPath"];
                string uploadfilepath = MppUtility.GetFilelocation(userid, downloaddir, "bulk");
                string fileName       = ConfigurationManager.AppSettings["filename"];
                string fileName1      = fileName.PadRight(29) + MppUtility.DateFormat(startDate, 2).PadRight(11) + "-" + MppUtility.DateFormat(endDate, 2).PadLeft(11) + ".csv";
                string filePath       = Path.Combine(uploadfilepath, fileName1);
                bool   test           = System.IO.File.Exists(filePath);
                if (System.IO.File.Exists(filePath))
                {
                    Response.ClearHeaders();
                    Response.Clear();
                    //context.Response.ContentType = "application/octet-stream";
                    //context.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName1);
                    //context.Response.WriteFile(filePath);
                    //context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    byte[] Content = System.IO.File.ReadAllBytes(filePath);
                    Response.ContentType = "text/csv";
                    Response.AddHeader("content-disposition", "attachment; filename=" + fileName1 + ".csv");
                    Response.BufferOutput = true;
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    Response.OutputStream.Write(Content, 0, Content.Length);
                    Response.End();
                    Response.Close();
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
        }
        public JsonResult Uploadfile(DateTime startDate, DateTime endDate)
        {
            var res = rdata.UploadFileData(MppUtility.DateFormat(startDate, 2), MppUtility.DateFormat(endDate, 2));

            return(Json(res, JsonRequestBehavior.AllowGet));
        }