Ejemplo n.º 1
0
		public void TaskQueueRepositoryTest_Add()
		{
			var task = new Task();
			task.CreateDate = DateTime.Now;
			task.TaskTypeEnum = TaskTypeEnum.Notifications;
			task.TaskStatus = TaskStatus.Pending;
			_repository.Add(task);

			using (var dc = new TaskQueueContext())
			{
				var tTask = dc.Tasks.Single(e => e.TaskTypeId == (int)TaskTypeEnum.Notifications);
				tTask.Should().NotBeNull();
				tTask.TaskStatusId.Should().Be((int)TaskStatus.Pending);
			}
		}
Ejemplo n.º 2
0
		public void TaskQueueRepositoryTest_KillBuzzTask()
		{
			var task = new Task();
			task.CreateDate = DateTime.Now.AddMinutes(-22);
			task.StartDate = DateTime.Now.AddMinutes(-21);
			task.TaskTypeEnum = TaskTypeEnum.AscGov;
			task.TaskStatus = TaskStatus.Executing;
			_repository.Add(task);

			var tasks = _repository.GetTasksToRun();
			tasks.Should().NotBeNull();
			tasks.Should().HaveCount(0);

			using (var dc = new TaskQueueContext())
			{
				var tTask = dc.Tasks.Single(e => e.TaskTypeId == (int)TaskTypeEnum.AscGov);
				tTask.Should().NotBeNull();
				tTask.TaskStatusId.Should().Be((int)TaskStatus.Error);
			}
		}
Ejemplo n.º 3
0
		public void TaskQueueRepositoryTest_GetTasksToRun()
		{
			var task = new Task();
			task.CreateDate = DateTime.Now;
			task.TaskTypeEnum = TaskTypeEnum.AscGov;
			task.TaskStatus = TaskStatus.Pending;
			_repository.Add(task);

			var tasks = _repository.GetTasksToRun();
			tasks.Should().NotBeNull();
			tasks.Should().HaveCount(1);
			tasks.First().TaskType.Should().NotBeNull();
			tasks.First().TaskType.Name.Should().Be(TaskTypeEnum.AscGov.ToString());
			tasks.First().TaskType.MaxPoolingTask.Should().Be(5);


			using (var dc = new TaskQueueContext())
			{
				var tTask = dc.Tasks.Single(e => e.TaskTypeId == (int)TaskTypeEnum.AscGov);
				tTask.Should().NotBeNull();
				tTask.TaskStatusId.Should().Be((int)TaskStatus.Executing);
			}
		}
Ejemplo n.º 4
0
		public static void AddNew(TaskTypeEnum taskType, Dictionary<TaskParamsKey, string> parameters = null, DateTime? minStartDate = null, int? parentTaskId = null)
		{
			Task task = new Task();
			task.CreateDate = DateTime.Now;
			task.TaskStatus = TaskStatus.Pending;
			task.TaskTypeEnum = taskType;
			task.MinStartDate = minStartDate;
			task.ParentTaskId = parentTaskId;
			if (parameters != null)
			{
				task.TaskParams = new List<TaskParam>();
				foreach (var item in parameters)
				{
					task.TaskParams.Add(new TaskParam(item.Key, item.Value));
				}
			}

			using (var dbFactory = new DatabaseFactory())
			{
				var repository = new TaskQueueRepository(dbFactory);
				repository.Add(task);
			}
		}
Ejemplo n.º 5
0
		internal void Load(Task task)
		{
			Task = task;
		}