using System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Xml.Linq; using System.Timers; using System.Threading; using System.IO; using System.Net; namespace BLM_USDD_TESTING { public partial class Batch : System.Web.UI.Page { public string FilePath; public bool IsCallBack { get; set; } protected void Page_Load(object sender, EventArgs e) { lstFiles.DataSource = null; lstFiles.Items.Clear(); if (cbReport.Checked == true) { string[] FileEntries = null; string FileName = null; //counters is the directory name where in the text files are resided. FilePath = (Session["UploadReport"].ToString()); try { FileEntries = Directory.GetFiles(FilePath); } catch (Exception) { Console.WriteLine("{0} Exception caught."); } if (Page.IsPostBack) { foreach (string report in FileEntries) { FileName = Path.GetFileName(report); this.lstFiles.Items.Add(FileName); } } if (lstFiles.SelectedIndex != -1) lstFiles.Items.RemoveAt(lstFiles.SelectedIndex); cbError.Checked = false; cbDone.Checked = false; } else if (cbDone.Checked == true) { cbReport.Checked = false; string[] FileEntries = null; string FileName = null; //counters is the directory name where in the text files are resided. FilePath = (Session["UploadDone"].ToString()); try { FileEntries = Directory.GetFiles(FilePath); } catch (Exception) { Console.WriteLine("{0} Exception caught."); } if (Page.IsPostBack) { foreach (string zip in FileEntries) { FileName = Path.GetFileName(zip); this.lstFiles.Items.Add(FileName); } } if (lstFiles.SelectedIndex != -1) lstFiles.Items.RemoveAt(lstFiles.SelectedIndex); cbError.Checked = false; string blankText = ""; txtDisp.Text = blankText; } else if (cbError.Checked == true) { string[] FileEntries = null; string FileName = null; //counters is the directory name where in the text files are resided. FilePath = (Session["UploadError"].ToString()); try { FileEntries = Directory.GetFiles(FilePath); } catch (Exception) { Console.WriteLine("{0} Exception caught."); } if (Page.IsPostBack) { foreach (string zip in FileEntries) { FileName = Path.GetFileName(zip); this.lstFiles.Items.Add(FileName); } } if (lstFiles.SelectedIndex != -1) lstFiles.Items.RemoveAt(lstFiles.SelectedIndex); cbDone.Checked = false; cbReport.Checked = false; string blankText = ""; txtDisp.Text = blankText; } } protected void btnLoad_Click1(object sender, EventArgs e) { //Timer1.Enabled = true; //lblStatus.Text = "processing,please wait"; Session["UploadPath"] = System.Configuration.ConfigurationManager.AppSettings["UploadPath"]; Session["UploadError"] = System.Configuration.ConfigurationManager.AppSettings["UploadError"]; Session["UploadReport"] = System.Configuration.ConfigurationManager.AppSettings["UploadReport"]; Session["UploadDone"] = System.Configuration.ConfigurationManager.AppSettings["UploadDone"]; { if (FileUpload1.HasFile) try { lblStatus.Text = "processing,please wait"; string[] parts = FileUpload1.FileName.Split(new char[] { '.' }); if (parts.Length != 4) { lblStatus.Text = "Invalid file name"; return; } int intPar; if (!int.TryParse(parts[1], out intPar)) { lblStatus.Text = "Invalid date format"; return; } Session["BatchFile"] = FileUpload1.FileName; FileUpload1.SaveAs(Session["UploadPath"].ToString() + Session["BatchFile"].ToString()); this.txtDisp.Text = "File successfully uploaded"; /*this.txtDisp.Text = "File name: " + FileUpload1.PostedFile.FileName + "<br>" + FileUpload1.PostedFile.ContentLength + " kb<br>" + "Content type: " + FileUpload1.PostedFile.ContentType;*/ } catch (Exception ex) { this.txtDisp.Text = "ERROR: " + ex.Message.ToString(); } else { this.txtDisp.Text = "You have not specified a file."; } } }
HttpContext.Current.Session["username"]
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)