fixed status running task & remove re-start scheduling from controller(add field lastfinish - update sql)
This commit is contained in:
parent
c443d94ac3
commit
59b097b10b
6 changed files with 389 additions and 11 deletions
|
@ -1945,11 +1945,12 @@ namespace WebsitePanel.EnterpriseServer
|
|||
// read identity
|
||||
return Convert.ToInt32(prmId.Value);
|
||||
}
|
||||
|
||||
public static void UpdateSchedule(int actorId, int scheduleId, string taskId,
|
||||
string scheduleName, string scheduleTypeId, int interval,
|
||||
DateTime fromTime, DateTime toTime, DateTime startTime,
|
||||
DateTime lastRun, DateTime nextRun, bool enabled, string priorityId, int historiesNumber,
|
||||
int maxExecutionTime, int weekMonthDay, string xmlParameters)
|
||||
DateTime lastRun, DateTime lastFinish, DateTime nextRun, bool enabled, string priorityId,
|
||||
int historiesNumber, int maxExecutionTime, int weekMonthDay, string xmlParameters)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure,
|
||||
ObjectQualifier + "UpdateSchedule",
|
||||
|
@ -1963,6 +1964,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
new SqlParameter("@toTime", toTime),
|
||||
new SqlParameter("@startTime", startTime),
|
||||
new SqlParameter("@lastRun", (lastRun == DateTime.MinValue) ? DBNull.Value : (object)lastRun),
|
||||
new SqlParameter("@lastFinish", (lastFinish == DateTime.MinValue) ? DBNull.Value : (object)lastFinish),
|
||||
new SqlParameter("@nextRun", nextRun),
|
||||
new SqlParameter("@enabled", enabled),
|
||||
new SqlParameter("@priorityId", priorityId),
|
||||
|
@ -1971,6 +1973,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
new SqlParameter("@weekMonthDay", weekMonthDay),
|
||||
new SqlParameter("@xmlParameters", xmlParameters));
|
||||
}
|
||||
|
||||
public static void DeleteSchedule(int actorId, int scheduleId)
|
||||
{
|
||||
SqlHelper.ExecuteNonQuery(ConnectionString, CommandType.StoredProcedure,
|
||||
|
|
|
@ -58,13 +58,15 @@ namespace WebsitePanel.EnterpriseServer
|
|||
public static bool IsScheduleActive(int scheduleId)
|
||||
{
|
||||
Dictionary<int, BackgroundTask> scheduledTasks = TaskManager.GetScheduledTasks();
|
||||
return scheduledTasks.ContainsKey(scheduleId);
|
||||
|
||||
ScheduleInfo scheduleInfo = SchedulerController.GetSchedule(scheduleId);
|
||||
|
||||
return scheduledTasks.ContainsKey(scheduleId) || scheduleInfo.LastRun > scheduleInfo.LastFinish;
|
||||
}
|
||||
|
||||
public static void StartSchedule(SchedulerJob schedule)
|
||||
{
|
||||
Dictionary<int, BackgroundTask> scheduledTasks = TaskManager.GetScheduledTasks();
|
||||
if (scheduledTasks.ContainsKey(schedule.ScheduleInfo.ScheduleId))
|
||||
if (IsScheduleActive(schedule.ScheduleInfo.ScheduleId))
|
||||
return;
|
||||
|
||||
// run schedule
|
||||
|
@ -125,8 +127,6 @@ namespace WebsitePanel.EnterpriseServer
|
|||
|
||||
static void RunSchedule(SchedulerJob schedule, bool changeNextRun)
|
||||
{
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
// update next run (if required)
|
||||
|
|
|
@ -275,7 +275,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
schedule.HistoriesNumber, schedule.MaxExecutionTime, schedule.WeekMonthDay, xmlParameters);
|
||||
|
||||
// re-schedule tasks
|
||||
Scheduler.ScheduleTasks();
|
||||
//Scheduler.ScheduleTasks();
|
||||
|
||||
return scheduleId;
|
||||
}
|
||||
|
@ -297,11 +297,11 @@ namespace WebsitePanel.EnterpriseServer
|
|||
DataProvider.UpdateSchedule(SecurityContext.User.UserId,
|
||||
schedule.ScheduleId, schedule.TaskId, schedule.ScheduleName, schedule.ScheduleTypeId,
|
||||
schedule.Interval, schedule.FromTime, schedule.ToTime, schedule.StartTime,
|
||||
schedule.LastRun, schedule.NextRun, schedule.Enabled, schedule.PriorityId,
|
||||
schedule.LastRun, schedule.LastFinish, schedule.NextRun, schedule.Enabled, schedule.PriorityId,
|
||||
schedule.HistoriesNumber, schedule.MaxExecutionTime, schedule.WeekMonthDay, xmlParameters);
|
||||
|
||||
// re-schedule tasks
|
||||
Scheduler.ScheduleTasks();
|
||||
//Scheduler.ScheduleTasks();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ namespace WebsitePanel.EnterpriseServer
|
|||
DataProvider.DeleteSchedule(SecurityContext.User.UserId, scheduleId);
|
||||
|
||||
// re-schedule tasks
|
||||
Scheduler.ScheduleTasks();
|
||||
//Scheduler.ScheduleTasks();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -223,6 +223,14 @@ namespace WebsitePanel.EnterpriseServer
|
|||
TopTask.TaskName, executionLog);
|
||||
}
|
||||
|
||||
// update last finish time
|
||||
ScheduleInfo scheduleInfo = SchedulerController.GetSchedule(TopTask.ItemId);
|
||||
if (scheduleInfo != null)
|
||||
{
|
||||
scheduleInfo.LastFinish = DateTime.Now;
|
||||
SchedulerController.UpdateSchedule(scheduleInfo);
|
||||
}
|
||||
|
||||
// remove task from the stack
|
||||
TasksStack.RemoveAt(TasksStack.Count - 1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue