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();
                });
            }
        }
Beispiel #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;
     }
 }
Beispiel #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);
        }
Beispiel #4
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);
        }
Beispiel #5
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;
 }
        public Guid AddJob(DT.Job jobDto)
        {
            RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
            var pm = PersistenceManager;

            using (new PerformanceLogger("AddJob")) {
                var jobDao          = pm.JobDao;
                var userPriorityDao = pm.UserPriorityDao;
                return(pm.UseTransaction(() => {
                    jobDto.OwnerUserId = UserManager.CurrentUserId;
                    jobDto.DateCreated = DateTime.Now;
                    var job = jobDao.Save(jobDto.ToEntity());
                    if (userPriorityDao.GetById(jobDto.OwnerUserId) == null)
                    {
                        userPriorityDao.Save(new DA.UserPriority {
                            UserId = jobDto.OwnerUserId,
                            DateEnqueued = jobDto.DateCreated
                        });
                    }
                    pm.SubmitChanges();
                    return job.JobId;
                }));
            }
        }