예제 #1
0
        /// //////////////////////////////////////////////////////////////////
        protected static CResultAErreur ExecuteActionFormulaireCustom(CActionSur2iLinkAfficheFormulaireCustom action, object objetCible)
        {
            CResultAErreur result     = CResultAErreur.True;
            CFormulaire    formulaire = new CFormulaire(CSc2iWin32DataClient.ContexteCourant);

            if (formulaire.ReadIfExists(action.IdFormulaireInDb))
            {
                if (formulaire.Role != null)
                {
                    bool bObjetOk = false;
                    if (objetCible != null)
                    {
                        CRoleChampCustom role = CRoleChampCustom.GetRoleForType(objetCible.GetType());
                        if (role != null && formulaire.HasRole(role.CodeRole))
                        {
                            bObjetOk = true;
                        }
                    }
                    if (!bObjetOk)
                    {
                        result.EmpileErreur(I.T("The object does not correspond to the expected type of the form|30091"));
                        return(result);
                    }
                }
                CTimosApp.Navigateur.AffichePage(new CFormFormulaireCustom(formulaire, objetCible));
            }
            else
            {
                result.EmpileErreur(I.T("Form|30092") + action.IdFormulaireInDb + (I.T(" does not exist |30093")));
            }
            return(result);
        }
예제 #2
0
        //----------------------------------------------------------------------------
        /// <summary>
        /// Utilisée pour la recherche de références externes liées à cette Action
        /// </summary>
        /// <param name="contexteGetRef"></param>
        /// <returns></returns>
        public object[] GetReferencesExternesExplicites(CContexteGetReferenceExterne contexteGetRef)
        {
            if (contexteGetRef != null)
            {
                CContexteDonnee contexte = (CContexteDonnee)contexteGetRef.GetObjetAttache(typeof(CContexteDonnee));
                if (contexte != null)
                {
                    if (ExpressionEntiteDestination != null)
                    {
                        Type typeDestination = ExpressionEntiteDestination.TypeDonnee.TypeDotNetNatif;
                        if ((typeof(IElementAChamps)).IsAssignableFrom(typeDestination))
                        {
                            CRoleChampCustom role = CRoleChampCustom.GetRoleForType(typeDestination);
                            Type[]           typeDefinisseursChamps = role.TypeDefinisseurs;

                            if (typeDefinisseursChamps.Length > 0)
                            {
                                CObjetDonneeAIdNumeriqueAuto definisseur = (CObjetDonneeAIdNumeriqueAuto)Activator.CreateInstance(typeDefinisseursChamps[0], new object[] { contexte });
                                if (DbKeyDefinisseurChampsCustomEntiteDestination != null)
                                {
                                    if (definisseur.ReadIfExists(DbKeyDefinisseurChampsCustomEntiteDestination))
                                    {
                                        return new object[] { definisseur }
                                    }
                                    ;
                                }
                            }
                        }
                    }
                }
            }

            return(new object[] { });
        }
    }
예제 #3
0
        ////////////////////////////////////////////
        private void OnChangeExpression(string strTexte, ref C2iExpression expToSet, CComboboxAutoFilled combo)
        {
            CContexteAnalyse2iExpression ctx = new CContexteAnalyse2iExpression(ActionSynchronisme.Process, typeof(CProcess));
            CResultAErreur result            = new CAnalyseurSyntaxiqueExpression(ctx).AnalyseChaine(strTexte);

            if (result)
            {
                ArrayList lstChamps = new ArrayList();
                expToSet = (C2iExpression)result.Data;
                Type            tp        = expToSet.TypeDonnee.TypeDotNetNatif;
                CStructureTable structure = null;
                try
                {
                    structure = CStructureTable.GetStructure(tp);
                    ArrayList lst = new ArrayList();
                    foreach (CInfoChampTable champ in structure.Champs)
                    {
                        if (champ.TypeDonnee == typeof(DateTime) || champ.TypeDonnee == typeof(DateTime?))
                        {
                            lst.Add(champ);
                        }
                    }
                    //Cherche les champs custom
                    if (typeof(CElementAChamp).IsAssignableFrom(tp))
                    {
                        //Crée les infos champ custom pour le type
                        using (CContexteDonnee contexte = new CContexteDonnee(
                                   CSessionClient.GetSessionUnique().IdSession,
                                   true, false))
                        {
                            string strCodeRole = CRoleChampCustom.GetRoleForType(tp).CodeRole;
                            CListeObjetsDonnees listeChamps = CChampCustom.GetListeChampsForRole(
                                contexte, strCodeRole);
                            new CListeObjetsDonnees(contexte, typeof(CChampCustom));
                            listeChamps.Filtre = new CFiltreData(
                                CChampCustom.c_champType + "=@1",
                                (int)TypeDonnee.tDate);
                            foreach (CChampCustom champ in listeChamps)
                            {
                                CInfoChampTable info = new CInfoChampTable(
                                    CSynchronismeDonnees.c_idChampCustom + champ.Id.ToString(),
                                    typeof(DateTime),
                                    0,
                                    false,
                                    false,
                                    true,
                                    false,
                                    true);
                                info.NomConvivial = champ.Nom;
                                lst.Add(info);
                            }
                        }
                    }
                    combo.ListDonnees = lst;
                }
                catch
                {
                }
            }
        }
        private void CFormEditVariableFiltreCalculee_Load(object sender, System.EventArgs e)
        {
            // Lance la traduction du formulaire
            sc2i.win32.common.CWin32Traducteur.Translate(this);

            CRoleChampCustom role = CRoleChampCustom.GetRoleForType(m_typeDonnees);

            if (role != null)
            {
                CListeObjetsDonnees listeChamps = CChampCustom.GetListeChampsForRole(CSc2iWin32DataClient.ContexteCourant, role.CodeRole);
                listeChamps.Tri = CChampCustom.c_champNom;
                m_wndListeChamps.ListeSource = listeChamps;

                Dictionary <int, bool> lstChecks = new Dictionary <int, bool>();
                if (!(m_champ.Origine is C2iOrigineChampExportChampCustom))
                {
                    m_champ.Origine = new C2iOrigineChampExportChampCustom();
                }
                m_champ.NomChamp = "CUSTOM_FIELDS";
                C2iOrigineChampExportChampCustom origineChamp = (C2iOrigineChampExportChampCustom)m_champ.Origine;
                foreach (int nId in origineChamp.IdsChampCustom)
                {
                    lstChecks[nId] = true;
                }
                for (int nChamp = 0; nChamp < listeChamps.Count; nChamp++)
                {
                    CChampCustom champ = (CChampCustom)listeChamps[nChamp];
                    if (lstChecks.ContainsKey(champ.Id))
                    {
                        m_wndListeChamps.CheckItem(nChamp);
                    }
                }
            }
        }
        //------------------------------------------------------------------------
        private void m_lnkSelectFormulaires_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            C2iExpression formule = GetFormuleValideElementEdite(m_txtFormuleElementEdite);

            if (formule != null)
            {
                Type        tpEdite = formule.TypeDonnee.TypeDotNetNatif;
                CFiltreData filtre  = new CFiltreData(CFormulaire.c_champTypeElementEdite + "=@1",
                                                      tpEdite.ToString());
                CRoleChampCustom role = CRoleChampCustom.GetRoleForType(tpEdite);
                if (role != null)
                {
                    filtre = CFiltreData.GetOrFiltre(filtre,
                                                     CFormulaire.GetFiltreFormulairesForRole(role.CodeRole));
                }

                CListeObjetDonneeGenerique <CFormulaire> listeFormulaires = new CListeObjetDonneeGenerique <CFormulaire>(
                    CSc2iWin32DataClient.ContexteCourant, filtre);


                m_menuFormulaires.Items.Clear();

                foreach (CFormulaire formulaire in listeFormulaires)
                {
                    CDbKey            nKeyForm = formulaire.DbKey;
                    ToolStripMenuItem itemForm = new ToolStripMenuItem(formulaire.Libelle);
                    itemForm.Tag     = nKeyForm;
                    itemForm.Checked = m_listeDbKeysFormulaires.Contains(nKeyForm);
                    itemForm.Click  += new EventHandler(itemForm_Click);
                    itemForm.Enabled = true;
                    m_menuFormulaires.Items.Add(itemForm);
                }
                m_menuFormulaires.Show(m_lnkSelectFormulaires, new Point(0, m_lnkSelectFormulaires.Height));
            }
        }
예제 #6
0
        //-------------------------------------------------------------------------
        private void FillListeChamps(CRestrictionUtilisateurSurType restriction)
        {
            m_wndListeChamps.BeginUpdate();
            m_wndListeChamps.Items.Clear();
            CInfoStructureDynamique info     = CInfoStructureDynamique.GetStructure(restriction.TypeAssocie, 0);
            List <ListViewItem>     lstItems = new List <ListViewItem>();

            foreach (CInfoChampDynamique champ in info.Champs)
            {
                string strTmp = "";
                CDefinitionProprieteDynamique def = CConvertisseurInfoStructureDynamiqueToDefinitionChamp.GetDefinitionProprieteDynamique(champ.NomPropriete, ref strTmp);
                //Uniquement les propriétés "classiques"
                //voir CTimosApp.GetStructure
                if (def != null && typeof(CDefinitionProprieteDynamiqueDotNet).IsAssignableFrom(def.GetType()))
                {
                    ListViewItem item = new ListViewItem();
                    item.Text       = champ.NomChamp;
                    item.Tag        = def.NomProprieteSansCleTypeChamp;
                    item.ImageIndex = GetIndexImage(restriction.GetRestriction(def.NomProprieteSansCleTypeChamp));
                    lstItems.Add(item);
                }
            }
            lstItems.Sort((x, y) => x.Text.CompareTo(y.Text));
            if (typeof(IElementAChamps).IsAssignableFrom(restriction.TypeAssocie))
            {
                CRoleChampCustom role = CRoleChampCustom.GetRoleForType(restriction.TypeAssocie);
                if (role != null)
                {
                    CListeObjetsDonnees listeChampsCustom = CChampCustom.GetListeChampsForRole(CContexteDonneeSysteme.GetInstance(), role.CodeRole);
                    foreach (CChampCustom champ in listeChampsCustom)
                    {
                        ListViewItem item = new ListViewItem();
                        item.Text       = champ.Nom;
                        item.Tag        = champ.CleRestriction;
                        item.ImageIndex = GetIndexImage(restriction.GetRestriction(champ.CleRestriction));
                        lstItems.Add(item);
                    }
                    lstItems.Sort((x, y) => x.Text.CompareTo(y.Text));

                    CListeObjetsDonnees listeFormulaires = new CListeObjetsDonnees(CContexteDonneeSysteme.GetInstance(), typeof(CFormulaire));
                    listeFormulaires.Filtre = CFormulaire.GetFiltreFormulairesForRole(role.CodeRole);
                    foreach (CFormulaire formulaire in listeFormulaires)
                    {
                        ListViewItem item = new ListViewItem();
                        item.Text       = "{" + formulaire.Libelle + "}";
                        item.Tag        = formulaire.CleRestriction;
                        item.ImageIndex = GetIndexImage(restriction.GetRestriction(formulaire.CleRestriction));
                        lstItems.Add(item);
                    }
                }
            }
            m_wndListeChamps.Items.AddRange(lstItems.ToArray());
            m_wndListeChamps.EndUpdate();
        }
예제 #7
0
        //----------------------------------------------------------------------------------
        private void InitPanelDefinisseurChamps()
        {
            if (ActionCopierEntite.ExpressionEntiteDestination != null)
            {
                Type typeDestination = ActionCopierEntite.ExpressionEntiteDestination.TypeDonnee.TypeDotNetNatif;
                if ((typeof(IElementAChamps)).IsAssignableFrom(typeDestination))
                {
                    m_panelDefinisseurChamps.Visible = !m_chkFullCopy.Checked;
                    CContexteDonnee ctx = ActionCopierEntite.Process.ContexteDonnee;

                    CRoleChampCustom role = CRoleChampCustom.GetRoleForType(typeDestination);
                    Type[]           typeDefinisseursChamps = role.TypeDefinisseurs;

                    if (typeDefinisseursChamps.Length > 0)
                    {
                        // Init la textBoxSelectionne
                        m_txtSelectDefinisseurChampsCustom.InitForSelect(typeDefinisseursChamps[0],
                                                                         "Libelle",
                                                                         false);

                        CObjetDonneeAIdNumeriqueAuto objet = (CObjetDonneeAIdNumeriqueAuto)Activator.CreateInstance(typeDefinisseursChamps[0], new object[] { ctx });
                        if (ActionCopierEntite.DbKeyDefinisseurChampsCustomEntiteDestination != null)
                        {
                            if (objet.ReadIfExists(ActionCopierEntite.DbKeyDefinisseurChampsCustomEntiteDestination))
                            {
                                m_txtSelectDefinisseurChampsCustom.ElementSelectionne = objet;
                            }
                            else
                            {
                                m_txtSelectDefinisseurChampsCustom.ElementSelectionne = null;
                            }
                        }
                        else
                        {
                            m_txtSelectDefinisseurChampsCustom.ElementSelectionne = null;
                        }
                    }
                }
                else
                {
                    m_panelDefinisseurChamps.Visible = false;
                }
            }
        }
        //-------------------------------------------------------
        private void InitSelectFormulaire(CTextBoxZoomFormule editeur)
        {
            if (editeur == null)
            {
                return;
            }
            C2iExpression          formule       = GetFormuleValideElementEdite(editeur);
            CFormulaire            formulaireSel = null;
            C2iTextBoxFiltreRapide selecteur     = null;

            if (editeur == m_txtFormuleElementSecondaire)
            {
                formulaireSel = m_txtSelectFormulaireSecondaire.ElementSelectionne as CFormulaire;
                selecteur     = m_txtSelectFormulaireSecondaire;
            }
            if (formule != null && selecteur != null)
            {
                Type        tpEdite = formule.TypeDonnee.TypeDotNetNatif;
                CFiltreData filtre  = new CFiltreData(CFormulaire.c_champTypeElementEdite + "=@1",
                                                      tpEdite.ToString());
                CRoleChampCustom role = CRoleChampCustom.GetRoleForType(tpEdite);
                if (role != null)
                {
                    filtre = CFiltreData.GetOrFiltre(filtre,
                                                     CFormulaire.GetFiltreFormulairesForRole(role.CodeRole));
                }

                selecteur.InitAvecFiltreDeBase(typeof(CFormulaire),
                                               "Libelle",
                                               filtre, true);
                if (formulaireSel != null && formulaireSel.TypeElementEdite == tpEdite)
                {
                    selecteur.ElementSelectionne = formulaireSel;
                }
                else
                {
                    selecteur.ElementSelectionne = null;
                }
            }
        }