protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var patron = Session[SessionKey.Patron] as DAL.Patron; if (patron == null) { return; } var program = DAL.Programs.FetchObject(patron.ProgID); if (program == null || !program.IsOpen || !program.DisplayDailyImage || DateTime.Now < program.LoggingStart || DateTime.Now > program.LoggingEnd) { return; } string imagePath = string.Format(DailyImagePath, program.PID, (DateTime.Now - program.LoggingStart).Days + 1); if (System.IO.File.Exists(Server.MapPath(imagePath))) { DailyImageButton.HRef = Page.ResolveUrl(imagePath); DailyImageButton.Visible = true; } else { var sessionTools = new SessionTools(Session); var cached = sessionTools.GetCache(Cache, "LoggedAboutDailyImage"); if (cached == null) { this.Log().Warn("Unable to show daily image - file doesn't exist: {0}", Server.MapPath(imagePath)); sessionTools.SetCache(Cache, "LoggedAboutDailyImage", true); } } } }
public int UnreadCrMail(HttpContext context) { if (context.Session == null) { return(0); } var tenant = context.Session[GRA.SRP.ControlRoom.CRSessionKey.TenantID]; int tenantId = tenant as int? ?? -1; if (tenantId == -1) { return(0); } var sessionTool = new SessionTools(context.Session); var cachedFeed = sessionTool.GetCache(context.Cache, GRA.SRP.ControlRoom.CRSessionKey.UnreadMail, tenantId) as int?; if (cachedFeed != null) { return((int)cachedFeed); } else { var unread = SRP.DAL.Notifications.GetAllUnreadToPatron(0); if (unread != null && unread.Tables.Count > 0) { int unreadMessages = unread.Tables[0].Rows.Count; sessionTool.SetCache(context.Cache, GRA.SRP.ControlRoom.CRSessionKey.UnreadMail, unreadMessages, tenantId, 60); return(unreadMessages); } return(0); } }
public int UnreadCrMail(HttpContext context) { if (context.Session == null) { return 0; } var tenant = context.Session[GRA.SRP.ControlRoom.CRSessionKey.TenantID]; int tenantId = tenant as int? ?? -1; if (tenantId == -1) { return 0; } var sessionTool = new SessionTools(context.Session); var cachedFeed = sessionTool.GetCache(context.Cache, GRA.SRP.ControlRoom.CRSessionKey.UnreadMail, tenantId) as int?; if (cachedFeed != null) { return (int)cachedFeed; } else { var unread = SRP.DAL.Notifications.GetAllUnreadToPatron(0); if (unread != null && unread.Tables.Count > 0) { int unreadMessages = unread.Tables[0].Rows.Count; sessionTool.SetCache(context.Cache, GRA.SRP.ControlRoom.CRSessionKey.UnreadMail, unreadMessages, tenantId, 60); return unreadMessages; } return 0; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Session["Patron"] == null) { Response.Redirect("~"); } var patron = (Patron)Session[SessionKey.Patron]; var program = Programs.FetchObject(patron.ProgID); ViewState[RequireBookDetailsKey] = program.RequireBookDetails; ViewState[PatronCanReviewKey] = program.PatronReviewFlag; if (program == null || !program.IsOpen) { readingLogControlPanel.Visible = false; return; } ViewState[ProgramGameIdKey] = program.PID.ToString(); if (Request.Cookies[CookieKey.LogBookDetails] != null) { enterBookDetails.Checked = true; } foreach (ActivityType activityTypeValue in Enum.GetValues(typeof(ActivityType))) { int activityTypeId = (int)activityTypeValue; var sessionTool = new SessionTools(Session); string lookupString = string.Format("{0}.{1}.{2}", CacheKey.PointGameConversionStub, patron.ProgID, activityTypeId); var pgc = sessionTool.GetCache(Cache, lookupString) as ProgramGamePointConversion; if (pgc == null) { this.Log().Debug("Cache miss looking up {0}", lookupString); pgc = ProgramGamePointConversion.FetchObjectByActivityId(patron.ProgID, activityTypeId); sessionTool.SetCache(Cache, lookupString, pgc); } if (pgc != null && pgc.PointCount > 0) { activityTypeSelector.Items.Add(new ListItem(activityTypeValue.ToString(), activityTypeId.ToString())); } } if (activityTypeSelector.Items.Count == 1) { var singleOption = activityTypeSelector.Items[0]; if (int.Parse(singleOption.Value) == (int)ActivityType.Books) { countSubmittedLabel.Visible = false; readingActivityField.Text = "1"; readingActivityField.Attributes.Remove("style"); readingActivityField.Attributes.Add("style", "display: none;"); activityTypeSelector.Attributes.Remove("style"); activityTypeSelector.Attributes.Add("style", "display: none;"); activityTypeSingleLabel.Visible = false; submitButton.Text = StringResources.getString("readinglog-read-a-book"); } else { activityTypeSelector.Attributes.Remove("style"); activityTypeSelector.Attributes.Add("style", "display: none;"); activityTypeSingleLabel.Text = singleOption.Text; activityTypeSingleLabel.Visible = true; } } else { activityTypeSingleLabel.Visible = false; } } }