public void ListServerFilesInDirectory() { ddlFileList.Items.Clear(); string path = Server.MapPath("~/upload/"); DirectoryInfo di = new DirectoryInfo(path); FileInfo[] fi = di.GetFiles(); string fileText = ""; string fName = ""; foreach (var f in fi) { long len = f.Length; if (len > 999) { fName = string.Format("{0} Kb", BusLogic.parseFileSize(len)); } else if (len > 9999) { fName = string.Format("{0} Mb", BusLogic.parseFileSize(len)); } else { fName = string.Format("{0} bytes", len); } fileText = string.Format("File: {0} Created On: {1} Size: {2}", f.Name, f.CreationTime, fName); // ddlFileList.Items.Add(new ListItem(fileText)); ddlFileList.Items.Add(new ListItem(f.Name)); } }
protected void btnYes_Click(object sender, EventArgs e) { int deleteId = 0; if (ViewState["index"] != null) { rowIdx = int.Parse(ViewState["index"].ToString()); } if (gView.DataKeys[rowIdx].Value.ToString() != null) { deleteId = int.Parse(gView.DataKeys[rowIdx].Value.ToString()); } AdminDataContext admin = new AdminDataContext(); var rec = (from d in admin.tblLogonIds select d ).Where(p => p.Id == deleteId); foreach (var deletedRecord in rec) { admin.tblLogonIds.DeleteOnSubmit(deletedRecord); admin.SubmitChanges(); } gView.EditIndex = -1; var dat = BusLogic.SelectUsers(); gView.DataSource = dat; gView.DataBind(); }
public void SendEmail() { emailGrid = true; string from = System.Configuration.ConfigurationManager.AppSettings["FromAddress"].ToString(); string to = System.Configuration.ConfigurationManager.AppSettings["ToAddress"].ToString(); string subject = string.Format("Time Sheet for Week Ending {0}", GetWeekEndDate().ToString()); string Body = GetBody(sumView); string Attachment = ""; string msg = string.Empty; BusLogic chk = new BusLogic(); if (chk.ValidateEmail(from) == true && chk.ValidateEmail(to) == true) { var hours = from j in TNEDB.tblTimeExpensesSummaries where (j.Date >= GetWeekStartDate() && j.Date <= GetWeekEndDate()) && j.NewId.ToString() == userId.ToString() orderby j.Date group j by j.Date into grouping select new { WorkDay = string.Format("{0:dddd, MMMM d, yyyy}", grouping.Key), Total = grouping.Sum(p => p.WorkHrs) }; } if (sumView.Rows.Count != 0) { chk.SendEmail(from, to, subject, Body); ShowClientFunction("EmailSuccess();"); } }
public Boolean CheckIfItsMe() { bool val = false; if (BusLogic.SelectUserId(Request.QueryString["enum"]) == 1) { val = true; } return(val); }
public bool PrepareSendEmail(string[] EmailId, string WeekEndDate) { WeekEndDate = WeekEndDate.Substring(0, 9) + " " + DateTime.Now.ToShortTimeString(); string email1 = string.Empty; string email2 = string.Empty; string emailIdFromRequestor = Request.QueryString["eid"]; char[] delimiter = new char[] { ';' }; string [] emailArray = emailIdFromRequestor.Split(delimiter); email1 = EmailId[0].ToString(); email2 = EmailId[1].ToString(); if (email2 != "NoCC") { System.Configuration.ConfigurationManager.AppSettings["ToAddress"] = GetEmailId(userId, email1); System.Configuration.ConfigurationManager.AppSettings["CCAddress"] = GetEmailId(userId, email2); } else { System.Configuration.ConfigurationManager.AppSettings["ToAddress"] = GetEmailId(userId, email1); System.Configuration.ConfigurationManager.AppSettings["CCAddress"] = System.Configuration.ConfigurationManager.AppSettings["NetUser"]; } emailGrid = true; string from = System.Configuration.ConfigurationManager.AppSettings["FromAddress"].ToString(); string to = System.Configuration.ConfigurationManager.AppSettings["ToAddress"].ToString(); string cc = System.Configuration.ConfigurationManager.AppSettings["CCAddress"].ToString(); string subject = string.Format("Time Sheet for Week Ending {0}", WeekEndDate); string Body = GetBody(Application["HistGrid"] as GridView); string Attachment = ""; string msg = string.Empty; BusLogic chk = new BusLogic(); if (chk.ValidateEmail(from) == true && chk.ValidateEmail(to) == true) { try { SendEmail(from, to, cc, subject, Body); success = true; ShowClientFunction("EmailSuccess();"); } catch (Exception) { success = false; } finally { } } return(success); }
protected void btnCreate_Click(object sender, EventArgs e) { AdminDataContext ad = new AdminDataContext(); tblLogonId logIn = new tblLogonId(); BusLogic bl = new BusLogic(); if (txtNewUser.Text != string.Empty) { logIn.UserName = txtNewUser.Text; } if (txtPword.Text != string.Empty) { logIn.Password = bl.getMd5Hash(txtPword.Text); } if (txtRole.Text != string.Empty) { logIn.Role = int.Parse(txtRole.Text); } if (txtEmail.Text != string.Empty) { if (bl.ValidateEmail(txtEmail.Text)) { logIn.emailAddress = txtEmail.Text; } } try { ad.tblLogonIds.InsertOnSubmit(logIn); ad.SubmitChanges(); string fn = "alert('" + txtNewUser.Text + " was successfully added!');"; ShowClientFunction(fn); btnView_Click(sender, e); } catch (Exception) { } finally { txtNewUser.Text = string.Empty; txtPword.Text = string.Empty; txtEmail.Text = string.Empty; } }
protected void btnSendEmail_Click(object sender, EventArgs e) { BusLogic bus = new BusLogic(); if (flag) { txtEmailfrom.Text = System.Configuration.ConfigurationManager.AppSettings["FromAddress"].ToString(); if (sumView.Rows.Count != 0) { if (bus.ValidateEmail(txtEmailRec.Text)) { //Update AppSettings if (!string.IsNullOrEmpty(txtEmailRec.Text)) { System.Configuration.ConfigurationManager.AppSettings["ToAddress"] = txtEmailRec.Text; SendEmail(); } } } } }
void InsertTime() { var t = new tblTimeExpensesSummary(); t.Comments = txtComments.Text == string.Empty ? "No Comments" : txtComments.Text; if (!String.IsNullOrEmpty(lstCalendar.SelectedValue)) { t.Date = DateTime.Parse(lstCalendar.SelectedValue); } else { t.Date = DateTime.Parse(string.Format("{0:dddd, MMMM d, yyyy}", DateTime.Today.ToString())); } t.Expenses = null; t.LastUpdated = null; t.PaymentReceived = false; t.pictureUrl = null; t.CreatedDate = DateTime.Now; t.Location = ddlAddLocation.SelectedValue.ToString(); t.WorkDescription = ddlWorkDesc.SelectedValue.ToString(); if (ddlHoursSelect.SelectedIndex > -1) { t.WorkHrs = Decimal.Parse(ddlHoursSelect.SelectedValue); } int nUserId = BusLogic.SelectUserId(Application["UserId"].ToString()); if (nUserId != 0) { t.Id = nUserId; } if (!String.IsNullOrEmpty(Request.QueryString["enum"].ToString())) { t.NewId = Guid.Parse(Request.QueryString["enum"].ToString()); } TNEDB.tblTimeExpensesSummaries.InsertOnSubmit(t); TNEDB.SubmitChanges(); }
protected void btnView_Click(object sender, EventArgs e) { gView.AutoGenerateDeleteButton = true; gView.DataSource = BusLogic.SelectUsers(); gView.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { bool d = checkforcurl("hello I have a & in my text."); // btnSubmitAll.Click += new System.EventHandler(btnUpdate_Click); //String userId = Application["NewId"].ToString(); string userId = Request.QueryString["enum"].ToString(); BusLogic.BaseDt b = new BusLogic.BaseDt(); b.name = "Rich"; string x = b.name; BusLogic bus = new BusLogic(); { if (!IsPostBack) { Bind(); BindSummary(); } if (IsPostBack) { Bind(); } if (!IsPostBack) { this.lblPageView.Text = string.Format("Viewing page {0} of {1}", "1", gView.PageCount.ToString()); this.lblPageView.Text = string.Format("Viewing page {0} of {1}. Displaying records {2} thru {3}.", 1, gView.PageCount, 1, 10); } this.Page.Title = "TimeKeeper Pro© | Time Entry"; HttpSessionStateWrapper Wrapper = new HttpSessionStateWrapper(this.Session); int cnt = Wrapper.Count; bool s = Wrapper.IsNewSession; if (!IsPostBack) { if (String.IsNullOrEmpty(userId.ToString())) { Response.Redirect("Login.aspx"); } hfUserId.Value = userId.ToString(); } // if (userId == 2 || userId == 1) //{ //lblLocation.Text = "Client"; //lblLoc.Text = "Select Client"; //} //To update this value use the Web.config file int startWeekVal = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["startWeek"]); int endWeekVal = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["endWeek"]); startweek = DateTime.Now.AddDays(startWeekVal).ToShortDateString(); endweek = DateTime.Now.AddDays(endWeekVal).ToShortDateString(); Thread T1 = new Thread(new ThreadStart(Thread1)); Thread T2 = new Thread(new ThreadStart(Thread2)); //btnSend.Visible = true; flag = false; if (IsPostBack) { updateGrid = true; flag = true; } if (!IsPostBack) { IEnumerable list = PopulateDates(startweek, endweek); lstCalendar.DataSource = list; lstCalendar.DataTextField = "Day"; lstCalendar.DataValueField = "dates"; DateTime curDate = DateTime.Today; //Get Server Time DateTime UTCTime = DateTime.UtcNow; lstCalendar.DataBind(); for (int k = 0; k < lstCalendar.Items.Count; k++) { if (lstCalendar.Items[k].Value == curDate.ToString()) { lstCalendar.SelectedIndex = k; } } LoadWorkDescriptions(); LoadLocations(); LoadHours(); } //Get requestor info if (Page.Request.Browser.Browser.ToString() != null) { string browser = Page.Request.Browser.Browser.ToString(); } if (Page.Request.UrlReferrer != null) { if (Page.Request.UrlReferrer.AbsolutePath != null) { string urlRef = Request.UrlReferrer.AbsolutePath.ToString(); //Application.Add("CurrentPage", urlRef); } } if (Request.Url.Host != null) { string host = Request.Url.Host; } if (Request.UserHostName != null) { string dns = Request.UserHostName; } if (Request.UserAgent != null) { string useragent = Request.UserAgent; } List <string> requestVars = new List <string>(); for (int i = 0; i < Request.ServerVariables.Count; i++) { requestVars.Add(Request.ServerVariables[i].ToString()); } Application.Add("IPAddress", requestVars[28].ToString()); Application.Add("CurrentPage", requestVars[29].ToString()); // Application.Add("Browser", requestVars[52].ToString()); if (!IsPostBack) { appList.Add(Application["IPAddress"]); appList.Add(Application["CurrentPage"]); //appList.Add(Application["Browser"]); } } }