Пример #1
0
		public void Run()
		{
			try
			{
				if (Task.TaskStatus != TaskStatus.Error)
				{
					if (Task.TaskType.MaxPoolingTask.HasValue && Task.PoolingTaskNumber >= Task.TaskType.MaxPoolingTask)
					{
						Task.TaskStatus = TaskStatus.Error;
						Task.ErrorMessage = "Max pooling task";
						SendMaxPoolingTaskNotificationInternal();
					}
					else
					{
						LaunchTask();
						if (Task.TaskStatus != TaskStatus.Error)
							Task.TaskStatus = TaskStatus.Completed;
					}
					EndTask();
				}
			}
			catch (Exception ex)
			{
				if (!ex.Data.Contains("TaskId"))
					ex.Data.Add("TaskId", Task.Id);
				Task.ErrorMessage = Logger.WriteError(ex).ToString();
				Task.TaskStatus = TaskStatus.Error;
				CreateResendOnErrorTask();
			}
			finally
			{
				try
				{
					using (var dbFactory = new DatabaseFactory())
					{
						var repository = new TaskQueueRepository(dbFactory);
						repository.SetTaskEnd(Task.Id, Task.TaskStatus, Task.Result, Task.ErrorMessage);
					}
				}
				catch (Exception ex)
				{
					Logger.WriteError(ex);
				}
			}
		}