Пример #1
0
        public static void TaskCompleted(TaskBase task)
        {
            try
            {
                ScheduleHistory objScheduleHistory = task.TaskRecordItem;
                objScheduleHistory = task.TaskRecordItem;

                RemoveFromScheduleInProgress(objScheduleHistory);
                Interlocked.Decrement(ref ActiveThreadCount);

                objScheduleHistory.HistoryEndDate = DateTime.Now;

                objScheduleHistory.Status    = true;
                objScheduleHistory.NextStart = SchedulerController.GetNextStart(objScheduleHistory);

                task.TaskRecordItem.ReturnText = "Successfully completed";

                SchedulerController.UpdateTaskHistory(objScheduleHistory);

                if (!string.IsNullOrEmpty(objScheduleHistory.NextStart))
                {
                    objScheduleHistory.HistoryStartDate = null;
                    objScheduleHistory.HistoryEndDate   = null;
                    objScheduleHistory.ReturnText       = "";
                    objScheduleHistory.ProcessGroup     = -1;
                    objScheduleHistory.Status           = false;
                    AddToScheduleQueue(objScheduleHistory);
                }
            }
            catch (Exception exc)
            {
                if (task.TaskRecordItem != null)
                {
                    ErrorLogger.SchedulerProcessException(exc);
                }
            }
        }
Пример #2
0
        public static void TaskErrored(TaskBase task, Exception exception)
        {
            try
            {
                ScheduleHistory objScheduleHistoryItem = task.TaskRecordItem;

                RemoveFromScheduleInProgress(objScheduleHistoryItem);

                Interlocked.Decrement(ref ActiveThreadCount);

                objScheduleHistoryItem.HistoryEndDate = DateTime.Now;

                DateTime startedTime = objScheduleHistoryItem.HistoryStartDate ?? DateTime.Now;

                if (objScheduleHistoryItem.RetryTimeLapse > 0)
                {
                    switch (objScheduleHistoryItem.RetryFrequencyUnit)
                    {
                    case 1:
                        startedTime.AddSeconds(objScheduleHistoryItem.RetryTimeLapse);
                        break;

                    case 2:
                        startedTime.AddMinutes(objScheduleHistoryItem.RetryTimeLapse);
                        break;

                    case 3:
                        startedTime.AddHours(objScheduleHistoryItem.RetryTimeLapse);
                        break;

                    case 4:
                        startedTime.AddDays(objScheduleHistoryItem.RetryTimeLapse);
                        break;
                    }
                    objScheduleHistoryItem.NextStart = Convert.ToString(startedTime);
                }

                objScheduleHistoryItem.Status = false;
                string error = "";

                StringBuilder errorlog = new StringBuilder();

                errorlog.AppendLine("Error");
                if ((exception != null))
                {
                    error = exception.Message;
                }
                errorlog.AppendLine(error);

                task.TaskRecordItem.ReturnText = errorlog.ToString();

                SchedulerController.UpdateTaskHistory(objScheduleHistoryItem);

                if (!string.IsNullOrEmpty(objScheduleHistoryItem.NextStart) && objScheduleHistoryItem.RetryTimeLapse > 0)
                {
                    objScheduleHistoryItem.HistoryStartDate = null;
                    objScheduleHistoryItem.HistoryEndDate   = null;
                    objScheduleHistoryItem.ReturnText       = "";
                    objScheduleHistoryItem.ProcessGroup     = -1;
                    AddToScheduleQueue(objScheduleHistoryItem);
                }
            }
            catch (Exception exc)
            {
                if (task.TaskRecordItem != null)
                {
                    ErrorLogger.SchedulerProcessException(exc);
                }
            }
        }