Ejemplo n.º 1
0
 ///<summary></summary>
 public static long Insert(JobActiveLink jobActiveLink)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         jobActiveLink.JobActiveLinkNum = Meth.GetLong(MethodBase.GetCurrentMethod(), jobActiveLink);
         return(jobActiveLink.JobActiveLinkNum);
     }
     return(Crud.JobActiveLinkCrud.Insert(jobActiveLink));
 }
Ejemplo n.º 2
0
 ///<summary></summary>
 public static void Update(JobActiveLink jobActiveLink)
 {
     if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
     {
         Meth.GetVoid(MethodBase.GetCurrentMethod(), jobActiveLink);
         return;
     }
     Crud.JobActiveLinkCrud.Update(jobActiveLink);
 }
Ejemplo n.º 3
0
        ///<summary>Returns the jobs new list of JobActiveLinks</summary>
        public static List <JobActiveLink> UpsertLink(Job job, Job jobOld, long userNum, bool isActive)
        {
            //No need for remoting call here.
            List <JobActiveLink> listJobActiveLinks = job.ListJobActiveLinks;

            if (!jobOld.PhaseCur.In(JobPhase.Cancelled, JobPhase.Complete, JobPhase.Documentation) &&
                job.PhaseCur.In(JobPhase.Cancelled, JobPhase.Complete, JobPhase.Documentation))
            {
                EndForJobNum(job.JobNum);
                return(new List <JobActiveLink>());
            }
            JobActiveLink activeLink = listJobActiveLinks.FirstOrDefault(x => x.JobNum == job.JobNum && x.UserNum == userNum && x.DateTimeEnd == DateTime.MinValue);

            if (activeLink == null)
            {
                if (!isActive)
                {
                    return(listJobActiveLinks);
                }
                activeLink         = new JobActiveLink();
                activeLink.JobNum  = job.JobNum;
                activeLink.UserNum = userNum;
                Insert(activeLink);
            }
            else
            {
                if (isActive)
                {
                    return(listJobActiveLinks);
                }
                activeLink.DateTimeEnd = DateTime.Now;
                Update(activeLink);
            }
            //Only occurs if an actual db change happened for a single user
            //Mass delete does not make a log entry
            JobLogs.MakeLogEntryForActive(job, userNum, isActive);
            listJobActiveLinks.Add(activeLink);
            return(listJobActiveLinks);
        }