Christoc.Modules.DnnChat.Archive.Page_Load C# (CSharp) Method

Page_Load() protected method

protected Page_Load ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {

                //TODO: be sure to check for permissions when enabled
                if (!Page.IsPostBack)
                {
                    var sd = Request.QueryString["sd"];
                    var ed = Request.QueryString["ed"];

                    var startDate = DateTime.UtcNow.Date;
                    var endDate = DateTime.UtcNow;
                    if (sd != null)
                    {
                        startDate = Convert.ToDateTime(sd);
                    }
                    if (ed != null)
                    {
                        endDate = Convert.ToDateTime(ed);
                    }

                    txtStartDate.Text = startDate.ToString(CultureInfo.InvariantCulture);
                    txtEndDate.Text = endDate.ToString(CultureInfo.InvariantCulture);
                    var mc = new MessageController();
                    rptMessages.DataSource = mc.GetMessagesByDate(ModuleId, startDate, endDate, RoomId);
                    rptMessages.DataBind();

                    //if we have any items, don't display the "no results found" message
                    if (rptMessages.Items.Count > 0)
                    {
                        lblNoResults.Visible = false;
                    }
                    BuildArchiveLinks(RoomId);

                    var rc = new RoomController();
                    var r = rc.GetRoom(RoomId, ModuleId);
                    var tp = (CDefault)Page;
                    var t = new TabController().GetTab(TabId, PortalId, false);
                    tp.Title += string.Format(Localization.GetString("ChatArchiveTitle.Text", LocalResourceFile), t.TabName, r.RoomName, startDate.ToShortDateString(), endDate.ToShortDateString());
                    lblArchiveTitle.Text = string.Format(Localization.GetString("ChatArchiveContentTitle.Text", LocalResourceFile), r.RoomName, startDate.ToShortDateString(), endDate.ToShortDateString());
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }