Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var dataTable = new DataTable();

            dataTable.Columns.Add("key");
            dataTable.Columns.Add("scheduletype");
            dataTable.Columns.Add("exetime");
            dataTable.Columns.Add("lastexecute");
            dataTable.Columns.Add("issystemevent");
            dataTable.Columns.Add("enable");
            var events = ScheduleConfigInfo.Current.Events;

            for (int i = 0; i < events.Length; i++)
            {
                var     ev      = events[i];
                DataRow dataRow = dataTable.NewRow();
                dataRow["key"]          = ev.Key;
                dataRow["scheduletype"] = ev.ScheduleType;
                if (ev.TimeOfDay != -1)
                {
                    dataRow["exetime"] = "定时执行:" + ev.TimeOfDay / 60 + "时" + ev.TimeOfDay % 60 + "分";
                }
                else
                {
                    dataRow["exetime"] = "周期执行:" + ev.Minutes + "分钟";
                }
                //DateTime lastExecuteScheduledEventDateTime = BBX.Forum.ScheduledEvents.Event.GetLastExecuteScheduledEventDateTime(@event.Key, Environment.MachineName);
                DateTime lastExecuteScheduledEventDateTime = ScheduledEvent.GetLast(ev.Key, Environment.MachineName);
                if (lastExecuteScheduledEventDateTime == DateTime.MinValue)
                {
                    dataRow["lastexecute"] = "从未执行";
                }
                else
                {
                    dataRow["lastexecute"] = lastExecuteScheduledEventDateTime.ToString("yyyy-MM-dd HH:mm:ss");
                }
                dataRow["issystemevent"] = (ev.IsSystemEvent ? "系统级" : "非系统级");
                dataRow["enable"]        = (ev.Enabled ? "启用" : "禁用");
                dataTable.Rows.Add(dataRow);
            }
            this.DataGrid1.DataSource   = dataTable;
            this.DataGrid1.DataKeyField = "key";
            this.DataGrid1.DataBind();
        }