Exemplo n.º 1
0
        private void InitProfilPreFiltreEquipementRemplacant()
        {
            m_bIsInitProfils = true;
            CFiltreData filtre = new CFiltreData(
                CProfilElement.c_champTypeSource + " =@1 and " +
                CProfilElement.c_champTypeElements + " =@2",
                typeof(CIntervention).ToString(),
                typeof(CEquipement).ToString());

            m_cmbSelectProfil.Init(
                typeof(CProfilElement),
                filtre,
                "Libelle",
                false);
            int nId = new CTimosAppRegistre().LastIdProfilEchangeEquipement;

            m_bIsInitProfils = false;
            if (nId >= 0)
            {
                CProfilElement profil = new CProfilElement(m_operation.ContexteDonnee);
                if (profil.ReadIfExists(nId))
                {
                    m_cmbSelectProfil.ElementSelectionne = profil;
                }
            }
        }
Exemplo n.º 2
0
 //------------------------------------------------------------
 public bool UtiliseLeProfil(CProfilElement profil)
 {
     if (ModeInclusion == EModeInclusionProfilElement.Profil)
     {
         if (ProfilInclu != null)
         {
             if (profil.Equals(ProfilInclu))
             {
                 return(true);
             }
             if (ProfilInclu.UtiliseLeProfil(profil))
             {
                 return(true);
             }
         }
     }
     else
     {
         foreach (CProfilElement_ProfilInclu inclusion in InclusionsFilles)
         {
             if (inclusion.UtiliseLeProfil(profil))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Exemplo n.º 3
0
        //-------------------------------------------------------------------------------
        public bool CanBeUseFor(IProfilElement profil, IEntreePlanning entree)
        {
            CProfilElement[] profils = profil.TousLesProfilsARemplir;
            if (profils.Length == 0)
            {
                return(true);
            }
            if (profils[0].TypeElements != typeof(CRessourceMaterielle))
            {
                return(false);
            }
            CContrainte contrainte = null;

            if (profil is CContrainte && entree is CIntervention)
            {
                contrainte = (CContrainte)profil;
                profil     = ((CIntervention)entree).TypeIntervention.ProfilRessourceDefaut;
            }

            CListeObjetsDonnees liste = CProfilElement.GetElementsForSource(profil, (IObjetDonneeAIdNumerique)entree, contrainte, null);

            if (liste != null)
            {
                foreach (CObjetDonneeAIdNumerique objet in liste)
                {
                    if (objet.Id == Id)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
        //Ajout
        private void m_lnkAjouterProfil_LinkClicked(object sender, EventArgs e)
        {
            if (m_cmbProfils.ElementSelectionne == null)
            {
                CFormAlerte.Afficher(I.T("Select the supplier to add|203"));
                return;
            }

            CProfilElement profselec = (CProfilElement)m_cmbProfils.ElementSelectionne;

            //Test d'unicité
            foreach (ListViewItem itm in m_lvProfils.Items)
            {
                if (itm.SubItems[1].Text == profselec.Libelle)
                {
                    m_lvProfils.SelectedItems.Clear();
                    itm.Selected = true;
                    return;
                }
            }

            CActeursSelonProfil rel = new CActeursSelonProfil(m_typeelem.ContexteDonnee);

            rel.CreateNewInCurrentContexte();
            rel.Profil = profselec;
            if (m_typeelem is CTypePhase)
            {
                rel.TypePhase        = (CTypePhase)m_typeelem;
                rel.TypeIntervention = null;
            }
            else if (m_typeelem is CTypeIntervention)
            {
                rel.TypePhase        = null;
                rel.TypeIntervention = (CTypeIntervention)m_typeelem;
            }

            rel.Ordre = m_lvProfils.Items.Count;


            ListViewItem item = new ListViewItem();

            m_lvProfils.Items.Add(item);
            m_lvProfils.UpdateItemWithObject(item, rel);
            foreach (ListViewItem itemSel in m_lvProfils.SelectedItems)
            {
                itemSel.Selected = false;
            }
            item.Selected = true;
        }
Exemplo n.º 5
0
 //-------------------------------------------------------------------------
 private void m_cmbSelectProfil_SelectedValueChanged(object sender, EventArgs e)
 {
     if (!m_bIsInitProfils)
     {
         CProfilElement profil = (CProfilElement)m_cmbSelectProfil.ElementSelectionne;
         if (profil != null)
         {
             new CTimosAppRegistre().LastIdProfilEchangeEquipement = profil.Id;
         }
         else
         {
             new CTimosAppRegistre().LastIdProfilEchangeEquipement = -1;
         }
         InitSelectEquipementRemplacant();
     }
 }
Exemplo n.º 6
0
        //-------------------------------------------------------------------
        public override CResultAErreur VerifieDonnees(CObjetDonnee objet)
        {
            CResultAErreur result = CResultAErreur.True;

            try
            {
                CActeursSelonProfil ActeursSelonProf = (CActeursSelonProfil)objet;

                CProfilElement prof = ActeursSelonProf.Profil;

                if (prof == null)
                {
                    result.EmpileErreur(I.T("The profile cannot be empty|263"));
                }

                if (prof.TypeElements != typeof(CActeur))
                {
                    result.EmpileErreur(I.T("The profile must return Members|264"));
                }

                if (ActeursSelonProf.TypeIntervention != null)
                {
                    if (prof.TypeSource != typeof(CIntervention))
                    {
                        result.EmpileErreur(I.T("Profile Source Elements must be Interventions|265"));
                    }
                    else if (ActeursSelonProf.TypePhase != null)
                    {
                        if (prof.TypeSource != typeof(CPhaseTicket))
                        {
                            result.EmpileErreur(I.T("Profile Source Elements must be Ticket Phases|266"));
                        }
                        else
                        {
                            result.EmpileErreur(I.T("Profie objetc Type must be defined|267"));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
            }
            return(result);
        }
Exemplo n.º 7
0
        //----------------------------------------------------------------
        /// <summary>
        /// Retourne la liste des Sites du Contrat, qu'ils soient définis par Profil ou par une liste de relations "manuelle"
        /// </summary>
        /// <returns></returns>
        public IList <CSite> GetTousLesSitesDuContrat()
        {
            IList <CSite> listeSites = new List <CSite>();
            StringBuilder bl         = new StringBuilder();

            if (this.TypeContrat != null && this.TypeContrat.GestionSitesManuel)
            {
                // Ajout des Sites par relation
                RelationsSites.ReadDependances("Site");
                foreach (CContrat_Site rel in RelationsSites)
                {
                    listeSites.Add(rel.Site);
                    bl.Append(rel.Site.Id);
                    bl.Append(",");
                }
                if (bl.Length > 0)
                {
                    bl.Remove(bl.Length - 1, 1);
                }
                CFiltreData filtre;
                if (bl.Length > 0)
                {
                    filtre = new CFiltreData(CSite.c_champId + " in (" + bl.ToString() + ")");
                    CListeObjetDonneeGenerique <CSite> lst = new CListeObjetDonneeGenerique <CSite>(ContexteDonnee, filtre);
                    return(lst);
                }
                else
                {
                    return(new List <CSite>());
                }
            }
            else
            {
                CProfilElement profil = ProfilSite;
                if (profil != null)
                {
                    CListeObjetsDonnees liste = profil.GetElementListForSource(this);
                    foreach (CSite site in liste)
                    {
                        listeSites.Add(site);
                    }
                }
                return(listeSites);
            }
        }
        private void m_lnkProfilIntervenant_LinkClicked(object sender, EventArgs e)
        {
            CProfilElement prof = m_acteursSelonProf.Profil;
            //Type t = CFormFinder.GetTypeFormToEdit(typeof(CProfilElement));
            //if (typeof(IFormNavigable).IsAssignableFrom(t))
            //{
            //    IFormNavigable iformnav = (IFormNavigable)Activator.CreateInstance(t, new object[] { prof });
            //    CTimosApp.Navigateur.AffichePage(iformnav);
            //}
            CReferenceTypeForm refTypeForm = CFormFinder.GetRefFormToEdit(typeof(CProfilElement));

            if (refTypeForm != null)
            {
                IFormNavigable iformnav = refTypeForm.GetForm(prof) as IFormNavigable;
                if (iformnav != null)
                {
                    CTimosApp.Navigateur.AffichePage(iformnav);
                }
            }
        }
Exemplo n.º 9
0
        //------------------------------------------------------------------
        private void FillArbre()
        {
            CProfilElement profil = (CProfilElement)m_cmbProfilRessource.ElementSelectionne;
            IList          ressources;

            if (m_intervention != null)
            {
                if (profil != null)
                {
                    ressources = profil.GetElementsForSource(m_intervention, m_contrainte, null);
                }
                else
                {
                    return;
                }
            }
            else
            {
                ressources = m_contrainte.GetToutesLesRessourcesLevant(null);
            }

            m_arbre.Nodes.Clear();
            m_tableEmplacements.Clear();
            foreach (CRessourceMaterielle ressource in ressources)
            {
                TreeNode nodeEmplacement = GetNode(ressource.Emplacement);
                if (nodeEmplacement != null)
                {
                    TreeNode nodeRessource = new TreeNode(ressource.Libelle);
                    nodeRessource.Tag                = ressource;
                    nodeRessource.ImageIndex         = 2;
                    nodeRessource.SelectedImageIndex = 2;
                    nodeEmplacement.Nodes.Add(nodeRessource);
                }
            }
        }
Exemplo n.º 10
0
        //-------------------------------------------------------------------
        public override CResultAErreur VerifieDonnees(CObjetDonnee objet)
        {
            CResultAErreur result = CResultAErreur.True;

            try
            {
                CProfilElement profilElement = (CProfilElement)objet;

                // Verifie le champ "Libelle"
                if (profilElement.Libelle == "")
                {
                    result.EmpileErreur(I.T("The Profile label cannot be empty|214"));
                }

                if (profilElement.UtiliseLeProfil(profilElement))
                {
                    result.EmpileErreur(I.T("Cyclic reference of profiles : impossible to validate Profile|215"));
                }
                if (profilElement.FormuleApplication == null ||
                    profilElement.FormuleApplication.TypeDonnee.TypeDotNetNatif != typeof(bool))
                {
                    result.EmpileErreur(I.T("The application condition must return a boolean|216"));
                }
                if (profilElement.FormuleIntegration == null ||
                    profilElement.FormuleIntegration.TypeDonnee.TypeDotNetNatif != typeof(bool))
                {
                    result.EmpileErreur(I.T("The integration condition must return a boolean|217"));
                }

                if (profilElement.ToutesLesCorrespondancesEO.Count != 0 &&
                    profilElement.TypeElements != null &&
                    profilElement.TypeSource != null)
                {
                    CDefinitionProprieteDynamique propEO = profilElement.ProprieteCheminToEOElement;
                    if (propEO == null)
                    {
                        if (!typeof(IElementAEO).IsAssignableFrom(profilElement.TypeElements))
                        {
                            result.EmpileErreur(I.T("The Organisational entities on elements of type @1 cannot be tested|218", DynamicClassAttribute.GetNomConvivial(profilElement.TypeElements)));
                        }
                    }
                    else
                    {
                        if (!typeof(IElementAEO).IsAssignableFrom(propEO.TypeDonnee.TypeDotNetNatif))
                        {
                            result.EmpileErreur(I.T("The Organisational entities on elements of type @1 cannot be tested|218", DynamicClassAttribute.GetNomConvivial(propEO.TypeDonnee.TypeDotNetNatif)));
                        }
                    }


                    C2iExpression formuleEltAEo = profilElement.FormuleElementAEOSource;
                    if (formuleEltAEo != null)
                    {
                        if (!typeof(IElementAEO).IsAssignableFrom(formuleEltAEo.TypeDonnee.TypeDotNetNatif))
                        {
                            result.EmpileErreur(I.T("The formula for the Source Element with Organisational Enity must return an element with an Organisational Entity|219"));
                        }
                    }
                    else
                    {
                        if (!typeof(IElementAEO).IsAssignableFrom(profilElement.TypeSource))
                        {
                            result.EmpileErreur(I.T("The elements @1 are not related to Organisational Entities, the Organisational Entities cannot be used on these elements|220", DynamicClassAttribute.GetNomConvivial(profilElement.TypeSource)));
                        }
                    }
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
            }

            return(result);
        }
Exemplo n.º 11
0
        //-------------------------------------------------------------------------
        private void InitSelectEquipementRemplacant()
        {
            CFiltreData filtre = null;

            CTypeEquipement[] listeRemplacants = new CTypeEquipement[0];

            CTypeEquipement tpEqpt = null;

            if (m_operation.RemplacementAssocie != null)
            {
                tpEqpt = m_operation.RemplacementAssocie.TypeEquipementRemplace;
            }
            if (tpEqpt == null)
            {
                tpEqpt = (CTypeEquipement)m_selectTypeEquipementRemplace.ElementSelectionne;
            }

            if (tpEqpt != null)
            {
                listeRemplacants = tpEqpt.TousLesTypesRemplacants;
            }
            else
            {
                CEquipement equip = null;
                if (m_operation.RemplacementAssocie != null)
                {
                    equip = m_operation.RemplacementAssocie.EquipementRemplace;
                }
                if (equip == null)
                {
                    equip = (CEquipement)m_selectEquipementRemplace.ElementSelectionne;
                }

                if (equip != null)
                {
                    tpEqpt           = equip.TypeEquipement;
                    listeRemplacants = equip.TypeEquipement.TousLesTypesRemplacants;
                    filtre           = CFiltreData.GetAndFiltre(filtre,
                                                                new CFiltreData(CEquipement.c_champId + " <> @1", equip.Id));
                }
            }

            if (listeRemplacants.Length > 0)
            {
                string strIdTypeEqpt = "";

                for (int i = 0; i < listeRemplacants.Length; i++)
                {
                    strIdTypeEqpt += listeRemplacants[i].Id + ",";
                }
                if (strIdTypeEqpt.Length > 0)
                {
                    strIdTypeEqpt = strIdTypeEqpt.Substring(0, strIdTypeEqpt.Length - 1);
                    filtre        = CFiltreData.GetAndFiltre(filtre,
                                                             new CFiltreData(CTypeEquipement.c_champId + " in (" + strIdTypeEqpt + ")"));
                }
            }

            // Utilisation du profil pour pré-filtrer les équipements
            CProfilElement profil = (CProfilElement)m_cmbSelectProfil.ElementSelectionne;

            if (profil != null)
            {
                string         strIdEqptInProfile = "";
                CFiltreData    filtreTmp          = null;
                CResultAErreur result             = profil.GetIdsElementsForSource(m_operation.FractionIntervention.Intervention, null, ref filtreTmp);

                if (result && result.Data is int[])
                {
                    int[] listIdEquip = (int[])result.Data;
                    for (int i = 0; i < listIdEquip.Length; i++)
                    {
                        strIdEqptInProfile += listIdEquip[i] + ",";
                    }
                    if (strIdEqptInProfile.Length > 0)
                    {
                        strIdEqptInProfile = strIdEqptInProfile.Substring(0, strIdEqptInProfile.Length - 1);
                        filtre             = CFiltreData.GetAndFiltre(
                            filtre,
                            new CFiltreData(CEquipement.c_champId + " in (" + strIdEqptInProfile + ")"));
                    }
                }
            }

            if (m_selectEquipementRemplace.ElementSelectionne != null && m_selectEquipementRemplace.ElementSelectionne is CEquipement)
            {
                filtre = CFiltreData.GetAndFiltre(filtre, new CFiltreData(CEquipement.c_champId + " <> @1", ((CEquipement)m_selectEquipementRemplace.ElementSelectionne).Id));
            }

            m_selectEquipementRemplacant.InitAvecFiltreDeBase <CEquipement>("Libelle", filtre, true);
        }