private void ViewColumnsReports_Click(object sender, System.EventArgs e) { mainPane.Controls.Clear(); RecordsViewer cr = new RecordsViewer(mc); mainPane.Controls.Add(cr); }
public static string ListRecord(String formGuid, String pageStr) { FormState state = FormState.Approved; Range range = Range.Day; Show show = Show.five; int page = int.Parse(pageStr); if (Utils.GetPostParameter("State") != null && !string.IsNullOrEmpty(Utils.GetPostParameter("State").ToString())) HttpContext.Current.Session["State"] = Utils.GetPostParameter("State").ToString(); if (Utils.GetPostParameter("Range") != null && !string.IsNullOrEmpty(Utils.GetPostParameter("Range").ToString())) HttpContext.Current.Session["Range"] = Utils.GetPostParameter("Range").ToString(); if (Utils.GetPostParameter("Show") != null && !string.IsNullOrEmpty(Utils.GetPostParameter("Show").ToString())) HttpContext.Current.Session["Show"] = Utils.GetPostParameter("Show").ToString(); if (HttpContext.Current.Session["State"] != null && !string.IsNullOrEmpty(HttpContext.Current.Session["State"].ToString())) state = (FormState)Enum.Parse(typeof(FormState), HttpContext.Current.Session["State"].ToString()); if (HttpContext.Current.Session["Range"] != null && !string.IsNullOrEmpty(HttpContext.Current.Session["Range"].ToString())) range = (Range)Enum.Parse(typeof(Range), HttpContext.Current.Session["Range"].ToString()); if (HttpContext.Current.Session["Show"] != null && !string.IsNullOrEmpty(HttpContext.Current.Session["Show"].ToString())) show = (Show)Enum.Parse(typeof(Show), HttpContext.Current.Session["Show"].ToString()); FormStorage fs = new FormStorage(); RecordsViewer rv = new RecordsViewer(); RecordStorage recordStorage = new RecordStorage(); Umbraco.Forms.Core.Form form = fs.GetForm(Guid.Parse(formGuid)); System.Collections.Generic.List<Record> records = rv.GetRecords(0, 0, form, Sorting.descending, new List<FormState> { state }); List calls = new List(); calls.AddListItem(new ListItem("<b>Filter</b>", subtitle: state.ToString() + ", Last " + range.ToString() + ", " + (int)show + " records per page", icon: GenericIcon.Filter, action: new Call("ConfigFilter", new string[] { formGuid }))); DateTime minDate = DateTime.Now; switch (range) { case Range.hour: minDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, 0, 0); break; case Range.Month: minDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); break; case Range.Year: minDate = new DateTime(DateTime.Now.Year, 1, 1); break; case Range.Decade: minDate = DateTime.MinValue; break; case Range.Day: default: minDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0); break; } if (records.Where(r => r.Created > minDate).Any()) { int total = records.Where(r => r.Created > minDate).Count(); IEnumerable<Record> results = records.Where(r => r.Created > minDate).OrderByDescending(r => r.Created).Skip((page - 1) * (int)show).Take((int)show); Button nextButton = null; if (total > (results.Count() + (page - 1) * (int)show)) nextButton = new Button(icon: GenericIcon.ArrowRight, action: new Call("ListRecord", new string[] { formGuid, (page + 1).ToString() })); calls.AddListItem(new ListItem("<b>Total result:</b> " + total.ToString(), subtitle: "Page <b>" + page.ToString() + "</b> to <b>" + (((int)(total / (int)show)) + 1).ToString() + "</b>", contextual_button: nextButton)); foreach (Record record in results) { calls.AddListItem(new ListItem(record.Created.ToString(), subtitle: "Ip: " + record.IP, action: new Call("ViewData", new string[] { record.Id.ToString() }))); } } else { calls.AddListItem(new ListItem("<b>Total result:</b> 0", subtitle: "Page <b>0</b> to <b>0</b>")); } return calls.UmGo(); }