예제 #1
0
        private void UpdateTaskState(IPersistenceManager pm, DA.Task task, DT.TaskState taskState, Guid?slaveId, Guid?userId, string exception)
        {
            var stateLogDao     = pm.StateLogDao;
            var taskStateEntity = taskState.ToEntity();

            if (task.Command == DA.Command.Pause && task.State == DA.TaskState.Paused ||
                task.Command == DA.Command.Abort && task.State == DA.TaskState.Aborted ||
                task.Command == DA.Command.Stop && task.State == DA.TaskState.Aborted)
            {
                task.Command = null;
            }
            else if (taskStateEntity == DA.TaskState.Paused && task.Command == null)
            {
                // slave paused and uploaded the task (no user-command) -> set waiting.
                taskStateEntity = DA.TaskState.Waiting;
            }
            stateLogDao.Save(new DA.StateLog {
                State     = taskStateEntity,
                DateTime  = DateTime.Now,
                TaskId    = task.TaskId,
                UserId    = userId,
                SlaveId   = slaveId,
                Exception = exception
            });
            task.State = taskStateEntity;
        }
예제 #2
0
        public DT.Task UpdateTaskState(Guid taskId, DT.TaskState taskState, Guid?slaveId, Guid?userId, string exception)
        {
            RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client, HiveRoles.Slave);
            AuthorizationManager.AuthorizeForTask(taskId, Permission.Full);
            var pm = PersistenceManager;

            using (new PerformanceLogger("UpdateTaskState")) {
                var taskDao = pm.TaskDao;
                return(pm.UseTransaction(() => {
                    var task = taskDao.GetById(taskId);
                    UpdateTaskState(pm, task, taskState, slaveId, userId, exception);
                    pm.SubmitChanges();
                    return task.ToDto();
                }));
            }
        }
예제 #3
0
 public static DB.TaskState ToEntity(DT.TaskState source)
 {
     if (source == DT.TaskState.Aborted)
     {
         return(DB.TaskState.Aborted);
     }
     else if (source == DT.TaskState.Calculating)
     {
         return(DB.TaskState.Calculating);
     }
     else if (source == DT.TaskState.Failed)
     {
         return(DB.TaskState.Failed);
     }
     else if (source == DT.TaskState.Finished)
     {
         return(DB.TaskState.Finished);
     }
     else if (source == DT.TaskState.Offline)
     {
         return(DB.TaskState.Offline);
     }
     else if (source == DT.TaskState.Paused)
     {
         return(DB.TaskState.Paused);
     }
     else if (source == DT.TaskState.Transferring)
     {
         return(DB.TaskState.Transferring);
     }
     else if (source == DT.TaskState.Waiting)
     {
         return(DB.TaskState.Waiting);
     }
     else
     {
         return(DB.TaskState.Failed);
     }
 }
예제 #4
0
        public static DA.TaskState ToEntity(this DT.TaskState source)
        {
            switch (source)
            {
            case DT.TaskState.Aborted: return(DA.TaskState.Aborted);

            case DT.TaskState.Calculating: return(DA.TaskState.Calculating);

            case DT.TaskState.Failed: return(DA.TaskState.Failed);

            case DT.TaskState.Finished: return(DA.TaskState.Finished);

            case DT.TaskState.Offline: return(DA.TaskState.Offline);

            case DT.TaskState.Paused: return(DA.TaskState.Paused);

            case DT.TaskState.Transferring: return(DA.TaskState.Transferring);

            case DT.TaskState.Waiting: return(DA.TaskState.Waiting);

            default: return(DA.TaskState.Failed);
            }
        }