protected void Page_Load(object sender, EventArgs e) { try { HttpCookie cookie = Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName]; if (null != cookie && !string.IsNullOrEmpty(cookie.Value)) { System.Web.Security.FormsAuthenticationTicket ticket = System.Web.Security.FormsAuthentication.Decrypt(cookie.Value); ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); zxpUD = ZXPUserData.DeserializeZXPUserData(ticket.UserData); if (!(zxpUD._isAdmin || zxpUD._isDockManager || zxpUD._isLoader || zxpUD._isYardMule)) //make sure this matches whats in Site.Master and Default { Response.BufferOutput = true; Response.Redirect("ErrorPage.aspx?ErrorCode=5", false); //zxp live url } } else { Response.BufferOutput = true; Response.Redirect("Account/Login.aspx?ReturnURL=~/loaderMobile.aspx", false);//zxp live url } } catch (SqlException excep) { string strErr = " SQLException Error in loaderMobile Page_Load(). Details: " + excep.ToString(); ErrorLogging.LogErrorAndRedirect(2, strErr); } catch (Exception ex) { string strErr = " Exception Error in loaderMobile Page_Load(). Details: " + ex.ToString(); ErrorLogging.LogErrorAndRedirect(1, strErr); } }//page_load()
protected void Page_Load(object sender, EventArgs e) { try { HttpCookie cookie = Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName]; if (null != cookie && !string.IsNullOrEmpty(cookie.Value)) { System.Web.Security.FormsAuthenticationTicket ticket = System.Web.Security.FormsAuthentication.Decrypt(cookie.Value); zxpUD = ZXPUserData.DeserializeZXPUserData(ticket.UserData); } else { Response.BufferOutput = true; // Response.Redirect("/Account/Login.aspx?ReturnURL=/Default.aspx", false); mi4 url Response.Redirect("Account/Login.aspx?ReturnURL=~/Default.aspx", false);//zxp live url } } catch (Exception ex) { string strErr = " Exception Error in Default Page_Load(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); } }
public static ZXPUserData GetZXPUserDataFromCookie() { ZXPUserData zxpUD = new ZXPUserData(); try { HttpCookie cookie = HttpContext.Current.Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName]; if (null != cookie) { if (!string.IsNullOrEmpty(cookie.Value)) { System.Web.Security.FormsAuthenticationTicket ticket = System.Web.Security.FormsAuthentication.Decrypt(cookie.Value); zxpUD = ZXPUserData.DeserializeZXPUserData(ticket.UserData); } } } catch (Exception ex) { string strErr = " Exception Error in ZXPUserData GetZXPUserDataFromCookie(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; throw; } return(zxpUD); }
protected void Page_Load(object sender, EventArgs e) { try { string sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; HttpCookie cookie = Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName]; if (null != cookie && !string.IsNullOrEmpty(cookie.Value)) { ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); System.Web.Security.FormsAuthenticationTicket ticket = System.Web.Security.FormsAuthentication.Decrypt(cookie.Value); zxpUD = ZXPUserData.DeserializeZXPUserData(ticket.UserData); if (!(zxpUD._isGuard || zxpUD._isLabAdmin || zxpUD._isLabPersonnel || zxpUD._isAccountManager || zxpUD._isAdmin)) //make sure this matches whats in Site.Master and Default { Response.BufferOutput = true; Response.Redirect("/ErrorPage.aspx?ErrorCode=5", false); } } else { Response.BufferOutput = true; Response.Redirect("/Account/Login.aspx?ReturnURL=/COFAUpload.aspx", false); //zxp live } } catch (SqlException excep) { string strErr = " SQLException Error in COFAUpload Page_Load(). Details: " + excep.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 2; ErrorLogging.sendtoErrorPage(2); } catch (Exception ex) { string strErr = " Exception Error in COFAUpload Page_Load(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); } }
private void createMenuItems() { try { string currentUrl = Request.Url.ToString(); HttpCookie cookie = Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName]; if (null != cookie && !string.IsNullOrEmpty(cookie.Value)) { System.Web.Security.FormsAuthenticationTicket ticket = System.Web.Security.FormsAuthentication.Decrypt(cookie.Value); ZXPUserData zxpUD = new ZXPUserData(); zxpUD = ZXPUserData.DeserializeZXPUserData(ticket.UserData); AuditLog aLog = new AuditLog(zxpUD._uid); aLog.createNewAuditLogEntry(aLog); MenuItem temp = new MenuItem(); if (true) { temp.NavigateUrl = "~/Default.aspx"; temp.Text = "Home"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isAdmin || zxpUD._isDockManager || zxpUD._isGuard || zxpUD._isLabPersonnel || zxpUD._isLoader || zxpUD._isLabAdmin || zxpUD._isAccountManager) { temp.NavigateUrl = "~/trailerOverview.aspx"; temp.Text = "Truck Schedule"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); //need to set to new Menuitem for next and prevent index bound error } if (zxpUD._isAdmin || zxpUD._isGuard || zxpUD._isAccountManager) { temp.NavigateUrl = "~/guardStation.aspx"; temp.Text = "Guard Station"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); //need to set to new Menuitem for next and prevent index bound error } if (zxpUD._isAdmin || zxpUD._isDockManager || zxpUD._isInspector || zxpUD._isLabPersonnel || zxpUD._isLoader || zxpUD._isLabAdmin || zxpUD._isGuard || zxpUD._isYardMule) { temp.NavigateUrl = "~/yardAndWaiting.aspx"; temp.Text = "Yard and Waiting Area"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isAdmin || zxpUD._isDockManager || zxpUD._isInspector || zxpUD._isLoader) { temp.NavigateUrl = "~/inspectionMobile.aspx"; temp.Text = "Inspections"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isAdmin || zxpUD._isDockManager || zxpUD._isInspector || zxpUD._isLabPersonnel || zxpUD._isLoader || zxpUD._isLabAdmin) { temp.NavigateUrl = "~/Samples.aspx"; temp.Text = "Samples"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._uid != -1) //make available to everyone logged in { temp.NavigateUrl = "~/waitAndDockOverview.aspx"; temp.Text = "Dashboard"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isAdmin || zxpUD._isDockManager) { temp.NavigateUrl = "~/dockManager.aspx"; temp.Text = "Dock Manager"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (true) { temp.NavigateUrl = "~/loadermobile.aspx"; temp.Text = "Loader Mobile"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isAdmin || zxpUD._isDockManager || zxpUD._isLoader) { temp.NavigateUrl = "~/loaderTimeTracking.aspx"; temp.Text = "Loader Requests"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isAdmin || zxpUD._isDockManager || zxpUD._isYardMule) { temp.NavigateUrl = "~/yardMuleRequestOverview.aspx"; temp.Text = "Yard Mule Requests"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._canViewReports) { temp.NavigateUrl = Properties.Settings.Default.ReportViewerLink; temp.Text = "Reports"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isGuard || zxpUD._isLabAdmin || zxpUD._isLabPersonnel || zxpUD._isAccountManager || zxpUD._isAdmin) { temp.NavigateUrl = "~/COFAUpload.aspx"; temp.Text = "COFA Upload"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isLabAdmin || zxpUD._isLabPersonnel || zxpUD._isGuard || zxpUD._isAdmin) { temp.NavigateUrl = "~/rejectTruck.aspx"; temp.Text = "Reject Truck"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } if (zxpUD._isAdmin) { temp.NavigateUrl = "~/AdminMainPage.aspx"; temp.Text = "Admin"; NavigationMenu.Items.Add(temp); temp = new MenuItem(); } } } catch (Exception ex) { string strErr = " Exception Error in Site.Master createMenuItems(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); } }
protected void Page_Load(object sender, EventArgs e) { //1- Check if user already authenticated //2- IF user auth. then show all contents //else look for query string user/passhash params // if they exist - attempt to auth. // if auth. success show all contents //else show error message and quit // else show error message and quit int exceptionErrorCode = 0; try { string sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; if (sql_connStr == String.Empty) { throw new Exception("Missing SQLConnectionString in web.config"); } as400_connStr = ConfigurationManager.ConnectionStrings["AS400ConnectionString"].ConnectionString; //as400_connStr = ConfigurationManager.AppSettings["AS400ConnectionString"]; if (string.IsNullOrEmpty(as400_connStr)) { throw new Exception("Missing AS400ConnectionString in web.config"); } HttpCookie cookie = Request.Cookies[System.Web.Security.FormsAuthentication.FormsCookieName]; if (null != cookie && !string.IsNullOrEmpty(cookie.Value)) { System.Web.Security.FormsAuthenticationTicket ticket = System.Web.Security.FormsAuthentication.Decrypt(cookie.Value); zxpUD = ZXPUserData.DeserializeZXPUserData(ticket.UserData); } else { Response.BufferOutput = true; bool isValidUser = false; string userName = Request.QueryString["UN"]; string password = Request.QueryString["PS"]; if ((userName == null || userName == String.Empty) || (password == null || password == String.Empty)) { exceptionErrorCode = 6;//error code for unable to validate login throw new Exception("Unable to validate user: no login provided."); } else { isValidUser = isUserCredentialsValid(userName, password); } if (isValidUser == true) { string strUserData = zxpUD.SerializeZXPUserData(zxpUD); System.Web.Security.FormsAuthenticationTicket ticket = new System.Web.Security.FormsAuthenticationTicket(1, userName, DateTime.Now, DateTime.Now.AddDays(5), true, strUserData); string enticket = System.Web.Security.FormsAuthentication.Encrypt(ticket); System.Web.HttpCookie authcookie = new System.Web.HttpCookie(System.Web.Security.FormsAuthentication.FormsCookieName, enticket); if (ticket.IsPersistent) { authcookie.Expires = ticket.Expiration; } Response.Cookies.Add(authcookie); callAllCleanUpFunctions(); callAllUpdateFunctions(); } else { exceptionErrorCode = 6;//error code for unable to validate login throw new Exception("User is not valid or does not have permission."); } } } catch (SqlException excep) { string strErr = " SQLException Error in dataProcessingAndCleanup Page_Load(). Details: " + excep.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 2; ErrorLogging.sendtoErrorPage(2); } catch (Exception ex) { string strErr = " Exception Error in dataProcessingAndCleanup Page_Load(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); if (exceptionErrorCode > 0) { System.Web.HttpContext.Current.Session["ErrorNum"] = exceptionErrorCode; ErrorLogging.sendtoErrorPage(exceptionErrorCode); } else { System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); } } }