Ejemplo n.º 1
0
 public void UpdateJob(DT.Job dto)
 {
     using (var db = CreateContext()) {
         var entity = db.Jobs.FirstOrDefault(x => x.JobId == dto.Id);
         if (entity == null)
         {
             db.Jobs.InsertOnSubmit(Convert.ToEntity(dto));
         }
         else
         {
             Convert.ToEntity(dto, entity);
         }
         foreach (Guid pluginId in dto.PluginsNeededIds)
         {
             if (db.RequiredPlugins.Count(p => p.PluginId == pluginId) == 0)
             {
                 db.RequiredPlugins.InsertOnSubmit(new RequiredPlugin()
                 {
                     JobId = entity.JobId, PluginId = pluginId
                 });
             }
         }
         db.SubmitChanges();
     }
 }
Ejemplo n.º 2
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;
     }
 }
Ejemplo n.º 3
0
        public static Job ToEntity(DT.Job source)
        {
            if (source == null)
            {
                return(null);
            }
            var entity = new Job(); ToEntity(source, entity);

            return(entity);
        }
Ejemplo n.º 4
0
 public Guid AddJob(DT.Job dto)
 {
     using (var db = CreateContext()) {
         var entity = Convert.ToEntity(dto);
         db.Jobs.InsertOnSubmit(entity);
         db.SubmitChanges();
         foreach (Guid pluginId in dto.PluginsNeededIds)
         {
             db.RequiredPlugins.InsertOnSubmit(new RequiredPlugin()
             {
                 JobId = entity.JobId, PluginId = pluginId
             });
         }
         db.SubmitChanges();
         return(entity.JobId);
     }
 }