protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e) { MembershipUser mu = System.Web.Security.Membership.GetUser(PasswordRecovery1.UserName); if (mu != null) // The username exists { var userID = (Guid)mu.ProviderUserKey; PollinatorEntities mydb = new PollinatorEntities(); var userDetail = (from ud in mydb.UserDetails where ud.UserId == userID select ud).FirstOrDefault(); string name = PasswordRecovery1.UserName; if (userDetail != null) { name = userDetail.FirstName; } string logoPath = Request.Url.Authority + Request.ApplicationPath + "/Images/logo/Bee-Friendly-Farmer-Logo1.png"; if (!logoPath.StartsWith("http://")) { logoPath = "http://" + logoPath; } e.Message.Body = e.Message.Body.Replace("{Logo}", logoPath); e.Message.Body = e.Message.Body.Replace("{FirstName}", name); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { PollinatorEntities mydb = new PollinatorEntities(); } }
protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e) { MembershipUser mu = System.Web.Security.Membership.GetUser(PasswordRecovery1.UserName); if (mu != null) // The username exists { var userID = (Guid)mu.ProviderUserKey; PollinatorEntities mydb = new PollinatorEntities(); var userDetail = (from ud in mydb.UserDetails where ud.UserId == userID select ud).FirstOrDefault(); string name = PasswordRecovery1.UserName; if (userDetail != null) { name = userDetail.FirstName; } string logoPath = Request.Url.Authority + Request.ApplicationPath + "/Images/logo/Bee-Friendly-Farmer-Logo1.png"; if (!logoPath.StartsWith("http://")) logoPath = "http://" + logoPath; e.Message.Body = e.Message.Body.Replace("{Logo}", logoPath); e.Message.Body = e.Message.Body.Replace("{FirstName}", name); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { PollinatorEntities mydb = new PollinatorEntities(); var countryList = (from ct in mydb.Countries orderby ct.SortOder, ct.Name select new { ct.ID, ct.Name, ct.SortOder }).ToList(); DropDownList ddlCountry = this.ddlCountry; if (ddlCountry != null) { ddlCountry.DataSource = countryList; ddlCountry.DataValueField = "ID"; ddlCountry.DataTextField = "Name"; ddlCountry.DataBind(); } var pollinatorSizeList = (from ps in mydb.PollinatorSizes select new { ps.ID, ps.Name }).OrderBy(o => o.ID).ToList(); var pollinatorTypeList = (from pt in mydb.PollinatorTypes select new { pt.ID, pt.Name }).OrderBy(o => o.Name).ToList(); DropDownList ddlPollinatorSize = this.ddlPollinatorSize; if (ddlPollinatorSize != null) { ddlPollinatorSize.DataSource = pollinatorSizeList; ddlPollinatorSize.DataValueField = "ID"; ddlPollinatorSize.DataTextField = "Name"; ddlPollinatorSize.DataBind(); } DropDownList ddlPollinatorType = this.ddlPollinatorType; if (ddlPollinatorType != null) { ddlPollinatorType.DataSource = pollinatorTypeList; ddlPollinatorType.DataValueField = "ID"; ddlPollinatorType.DataTextField = "Name"; ddlPollinatorType.DataBind(); } var organizationList = (from ct in mydb.Organizations orderby ct.SortOder, ct.Name select new { ct.ID, ct.SortOder, ct.Name }).ToList(); DropDownList ddlFindOut = this.ddlFindOut; if (ddlCountry != null) { ddlFindOut.DataSource = organizationList; ddlFindOut.DataValueField = "ID"; ddlFindOut.DataTextField = "Name"; ddlFindOut.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { PollinatorEntities mydb = new PollinatorEntities(); var countryList = (from ct in mydb.Countries orderby ct.SortOder, ct.Name select new { ct.ID, ct.Name, ct.SortOder }).ToList(); DropDownList ddlCountry = this.ddlCountry; if (ddlCountry != null) { ddlCountry.DataSource = countryList; ddlCountry.DataValueField = "ID"; ddlCountry.DataTextField = "Name"; ddlCountry.DataBind(); } var pollinatorSizeList = (from ps in mydb.PollinatorSizes select new { ps.ID, ps.Name }).OrderBy(o => o.ID).ToList(); var pollinatorTypeList = (from pt in mydb.PollinatorTypes select new { pt.ID, pt.Name }).OrderBy(o => o.Name).ToList(); DropDownList ddlPollinatorSize = this.ddlPollinatorSize; if (ddlPollinatorSize != null) { ddlPollinatorSize.DataSource = pollinatorSizeList; ddlPollinatorSize.DataValueField = "ID"; ddlPollinatorSize.DataTextField = "Name"; ddlPollinatorSize.DataBind(); } DropDownList ddlPollinatorType = this.ddlPollinatorType; if (ddlPollinatorType != null) { ddlPollinatorType.DataSource = pollinatorTypeList; ddlPollinatorType.DataValueField = "ID"; ddlPollinatorType.DataTextField = "Name"; ddlPollinatorType.DataBind(); } var organizationList = (from ct in mydb.Organizations orderby ct.SortOder, ct.Name select new { ct.ID, ct.SortOder, ct.Name}).ToList(); DropDownList ddlFindOut = this.ddlFindOut; if (ddlCountry != null) { ddlFindOut.DataSource = organizationList; ddlFindOut.DataValueField = "ID"; ddlFindOut.DataTextField = "Name"; ddlFindOut.DataBind(); } } }
protected void btnDeleteJunkyUploadFolder_Click(object sender, EventArgs e) { try { PollinatorEntities mydb = new PollinatorEntities(); var listSponsorPhoto = mydb.Sponsors.Select(pi => pi.PhotoUrl).ToList(); List <string> folderList = new List <string>(); string folderName; int firstIndex; int lastIndex; foreach (var url in listSponsorPhoto) { firstIndex = url.IndexOf("/") + 1; lastIndex = url.LastIndexOf("/"); if (firstIndex != -1) { folderName = url.Substring(firstIndex, lastIndex - firstIndex); folderList.Add(folderName); } } var listPolinatorPhoto = mydb.PolinatorInformations.Select(pi => pi.PhotoUrl).ToList(); foreach (var url in listPolinatorPhoto) { folderName = Utility.GetUserFolder(url); if (!string.IsNullOrEmpty(folderName)) { folderList.Add(folderName); } } folderList.Add("Admin"); string uploadFolder = Request.MapPath("~/" + ConfigurationManager.AppSettings["FolderPath"]).Replace(@"//", "/"); DirectoryInfo dInfo = new DirectoryInfo(uploadFolder); DirectoryInfo[] subdirs = dInfo.GetDirectories(); for (int i = 0; i < subdirs.Length; i++) { if (!folderList.Contains(subdirs[i].Name)) { Directory.Delete(subdirs[i].FullName, true); } } GoToAlertMessage(panelSuccessMessage); } catch (Exception ex) { Pollinator.Common.Logger.Error("Error occured at " + typeof(Admin_CleanUnusedFolders).Name + "btnDeleteJunkyUploadFolder_Click(). ", ex); GoToAlertMessage(panelErrorMessage); } }
protected void btnDeleteJunkyUploadFolder_Click(object sender, EventArgs e) { try { PollinatorEntities mydb = new PollinatorEntities(); var listSponsorPhoto = mydb.Sponsors.Select(pi => pi.PhotoUrl).ToList(); List<string> folderList = new List<string>(); string folderName; int firstIndex; int lastIndex; foreach (var url in listSponsorPhoto) { firstIndex = url.IndexOf("/") + 1; lastIndex = url.LastIndexOf("/"); if (firstIndex != -1) { folderName = url.Substring(firstIndex, lastIndex - firstIndex); folderList.Add(folderName); } } var listPolinatorPhoto = mydb.PolinatorInformations.Select(pi => pi.PhotoUrl).ToList(); foreach (var url in listPolinatorPhoto) { folderName = Utility.GetUserFolder(url); if (!string.IsNullOrEmpty(folderName)) folderList.Add(folderName); } folderList.Add("Admin"); string uploadFolder = Request.MapPath("~/" + ConfigurationManager.AppSettings["FolderPath"]).Replace(@"//", "/"); DirectoryInfo dInfo = new DirectoryInfo(uploadFolder); DirectoryInfo[] subdirs = dInfo.GetDirectories(); for (int i = 0; i < subdirs.Length; i++) { if (!folderList.Contains(subdirs[i].Name)) { Directory.Delete(subdirs[i].FullName, true); } } GoToAlertMessage(panelSuccessMessage); } catch (Exception ex) { Pollinator.Common.Logger.Error("Error occured at " + typeof(Admin_CleanUnusedFolders).Name + "btnDeleteJunkyUploadFolder_Click(). ", ex); GoToAlertMessage(panelErrorMessage); } }
private void BindUserAccounts(bool refreshTotal) { var sSearch = txtSearch.Text.Trim().ToLower(); Session["SearchUseKeyWork"] = sSearch; PollinatorEntities mydb = new PollinatorEntities(); var users = (from ud in mydb.UserDetails from pi in mydb.PolinatorInformations where ud.UserId == pi.UserId && (!this.OnlyShowBFF || (this.OnlyShowBFF && ud.MembershipLevel >= 1)) && ((this.UsernameToMatch == string.Empty) || ud.FirstName.StartsWith(this.UsernameToMatch)) && (sSearch == string.Empty || ud.FirstName.ToLower().IndexOf(sSearch) >= 0 || ud.LastName.ToLower().IndexOf(sSearch) >= 0 || pi.OrganizationName.ToLower().IndexOf(sSearch) >= 0 || pi.LandscapeStreet.ToLower().IndexOf(sSearch) >= 0 || pi.LandscapeCity.ToLower().IndexOf(sSearch) >= 0 || pi.LandscapeState.ToLower().IndexOf(sSearch) >= 0 ) orderby pi.IsApproved, pi.LastUpdated descending select new { ud.UserId, ud.FirstName, ud.LastName, ud.MembershipLevel, pi.PhotoUrl, pi.OrganizationName, pi.LandscapeStreet, pi.LandscapeCity, pi.LandscapeState, pi.IsApproved, pi.IsNew, pi.LastUpdated }).ToList(); UserAccounts.DataSource = users; UserAccounts.DataBind(); if (refreshTotal) { var totalUser = users.Count; var totalPremium = users.Where(u => u.MembershipLevel > 0).Count(); lblSummary.Text = String.Format("Total: {0} users ({1} ", totalUser, totalPremium); // lblSummary.Text = String.Format("Total: {0} users ({1} <font color='violet'>BFF </font> users)", totalUser, totalPremium); } }
protected void Page_Load(object sender, EventArgs e) { PollinatorEntities mydb = new PollinatorEntities(); var list = (from sp in mydb.Sponsors select new { sp.Name, sp.PhotoUrl, sp.Website, }).ToList(); var typelist = (from sp in mydb.PollinatorTypes select new { sp.ID, sp.Name, }).OrderBy(o => o.Name).ToList(); var sizelist = (from sp in mydb.PollinatorSizes select new { sp.ID, sp.Name, }).OrderBy(o => o.Name).ToList(); var countrylist = (from sp in mydb.Countries select new { sp.ID, sp.Name, sp.SortOder, }).OrderBy(o => o.SortOder).ToList(); this.SponsorJson = new JavaScriptSerializer().Serialize(list); this.PollinatorTypeJson = new JavaScriptSerializer().Serialize(typelist); this.PollinatorSizeJson = new JavaScriptSerializer().Serialize(sizelist); this.CountryJson = new JavaScriptSerializer().Serialize(countrylist); if (!IsPostBack) { //System.Web.UI.WebControls.LoginView LoginView2 = ((System.Web.UI.WebControls.LoginView)Master.FindControl("LoginView2")); //var texssst = LoginView2.ClientID; //ControlCollection controls= LoginView2.Controls; //HtmlAnchor aPreSince = (HtmlAnchor)LoginView2.FindControl("aPreSince"); //var text = aPreSince.InnerText; } }
private void BindSponsors() { PollinatorEntities mydb = new PollinatorEntities(); var list = (from sp in mydb.Sponsors select new { sp.ID, sp.Name, sp.PhotoUrl, sp.Website, sp.IsActive, }).ToList(); Sponsor.DataSource = list; Sponsor.DataBind(); }
protected string GetUserFirstName() { try { var userID = (Guid)Membership.GetUser(Context.User.Identity.Name).ProviderUserKey; PollinatorEntities mydb = new PollinatorEntities(); var userDetail = (from ud in mydb.UserDetails where ud.UserId == userID select ud).FirstOrDefault(); return userDetail.FirstName; } catch (Exception ex) { Console.WriteLine(ex); return ""; } }
protected string GetUserFirstName() { try { var userID = (Guid)Membership.GetUser(Context.User.Identity.Name).ProviderUserKey; PollinatorEntities mydb = new PollinatorEntities(); var userDetail = (from ud in mydb.UserDetails where ud.UserId == userID select ud).FirstOrDefault(); return(userDetail.FirstName); } catch (Exception ex) { Console.WriteLine(ex); return(""); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { PollinatorEntities mydb = new PollinatorEntities(); var orglist = (from sp in mydb.Organizations select new { sp.ID, sp.SortOder, sp.Name, }).OrderBy(o => o.SortOder).ToList(); this.OrgListJson = new JavaScriptSerializer().Serialize(orglist); var list = (from sp in mydb.Sponsors.Where(s => s.IsActive == true) select new { sp.Name, sp.PhotoUrl, sp.Website, }).ToList(); var typelist = (from sp in mydb.PollinatorTypes select new { sp.ID, sp.Name, }).OrderBy(o => o.Name).ToList(); var sizelist = (from sp in mydb.PollinatorSizes select new { sp.ID, sp.Name, }).OrderBy(o => o.Name).ToList(); var countrylist = (from sp in mydb.Countries select new { sp.ID, sp.Name, sp.SortOder, }).OrderBy(o => o.SortOder).ToList(); this.SponsorJson = new JavaScriptSerializer().Serialize(list); this.PollinatorTypeJson = new JavaScriptSerializer().Serialize(typelist); this.PollinatorSizeJson = new JavaScriptSerializer().Serialize(sizelist); this.CountryJson = new JavaScriptSerializer().Serialize(countrylist); } catch (global::System.Exception ex) { Response.Write(ex.Message); //write log Pollinator.Common.Logger.Error("Occured in function: " + typeof(Controls_MapViewControl).Name + ".Page_Load()", ex); } } }
protected void btnExport_Click(object sender, EventArgs e) { try { byte? membeshipLevel = null; string filename = "AllUsers"; if (drMemberShip.SelectedValue == "0")//Share User { membeshipLevel = 0; filename = "ShareUsers"; } else if (drMemberShip.SelectedValue == "1")//BFF User { membeshipLevel = 1; filename = "BffUsers"; } //Query data PollinatorEntities mydb = new PollinatorEntities(); var listData = (from ud in mydb.UserDetails.Where(ud => !membeshipLevel.HasValue || ud.MembershipLevel == membeshipLevel || (ud.MembershipLevel > membeshipLevel && membeshipLevel == 1)) join user in mydb.Memberships on ud.UserId equals user.UserId into group1 from ui in group1.DefaultIfEmpty() join pi in mydb.PolinatorInformations on ud.UserId equals pi.UserId join py in mydb.PollinatorTypes on pi.PollinatorType equals py.ID into group2 from uit in group2.DefaultIfEmpty() join ps in mydb.PollinatorSizes on pi.PollinatorSize equals ps.ID join c in mydb.Countries on pi.LandscapeCountry equals c.ID into group3 from ex in group3.DefaultIfEmpty() orderby pi.IsApproved, pi.LastUpdated descending select new ImportExportFields { UserId = ud.UserId, FirstName = ud.FirstName, LastName = ud.LastName, OrganizationName = pi.OrganizationName != null ? pi.OrganizationName : string.Empty, Website = pi.Website != null ? pi.Website : string.Empty, PhoneNumber = ud.PhoneNumber != null ? ud.PhoneNumber : string.Empty, Email = (ui != null && ui.Email != null) ? ui.Email : string.Empty, PollinatorTypeName = (uit != null && uit.Name != null) ? uit.Name : (ud.MembershipLevel == 0) ? string.Empty : "Bee Friendly Farmers", OrganizationDescription = pi.Description != null ? pi.Description : string.Empty, PollinatorSizeName = ps.Name, LandscapeStreet = pi.LandscapeStreet != null ? pi.LandscapeStreet : string.Empty, LandscapeCity = pi.LandscapeCity != null ? pi.LandscapeCity : string.Empty, LandscapeState = pi.LandscapeState != null ? pi.LandscapeState : string.Empty, LandscapeZipcode = pi.LandscapeZipcode != null ? pi.LandscapeZipcode : string.Empty, LandscapeCountryName = (ex != null && ex.Name != null) ? ex.Name : string.Empty, Latitude = pi.Latitude, Longitude = pi.Longitude, }).ToList(); this.EnableViewState = false; if (drExportFormat.SelectedValue == "Excel") { filename = filename + System.DateTime.Now.ToString("_MMddyyyy_HHmm") + ".xlsx"; ImportExportUltility.ExportExcel(Response, filename, listData); } else { filename = filename + System.DateTime.Now.ToString("_MMddyyyy_HHmm") + ".csv"; ImportExportUltility.ExportCSV(Response, filename, listData); } } catch (Exception ex) { Pollinator.Common.Logger.Error("Error occured at " + typeof(Admin_ExportData).Name + "btnExport_Click(). Exception:", ex); } }
protected void Page_Load(object sender, EventArgs e) { PollinatorEntities mydb = new PollinatorEntities(); var list = (from sp in mydb.Sponsors select new { sp.Name, sp.PhotoUrl, sp.Website, }).ToList(); var typelist = (from sp in mydb.PollinatorTypes select new { sp.ID, sp.Name, }).OrderBy(o => o.Name).ToList(); var sizelist = (from sp in mydb.PollinatorSizes select new { sp.ID, sp.Name, }).OrderBy(o => o.Name).ToList(); var countrylist = (from sp in mydb.Countries select new { sp.ID, sp.Name, sp.SortOder, }).OrderBy(o => o.SortOder).ToList(); this.SponsorJson = new JavaScriptSerializer().Serialize(list); this.PollinatorTypeJson = new JavaScriptSerializer().Serialize(typelist); this.PollinatorSizeJson = new JavaScriptSerializer().Serialize(sizelist); this.CountryJson = new JavaScriptSerializer().Serialize(countrylist); if (!IsPostBack ) { //System.Web.UI.WebControls.LoginView LoginView2 = ((System.Web.UI.WebControls.LoginView)Master.FindControl("LoginView2")); //var texssst = LoginView2.ClientID; //ControlCollection controls= LoginView2.Controls; //HtmlAnchor aPreSince = (HtmlAnchor)LoginView2.FindControl("aPreSince"); //var text = aPreSince.InnerText; } }
/// <summary> /// Custom display at top of site /// (1)Set logonName display FirstName /// (2)Set Premium Since MMM, yyyy /// </summary> private void SetMessageAfterLogin() { try { //if (Context.User.Identity.IsAuthenticated) //{ // string test = HttpUtility.HtmlEncode(@"<newuser2>?:!@#%^&*()_+""'.,/\[]|\!@#$%^&*()_+"); // //test = "<newuser2>?:{}|\\!@#$%^&*()_+"; // LoginName loginName1 = (LoginName)LoginView2.FindControl("loginName"); // loginName1.FormatString = test; //} if (Context.User.Identity.IsAuthenticated && Roles.IsUserInRole(Utility.RoleName.Members.ToString())) { string sesloginName = "loginName" + Context.User.Identity.Name; string sesPreSince = "aPreSince" + Context.User.Identity.Name; LoginName loginName = (LoginName)LoginView2.FindControl("loginName"); if (Session[sesloginName] != null) loginName.FormatString = Session[sesloginName].ToString(); HtmlAnchor aPreSince = (HtmlAnchor)LoginView2.FindControl("aPreSince"); if (Session[sesPreSince] != null) aPreSince.InnerText = Session[sesPreSince].ToString(); else { Guid userID = (Guid)System.Web.Security.Membership.GetUser(Context.User.Identity.Name).ProviderUserKey; PollinatorEntities mydb = new PollinatorEntities(); UserDetail userDetail = new UserDetail(); var selectedUserDetail = (from user in mydb.UserDetails where user.UserId == userID select user).FirstOrDefault(); if (selectedUserDetail != null) { //set loginName Session[sesloginName] = selectedUserDetail.FirstName; loginName.FormatString = HttpUtility.HtmlEncode(Session[sesloginName].ToString()); if (selectedUserDetail.MembershipLevel == 0) aPreSince.Visible = false; else if (selectedUserDetail.MembershipLevel > 0) { var pollinatorInfomation = (from poll in mydb.PolinatorInformations where poll.UserId == userID select poll).FirstOrDefault(); DateTime paidDate = pollinatorInfomation.PaidDate == null ? DateTime.MinValue : (DateTime)pollinatorInfomation.PaidDate; if (paidDate > DateTime.MinValue) { aPreSince.Visible = true; Session[sesPreSince] = string.Format("Premium since {0}", String.Format("{0:MMM, yyyy}", paidDate)); aPreSince.InnerText = Session[sesPreSince].ToString(); } } } } } else if (Context.User.Identity.IsAuthenticated) { string sesloginName = "loginName" + Context.User.Identity.Name; string sesPreSince = "aPreSince" + Context.User.Identity.Name; HtmlAnchor aPreSince = (HtmlAnchor)LoginView2.FindControl("aPreSince"); aPreSince.Visible = false; LoginName loginName = (LoginName)LoginView2.FindControl("loginName"); if (Session[sesloginName] != null) loginName.FormatString = Session[sesloginName].ToString(); else { Guid userID = (Guid)System.Web.Security.Membership.GetUser(Context.User.Identity.Name).ProviderUserKey; PollinatorEntities mydb = new PollinatorEntities(); UserDetail userDetail = new UserDetail(); var selectedUserDetail = (from user in mydb.UserDetails where user.UserId == userID select user).FirstOrDefault(); if (selectedUserDetail != null) { //set loginName Session[sesloginName] = selectedUserDetail.FirstName; loginName.FormatString = Session[sesloginName].ToString(); } } } } catch (Exception ex) { //write log Pollinator.Common.Logger.Error("Occured in function: " + typeof(SiteMap).Name + ".SetMessageAfterLogin()", ex); } }
/// <summary> /// Custom display at top of site /// (1)Set logonName display FirstName /// (2)Set Premium Since MMM, yyyy /// </summary> private void SetMessageAfterLogin() { try { //if (Context.User.Identity.IsAuthenticated) //{ // string test = HttpUtility.HtmlEncode(@"<newuser2>?:!@#%^&*()_+""'.,/\[]|\!@#$%^&*()_+"); // //test = "<newuser2>?:{}|\\!@#$%^&*()_+"; // LoginName loginName1 = (LoginName)LoginView2.FindControl("loginName"); // loginName1.FormatString = test; //} if (Context.User.Identity.IsAuthenticated && Roles.IsUserInRole(Utility.RoleName.Members.ToString())) { string sesloginName = "loginName" + Context.User.Identity.Name; string sesPreSince = "aPreSince" + Context.User.Identity.Name; LoginName loginName = (LoginName)LoginView2.FindControl("loginName"); if (Session[sesloginName] != null) { loginName.FormatString = Session[sesloginName].ToString(); } HtmlAnchor aPreSince = (HtmlAnchor)LoginView2.FindControl("aPreSince"); if (Session[sesPreSince] != null) { aPreSince.InnerText = Session[sesPreSince].ToString(); } else { Guid userID = (Guid)System.Web.Security.Membership.GetUser(Context.User.Identity.Name).ProviderUserKey; PollinatorEntities mydb = new PollinatorEntities(); UserDetail userDetail = new UserDetail(); var selectedUserDetail = (from user in mydb.UserDetails where user.UserId == userID select user).FirstOrDefault(); if (selectedUserDetail != null) { //set loginName Session[sesloginName] = selectedUserDetail.FirstName; loginName.FormatString = HttpUtility.HtmlEncode(Session[sesloginName].ToString()); if (selectedUserDetail.MembershipLevel == 0) { aPreSince.Visible = false; } else if (selectedUserDetail.MembershipLevel > 0) { var pollinatorInfomation = (from poll in mydb.PolinatorInformations where poll.UserId == userID select poll).FirstOrDefault(); DateTime paidDate = pollinatorInfomation.PaidDate == null ? DateTime.MinValue : (DateTime)pollinatorInfomation.PaidDate; if (paidDate > DateTime.MinValue) { aPreSince.Visible = true; Session[sesPreSince] = string.Format("Premium since {0}", String.Format("{0:MMM, yyyy}", paidDate)); aPreSince.InnerText = Session[sesPreSince].ToString(); } } } } } else if (Context.User.Identity.IsAuthenticated) { string sesloginName = "loginName" + Context.User.Identity.Name; string sesPreSince = "aPreSince" + Context.User.Identity.Name; HtmlAnchor aPreSince = (HtmlAnchor)LoginView2.FindControl("aPreSince"); aPreSince.Visible = false; LoginName loginName = (LoginName)LoginView2.FindControl("loginName"); if (Session[sesloginName] != null) { loginName.FormatString = Session[sesloginName].ToString(); } else { Guid userID = (Guid)System.Web.Security.Membership.GetUser(Context.User.Identity.Name).ProviderUserKey; PollinatorEntities mydb = new PollinatorEntities(); UserDetail userDetail = new UserDetail(); var selectedUserDetail = (from user in mydb.UserDetails where user.UserId == userID select user).FirstOrDefault(); if (selectedUserDetail != null) { //set loginName Session[sesloginName] = selectedUserDetail.FirstName; loginName.FormatString = Session[sesloginName].ToString(); } } } } catch (Exception ex) { //write log Pollinator.Common.Logger.Error("Occured in function: " + typeof(SiteMap).Name + ".SetMessageAfterLogin()", ex); } }