Ejemplo n.º 1
0
 public void UpdateDowntime(DT.Downtime downtimeDto) {
   RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
   AuthorizationManager.AuthorizeForResourceAdministration(downtimeDto.ResourceId);
   var pm = PersistenceManager;
   using (new PerformanceLogger("UpdateDowntime")) {
     var downtimeDao = pm.DowntimeDao;
     pm.UseTransaction(() => {
       var downtime = downtimeDao.GetById(downtimeDto.Id);
       if (downtime != null) {
         downtimeDto.CopyToEntity(downtime);
       } else {
         downtimeDao.Save(downtimeDto.ToEntity());
       }
       pm.SubmitChanges();
     });
   }
 }
Ejemplo n.º 2
0
 public void UpdateSlaveGroup(DT.SlaveGroup slaveGroupDto) {
   RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
   var pm = PersistenceManager;
   using (new PerformanceLogger("UpdateSlaveGroup")) {
     var slaveGroupDao = pm.SlaveGroupDao;
     pm.UseTransaction(() => {
       var slaveGroup = slaveGroupDao.GetById(slaveGroupDto.Id);
       if (slaveGroup != null) {
         slaveGroupDto.CopyToEntity(slaveGroup);
       } else {
         slaveGroupDao.Save(slaveGroupDto.ToEntity());
       }
       pm.SubmitChanges();
     });
   }
 }
Ejemplo n.º 3
0
 public void UpdateJob(DT.Job jobDto) {
   RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
   AuthorizationManager.AuthorizeForJob(jobDto.Id, DT.Permission.Full);
   var pm = PersistenceManager;
   using (new PerformanceLogger("UpdateJob")) {
     bool exists = true;
     var jobDao = pm.JobDao;
     pm.UseTransaction(() => {
       var job = jobDao.GetById(jobDto.Id);
       if (job == null) {
         exists = false;
         job = new DA.Job();
       }
       jobDto.CopyToEntity(job);
       if (!exists) {
         jobDao.Save(job);
       }
       pm.SubmitChanges();
     });
   }
 }
Ejemplo n.º 4
0
 public void Hello(DT.Slave slaveInfo) {
   RoleVerifier.AuthenticateForAnyRole(HiveRoles.Slave);
   if (UserManager.CurrentUser.UserName != "hiveslave") {
     slaveInfo.OwnerUserId = UserManager.CurrentUserId;
   }
   var pm = PersistenceManager;
   using (new PerformanceLogger("Hello")) {
     var slaveDao = pm.SlaveDao;
     pm.UseTransaction(() => {
       var slave = slaveDao.GetById(slaveInfo.Id);
       if (slave == null) {
         slaveDao.Save(slaveInfo.ToEntity());
       } else {
         bool oldIsAllowedToCalculate = slave.IsAllowedToCalculate;
         Guid? oldParentResourceId = slave.ParentResourceId;
         slaveInfo.CopyToEntity(slave);
         slave.IsAllowedToCalculate = oldIsAllowedToCalculate;
         slave.ParentResourceId = oldParentResourceId;
         slave.LastHeartbeat = DateTime.Now;
         slave.SlaveState = DA.SlaveState.Idle;
       }
       pm.SubmitChanges();
     });
   }
 }
Ejemplo n.º 5
0
 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();
     });
   }
 }