// 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.Threading.Tasks; using System.Data; public partial class Schedule : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (this.Page.IsPostBack == false) { this.DropDownList1.Items.Add("Display Complete Schedule"); foreach (string host in Spludlow.Config.Hosts()) this.DropDownList1.Items.Add(host); this.Calendar1.SelectedDate = DateTime.Now.Date; this._DisplayData(); } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { this._DisplayData(); } protected void Calendar1_SelectionChanged(object sender, EventArgs e) { this._DisplayData(); } private void _DisplayData() { DateTime now = this.Calendar1.SelectedDate.Date; string[] hosts; if (this.DropDownList1.SelectedIndex == 0) { hosts = Spludlow.Config.Hosts(); } else { hosts = new string[] { this.DropDownList1.SelectedValue }; try { DataTable tasksTable = Spludlow.Scheduler.ReadConfig(hosts[0]).Tables[0]; DataTable scheduleTable = Spludlow.Scheduler.DailySchedule(now, tasksTable); this.GridViewTasks.DataSource = tasksTable; this.GridViewTasks.DataBind(); this.GridViewSchedule.DataSource = scheduleTable; this.GridViewSchedule.DataBind(); } catch (Exception ee) { this.LabelError.Text = ee.Message; Spludlow.Log.Error("Schedule.aspx", ee); } } this.GridViewReport.DataSource = Spludlow.Scheduler.Report(hosts, now); this.GridViewReport.DataBind(); } }