コード例 #1
0
        public void MoveUpMainTaskPriority(MainTask iMainTask)
        {
            if (iMainTask == null)
            {
                throw new Exception("La tâche est nulle");
            }

            if (iMainTask.Priority != null)
            {
                if (iMainTask.Priority < 0)
                {
                    throw new Exception("La priorité doit être positive");
                }

                if (iMainTask.Priority == 1)
                {
                    throw new Exception("La priorité est déjà maximale");
                }
            }

            using (var ts = new TransactionScope())
            {
                var theTask = DBReleaseDataService.GetMainTaskById(iMainTask.MainTaskId);

                int?         thePriority  = 1;
                T_E_MainTask previousTask = null;

                if (theTask.Priority != null)
                {
                    thePriority  = theTask.Priority - 1;
                    previousTask = DBReleaseDataService.GetSingleOrDefault <T_E_MainTask>(x => x.Priority == iMainTask.Priority - 1);
                }
                else
                {
                    previousTask = DBReleaseDataService.GetSingleOrDefault <T_E_MainTask>(x => x.Priority == 1);

                    var taskWithPriority = DBReleaseDataService.GetList <T_E_MainTask>(x => x.Priority != null && x.Priority != 1).Enum().OrderByDescending(x => x.Priority).Enum().Select(x => x.Convert()).Enum().ToList();

                    foreach (var taskPriority in taskWithPriority.Enum())
                    {
                        MoveDownMainTaskPriority(taskPriority);
                    }
                }

                theTask.Priority = thePriority;
                DBReleaseDataService.Update(theTask);

                if (previousTask != null)
                {
                    previousTask.Priority += 1;
                    DBReleaseDataService.Update(previousTask);
                }

                ts.Complete();
            }
        }
コード例 #2
0
        public void SetTaskPriority(MainTask iMainTask, int iNewPriority)
        {
            if (iMainTask == null)
            {
                throw new Exception("La tâche est nulle");
            }

            if (iMainTask.Priority < 0)
            {
                throw new Exception("La priorité doit être positive");
            }

            if (iMainTask.Priority == iNewPriority)
            {
                return;
            }

            using (var ts = new TransactionScope())
            {
                var theTask = DBReleaseDataService.GetMainTaskById(iMainTask.MainTaskId);

                List <T_E_MainTask> upPriorityTasks = null;
                if (iNewPriority < theTask.Priority)
                {
                    upPriorityTasks = DBReleaseDataService.GetList <T_E_MainTask>(null).Where(x => x.Priority >= iNewPriority).ToList();
                }
                else
                {
                    upPriorityTasks = DBReleaseDataService.GetList <T_E_MainTask>(null).Where(x => x.Priority > iNewPriority).ToList();
                }

                //enleve le package concerné si présent
                upPriorityTasks.RemoveAll(x => x.MainTaskId == theTask.MainTaskId);

                //incrémente toutes les priorités
                foreach (var item in upPriorityTasks)
                {
                    item.Priority = item.Priority + 1;
                    DBReleaseDataService.Update(item);
                }

                //the package
                theTask.Priority = iNewPriority;
                DBReleaseDataService.Update(theTask);

                //Nettoyage des trous
                FillGapTaskPriority();

                ts.Complete();
            }
        }
コード例 #3
0
        public void MoveDownMainTaskPriority(MainTask iMainTask)
        {
            if (iMainTask == null)
            {
                throw new Exception("La tâche est nulle");
            }

            if (iMainTask.Priority < 0)
            {
                throw new Exception("La priorité doit être positive");
            }

            using (var ts = new TransactionScope())
            {
                var theTask = DBReleaseDataService.GetMainTaskById(iMainTask.MainTaskId);

                T_E_MainTask followingTask = null;
                int?         thePriority;

                if (theTask.Priority != null)
                {
                    thePriority   = theTask.Priority + 1;
                    followingTask = DBReleaseDataService.GetSingleOrDefault <T_E_MainTask>(x => x.Priority == iMainTask.Priority + 1);
                }
                else
                {
                    var lastPriority = DBReleaseDataService.GetQuery <T_E_MainTask>(null).Max(x => x.Priority);
                    if (lastPriority == null)
                    {
                        thePriority = 1;
                    }
                    else
                    {
                        thePriority = lastPriority + 1;
                    }
                }

                theTask.Priority = thePriority;
                DBReleaseDataService.Update(theTask);

                if (followingTask != null)
                {
                    followingTask.Priority -= 1;
                    DBReleaseDataService.Update(followingTask);
                }

                ts.Complete();
            }
        }
コード例 #4
0
        public MainTask GetMainTaskById(long iMainTaskId, GranularityEnum iGranularity)
        {
            if (iMainTaskId < 1)
            {
                throw new Exception("L'id de la tâche est invalide");
            }

            //MainTask
            var entity      = DBReleaseDataService.GetMainTaskById(iMainTaskId);
            var theMainTask = entity.Convert();

            if (theMainTask == null)
            {
                return(null);
            }

            if (iGranularity == GranularityEnum.Full)
            {
                //SubTask
                theMainTask.SubTasks = GetSubTaskByMainTaskId(iMainTaskId);

                //Package
                if (theMainTask.PackageId != null)
                {
                    theMainTask.Package = GetPackageById((long)theMainTask.PackageId, GranularityEnum.Full);
                }

                //ProductLine
                theMainTask.ProductLines = GetProductLineByMainTaskId(theMainTask.MainTaskId);

                //ExternalProject
                if (theMainTask.ExternalProjectId != null)
                {
                    theMainTask.ExternalProject = GetExternalProject((long)theMainTask.ExternalProjectId);
                }
            }

            return(theMainTask);
        }