//---------------------------------------------------------------------------- /// <summary> /// /// </summary> /// <param name="nIdEO"></param> /// <returns></returns> public static CResultAErreur AjouterEO(IElementAEO element, int nIdEO) { CResultAErreur result = CResultAErreur.True; CListeObjetsDonnees listeEOExistantes = CRelationElement_EO.GetListeRelationsForElement((CObjetDonneeAIdNumerique)element); listeEOExistantes.Filtre = new CFiltreData(CEntiteOrganisationnelle.c_champId + " = @1", nIdEO); if (listeEOExistantes.Count > 0) { result.EmpileErreur(I.T("This Organisationnal Entity is already assigned to the element: @1|565", element.DescriptionElement)); return(result); } // Affecte l'EO à l'élement CEntiteOrganisationnelle entite = new CEntiteOrganisationnelle(element.ContexteDonnee); if (entite.ReadIfExists(nIdEO)) { CRelationElement_EO relation = new CRelationElement_EO(element.ContexteDonnee); relation.CreateNewInCurrentContexte(); relation.EntiteOrganisationnelle = entite; relation.ElementLie = (CObjetDonneeAIdNumerique)element; } return(result); }
//-*------------------------------------------------------- public void TiagSetOEKeys(object[] keys) { CEntiteOrganisationnelle entite = new CEntiteOrganisationnelle(ContexteDonnee); if (entite.ReadIfExists(keys)) { EntiteOrganisationnelle = entite; } }
//------------------------------------------------------------------- /// <summary> /// Utilisé par TIAG pour affecter le l'entité parente par ses clés /// </summary> /// <param name="lstCles"></param> public void TiagSetParentEntityKeys(object[] lstCles) { CEntiteOrganisationnelle entite = new CEntiteOrganisationnelle(ContexteDonnee); if (entite.ReadIfExists(lstCles)) { EntiteParente = entite; } }
//---------------------------------------------------------------- public static void CopyAndReplaceEOS(IElementAEO eltAModifier, IElementAEO eltSource, string strCodeRacine) { string[] strCodesAModifier = eltAModifier.CodesEntitesOrganisationnelles.Split('~'); string[] strCodesAAffecter = eltSource.CodesEntitesOrganisationnelles.Split('~'); HashSet <string> setCodesAModifier = new HashSet <string>(); HashSet <string> setcodesAAffecter = new HashSet <string>(); foreach (string strCode in strCodesAAffecter) { if (strCode.StartsWith(strCodeRacine)) { setcodesAAffecter.Add(strCode); } } foreach (string strCode in strCodesAModifier) { if (strCode.StartsWith(strCodeRacine) && strCode.Length > 0) { if (!setcodesAAffecter.Contains(strCodeRacine)) { CEntiteOrganisationnelle ett = new CEntiteOrganisationnelle(eltAModifier.ContexteDonnee); if (ett.ReadIfExists(new CFiltreData(CEntiteOrganisationnelle.c_champCodeSystemeComplet + "=@1", strCode))) { eltAModifier.SupprimerEO(ett.Id); } } else { setCodesAModifier.Add(strCode); } } } foreach (string strCode in strCodesAAffecter) { if (strCode.StartsWith(strCodeRacine) && !setCodesAModifier.Contains(strCode) && strCode.Length > 0) { CEntiteOrganisationnelle ett = new CEntiteOrganisationnelle(eltAModifier.ContexteDonnee); if (ett.ReadIfExists(new CFiltreData(CEntiteOrganisationnelle.c_champCodeSystemeComplet + "=@1", strCode))) { eltAModifier.AjouterEO(ett.Id); } } } }