예제 #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");
            }
        }
예제 #2
0
        /// <summary>
        /// Download File
        ///<param name="strtdate">strtdate</param>
        ///<param name="enddate">enddate</param>
        /// </summary>
        /// <returns></returns>


        /// <summary>
        /// Upload File
        ///<param name="strtdate">strtdate</param>
        ///<param name="enddate">enddate</param>
        /// </summary>
        /// <returns></returns>
        public String UploadFileData(String strtdate, String enddate)
        {
            String msg = "";

            try
            {
                Int32  userid         = SessionData.UserID;
                String uploadFileDir  = ConfigurationManager.AppSettings["UploadFolderPath"];
                string uploadfilepath = MppUtility.GetFilelocation(userid, uploadFileDir, "bulk");
                string fileName       = ConfigurationManager.AppSettings["filename"];
                string fileName1      = fileName.PadRight(29) + strtdate + "-" + enddate + ".csv";
                string filePath       = Path.Combine(uploadfilepath, fileName1);
                if (File.Exists(filePath) == true)
                {
                    HttpContext context = HttpContext.Current;
                    context.Response.Clear();
                    context.Response.ContentType = "text/csv";
                    context.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName1);
                    context.Response.WriteFile(filePath);
                }
            }
            catch (Exception ex)
            {
                msg = ex.Message;
            }
            return(msg);
        }
예제 #3
0
        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;
            }
        }