protected void ArchiveBtn_Click(object sender, EventArgs e) { int numDays; string strStartDate; DateTime dt = DateTime.Now; numDays = Convert.ToInt32(dateList.SelectedValue); TimeSpan ts = new TimeSpan(-numDays, (int)Config.TimeAdjust, 0, 0); dt += ts; strStartDate = dt.ToString("yyyyMMddHHmmss"); if (ArchiveForumsList.Items.Count != 0) { int count = 0; int[] forumList = new int[ArchiveForumsList.Items.Count]; foreach (ListItem li in ArchiveForumsList.Items) { forumList[count++] = Convert.ToInt32(li.Value); } int res = Archive.ArchiveForums(forumList, strStartDate); if (res >= 0) { lblRes.Text = String.Format("Topic Archiving Completed.", res); Panel2.Visible = true; } else { lblRes.Text = "Error archiving forums."; Panel2.Visible = true; } } }
private void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { string postbackbtn = Request.Form["__EVENTTARGET"]; string argument = Request.Form["__EVENTARGUMENT"]; int id; switch (postbackbtn) { case "ForumDelete": id = Convert.ToInt32(argument); DeleteForum(id); break; case "ForumLock": id = Convert.ToInt32(argument); SetForumLockState(id, Enumerators.PostStatus.Closed); break; case "ForumUnLock": id = Convert.ToInt32(argument); SetForumLockState(id, Enumerators.PostStatus.Open); break; case "ForumEmpty": id = Convert.ToInt32(argument); EmptyForum(id); break; case "DeleteCategory": id = Convert.ToInt32(argument); DeleteCategory(id); break; case "LockCategory": id = Convert.ToInt32(argument); SetCategoryLockState(id, Enumerators.PostStatus.Closed); break; case "UnLockCategory": id = Convert.ToInt32(argument); SetCategoryLockState(id, Enumerators.PostStatus.Open); break; case "ForumArchive": id = Convert.ToInt32(argument); Archive.ArchiveForums(new int[] { id }, null); break; } } if (!Config.ShowStats) { ContentPlaceHolder holder = (ContentPlaceHolder)Master.FindControl("CPF1"); holder.Controls.Clear(); } Session["TopicId"] = ""; Session["ForumId"] = ""; Session["CatId"] = ""; var cats = Categories.GetCategories(); if (CatId != null) { cats = cats.Where(c => c.Id == CatId).ToList(); } repCatDL.DataSource = cats; repCatDL.DataBind(); Page.Title = string.Format(webResources.ttlDefaultPage, Config.ForumTitle); GroupDIV.Visible = Config.ShowGroups; var smp = (SiteMapPath)Master.FindControl("SiteMap"); if (smp != null) { smp.Visible = false; } }