예제 #1
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();
                });
            }
        }
예제 #2
0
 public static void ToEntity(DT.Job source, DB.Job target)
 {
     if ((source != null) && (target != null))
     {
         target.JobId = source.Id; target.Description = source.Description; target.Name = source.Name; target.OwnerUserId = source.OwnerUserId; target.DateCreated = source.DateCreated; target.ResourceIds = source.ResourceNames;
     }
 }
예제 #3
0
        public static DB.Job ToEntity(DT.Job source)
        {
            if (source == null)
            {
                return(null);
            }
            var entity = new DB.Job(); ToEntity(source, entity);

            return(entity);
        }
예제 #4
0
 public static DT.Job ToDto(DB.Job source)
 {
     if (source == null)
     {
         return(null);
     }
     return(new DT.Job {
         Id = source.JobId, Description = source.Description, Name = source.Name, OwnerUserId = source.OwnerUserId, DateCreated = source.DateCreated, ResourceNames = source.ResourceIds
     });
 }
예제 #5
0
        public static DA.Job ToEntity(this DT.Job source)
        {
            if (source == null)
            {
                return(null);
            }
            var result = new DA.Job();

            source.CopyToEntity(result);
            return(result);
        }
예제 #6
0
 public static DT.Job ToDto(this DA.Job source)
 {
     return(new DT.Job {
         Id = source.JobId,
         Description = source.Description,
         Name = source.Name,
         OwnerUserId = source.OwnerUserId,
         DateCreated = source.DateCreated,
         ProjectId = source.ProjectId,
         State = source.State.ToDto()
     });
 }
예제 #7
0
 public static void CopyToEntity(this DT.Job source, DA.Job target)
 {
     if ((source == null) || (target == null))
     {
         return;
     }
     target.JobId       = source.Id;
     target.Description = source.Description;
     target.Name        = source.Name;
     target.OwnerUserId = source.OwnerUserId;
     target.DateCreated = source.DateCreated;
     target.ResourceIds = source.ResourceNames;
 }
예제 #8
0
 public static DT.Job ToDto(Job source) {
   if (source == null) return null;
   return new DT.Job {
     Id = source.JobId,
     CoresNeeded = source.CoresNeeded,
     ExecutionTime = TimeSpan.FromMilliseconds(source.ExecutionTimeMs),
     MemoryNeeded = source.MemoryNeeded,
     ParentJobId = source.ParentJobId,
     Priority = source.Priority,
     PluginsNeededIds = (source.RequiredPlugins == null ? new List<Guid>() : source.RequiredPlugins.Select(x => x.PluginId).ToList()),
     LastHeartbeat = source.LastHeartbeat,
     State = source.State,
     StateLog = (source.StateLogs == null ? new List<DT.StateLog>() : source.StateLogs.Select(x => Convert.ToDto(x)).OrderBy(x => x.DateTime).ToList()),
     IsParentJob = source.IsParentJob,
     FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished,
     Command = source.Command,
     LastJobDataUpdate = (source.JobData == null ? DateTime.MinValue : source.JobData.LastUpdate),
     HiveExperimentId = source.HiveExperimentId,
     IsPrivileged = source.IsPrivileged
   };
 }
예제 #9
0
 public static void ToEntity(DT.Job source, Job target) {
   if ((source != null) && (target != null)) {
     target.JobId = source.Id;
     target.CoresNeeded = source.CoresNeeded;
     target.ExecutionTimeMs = source.ExecutionTime.TotalMilliseconds;
     target.MemoryNeeded = source.MemoryNeeded;
     target.ParentJobId = source.ParentJobId;
     target.Priority = source.Priority;
     target.LastHeartbeat = source.LastHeartbeat;
     target.State = source.State;
     if (target.StateLogs == null) target.StateLogs = new EntitySet<StateLog>();
     foreach (DT.StateLog sl in source.StateLog.Where(x => x.Id == Guid.Empty)) {
       target.StateLogs.Add(Convert.ToEntity(sl));
     }
     target.IsParentJob = source.IsParentJob;
     target.FinishWhenChildJobsFinished = source.FinishWhenChildJobsFinished;
     target.Command = source.Command;
     // RequiredPlugins are added by Dao
     target.HiveExperimentId = source.HiveExperimentId;
     target.IsPrivileged = source.IsPrivileged;
   }
 }
예제 #10
0
 public static DB.Job ToEntity(DT.Job source) {
   if (source == null) return null;
   var entity = new DB.Job(); ToEntity(source, entity);
   return entity;
 }
예제 #11
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();
     });
   }
 }
예제 #12
0
 public static DA.Job ToEntity(this DT.Job source) {
   if (source == null) return null;
   var result = new DA.Job();
   source.CopyToEntity(result);
   return result;
 }
 partial void DeleteJob(Job instance);
 partial void UpdateJob(Job instance);
 partial void InsertJob(Job instance);