// Spludlow Software // Copyright © Samuel P. Ludlow 2020 All Rights Reserved // Distributed under the terms of the GNU General Public License version 3 // Distributed WITHOUT ANY WARRANTY; without implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE // https://www.spludlow.co.uk/LICENCE.TXT // The Spludlow logo is a registered trademark of Samuel P. Ludlow and may not be used without permission // v1.14 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; public partial class Logs : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Spludlow.WebControls.DisableOnClick(this); if (this.IsPostBack == false) { foreach (int pageSize in new int[] { 25, 50, 100, 250, 500, 1000 }) this.DropDownListPageSize.Items.Add(pageSize.ToString()); string[] searchColumns = new string[] { "LogType", "OrganizationId", "NetworkId", "HostId", "WebSite", "Application", "MethodAssembly", "MethodType", "Method", }; foreach (string searchColumn in searchColumns) this.DropDownListSearch.Items.Add(searchColumn); this.DropDownListPageSize.SelectedIndex = 3; this.LiteralPage.Text = "1"; this._ShowData(); } } protected void ButtonQuery_Click(object sender, EventArgs e) { this.LiteralPage.Text = "1"; this._ShowData(); } private void _ShowData() { this.LiteralPage2.Text = this.LiteralPage.Text; int pageSize = Int32.Parse(this.DropDownListPageSize.SelectedValue); int pageIndex = Int32.Parse(this.LiteralPage.Text) - 1; this.TextBoxSearch.Text = this.TextBoxSearch.Text.Trim(); string searchText = this.TextBoxSearch.Text; string searchColumn = this.DropDownListSearch.SelectedValue; DataTable logsTable = Spludlow.Log.Query(pageIndex, pageSize, searchText, searchColumn).Tables[0]; this.GridViewLogs.DataSource = logsTable; this.GridViewLogs.DataBind(); } protected void GridViewLogs_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { DataRow row = ((DataRowView)e.Row.DataItem).Row; string logType = (string)row["LogType"]; Spludlow.Log.ColourGridRow(e, row); } } protected void ButtonMark_Click(object sender, EventArgs e) { Spludlow.Log.Mark(); this._ShowData(); } protected void ButtonPagePrev_Click(object sender, EventArgs e) { int page = Int32.Parse(this.LiteralPage.Text); --page; if (page < 1) page = 1; this.LiteralPage.Text = page.ToString(); this._ShowData(); } protected void ButtonPageNext_Click(object sender, EventArgs e) { int page = Int32.Parse(this.LiteralPage.Text); this.LiteralPage.Text = (page + 1).ToString(); this._ShowData(); } protected void DropDownListPageSize_SelectedIndexChanged(object sender, EventArgs e) { this._ShowData(); } }