Exemple #1
0
        public TaskData GetTaskDataByDto(DT.TaskData dto)
        {
            var taskData = GetTaskDataById(dto.TaskId);

            DT.Convert.ToEntity(dto, taskData);
            return(taskData);
        }
        public Guid AddTask(DT.Task task, DT.TaskData taskData, IEnumerable <Guid> resourceIds)
        {
            RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
            var pm = PersistenceManager;

            using (new PerformanceLogger("AddTask")) {
                var taskDao     = pm.TaskDao;
                var stateLogDao = pm.StateLogDao;
                var newTask     = task.ToEntity();
                newTask.JobData            = taskData.ToEntity();
                newTask.JobData.LastUpdate = DateTime.Now;
                newTask.AssignedResources.AddRange(resourceIds.Select(
                                                       x => new DA.AssignedResource {
                    ResourceId = x
                }));
                newTask.State = DA.TaskState.Waiting;
                return(pm.UseTransaction(() => {
                    taskDao.Save(newTask);
                    pm.SubmitChanges();
                    stateLogDao.Save(new DA.StateLog {
                        State = DA.TaskState.Waiting,
                        DateTime = DateTime.Now,
                        TaskId = newTask.TaskId,
                        UserId = UserManager.CurrentUserId,
                        SlaveId = null,
                        Exception = null
                    });
                    pm.SubmitChanges();
                    return newTask.TaskId;
                }, false, true));
            }
        }
Exemple #3
0
 public static void ToEntity(DT.TaskData source, DB.TaskData target)
 {
     if ((source != null) && (target != null))
     {
         target.TaskId     = source.TaskId;
         target.Data       = source.Data;
         target.LastUpdate = source.LastUpdate;
     }
 }
Exemple #4
0
 public static void CopyToEntity(this DT.TaskData source, DA.TaskData target)
 {
     if ((source == null) || (target == null))
     {
         return;
     }
     target.TaskId     = source.TaskId;
     target.Data       = source.Data;
     target.LastUpdate = source.LastUpdate;
 }
Exemple #5
0
        public static DB.TaskData ToEntity(DT.TaskData source)
        {
            if (source == null)
            {
                return(null);
            }
            var entity = new DB.TaskData(); ToEntity(source, entity);

            return(entity);
        }
Exemple #6
0
        public static DA.TaskData ToEntity(this DT.TaskData source)
        {
            if (source == null)
            {
                return(null);
            }
            var result = new DA.TaskData();

            source.CopyToEntity(result);
            return(result);
        }
        public Guid AddChildTask(Guid parentTaskId, DT.Task task, DT.TaskData taskData)
        {
            RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
            IEnumerable <Guid> resourceIds;
            var pm = PersistenceManager;

            using (new PerformanceLogger("AddChildTask")) {
                var assignedResourceDao = pm.AssignedResourceDao;
                resourceIds = pm.UseTransaction(() => {
                    return(assignedResourceDao.GetByTaskId(parentTaskId)
                           .Select(x => x.ResourceId)
                           .ToList());
                });
            }
            task.ParentTaskId = parentTaskId;
            return(AddTask(task, taskData, resourceIds));
        }
        public void UpdateTaskData(DT.Task taskDto, DT.TaskData taskDataDto)
        {
            RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
            AuthorizationManager.AuthorizeForTask(taskDto.Id, Permission.Full);
            var pm = PersistenceManager;

            using (new PerformanceLogger("UpdateTaskData")) {
                var taskDao     = pm.TaskDao;
                var taskDataDao = pm.TaskDataDao;
                pm.UseTransaction(() => {
                    var task     = taskDao.GetById(taskDto.Id);
                    var taskData = taskDataDao.GetById(taskDataDto.TaskId);
                    taskDto.CopyToEntity(task);
                    taskDataDto.CopyToEntity(taskData);
                    taskData.LastUpdate = DateTime.Now;
                    pm.SubmitChanges();
                });
            }
        }