public static void Merge(this T_E_Package iEntity, Package iObj) { iEntity.PackageId = iObj.PackageId; iEntity.ReleaseNumber = iObj.ReleaseNumber; iEntity.IsLocked = iObj.IsLocked; iEntity.StatusRef = (short)iObj.Status; iEntity.Priority = iObj.Priority; iEntity.DeployementObjectifDate = iObj.DeployementDateObjectif; }
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 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 long AddPackage() { var newPackage = new Package(); newPackage.PackageId = -1; newPackage.ReleaseNumber = null; newPackage.IsLocked = false; newPackage.Status = PackageStatusEnum.Waiting; newPackage.Priority = null; newPackage.DeployementDateObjectif = null; var newEntity = new T_E_Package(); newEntity.Merge(newPackage); return(DBReleaseDataService.AddPackage(newEntity)); }
public static Package Convert(this T_E_Package iEntity) { if (iEntity == null) { return(null); } return(new Package { PackageId = iEntity.PackageId, ReleaseNumber = iEntity.ReleaseNumber, Status = (PackageStatusEnum)iEntity.StatusRef, IsLocked = iEntity.IsLocked, Priority = iEntity.Priority, DeployementDateObjectif = iEntity.DeployementObjectifDate, }); }
public void UpdatePackage(Package iPackage) { if (iPackage == null) { throw new Exception("Le package est null"); } var originalPackage = GetPackageById(iPackage.PackageId, GranularityEnum.Nude); if (originalPackage == null) { throw new Exception("Le package est null"); } if (iPackage.Status != originalPackage.Status) { throw new Exception("La fonction n'est pas supportée pour le changement de statut"); } var entity = new T_E_Package(); entity.Merge(iPackage); DBReleaseDataService.UpdatePackage(entity); }
private void UpdatePackageStatus(Package iPackage, PackageStatusEnum iNewPackageStatus) { if (iPackage == null) { throw new Exception("Le package est null"); } var originalPackage = GetPackageById(iPackage.PackageId, GranularityEnum.Nude); if (originalPackage == null) { throw new Exception("Le package est null"); } if (iPackage.Status != originalPackage.Status) { throw new Exception("Le status en base de données est différent, veuillez recharger les packages"); } //Vérification workflow if (iPackage.Status == PackageStatusEnum.Waiting && iNewPackageStatus != PackageStatusEnum.Developpement && iNewPackageStatus != PackageStatusEnum.Canceled) { throw new Exception("Ce changement de statut n'est pas permis"); } else if (iPackage.Status == PackageStatusEnum.Developpement && iNewPackageStatus != PackageStatusEnum.Staging && iNewPackageStatus != PackageStatusEnum.Waiting && iNewPackageStatus != PackageStatusEnum.Canceled) { throw new Exception("Ce changement de statut n'est pas permis"); } else if (iPackage.Status == PackageStatusEnum.Staging && iNewPackageStatus != PackageStatusEnum.Production && iNewPackageStatus != PackageStatusEnum.Developpement && iNewPackageStatus != PackageStatusEnum.Canceled) { throw new Exception("Ce changement de statut n'est pas permis"); } //Condition de changement bool isLocked = false; int? priority = null; if (iNewPackageStatus == PackageStatusEnum.Waiting) { isLocked = originalPackage.IsLocked; priority = originalPackage.Priority; } else if (iNewPackageStatus == PackageStatusEnum.Developpement) { isLocked = true; priority = originalPackage.Priority; } else if (iNewPackageStatus == PackageStatusEnum.Staging) { isLocked = true; priority = originalPackage.Priority; } else if (iNewPackageStatus == PackageStatusEnum.Production) { isLocked = true; priority = null; } else { throw new NotSupportedException(iPackage.Status.ToStringWithEnumName()); } //Modification du status var entity = new T_E_Package(); originalPackage.Status = iNewPackageStatus; originalPackage.IsLocked = isLocked; originalPackage.Priority = priority; entity.Merge(originalPackage); DBReleaseDataService.UpdatePackage(entity); }