//-------------------------------------------------------------------------
        public I2iWebControl GetWebControle(C2iWnd wnd, CContexteGenerationControleWeb contexteWeb)
        {
            if (wnd == null)
            {
                return(null);
            }
            Type tp = null;

            if (m_dicType2iWndTo2iWebControl.TryGetValue(wnd.GetType(), out tp))
            {
                I2iWebControl webControl = Activator.CreateInstance(tp, new object[0]) as I2iWebControl;
                return(webControl);
            }
            return(null);
        }
Example #2
0
        public CChampTimosWebApp(DataSet ds, I2iWebControl wndControl, IElementAVariables elementEdite, int nIdGroupe, string strIdCarac, bool bIsEditable)
        {
            DataTable dt = ds.Tables[c_nomTable];

            if (dt == null)
            {
                return;
            }
            m_elementAVariables = elementEdite;

            DataRow row = dt.NewRow();

            string strNomChamp   = wndControl.WebLabel;
            string strLibelleWeb = wndControl.WebLabel;
            int    nIdChampFictif;

            if (!s_dicWebControl.TryGetValue(strLibelleWeb, out nIdChampFictif))
            {
                nIdChampFictif = s_nIdChampFictif++;
                s_dicWebControl.Add(strLibelleWeb, nIdChampFictif);
            }
            int    nIdChampCustom   = -1;
            int    nOrdreWeb        = wndControl.WebNumOrder;
            int    nTypeDonneeChamp = 2; // par défaut type string
            bool   bIsChoixParmis   = false;
            bool   bIsMultiline     = false;
            string strCustomClass   = "";

            if (wndControl is C2iWndChampCustom)
            {
                C2iWndChampCustom wndChamp = (C2iWndChampCustom)wndControl;
                bIsMultiline = wndChamp.MultiLine;
                CChampCustom champ = wndChamp.ChampCustom;
                if (champ != null)
                {
                    m_champ          = champ;
                    nIdChampCustom   = champ.Id;
                    strNomChamp      = champ.Nom;
                    nTypeDonneeChamp = (int)champ.TypeDonneeChamp.TypeDonnee;
                    bIsChoixParmis   = champ.IsChoixParmis();
                }
            }
            else if (wndControl is C2iWndFormule)
            {
                C2iWndFormule wndFormule = (C2iWndFormule)wndControl;
                C2iExpression formule    = wndFormule.Formule;
                if (formule != null)
                {
                    m_formule   = formule;
                    bIsEditable = false;
                }
            }
            else if (wndControl is C2iWndPanel || wndControl is C2iWndSlidingPanel)
            {
                bIsEditable    = false;
                strCustomClass = "sous-titre-champ";
            }

            row[c_champId]                = bIsEditable ? nIdChampCustom : nIdChampFictif;
            row[c_champIdTimos]           = nIdChampCustom;
            row[c_champNom]               = strNomChamp;
            row[c_champLibelleConvivial]  = strLibelleWeb == "" ? strNomChamp : strLibelleWeb;
            row[c_champOrdreAffichage]    = nOrdreWeb;
            row[c_champTypeDonne]         = nTypeDonneeChamp;
            row[c_champIsChoixParmis]     = bIsChoixParmis && bIsEditable;
            row[c_champIsMultiline]       = bIsMultiline;
            row[c_champIsEditable]        = bIsEditable;
            row[c_champCustomClass]       = strCustomClass;
            row[c_champIdGroupeChamps]    = nIdGroupe;
            row[c_champIdCaracteristique] = strIdCarac;
            row[c_champUseAutoComplete]   = false;

            m_row = row;
            dt.Rows.Add(row);
        }
Example #3
0
        //------------------------------------------------------------------------------------------------
        public CResultAErreur FillDataSet(DataSet ds, C2iWnd fenetre, IObjetDonneeAChamps objetEdite, CListeRestrictionsUtilisateurSurType lstRestrictions)
        {
            CResultAErreur result = CResultAErreur.True;

            string strIdCarac     = (string)m_row[c_champId];
            string strTypeElement = (string)m_row[c_champElementType];

            if (fenetre != null)
            {
                ArrayList lst = fenetre.AllChilds();
                foreach (object obj in lst)
                {
                    if (obj is I2iWebControl)
                    {
                        I2iWebControl webControl = (I2iWebControl)obj;
                        if (webControl.WebLabel == "")
                        {
                            continue;
                        }

                        C2iWnd wndControl = webControl as C2iWnd;
                        if (wndControl != null)
                        {
                            // Traite la visibilité du champ
                            CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(objetEdite);
                            C2iExpression expVisible          = wndControl.Visiblity;
                            if (expVisible != null)
                            {
                                CResultAErreur resVisible = expVisible.Eval(ctx);
                                if (resVisible && resVisible.Data != null)
                                {
                                    if (resVisible.Data.ToString() == "0" || resVisible.Data.ToString().ToUpper() == "FALSE")
                                    {
                                        continue;
                                    }
                                }
                            }
                            // Applique les restrictions
                            bool bIsEditable = true;
                            if (wndControl is C2iWndFormule || wndControl is C2iWndPanel || wndControl is C2iWndSlidingPanel)
                            {
                                bIsEditable = false;
                            }
                            else if (wndControl is C2iWndChampCustom)
                            {
                                // Sinon on regarde les restrictions du champ
                                C2iWndChampCustom wndChamp = (C2iWndChampCustom)wndControl;
                                CChampCustom      cc       = wndChamp.ChampCustom;
                                CRestrictionUtilisateurSurType restrictionSurObjetEdite = lstRestrictions.GetRestriction(objetEdite.GetType());
                                if (restrictionSurObjetEdite != null)
                                {
                                    ERestriction rest = restrictionSurObjetEdite.GetRestriction(cc.CleRestriction);
                                    if ((rest & ERestriction.ReadOnly) == ERestriction.ReadOnly)
                                    {
                                        bIsEditable = false;
                                    }
                                }
                            }
                            CChampTimosWebApp champWeb = new CChampTimosWebApp(ds, webControl, objetEdite, -1, strIdCarac, bIsEditable);
                            result = champWeb.FillDataSet(ds);

                            CCaracValeurChamp valeur = new CCaracValeurChamp(ds, objetEdite, champWeb, strTypeElement, strIdCarac, bIsEditable);
                            result = valeur.FillDataSet(ds);
                        }
                    }
                    // Traitement dans le cas d'un sous-formulaire
                    else if (obj is C2iWndConteneurSousFormulaire)
                    {
                        C2iWndConteneurSousFormulaire subForm = (C2iWndConteneurSousFormulaire)obj;
                        if (subForm != null && subForm.SubFormReference != null)
                        {
                            C2iWnd frm = sc2i.formulaire.subform.C2iWndProvider.GetForm(subForm.SubFormReference);
                            if (frm != null)
                            {
                                if (subForm.EditedElement != null)
                                {
                                    C2iExpression expression          = subForm.EditedElement;
                                    CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(objetEdite);
                                    CResultAErreur resEval            = expression.Eval(ctx);
                                    if (!resEval)
                                    {
                                        result += resEval;
                                        return(result);
                                    }
                                    IObjetDonneeAChamps sousObjetEdite = resEval.Data as IObjetDonneeAChamps;
                                    if (sousObjetEdite != null)
                                    {
                                        // Traite la visibilité du champ
                                        ctx = new CContexteEvaluationExpression(sousObjetEdite);
                                        C2iExpression expVisible = subForm.Visiblity;
                                        if (expVisible != null)
                                        {
                                            CResultAErreur resVisible = expVisible.Eval(ctx);
                                            if (resVisible && resVisible.Data != null)
                                            {
                                                if (resVisible.Data.ToString() == "0" || resVisible.Data.ToString().ToUpper() == "FALSE")
                                                {
                                                    continue;
                                                }
                                            }
                                        }
                                        FillDataSet(ds, frm, sousObjetEdite, lstRestrictions);
                                    }
                                }
                            }
                        }
                    }//*/
                }
            }
            return(result);
        }
Example #4
0
        public CResultAErreur FillDataSet(DataSet ds, C2iWnd fenetre, IObjetDonneeAChamps objetEdite, CListeRestrictionsUtilisateurSurType lstRestrictions)
        {
            CResultAErreur result = CResultAErreur.True;

            if (m_formulaire == null)
            {
                result.EmpileErreur("m_formulaire is null");
                return(result);
            }
            if (fenetre != null)
            {
                try
                {
                    ArrayList lst = fenetre.AllChilds();
                    bool      bConserverCeGroupe = false;
                    CRestrictionUtilisateurSurType restrictionSurObjetEdite = lstRestrictions.GetRestriction(objetEdite.GetType());

                    foreach (object obj in lst)
                    {
                        if (obj is I2iWebControl)
                        {
                            I2iWebControl webControl = (I2iWebControl)obj;
                            if (webControl.WebLabel == "")
                            {
                                continue;
                            }

                            C2iWnd wndControl = webControl as C2iWnd;
                            if (wndControl != null)
                            {
                                // Traite la visibilité du champ
                                C2iExpression expVisible = wndControl.Visiblity;
                                if (expVisible != null)
                                {
                                    CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(objetEdite);
                                    CResultAErreur resVisible         = expVisible.Eval(ctx);
                                    if (resVisible && resVisible.Data != null)
                                    {
                                        if (resVisible.Data.ToString() == "0" || resVisible.Data.ToString().ToUpper() == "FALSE")
                                        {
                                            continue;
                                        }
                                    }
                                }
                                // Applique les restrictions
                                bool bIsEditable = true;
                                if (wndControl is C2iWndFormule || wndControl is C2iWndPanel || wndControl is C2iWndSlidingPanel)
                                {
                                    bIsEditable = false;
                                }
                                else if ((bool)m_row[c_champIsInfosSecondaires])
                                {
                                    // Si c'est un groupe d'infos secondaire, aucun champ n'est éditable
                                    bIsEditable = false;
                                }
                                else if (wndControl is C2iWndChampCustom)
                                {
                                    // Sinon on regarde les restrictions du champ
                                    C2iWndChampCustom wndChamp = (C2iWndChampCustom)wndControl;
                                    CChampCustom      cc       = wndChamp.ChampCustom;
                                    if (restrictionSurObjetEdite != null)
                                    {
                                        ERestriction rest = restrictionSurObjetEdite.GetRestriction(cc.CleRestriction);
                                        if ((rest & ERestriction.ReadOnly) == ERestriction.ReadOnly)
                                        {
                                            bIsEditable = false;
                                        }
                                    }
                                }
                                CChampTimosWebApp champWeb = new CChampTimosWebApp(ds, webControl, objetEdite, m_formulaire.Id, "-1", bIsEditable);
                                result = champWeb.FillDataSet(ds);

                                CTodoValeurChamp valeur = new CTodoValeurChamp(ds, objetEdite, champWeb, m_formulaire.Id, bIsEditable);
                                result             = valeur.FillDataSet(ds);
                                bConserverCeGroupe = true;
                            }
                        }
                        // Traitement dans le cas d'un sous-formulaire
                        else if (obj is C2iWndConteneurSousFormulaire)
                        {
                            C2iWndConteneurSousFormulaire subForm = (C2iWndConteneurSousFormulaire)obj;
                            if (subForm != null && subForm.SubFormReference != null)
                            {
                                C2iWnd frm = sc2i.formulaire.subform.C2iWndProvider.GetForm(subForm.SubFormReference);
                                if (frm != null)
                                {
                                    if (subForm.EditedElement != null)
                                    {
                                        C2iExpression expression          = subForm.EditedElement;
                                        CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(objetEdite);
                                        CResultAErreur resEval            = expression.Eval(ctx);
                                        if (!resEval)
                                        {
                                            result += resEval;
                                            return(result);
                                        }
                                        IObjetDonneeAChamps sousObjetEdite = resEval.Data as IObjetDonneeAChamps;
                                        if (sousObjetEdite != null)
                                        {
                                            // Traite la visibilité du champ
                                            var           ctxSousObjet = new CContexteEvaluationExpression(sousObjetEdite);
                                            C2iExpression expVisible   = subForm.Visiblity;
                                            if (expVisible != null)
                                            {
                                                CResultAErreur resVisible = expVisible.Eval(ctxSousObjet);
                                                if (resVisible && resVisible.Data != null)
                                                {
                                                    if (resVisible.Data.ToString() == "0" || resVisible.Data.ToString().ToUpper() == "FALSE")
                                                    {
                                                        continue;
                                                    }
                                                }
                                            }
                                            bConserverCeGroupe = true;
                                            FillDataSet(ds, frm, sousObjetEdite, lstRestrictions);
                                        }
                                    }
                                }
                            }
                        }
                        // Traitement dans le cas d'une Child Zone
                        else if (obj is C2iWndZoneMultiple)
                        {
                            C2iWndZoneMultiple   childZone   = (C2iWndZoneMultiple)obj;
                            C2iWndSousFormulaire sousFenetre = childZone.FormulaireFils;
                            bool bHasAddButton = childZone.HasAddButton;
                            bool bCanCreate    = false;

                            if (childZone.SourceFormula != null)
                            {
                                CContexteEvaluationExpression ctxEval = new CContexteEvaluationExpression(objetEdite);
                                C2iExpression source = childZone.SourceFormula;
                                Type          tp     = source.TypeDonnee.TypeDotNetNatif;
                                if (tp != null)
                                {
                                    // Gestion des restrictions
                                    CRestrictionUtilisateurSurType restrictions = lstRestrictions.GetRestriction(tp);
                                    if (restrictions != null)
                                    {
                                        bCanCreate = restrictions.CanCreateType();
                                    }
                                }
                                CResultAErreur resEval = source.Eval(ctxEval);
                                if (!resEval)
                                {
                                    result += resEval;
                                    return(result);
                                }
                                object datas = resEval.Data;
                                if (datas != null)
                                {
                                    bConserverCeGroupe = true;

                                    IEnumerable collection = datas as IEnumerable;
                                    if (collection != null)
                                    {
                                        // La source de données est une collection, il s'agit certainement de caractéristiques
                                        // Mais c'est peut-être aussi un Workbook, un Site, un Projet... on ne sait pas car ça dépend du paramétrage
                                        m_row[c_champTitreCaracteristiques]  = childZone.WebLabel;
                                        m_row[c_champCanAddCaracteristiques] = bHasAddButton && bCanCreate;

                                        int nOrdre = 0;
                                        foreach (var data in collection)
                                        {
                                            IObjetDonneeAChamps objEdite = data as IObjetDonneeAChamps;
                                            if (objEdite != null)
                                            {
                                                CCaracteristique caracWeb = new CCaracteristique(
                                                    ds,
                                                    objEdite as IObjetDonneeAIdNumeriqueAuto,
                                                    tp,
                                                    objetEdite.GetType().ToString(),
                                                    ((IObjetDonneeAIdNumeriqueAuto)objetEdite).Id,
                                                    nOrdre++,
                                                    m_formulaire.Id,
                                                    false);
                                                caracWeb.FillDataSet(ds, sousFenetre, objEdite, lstRestrictions);
                                            }
                                        }
                                        // Création d'un template
                                        if (childZone.Affectations.Count > 0)
                                        {
                                            CAffectationsProprietes affectation = childZone.Affectations[0];
                                            if (tp != null && affectation != null)
                                            {
                                                IAllocateurSupprimeurElements allocateur = objetEdite as IAllocateurSupprimeurElements;
                                                object newObj = null;
                                                try
                                                {
                                                    if (allocateur != null)
                                                    {
                                                        result = allocateur.AlloueElement(tp);
                                                        if (result)
                                                        {
                                                            newObj = result.Data;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        newObj = Activator.CreateInstance(tp);
                                                    }
                                                }
                                                catch (Exception ex)
                                                {
                                                    result.EmpileErreur(new CErreurException(ex));
                                                }
                                                if (newObj == null | !result)
                                                {
                                                    result.EmpileErreur(I.T("Error while allocating element|20003"));
                                                }
                                                result = affectation.AffecteProprietes(newObj, objetEdite, new CFournisseurPropDynStd(true));
                                                if (!result)
                                                {
                                                    result.EmpileErreur(I.T("Some values cannot be assigned|20004"));
                                                }
                                                CCaracteristique caracTemplate = new CCaracteristique(
                                                    ds,
                                                    newObj as IObjetDonneeAIdNumeriqueAuto,
                                                    tp,
                                                    objetEdite.GetType().ToString(),
                                                    ((IObjetDonneeAIdNumeriqueAuto)objetEdite).Id,
                                                    nOrdre++,
                                                    m_formulaire.Id,
                                                    true);
                                                caracTemplate.FillDataSet(ds, sousFenetre, newObj as IObjetDonneeAChamps, lstRestrictions);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        // La source de donnée est un objet unique
                                        IObjetDonneeAChamps objEdite = datas as IObjetDonneeAChamps;
                                        if (objEdite != null)
                                        {
                                            FillDataSet(ds, sousFenetre, objEdite, lstRestrictions);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    /*if (!bConserverCeGroupe)
                     * {
                     *  DataTable dt = ds.Tables[c_nomTable];
                     *  if (dt != null)
                     *      dt.Rows.Remove(m_row);
                     * }*/
                }
                catch (Exception ex)
                {
                    result.EmpileErreur(ex.Message);
                    return(result);
                }
            }
            return(result);
        }