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();
            }
        }
Beispiel #2
0
        public void MoveUpPackagePriority(Package iPackage)
        {
            if (iPackage == null)
            {
                throw new Exception("La tâche est nulle");
            }

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

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

            using (var ts = new TransactionScope())
            {
                var thePackage = DBReleaseDataService.GetPackageById(iPackage.PackageId);

                int?        thePriority     = 1;
                T_E_Package previousPackage = null;

                if (thePackage.Priority != null)
                {
                    //package
                    thePriority = thePackage.Priority - 1;


                    //package précédent
                    previousPackage = DBReleaseDataService.GetSingleOrDefault <T_E_Package>(x => x.Priority == iPackage.Priority - 1);
                    previousPackage.Priority++;
                    DBReleaseDataService.Update(previousPackage);
                }
                else
                {
                    previousPackage = DBReleaseDataService.GetSingleOrDefault <T_E_Package>(x => x.Priority == 1);

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

                    foreach (var packagePriority in packageWithPriority.Enum())
                    {
                        MoveDownPackagePriority(packagePriority);
                    }
                }

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

                ts.Complete();
            }
        }
        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();
            }
        }
Beispiel #4
0
        public void SetPackagePriority(Package iPackage, int iNewPriority)
        {
            if (iPackage == null)
            {
                throw new Exception("Le package est nulle");
            }

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

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

            using (var ts = new TransactionScope())
            {
                var thePackage = DBReleaseDataService.GetPackageById(iPackage.PackageId);

                List <T_E_Package> upPriorityPackages = null;
                if (iNewPriority < thePackage.Priority)
                {
                    upPriorityPackages = DBReleaseDataService.GetList <T_E_Package>(null).Where(x => x.Priority >= iNewPriority).ToList();
                }
                else
                {
                    upPriorityPackages = DBReleaseDataService.GetList <T_E_Package>(null).Where(x => x.Priority > iNewPriority).ToList();
                }

                //enleve le package concerné si présent
                upPriorityPackages.RemoveAll(x => x.PackageId == thePackage.PackageId);

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

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

                //Nettoyage des trous
                FillGapPackagePriority();

                ts.Complete();
            }
        }
        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();
            }
        }
Beispiel #6
0
        public void MoveDownPackagePriority(Package iPackage)
        {
            if (iPackage == null)
            {
                throw new Exception("La tâche est nulle");
            }

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

            using (var ts = new TransactionScope())
            {
                var thePackage = DBReleaseDataService.GetPackageById(iPackage.PackageId);

                T_E_Package followingPackage = null;
                int?        thePriority;

                if (thePackage.Priority != null)
                {
                    thePriority      = thePackage.Priority + 1;
                    followingPackage = DBReleaseDataService.GetSingleOrDefault <T_E_Package>(x => x.Priority == iPackage.Priority + 1);
                }
                else
                {
                    var lastPriority = DBReleaseDataService.GetQuery <T_E_Package>(null).Max(x => x.Priority);
                    if (lastPriority == null)
                    {
                        thePriority = 1;
                    }
                    else
                    {
                        thePriority = lastPriority + 1;
                    }
                }

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

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

                ts.Complete();
            }
        }
        public void FillGapTaskPriority()
        {
            var taskList = DBReleaseDataService.GetQuery <T_E_MainTask>(null).Where(x => x.Priority != null).ToList().Enum().OrderBy(x => x.Priority).Enum().ToList();

            var priorityCounter = 1;

            using (var ts = new TransactionScope())
            {
                //boucle sur chaque tâche pour attribuer la bonne priorité
                foreach (var item in taskList.Enum())
                {
                    if (item.Priority != priorityCounter)
                    {
                        item.Priority = priorityCounter;
                        DBReleaseDataService.Update(item);
                    }

                    priorityCounter++;
                }
                ts.Complete();
            }
        }