protected void ProcessPageRequest(SPWeb web) { if (!string.IsNullOrWhiteSpace(Page.Request[NewPeriod])) { Page.Response.Cookies.Remove(EpmLiveTsPeriod); Page.Request.Cookies.Remove(EpmLiveTsPeriod); var myCookie = new HttpCookie(EpmLiveTsPeriod) { [PeriodText] = Page.Request[NewPeriod], Expires = DateTime.Now.AddMinutes(30) }; Page.Response.Cookies.Add(myCookie); } var period = string.Empty; if (Page.Request.Cookies[EpmLiveTsPeriod] != null) { period = Page.Request.Cookies[EpmLiveTsPeriod][PeriodText]; } if (string.IsNullOrWhiteSpace(period)) { using (var sqlCommand = new SqlCommand( "SELECT period_id from TSPERIOD where period_start<=@dtchecked and period_end>=@dtchecked and locked = 0 and site_id=@siteid", Connection) { CommandType = CommandType.Text }) { sqlCommand.Parameters.AddWithValue("@dtchecked", DateTime.Now); sqlCommand.Parameters.AddWithValue("@siteid", web.Site.ID); using (var dataReader = sqlCommand.ExecuteReader()) { Period = dataReader.Read() ? dataReader.GetInt32(0) : int.Parse(Periods.GetKey(0).ToString()); } } } else { Period = int.Parse(period); } var tempAllPeriods = new StringBuilder(AllPeriods); foreach (DictionaryEntry dictionaryEntry in Periods) { tempAllPeriods.Append($",{dictionaryEntry.Value}|{dictionaryEntry.Key}"); if (Period == (int)dictionaryEntry.Key) { CurrentPeriodName = dictionaryEntry.Value.ToString(); if (Periods.IndexOfKey(dictionaryEntry.Key) > 0) { PreviousPeriod = Periods.GetKey(Periods.IndexOfKey(dictionaryEntry.Key) - 1).ToString(); } if (Periods.IndexOfKey(dictionaryEntry.Key) < Periods.Count - 1) { NextPeriod = Periods.GetKey(Periods.IndexOfKey(dictionaryEntry.Key) + 1).ToString(); } } } AllPeriods = tempAllPeriods.ToString(); if (AllPeriods.Length > 0) { AllPeriods = AllPeriods.Substring(1); } using (var command = new SqlCommand("SELECT locked from TSPERIOD where period_id=@periodid and site_id=@site_id", Connection) { CommandType = CommandType.Text }) { command.Parameters.AddWithValue("@periodid", Period); command.Parameters.AddWithValue("@site_id", web.Site.ID); using (var executeReader = command.ExecuteReader()) { Status = OpenStatus; if (executeReader.Read()) { if (executeReader.GetBoolean(0)) { Status = ClosedStatus; SetToolBarControlsVisible(); } } } } }