//------------------------------------------------ private TreeNode AddNodeEoHerite(CEntiteOrganisationnelle entite, Dictionary <CEntiteOrganisationnelle, TreeNode> tableEOtoNode) { if (tableEOtoNode.ContainsKey(entite)) { return(tableEOtoNode[entite]); } TreeNode nodeParent = null; if (entite.EntiteParente != null) { nodeParent = AddNodeEoHerite(entite.EntiteParente, tableEOtoNode); } TreeNode node = new TreeNode(entite.Libelle); if (nodeParent != null) { nodeParent.Nodes.Add(node); } else { m_arbreHeritage.Nodes.Add(node); } tableEOtoNode[entite] = node; return(node); }
private void m_lnkAjouter_LinkClicked(object sender, EventArgs e) { CEntiteOrganisationnelle entite = (CEntiteOrganisationnelle)CFormSelectObjetHierarchique.SelectObjet(typeof(CEntiteOrganisationnelle), null); if (entite != null) { //Vérifie qu'aucun parent n'est affecté à l'élément ArrayList lst = new ArrayList(m_wndListeEos.ListeSource); foreach (CRelationElement_EO rel in lst) { if (rel.EntiteOrganisationnelle.IsParentOf(entite)) { CFormAlerte.Afficher(I.T("The object ever belong to this entity|128") + " (" + rel.EntiteOrganisationnelle.Libelle + ")", EFormAlerteType.Exclamation); return; } if (rel.EntiteOrganisationnelle.IsChildOf(entite)) { rel.Delete(); } } CRelationElement_EO newRel = new CRelationElement_EO(m_objet.ContexteDonnee); newRel.CreateNewInCurrentContexte(); newRel.EntiteOrganisationnelle = entite; newRel.ElementLie = m_objet; m_wndListeEos.ListeSource = CRelationElement_EO.GetListeRelationsForElement(m_objet); m_wndListeEos.Refresh(); } }
//------------------------------------------------- private void m_btnSelectEntite_Click(object sender, EventArgs e) { CEntiteOrganisationnelle racine = null; if (m_relationEditee.Profil != null) { racine = m_relationEditee.Profil.EntiteOrganisationnelle; } else if (m_relationEditee.Profil_Inclusion != null) { racine = m_relationEditee.Profil_Inclusion.ProfilFils.EntiteOrganisationnelle; } if (racine != null) { CObjetHierarchique[] selection = CFormSelectObjetHierarchique.SelectObjets( typeof(CEntiteOrganisationnelle), racine, (CObjetHierarchique[])m_relationEditee.EntitesLiesExplicites.ToArray()); if (selection != null) { ArrayList lst = new ArrayList(selection); m_relationEditee.SetEntitesLiees((CEntiteOrganisationnelle[])lst.ToArray(typeof(CEntiteOrganisationnelle))); UpdateLibelleEntite(); } } }
//------------------------------------------------ private void m_arbre_AfterSelect(object sender, TreeViewEventArgs e) { if (e.Node.Checked) { CRelationElement_EO rel = (CRelationElement_EO)m_tableEOToRelation[e.Node]; if (rel == null) { CEntiteOrganisationnelle eo = (CEntiteOrganisationnelle)m_arbre.GetObjetInNode(e.Node); foreach (CRelationElement_EO relTmp in CRelationElement_EO.GetListeRelationsForElement((CObjetDonneeAIdNumerique)m_elementEdite)) { if (relTmp.EntiteOrganisationnelle.Id == eo.Id) { rel = relTmp; break; } } } if (rel != null) { ChangeElementAChamps(rel); return; } } ChangeElementAChamps(null); }
//------------------------------------------------------------------------- /// <summary> /// /// </summary> /// <param name="tableau"></param> public CResultAErreur SetDataTable(DataTable tableau) { CResultAErreur result = CResultAErreur.True; if (tableau.Rows.Count != ElementsLignes.Count) { result.EmpileErreur("Error"); return(result); } int i; for (i = 0; i < tableau.Rows.Count; i++) { DataRow row = tableau.Rows[i]; CEntiteOrganisationnelle eo = (CEntiteOrganisationnelle)ElementsLignes[i]; foreach (DataColumn col in tableau.Columns) { if (row[col] is CDataPlanning) { CDataPlanning data = (CDataPlanning)row[col]; CEOplanifiee_Acteur planif = new CEOplanifiee_Acteur(m_typeTableauPlanning.ContexteDonnee); if (planif.ReadIfExists(new CFiltreData( CEntiteOrganisationnelle.c_champId + " =@1 and " + CEOplanifiee_Acteur.c_champDate + " =@2 and " + CHoraireJournalier_Tranche.c_champId + " =@3", eo.Id, ((DateTime)col.ExtendedProperties[c_strDatePourColonne]).Date, ((CHoraireJournalier_Tranche)col.ExtendedProperties[c_strTrancheHorairePourColonne]).Id ), false)) { planif.Acteur = (CActeur)data.Element; if (planif.Acteur == null && planif.IsValide()) { result = planif.Delete(); if (!result) { return(result); } } } else { if (data.Element != null) { planif.CreateNewInCurrentContexte(); planif.Acteur = (CActeur)data.Element; planif.EntiteOrganisationnelle = eo; planif.TrancheHoraire = (CHoraireJournalier_Tranche)col.ExtendedProperties[c_strTrancheHorairePourColonne]; planif.Date = ((DateTime)col.ExtendedProperties[c_strDatePourColonne]).Date; } } } } } return(result); }
private void m_lnkEnseignes_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { using (CContexteDonnee contexte = new CContexteDonnee(CTimosApp.SessionClient.IdSession, true, false)) { CListeObjetsDonnees liste = new CListeObjetsDonnees(contexte, typeof(CEntiteOrganisationnelle)); Random rnd = new Random(); for (int nNumero = 0; nNumero < 10000; nNumero++) { int nNbEOs = rnd.Next(liste.Count - 1); //CTestSecurite test = new CTestSecurite(contexte); //test.CreateNewInCurrentContexte(); //test.Libelle = "Test n°" + nNumero; StringBuilder builder = new StringBuilder(); for (int nEO = 0; nEO < nNbEOs; nEO++) { int nNumEO = rnd.Next(liste.Count - 1); CEntiteOrganisationnelle entite = (CEntiteOrganisationnelle)liste[nNumEO]; builder.Append("~"); builder.Append(entite.CodeSystemeComplet); } //test.EOs = builder.ToString(); } contexte.SaveAll(true); } }
//------------------------------------------------------------------- public override CResultAErreur TraitementAvantSauvegarde(CContexteDonnee contexte) { CResultAErreur result = base.TraitementAvantSauvegarde(contexte); if (!result) { return(result); } DataTable table = contexte.Tables[GetNomTable()]; if (table == null) { return(result); } ArrayList lst = new ArrayList(table.Rows); foreach (DataRow row in lst) { if (row.RowState == DataRowState.Modified || row.RowState == DataRowState.Added) { CEntiteOrganisationnelle entite = new CEntiteOrganisationnelle(row); result = VerifieDonnees(entite); if (!result) { return(result); } } } return(result); }
//-------------------------------------------------------------------------------------------- private void m_lnkAjouterEO_LinkClicked(object sender, EventArgs e) { if (m_txtSelectEO.ElementSelectionne == null) { return; } CEntiteOrganisationnelle eo = (CEntiteOrganisationnelle)m_txtSelectEO.ElementSelectionne; CListeObjetsDonnees listeRelEO = m_ticketEdite.RelationsEOconcernees; listeRelEO.Filtre = new CFiltreData(CEntiteOrganisationnelle.c_champId + " = @1 ", eo.Id); if (listeRelEO.Count != 0) { CFormAlerte.Afficher(I.T("This Organizational Entity is already in the list|1111"), EFormAlerteType.Exclamation); return; } m_txtSelectEO.ElementSelectionne = null; CRelationTicket_EOconcernees newRel = new CRelationTicket_EOconcernees(m_ticketEdite.ContexteDonnee); newRel.CreateNewInCurrentContexte(); newRel.Ticket = m_ticketEdite; newRel.EntiteOrganisationnelle = eo; InitListeEOs(); }
//-------------------------------------------------------------------------------------------- private void l_lnkEditerEO_LinkClicked(object sender, EventArgs e) { if (m_listeEOs.SelectedItems.Count != 1) { return; } CRelationTicket_EOconcernees rel = (CRelationTicket_EOconcernees)m_listeEOs.SelectedItems[0].Tag; if (rel != null) { CEntiteOrganisationnelle eo = rel.EntiteOrganisationnelle; CFormEditionEntiteOrganisationnelle form = new CFormEditionEntiteOrganisationnelle(eo); CTimosApp.Navigateur.AffichePageDansNouvelOnglet(form); } }
protected override CResultAErreur MyInitChamps() { CResultAErreur result = base.MyInitChamps(); if (EntiteOrganisationnelle.IsNew() && EntiteOrganisationnelle.EntiteParente == null) { EntiteOrganisationnelle.EntiteParente = m_lastParent; } m_lastParent = EntiteOrganisationnelle.EntiteParente; m_arbreHierarchie.AfficheHierarchie(EntiteOrganisationnelle); InitComboTypeEntites(false); if (EntiteOrganisationnelle.EntiteParente == null && EntiteOrganisationnelle.EntiteFilles.Count == 0) { m_cmbTypeEntite.LockEdition = !m_gestionnaireModeEdition.ModeEdition; } else { m_cmbTypeEntite.LockEdition = true; } m_cmbTypeEntite.ElementSelectionne = EntiteOrganisationnelle.TypeEntite; if (EntiteOrganisationnelle.GetFormulaires().Length == 0) { if (m_tabControl.TabPages.Contains(m_pageFiche)) { m_tabControl.TabPages.Remove(m_pageFiche); } } else { if (!m_tabControl.TabPages.Contains(m_pageFiche)) { m_tabControl.TabPages.Insert(0, m_pageFiche); } } AffecterTitre(I.T("Organizational Entity @1|117", EntiteOrganisationnelle.Libelle)); result = InitPanelsCoordonnees(); return(result); }
public void TestUneEOPlanifieeSimple() { try { CTimosTestMetierApp.SessionClient.BeginTrans(); using (CContexteDonnee contexte = new CContexteDonnee(CTimosTestMetierApp.SessionClient.IdSession, true, false)) { // Jour CHoraireJournalier_Tranche t1 = new CHoraireJournalier_Tranche(contexte); t1.CreateNew(); t1.TypeOccupationHoraire = (CTypeOccupationHoraire)GetEntite(typeof(CTypeOccupationHoraire), m_nIdOccupationJour, contexte); t1.HeureDebut = 8 * 60; // 8 heures t1.HeureFin = 12 * 60; // 11 heures Assert.IsTrue(t1.CommitEdit()); CActeur acteur = (CActeur)GetEntite(typeof(CActeur), m_nIdActeur, contexte); CEntiteOrganisationnelle eo = (CEntiteOrganisationnelle)GetEntite(typeof(CEntiteOrganisationnelle), m_nIdEO, contexte); // Création des EO planifiées CEOplanifiee_Acteur eoPlan = new CEOplanifiee_Acteur(contexte); eoPlan.CreateNew(); eoPlan.Date = DateTime.Today; eoPlan.Acteur = acteur; eoPlan.EntiteOrganisationnelle = eo; eoPlan.TrancheHoraire = t1; Assert.IsTrue(eoPlan.CommitEdit()); // On demande les Horaires à l'acteur de maintenant à demain même heure (24 heures) CTrancheHoraire[] listeTranches = acteur.GetHoraires(DateTime.Now.Date, DateTime.Now.Date.AddDays(1)); Assert.AreEqual(1, listeTranches.Length); Assert.AreEqual(50, listeTranches[0].Priorite); Assert.AreEqual(4, listeTranches[0].Duree); } } finally { CTimosTestMetierApp.SessionClient.RollbackTrans(); } }
public void TestTroisEOsPlanifieesLeMemeJour() { try { CTimosTestMetierApp.SessionClient.BeginTrans(); using (CContexteDonnee contexte = new CContexteDonnee(CTimosTestMetierApp.SessionClient.IdSession, true, false)) { // Repos CHoraireJournalier_Tranche t2 = new CHoraireJournalier_Tranche(contexte); t2.CreateNew(); t2.TypeOccupationHoraire = (CTypeOccupationHoraire)GetEntite(typeof(CTypeOccupationHoraire), m_nIdOccupationRepos, contexte); t2.HeureDebut = 8 * 60; // 8 heures t2.HeureFin = 12 * 60; // 12 heures Assert.IsTrue(t2.CommitEdit()); // Jour CHoraireJournalier_Tranche t3 = new CHoraireJournalier_Tranche(contexte); t3.CreateNew(); t3.TypeOccupationHoraire = (CTypeOccupationHoraire)GetEntite(typeof(CTypeOccupationHoraire), m_nIdOccupationJour, contexte); t3.HeureDebut = 14 * 60; t3.HeureFin = 19 * 60; Assert.IsTrue(t3.CommitEdit()); // Astreinte CHoraireJournalier_Tranche t4 = new CHoraireJournalier_Tranche(contexte); t4.CreateNew(); t4.TypeOccupationHoraire = (CTypeOccupationHoraire)GetEntite(typeof(CTypeOccupationHoraire), m_nIdOccupationAstreinte, contexte); t4.HeureDebut = 19 * 60; // de 19 heures t4.HeureFin = 8 * 60; // à 8 heures le lendemain Assert.IsTrue(t4.CommitEdit()); CActeur acteur = (CActeur)GetEntite(typeof(CActeur), m_nIdActeur, contexte); CEntiteOrganisationnelle eo = (CEntiteOrganisationnelle)GetEntite(typeof(CEntiteOrganisationnelle), m_nIdEO, contexte); // Création des EO planifiées CEOplanifiee_Acteur eoPlan1 = new CEOplanifiee_Acteur(contexte); eoPlan1.CreateNew(); eoPlan1.Date = DateTime.Today.AddDays(-1); eoPlan1.Acteur = acteur; eoPlan1.EntiteOrganisationnelle = eo; eoPlan1.TrancheHoraire = t4; // Astreinte de la veille Assert.IsTrue(eoPlan1.CommitEdit()); // Création des EO planifiées CEOplanifiee_Acteur eoPlan2 = new CEOplanifiee_Acteur(contexte); eoPlan2.CreateNew(); eoPlan2.Date = DateTime.Today; eoPlan2.Acteur = acteur; eoPlan2.EntiteOrganisationnelle = eo; eoPlan2.TrancheHoraire = t2; Assert.IsTrue(eoPlan2.CommitEdit()); // Création des EO planifiées CEOplanifiee_Acteur eoPlan3 = new CEOplanifiee_Acteur(contexte); eoPlan3.CreateNew(); eoPlan3.Date = DateTime.Today; eoPlan3.Acteur = acteur; eoPlan3.EntiteOrganisationnelle = eo; eoPlan3.TrancheHoraire = t3; Assert.IsTrue(eoPlan3.CommitEdit()); // Création des EO planifiées CEOplanifiee_Acteur eoPlan4 = new CEOplanifiee_Acteur(contexte); eoPlan4.CreateNew(); eoPlan4.Date = DateTime.Today; eoPlan4.Acteur = acteur; eoPlan4.EntiteOrganisationnelle = eo; eoPlan4.TrancheHoraire = t4; Assert.IsTrue(eoPlan4.CommitEdit()); // On demande les Horaires à l'acteur de maintenant à demain même heure (24 heures) CTrancheHoraire[] listeTranches = acteur.GetHoraires(DateTime.Today, DateTime.Today.AddDays(1)); Assert.AreEqual(4, listeTranches.Length); Assert.AreEqual(100, listeTranches[0].Priorite); Assert.AreEqual(13, listeTranches[0].Duree); Assert.AreEqual(100, listeTranches[1].Priorite); Assert.AreEqual(13, listeTranches[1].Duree); Assert.AreEqual(50, listeTranches[2].Priorite); Assert.AreEqual(5, listeTranches[2].Duree); Assert.AreEqual(10, listeTranches[3].Priorite); Assert.AreEqual(4, listeTranches[3].Duree); } } finally { CTimosTestMetierApp.SessionClient.RollbackTrans(); } }
//------------------------------------------------------------------------- public CFormEditionEntiteOrganisationnelle(CEntiteOrganisationnelle EntiteOrganisationnelle, CListeObjetsDonnees liste) : base(EntiteOrganisationnelle, liste) { // Cet appel est requis par le Concepteur Windows Form. InitializeComponent(); }
public void TestCombineEOsPlanifieesEtCalendrier() { try { CTimosTestMetierApp.SessionClient.BeginTrans(); using (CContexteDonnee contexte = new CContexteDonnee(CTimosTestMetierApp.SessionClient.IdSession, true, false)) { //******** Calendrier ************** // Jour CHoraireJournalier_Tranche t1 = new CHoraireJournalier_Tranche(contexte); t1.CreateNew(); t1.HoraireJournalier = (CHoraireJournalier)GetEntite(typeof(CHoraireJournalier), m_nIdHoraireJournalier, contexte); t1.TypeOccupationHoraire = (CTypeOccupationHoraire)GetEntite(typeof(CTypeOccupationHoraire), m_nIdOccupationJour, contexte); t1.HeureDebut = 8 * 60; // 8 heures t1.HeureFin = 12 * 60; // 12 heures Assert.IsTrue(t1.CommitEdit()); // Repos CHoraireJournalier_Tranche t2 = new CHoraireJournalier_Tranche(contexte); t2.CreateNew(); t2.HoraireJournalier = (CHoraireJournalier)GetEntite(typeof(CHoraireJournalier), m_nIdHoraireJournalier, contexte); t2.TypeOccupationHoraire = (CTypeOccupationHoraire)GetEntite(typeof(CTypeOccupationHoraire), m_nIdOccupationRepos, contexte); t2.HeureDebut = 12 * 60; t2.HeureFin = 13 * 60; Assert.IsTrue(t2.CommitEdit()); // Jour CHoraireJournalier_Tranche t3 = new CHoraireJournalier_Tranche(contexte); t3.CreateNew(); t3.HoraireJournalier = (CHoraireJournalier)GetEntite(typeof(CHoraireJournalier), m_nIdHoraireJournalier, contexte); t3.TypeOccupationHoraire = (CTypeOccupationHoraire)GetEntite(typeof(CTypeOccupationHoraire), m_nIdOccupationJour, contexte); t3.HeureDebut = 13 * 60; t3.HeureFin = 17 * 60; Assert.IsTrue(t3.CommitEdit()); // Repos de nuit CHoraireJournalier_Tranche t4 = new CHoraireJournalier_Tranche(contexte); t4.CreateNew(); t4.HoraireJournalier = (CHoraireJournalier)GetEntite(typeof(CHoraireJournalier), m_nIdHoraireJournalier, contexte); t4.TypeOccupationHoraire = (CTypeOccupationHoraire)GetEntite(typeof(CTypeOccupationHoraire), m_nIdOccupationRepos, contexte); t4.HeureDebut = 17 * 60; t4.HeureFin = 8 * 60; Assert.IsTrue(t4.CommitEdit()); // *********** EO Planifiées ***************** // Repos CHoraireJournalier_Tranche t5 = new CHoraireJournalier_Tranche(contexte); t5.CreateNew(); t5.TypeOccupationHoraire = (CTypeOccupationHoraire)GetEntite(typeof(CTypeOccupationHoraire), m_nIdOccupationRepos, contexte); t5.HeureDebut = 6 * 60; t5.HeureFin = (int)(12.5 * 60); // 12H30 Assert.IsTrue(t5.CommitEdit()); // Astreinte CHoraireJournalier_Tranche t6 = new CHoraireJournalier_Tranche(contexte); t6.CreateNew(); t6.TypeOccupationHoraire = (CTypeOccupationHoraire)GetEntite(typeof(CTypeOccupationHoraire), m_nIdOccupationAstreinte, contexte); t6.HeureDebut = (int)(12.5 * 60); // 12h30 t6.HeureFin = (int)(20.5 * 60); // 20H30 Assert.IsTrue(t6.CommitEdit()); // Repos CHoraireJournalier_Tranche t7 = new CHoraireJournalier_Tranche(contexte); t7.CreateNew(); t7.TypeOccupationHoraire = (CTypeOccupationHoraire)GetEntite(typeof(CTypeOccupationHoraire), m_nIdOccupationRepos, contexte); t7.HeureDebut = (int)(20.5 * 60); t7.HeureFin = (int)(22.5 * 60); // 22H30 Assert.IsTrue(t7.CommitEdit()); // Astreinte CHoraireJournalier_Tranche t8 = new CHoraireJournalier_Tranche(contexte); t8.CreateNew(); t8.TypeOccupationHoraire = (CTypeOccupationHoraire)GetEntite(typeof(CTypeOccupationHoraire), m_nIdOccupationAstreinte, contexte); t8.HeureDebut = (int)(22.5 * 60); // 12h30 t8.HeureFin = 6 * 60; // 6 H le landemain Assert.IsTrue(t8.CommitEdit()); CActeur acteur = (CActeur)GetEntite(typeof(CActeur), m_nIdActeur, contexte); CEntiteOrganisationnelle eo = (CEntiteOrganisationnelle)GetEntite(typeof(CEntiteOrganisationnelle), m_nIdEO, contexte); // Création EO planifiée repos CEOplanifiee_Acteur eoPlan1 = new CEOplanifiee_Acteur(contexte); eoPlan1.CreateNew(); eoPlan1.Date = DateTime.Today; eoPlan1.Acteur = acteur; eoPlan1.EntiteOrganisationnelle = eo; eoPlan1.TrancheHoraire = t5; Assert.IsTrue(eoPlan1.CommitEdit()); // Création EO planifiée Astreinte CEOplanifiee_Acteur eoPlan2 = new CEOplanifiee_Acteur(contexte); eoPlan2.CreateNew(); eoPlan2.Date = DateTime.Today; eoPlan2.Acteur = acteur; eoPlan2.EntiteOrganisationnelle = eo; eoPlan2.TrancheHoraire = t6; Assert.IsTrue(eoPlan2.CommitEdit()); // Création EO repos CEOplanifiee_Acteur eoPlan3 = new CEOplanifiee_Acteur(contexte); eoPlan3.CreateNew(); eoPlan3.Date = DateTime.Today; eoPlan3.Acteur = acteur; eoPlan3.EntiteOrganisationnelle = eo; eoPlan3.TrancheHoraire = t7; Assert.IsTrue(eoPlan3.CommitEdit()); // Création EO astreinte CEOplanifiee_Acteur eoPlan4 = new CEOplanifiee_Acteur(contexte); eoPlan4.CreateNew(); eoPlan4.Date = DateTime.Today; eoPlan4.Acteur = acteur; eoPlan4.EntiteOrganisationnelle = eo; eoPlan4.TrancheHoraire = t8; Assert.IsTrue(eoPlan4.CommitEdit()); // On demande les Horaires à l'acteur de maintenant à demain même heure (24 heures) CTrancheHoraire[] listeTranches = acteur.GetHoraires(DateTime.Today, DateTime.Today.AddDays(1)); Assert.AreEqual(7, listeTranches.Length); Assert.AreEqual(100, listeTranches[0].Priorite); Assert.AreEqual(7.5, listeTranches[0].Duree); } } finally { CTimosTestMetierApp.SessionClient.RollbackTrans(); } }
public void SetUptTest() { CResultAErreur result = CResultAErreur.True; CTimosTestMetierApp.AssureInit(); m_contexteDonnee = new CContexteDonnee(CTimosTestMetierApp.SessionClient.IdSession, true, false); //Création de l'acteur de test CActeur acteur = new CActeur(m_contexteDonnee); if (!acteur.ReadIfExists(new CFiltreData(CActeur.c_champNom + "=@1", c_strNomActeur))) { acteur.CreateNew(); acteur.Nom = c_strNomActeur; acteur.Prenom = "Youcef"; result = acteur.CommitEdit(); Assert.IsTrue(result.Result); } m_nIdActeur = acteur.Id; // Création des Types d'occupation horraire // Repos CTypeOccupationHoraire toRepos = new CTypeOccupationHoraire(m_contexteDonnee); if (!toRepos.ReadIfExists( new CFiltreData(CTypeOccupationHoraire.c_champLibelle + "=@1", c_strRepos))) { toRepos.CreateNew(); toRepos.Libelle = c_strRepos; toRepos.Priorite = 10; result = toRepos.CommitEdit(); Assert.IsTrue(result.Result); } m_nIdOccupationRepos = toRepos.Id; // Jour CTypeOccupationHoraire toJour = new CTypeOccupationHoraire(m_contexteDonnee); if (!toJour.ReadIfExists( new CFiltreData(CTypeOccupationHoraire.c_champLibelle + "=@1", c_strJour))) { toJour.CreateNew(); toJour.Libelle = c_strJour; toJour.Priorite = 50; result = toJour.CommitEdit(); Assert.IsTrue(result.Result); } m_nIdOccupationJour = toJour.Id; // Astreinte CTypeOccupationHoraire toAstreinte = new CTypeOccupationHoraire(m_contexteDonnee); if (!toAstreinte.ReadIfExists( new CFiltreData(CTypeOccupationHoraire.c_champLibelle + "=@1", c_strAstreinte))) { toAstreinte.CreateNew(); toAstreinte.Libelle = c_strAstreinte; toAstreinte.Priorite = 100; result = toAstreinte.CommitEdit(); Assert.IsTrue(result.Result); } m_nIdOccupationAstreinte = toAstreinte.Id; // Création de l'Horaire journalier CHoraireJournalier horaire = new CHoraireJournalier(m_contexteDonnee); if (!horaire.ReadIfExists( new CFiltreData(CHoraireJournalier.c_champLibelle + "=@1", c_strLabelHoraireJournalier))) { horaire.CreateNew(); horaire.Libelle = c_strLabelHoraireJournalier; result = horaire.CommitEdit(); Assert.IsTrue(result.Result); } m_nIdHoraireJournalier = horaire.Id; // Création du Calendier CCalendrier calendrier = new CCalendrier(m_contexteDonnee); if (!calendrier.ReadIfExists( new CFiltreData(CCalendrier.c_champLibelle + "=@1", c_strLabelCalendrier))) { calendrier.CreateNew(); calendrier.Libelle = c_strLabelCalendrier; calendrier.Acteur = acteur; calendrier.HoraireParDefaut = horaire; result = calendrier.CommitEdit(); Assert.IsTrue(result.Result); } m_nIdCalendrier = calendrier.Id; // CRéation de l'EO de test CTypeEntiteOrganisationnelle tpEO = new CTypeEntiteOrganisationnelle(m_contexteDonnee); if (!tpEO.ReadIfExists( new CFiltreData(CTypeEntiteOrganisationnelle.c_champLibelle + "=@1", c_strLabelTypeEO))) { tpEO.CreateNew(); tpEO.Libelle = c_strLabelTypeEO; Assert.IsTrue(tpEO.CommitEdit()); } m_nIdTypeEO = tpEO.Id; CEntiteOrganisationnelle eo = new CEntiteOrganisationnelle(m_contexteDonnee); if (!eo.ReadIfExists( new CFiltreData(CEntiteOrganisationnelle.c_champLibelle + "=@1", c_strLabelEO))) { eo.CreateNew(); eo.Libelle = c_strLabelEO; eo.TypeEntite = tpEO; Assert.IsTrue(eo.CommitEdit()); } m_nIdEO = eo.Id; // Affecte l'EO à l'acteur de test acteur.AjouterEO(m_nIdEO); }
//------------------------------------------------------------------- public override CResultAErreur VerifieDonnees(CObjetDonnee objet) { CResultAErreur result = CResultAErreur.True; try { CEntiteOrganisationnelle entiteOrganisationnelle = (CEntiteOrganisationnelle)objet; if (entiteOrganisationnelle.Libelle == "") { result.EmpileErreur(I.T("Organisational Entity label cannot be empty|10007")); } //Vérifie l'unicité du EntiteOrganisationnelle dans son parent if (entiteOrganisationnelle.EntiteParente != null) { CListeObjetsDonnees liste = new CListeObjetsDonnees(objet.ContexteDonnee, typeof(CEntiteOrganisationnelle)); liste.Filtre = new CFiltreData(CEntiteOrganisationnelle.c_champIdParent + "=@1 and " + CEntiteOrganisationnelle.c_champLibelle + "=@2 and " + CEntiteOrganisationnelle.c_champId + "<>@3", entiteOrganisationnelle.EntiteParente.Id, entiteOrganisationnelle.Libelle, entiteOrganisationnelle.Id); if (liste.CountNoLoad > 0) { result.EmpileErreur(I.T("Organisational Entity '@1' already exists|10008", entiteOrganisationnelle.Libelle)); } } else //c'est une racine, on ne veut qu'une racine par type d'entité organisationnelle { CListeObjetsDonnees liste = new CListeObjetsDonnees(objet.ContexteDonnee, typeof(CEntiteOrganisationnelle)); liste.Filtre = new CFiltreData( CEntiteOrganisationnelle.c_champId + "<>@1 and " + CTypeEntiteOrganisationnelle.c_champId + "=@2", entiteOrganisationnelle.Id, entiteOrganisationnelle.TypeEntite.Id); if (liste.CountNoLoad > 0) { result.EmpileErreur(I.T("The Organisational Entity Type '@1' has already a root element|290", entiteOrganisationnelle.TypeEntite.Libelle)); } } //Verification de la coordonnée //result = CEntiteOrganisationnelle.VerifierCoor(EntiteOrganisationnelle); if (entiteOrganisationnelle.TypeEntite == null) { result.EmpileErreur(I.T("The Organisational Entity must be associated to a Type|101")); } else if (entiteOrganisationnelle.Niveau != entiteOrganisationnelle.TypeEntite.Niveau) { result.EmpileErreur(I.T("The type of the entity is not coherent with the related entity|102")); } else if (entiteOrganisationnelle.EntiteParente != null && entiteOrganisationnelle.EntiteParente.TypeEntite != null && entiteOrganisationnelle.EntiteParente.TypeEntite.TypeFils != entiteOrganisationnelle.TypeEntite) { result.EmpileErreur(I.T("The type of the Entity is not coherent with the related entity|102")); } string strLib = entiteOrganisationnelle.Libelle; /*if (result)//Pas besoin, car l'eo n'a pas son propre système de coordonnées, c'est son type qui peut le modifier * result = SObjetAFilsACoordonneeServeur.VerifieDonnees(entiteOrganisationnelle);*/ if (result) { result = entiteOrganisationnelle.VerifieCoordonnee(); } } catch (Exception e) { result.EmpileErreur(new CErreurException(e)); } return(result); }
//------------------------------------------------------------------------ /// <summary> /// /// </summary> /// <returns></returns> public DataTable GetDataTable() { DataTable tableau = new DataTable(); if (m_typeTableauPlanning == null) { return(new DataTable()); } CListeObjetsDonnees relTranchesHoraires = m_typeTableauPlanning.RelationsTranchesHoraires; // Ajout de la première colonne EO string nomCol1 = m_typeTableauPlanning.NomPremiereColonne; if (nomCol1 == String.Empty) { nomCol1 = DynamicClassAttribute.GetNomConvivial(typeof(CEntiteOrganisationnelle)); } DataColumn colonne0 = new DataColumn(nomCol1); colonne0.DataType = typeof(string); tableau.Columns.Add(colonne0); // Construction des colonnes / Date / tranche for (DateTime date = DateDebut; date <= DateFin; date = date.AddDays(1)) { foreach (CTypeTableauPlanning_TrancheHoraire rel in relTranchesHoraires) { if (rel.EvaluerFormuleConditionnelle(date)) { string nomColone = date.ToShortDateString() + "\n" + rel.Libelle; DataColumn colonne = new DataColumn(nomColone); colonne.ExtendedProperties.Add(c_strDatePourColonne, date); colonne.ExtendedProperties.Add(c_strTrancheHorairePourColonne, rel.TrancheHoraire); if (rel.TrancheHoraire.TypeOccupationHoraireAppliquee != null) { colonne.ExtendedProperties.Add(c_strCouleurPourColonne, Color.FromArgb(rel.TrancheHoraire.TypeOccupationHoraireAppliquee.Couleur)); } colonne.DataType = typeof(CDataPlanning); tableau.Columns.Add(colonne); } } } // Construction des lignes du DataTable int i; for (i = 0; i < ElementsLignes.Count; i++) { DataRow row = tableau.NewRow(); tableau.Rows.Add(row); object obj = ElementsLignes[i]; if (obj is CEntiteOrganisationnelle) { CEntiteOrganisationnelle eo = (CEntiteOrganisationnelle)obj; int j; for (j = 0; j < tableau.Columns.Count; j++) { if (j == 0) { // La première colonne contient les Elements de ligne (des EO) row[0] = (ElementsLignes[i]).Libelle; } else { CEOplanifiee_Acteur planif = new CEOplanifiee_Acteur(m_typeTableauPlanning.ContexteDonnee); if (planif.ReadIfExists(new CFiltreData( CEntiteOrganisationnelle.c_champId + " =@1 and " + CEOplanifiee_Acteur.c_champDate + " =@2 and " + CHoraireJournalier_Tranche.c_champId + " =@3", eo.Id, ((DateTime)(tableau.Columns[j]).ExtendedProperties[c_strDatePourColonne]).Date, ((CHoraireJournalier_Tranche)(tableau.Columns[j]).ExtendedProperties[c_strTrancheHorairePourColonne]).Id ), false)) { row[(tableau.Columns[j])] = new CDataPlanning(typeof(CActeur), planif.Acteur); } else { row[(tableau.Columns[j])] = null; } } } } } return(tableau); }