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 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); }