public void TestCalendrierTroisTranchesAvecRecouvrement() { try { CTimosTestMetierApp.SessionClient.BeginTrans(); using (CContexteDonnee contexte = new CContexteDonnee(CTimosTestMetierApp.SessionClient.IdSession, true, false)) { // Création des tranches horaires // Première tranche de Jour de 8h à 11 h 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; // 11 heures Assert.IsTrue(t1.CommitEdit().Result); // Deuxième tranche de Repos de 12h à 14 h 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 = 11 * 60; // 8 heures t2.HeureFin = 15 * 60; // 11 heures Assert.IsTrue(t2.CommitEdit().Result); // Troisième tranche dont l'occupation est indéfinie de 15h à 19h 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_nIdOccupationAstreinte, contexte); t3.HeureDebut = 14 * 60; // 8 heures t3.HeureFin = 19 * 60; // 11 heures Assert.IsTrue(t3.CommitEdit().Result); // On demande les Horaires à l'acteur de maintenant à demain même heure (24 heures) CActeur acteur = (CActeur)GetEntite(typeof(CActeur), m_nIdActeur, contexte); CTrancheHoraire[] listeTranches = acteur.GetHoraires(DateTime.Now.Date, DateTime.Now.Date.AddDays(1)); Assert.AreEqual(3, listeTranches.Length); Assert.AreEqual(100, listeTranches[0].Priorite); Assert.AreEqual(5, listeTranches[0].Duree); Assert.AreEqual(50, listeTranches[1].Priorite); Assert.AreEqual(4, listeTranches[1].Duree); Assert.AreEqual(10, listeTranches[2].Priorite); Assert.AreEqual(2, listeTranches[2].Duree); } } finally { CTimosTestMetierApp.SessionClient.RollbackTrans(); } }
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 Init(CActeur acteur, CModeleTexte modeleUtilise) { m_acteur = acteur; //SuspendLayout(); if (modeleUtilise == null) { m_lnkNomIntervenant.Visible = true; m_lnkActeur.Visible = false; m_modele.Visible = false; m_extLinkField.FillDialogFromObjet(m_acteur); m_largeurOptimale = 500; } else { m_lnkNomIntervenant.Visible = false; m_modele.Visible = true; m_modele.Init(modeleUtilise, acteur); m_lnkActeur.Visible = true; m_largeurOptimale = modeleUtilise.Largeur + m_panOccupation.Width + 6; m_hauteurOptimale = modeleUtilise.Hauteur; } Size = new Size(m_largeurOptimale, m_hauteurOptimale); { //On récupère la tranche de travail actuelle CTrancheHoraire[] tranches = m_acteur.GetHoraires(DateTime.Now, DateTime.Now); if (tranches.Length > 0) { CTrancheHoraire tranche = tranches[0]; CTypeOccupationHoraire typeoccup = tranche.TypeOccupationHoraire; m_lblEtat.Text = typeoccup.Libelle; m_panOccupation.BackColor = Color.FromArgb(typeoccup.Couleur); m_actif = typeoccup.EstDisponible; if (m_frmConteneur != null) { m_lblEtat.Click += new EventHandler(m_lblEtat_Click); } } else { m_lblEtat.Text = I.T("Inactive|1305"); m_panOccupation.BackColor = Color.Red; m_actif = false; } } //else //{ // m_lblEtat.Text = I.T("Missing information|1306"); // m_panOccupation.BackColor = Color.Red; // m_actif = false; //} //Position du label Etat if (m_lblEtat.Width > m_largeurEtat) { m_panOccupation.Width = m_lblEtat.Width + 6; m_largeurEtat = m_panOccupation.Width; } else { //On centre m_panOccupation.Width = m_largeurEtat; int x = (m_largeurEtat - m_lblEtat.Width) / 2; m_lblEtat.Location = new Point(x, m_lblEtat.Location.Y); } }
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 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 void TestCalendrierQuatresTranchesAChevalSurDeuxJours() { try { CTimosTestMetierApp.SessionClient.BeginTrans(); using (CContexteDonnee contexte = new CContexteDonnee(CTimosTestMetierApp.SessionClient.IdSession, true, false)) { // Création des tranches horaires // Première tranche de Jour de 8h à 11 h 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; // 11 heures Assert.IsTrue(t1.CommitEdit().Result); // Deuxième tranche de Repos de 12h à 14 h 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 = 14 * 60; Assert.IsTrue(t2.CommitEdit().Result); // Troisième tranche de travail 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 = 14 * 60; t3.HeureFin = 19 * 60; Assert.IsTrue(t3.CommitEdit().Result); // Troisième tranche : astreinte 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_nIdOccupationAstreinte, contexte); t4.HeureDebut = 19 * 60; // de 19 heures t4.HeureFin = 8 * 60; // à 8 heures le lendemain Assert.IsTrue(t4.CommitEdit().Result); // On demande les Horaires à l'acteur de maintenant à demain même heure (24 heures) CActeur acteur = (CActeur)GetEntite(typeof(CActeur), m_nIdActeur, contexte); CTrancheHoraire[] listeTranches = acteur.GetHoraires(DateTime.Now.Date, DateTime.Now.Date.AddDays(1)); Assert.AreEqual(5, 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(50, listeTranches[3].Priorite); Assert.AreEqual(4, listeTranches[3].Duree); Assert.AreEqual(10, listeTranches[4].Priorite); Assert.AreEqual(2, listeTranches[4].Duree); // On demande les Horaires à l'acteur de 12H au landemain 12H // -> attendu 6 tranches, car à 12H00 pile on comptabilise la tranche qui se termine à 12H et celle qui commence à 12H00 listeTranches = acteur.GetHoraires(DateTime.Today.AddHours(12), DateTime.Today.AddDays(1).AddHours(12)); Assert.AreEqual(6, listeTranches.Length); // On demande les horaires aujourd'hui entre 13H et 16H -> attendu 2 tranches listeTranches = acteur.GetHoraires(DateTime.Today.AddHours(13), DateTime.Today.AddHours(16)); Assert.AreEqual(2, listeTranches.Length); // On demande les horaires aujourd'hui entre 13H et 23H -> attendu 3 tranches listeTranches = acteur.GetHoraires(DateTime.Today.AddHours(13), DateTime.Today.AddHours(23)); Assert.AreEqual(3, listeTranches.Length); // On demande les horaires entre aujourd'hui 13H et demain matin 01H00 -> attendu 3 tranches listeTranches = acteur.GetHoraires(DateTime.Today.AddHours(13), DateTime.Today.AddDays(1).AddHours(1)); Assert.AreEqual(3, listeTranches.Length); } } finally { CTimosTestMetierApp.SessionClient.RollbackTrans(); } }