コード例 #1
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        var original_scheduledTask = new InfoControl.Web.ScheduledTasks.ScheduledTask();

        schedulerManager = new SchedulerManager(this);
        scheduledTask    = new InfoControl.Web.ScheduledTasks.ScheduledTask();

        if (scheduledTaskId > 0)
        {
            original_scheduledTask = schedulerManager.GetScheduleTask(scheduledTaskId);
            scheduledTask          = original_scheduledTask.Duplicate();
        }

        scheduledTask.Name         = txtName.Text;
        scheduledTask.Period       = ucCurrFieldTxtPeriod.IntValue;
        scheduledTask.Enabled      = chkEnabled.Checked;
        scheduledTask.TypeFullName = txtTypeFullName.Text;

        if (ucPeriodDate.DateTime != null)
        {
            scheduledTask.StartTime = Convert.ToDateTime(ucPeriodDate.DateTime);
        }

        schedulerManager.SaveScheduleTask(scheduledTask);

        Server.Transfer("ScheduleTasks.aspx");
    }
コード例 #2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        var original_scheduledTask = new InfoControl.Web.ScheduledTasks.ScheduledTask();

        schedulerManager = new SchedulerManager(this);
        scheduledTask = new InfoControl.Web.ScheduledTasks.ScheduledTask();

        if (scheduledTaskId > 0)
        {
            original_scheduledTask = schedulerManager.GetScheduleTask(scheduledTaskId);
            scheduledTask = original_scheduledTask.Duplicate();
        }

        scheduledTask.Name = txtName.Text;
        scheduledTask.Period = ucCurrFieldTxtPeriod.IntValue;
        scheduledTask.Enabled = chkEnabled.Checked;
        scheduledTask.TypeFullName = txtTypeFullName.Text;

        if (ucPeriodDate.DateTime != null)
            scheduledTask.StartTime = Convert.ToDateTime(ucPeriodDate.DateTime);
        
        schedulerManager.SaveScheduleTask(scheduledTask);

        Server.Transfer("ScheduleTasks.aspx");
    }
コード例 #3
0
        /// <summary>
        /// Verifies each second whether is to do work schedule task
        /// </summary>
        private void CheckTimer()
        {
            while (SchedulerSection.Enabled)
                using (var manager = new SchedulerManager(null))
                {
                    Tasks = manager.GetAllScheduleTasks().ToList();
                    foreach (ScheduledTask task in Tasks)
                        if (task.Enabled)
                        {
                            var start = task.StartTime;
                            var now = DateTime.Now;

                            if (start.Date == now.Date && start.Hour == now.Hour && start.Minute == now.Minute)
                                task.Start(ar => manager.SaveScheduleTask((ScheduledTask)ar.AsyncState));
                            else
                                while (task.StartTime < DateTime.Now.AddMinutes(-15))
                                    task.StartTime = task.StartTime.AddMinutes(task.Period);


                        }

                    Thread.Sleep(60000);
                }
        }