//------------------------------------------------------------------------- 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(); }
//------------------------------------------------------------------------------------- public void AppliqueRestrictions( CListeRestrictionsUtilisateurSurType lstRestrictions, CGestionnaireReadOnlySysteme gestionnaire) { if (SourceType == null) { return; } CRestrictionUtilisateurSurType restriction = lstRestrictions.GetRestriction(SourceType); if (restriction != null) { foreach (KeyValuePair <object, CInfoControle> kv in m_dicControleToInfo) { CInfoControle info = kv.Value; if (info.Field.Length > 0) { ERestriction rest = restriction.GetRestriction(info.Field); Control ctrl = kv.Key as Control; if (ctrl != null) { if ((rest & ERestriction.ReadOnly) == ERestriction.ReadOnly) { gestionnaire.SetReadOnly(ctrl, true); } else { gestionnaire.SetReadOnly(ctrl, false); } } } } } }
//--------------------------------------------- protected override void MyAppliqueRestriction( CRestrictionUtilisateurSurType restrictionSurObjetEdite, CListeRestrictionsUtilisateurSurType listeRestrictions, IGestionnaireReadOnlySysteme gestionnaireReadOnly) { bool bShowPictureRestriction = false; if (listeRestrictions != null && EditedElement != null) { CChampCustom champ = WndVariable.Variable as CChampCustom; if (champ != null && restrictionSurObjetEdite != null && m_controleForVariable.Control != null) { ERestriction rest = restrictionSurObjetEdite.GetRestriction(champ.CleRestriction); if ((rest & ERestriction.ReadOnly) == ERestriction.ReadOnly) { gestionnaireReadOnly.SetReadOnly(m_controleForVariable.Control, true); bShowPictureRestriction = true; } } } if (VisualiseurReadOnly != null) { if (bShowPictureRestriction) { VisualiseurReadOnly.Visible = true; } else { VisualiseurReadOnly.Visible = false; } } }
//--------------------------------------------------------------- public void AppliqueRestrictions(CListeRestrictionsUtilisateurSurType restrictions, sc2i.common.Restrictions.IGestionnaireReadOnlySysteme gestionnaireReadOnly) { if (m_createur != null && restrictions != null && gestionnaireReadOnly != null) { if (m_formulaire != null && m_formulaire.TypeElementEdite != null) { restrictions = restrictions.Clone() as CListeRestrictionsUtilisateurSurType; CRestrictionUtilisateurSurType restriction = restrictions.GetRestriction(m_formulaire.TypeElementEdite); ERestriction rest = restriction.GetRestriction(Formulaire.CleRestriction); if ((int)rest > (int)restriction.RestrictionGlobale) { restriction.RestrictionUtilisateur = rest; } restrictions.SetRestriction(restriction); } m_createur.AppliqueRestrictions(restrictions, gestionnaireReadOnly); } }
/// /////////////////////////////////////////// /// /// /////////////////////////////////////////// public void AppliqueRestriction( CRestrictionUtilisateurSurType restrictionSurElementEdite, CListeRestrictionsUtilisateurSurType listeRestriction, IGestionnaireReadOnlySysteme gestionnaire) { if (listeRestriction != null && EditedElement != null) { CChampCustom champ = m_wndSelectionValeurChamp.ChampCustom; if (champ != null && restrictionSurElementEdite != null) { ERestriction rest = restrictionSurElementEdite.GetRestriction(champ.CleRestriction); if ((rest & ERestriction.ReadOnly) == ERestriction.ReadOnly) { gestionnaire.SetReadOnly(Control, true); } } } }
public void UpdateOnglets() { if (!LockEdition) { //valide les modifs car on va tout supprimer MAJ_Champs(); } m_bIsInitializing = true; Hashtable tablePagesToHide = new Hashtable(); foreach (Crownwood.Magic.Controls.TabPage page in TabPages) { m_tablePagesInit[page] = false; tablePagesToHide[page] = true; } if (m_elementEdite == null) { return; } /* YK : On obtient la session de l'objet en cours d'édition au lieur de la session par défaut */ CSessionClient session = null; IObjetDonneeAIdNumeriqueAuto objetDonnee = m_elementEdite as IObjetDonneeAIdNumeriqueAuto; if (objetDonnee != null) { session = CSessionClient.GetSessionForIdSession(objetDonnee.ContexteDonnee.IdSession); } else { session = CSessionClient.GetSessionUnique(); } ArrayList lstFormulaires = new ArrayList(m_elementEdite.GetFormulaires()); lstFormulaires.Sort(new CSorterFormulaires()); //Lit les champs liés et leurs valeurs StringBuilder bl = new StringBuilder(); foreach (CFormulaire formulaire in lstFormulaires) { bl.Append(formulaire.Id); bl.Append(","); } if (bl.Length > 0) { bl.Remove(bl.Length - 1, 1); CListeObjetsDonnees lst = new CListeObjetsDonnees(((CFormulaire)lstFormulaires[0]).ContexteDonnee, typeof(CFormulaire)); lst.Filtre = new CFiltreData(CFormulaire.c_champId + " in (" + bl.ToString() + ")"); lst.AssureLectureFaite(); lst.ReadDependances("RelationsChamps", "RelationsChamps.Champ", "RelationsChamps.Champ.ListeValeurs"); } foreach (CFormulaire formulaire in lstFormulaires) { CRestrictionUtilisateurSurType restriction = new CRestrictionUtilisateurSurType(m_elementEdite.GetType()); if (session.GetInfoUtilisateur() != null) { int?nIdVersion = null; IObjetAContexteDonnee objetAContexte = m_elementEdite as IObjetAContexteDonnee; if (objetAContexte != null) { nIdVersion = objetAContexte.ContexteDonnee.IdVersionDeTravail; } restriction = session.GetInfoUtilisateur().GetRestrictionsSurObjet(m_elementEdite, nIdVersion); } ERestriction restrictionFormulaire = restriction.GetRestriction(formulaire.CleRestriction); if ((restrictionFormulaire & ERestriction.Hide) != ERestriction.Hide) { Crownwood.Magic.Controls.TabPage page = (Crownwood.Magic.Controls.TabPage)m_tableIdFormulaireToTabPage[formulaire.Id]; CCreateur2iFormulaire createur = null; if (page == null) { C2iWndFenetre wnd = formulaire.Formulaire; if (wnd != null) { page = new Crownwood.Magic.Controls.TabPage(wnd.Text); page.SuspendLayout(); if (wnd.Text == "") { page.Title = formulaire.Libelle; } TabPages.Add(page); m_tableCreateurs[page] = null; m_tablePageTo2iWnd[page] = wnd; m_tableIdFormulaireToTabPage[formulaire.Id] = page; } } else { createur = (CCreateur2iFormulaire)m_tableCreateurs[page]; } if (page != null) { m_tablePageToRestriction[page] = restrictionFormulaire; if (!TabPages.Contains(page)) { TabPages.Add(page); } tablePagesToHide.Remove(page); } } } /*CChampCustom[] champs = ElementEdite.GetChampsHorsFormulaire(); * if ( champs.Length != 0 ) * { * UpdatePageChamps( nRest ); * if ( m_pageGrid != null ) * tablePagesToHide.Remove(m_pageGrid); * }*/ foreach (Crownwood.Magic.Controls.TabPage pageToDel in tablePagesToHide.Keys) { TabPages.Remove(pageToDel); } if (TabPages.Count == 1) { this.HideTabsMode = Crownwood.Magic.Controls.TabControl.HideTabsModes.HideAlways; } else { this.HideTabsMode = Crownwood.Magic.Controls.TabControl.HideTabsModes.ShowAlways; } if (SelectedTab != null) { InitPageWithObjetCourant(SelectedTab); } m_bIsInitializing = false; }
/// //////////////////////////////////////////// public virtual ERestriction GetRestrictionAAppliquer(CRestrictionUtilisateurSurType rest) { return(rest.GetRestriction(NomProprieteSansCleTypeChamp)); }
public CDefinitionProprieteDynamique[] GetDefinitionsChamps(CObjetPourSousProprietes objet, CDefinitionProprieteDynamique defParente) { List <CDefinitionProprieteDynamique> lstProps = new List <CDefinitionProprieteDynamique>(); if (objet == null) { return(lstProps.ToArray()); } Type tp = objet.TypeAnalyse; if (tp == null) { return(lstProps.ToArray()); } if (!C2iFactory.IsInit()) { return(lstProps.ToArray()); } //Champs custom CRoleChampCustom role = CRoleChampCustom.GetRoleForType(tp); CRestrictionUtilisateurSurType rest = null; CSessionClient session = CSessionClient.GetSessionUnique(); if (session != null) { IInfoUtilisateur info = session.GetInfoUtilisateur(); if (info != null) { rest = info.GetRestrictionsSur(tp, null); } } if (role != null) { CContexteDonnee contexte = CContexteDonneeSysteme.GetInstance(); CListeObjetsDonnees listeChamps = CChampCustom.GetListeChampsForRole(contexte, role.CodeRole); foreach (CChampCustom champ in listeChamps) { if (rest != null) { ERestriction restChamp = rest.GetRestriction(champ.CleRestriction); if ((restChamp & ERestriction.Hide) == ERestriction.Hide) { continue; } } if (champ.ListeValeurs.Count > 0) { CDefinitionProprieteDynamiqueChampCustomDisplayValue def = new CDefinitionProprieteDynamiqueChampCustomDisplayValue(champ); if (champ.Categorie.Trim() != "") { def.Rubrique = champ.Categorie; } else { def.Rubrique = I.T("Complementary informations|59"); } lstProps.Add(def); } } } return(lstProps.ToArray()); }
/////////////////////////////////////////////////// public override CResultAErreur TraitementAvantSauvegarde(CContexteDonnee contexte) { CResultAErreur result = base.TraitementAvantSauvegarde(contexte); CSessionClient session = CSessionClient.GetSessionForIdSession(IdSession); //Annule les modifications sur les champs interdits en modification DataTable table = contexte.Tables[GetNomTable()]; //Objet témoin pour vérifier les valeurs non affectées CRelationElementAChamp_ChampCustom relTemoin = null; if (IdVersionDeTravail != null) //Dans les versions, on ne stocke pas les créations de valeurs nulles { relTemoin = (CRelationElementAChamp_ChampCustom)contexte.GetNewObjetForTable(table); relTemoin.CreateNewInCurrentContexte(); } if (table != null && session != null) { IInfoUtilisateur user = session.GetInfoUtilisateur(); if (user != null) { ArrayList lst = new ArrayList(table.Rows); IElementAChamps lastElt = null; CRestrictionUtilisateurSurType restDeBase = null; CRestrictionUtilisateurSurType restAppliquee = null; foreach (DataRow row in lst) { CRelationElementAChamp_ChampCustom rel = (CRelationElementAChamp_ChampCustom)contexte.GetNewObjetForRow(row); if (row.RowState == DataRowState.Added && relTemoin != null) { if (relTemoin.Valeur != null && relTemoin.Valeur.Equals(rel.Valeur) || relTemoin.Valeur == null && relTemoin.Valeur == null) { rel.CancelCreate(); } } if (row.RowState == DataRowState.Modified || row.RowState == DataRowState.Added) { if (restDeBase == null) { Type tp = rel.ElementAChamps.GetType(); restDeBase = user.GetRestrictionsSur(tp, contexte.IdVersionDeTravail); } if (restDeBase != null && rel.ElementAChamps.Equals(lastElt)) { restAppliquee = restDeBase.Clone() as CRestrictionUtilisateurSurType; } //Vérifie qu'on a le droit if (!rel.ElementAChamps.Equals(lastElt) && restAppliquee != null) { restAppliquee.ApplyToObjet(rel.ElementAChamps); } lastElt = rel.ElementAChamps; if (restAppliquee != null) { ERestriction restChamp = restAppliquee.GetRestriction(rel.ChampCustom.CleRestriction); if ((restChamp & ERestriction.ReadOnly) == ERestriction.ReadOnly) { row.RejectChanges(); } } } } } } if (relTemoin != null) { relTemoin.CancelCreate(); } return(result); }
public override object GetValeur(object obj, CCacheValeursProprietes cacheValeurs, CRestrictionUtilisateurSurType restriction) { IApplatisseurProprietes applatisseur = obj as IApplatisseurProprietes; if (applatisseur != null) { obj = applatisseur.GetObjetParDefaut(); } if (m_strCleRestriction == "") { if (m_champOrigine is CDefinitionProprieteDynamiqueChampCustom) { CDbKey keyChamp = ((CDefinitionProprieteDynamiqueChampCustom)m_champOrigine).DbKeyChamp; CChampCustom champ = new CChampCustom(CContexteDonneeSysteme.GetInstance()); if (champ.ReadIfExists(keyChamp)) { m_strCleRestriction = champ.CleRestriction; } } else if (m_champOrigine != null) { m_strCleRestriction = m_champOrigine.NomProprieteSansCleTypeChamp; } } if (restriction != null && m_strCleRestriction != "" && (restriction.GetRestriction(m_strCleRestriction) & ERestriction.Hide) == ERestriction.Hide) { return(null); } if (!m_bOptimFaite && obj != null) { m_bOptimFaite = true; if (obj is CObjetDonnee) { m_strChampOrigineOptim = ""; PropertyInfo info = obj.GetType().GetProperty(m_champOrigine.NomProprieteSansCleTypeChamp); //Il faut absolument stocker le type, car si //Le champ vient d'une interface, tous les éléments ne sont pas forcement //du même type, et ne proviennent pas forcement du même champ m_typeOptim = obj.GetType(); if (info != null) { object[] attribs = info.GetCustomAttributes(typeof(AccesDirectInterditAttribute), true); if (attribs.Length == 0) { attribs = info.GetCustomAttributes(typeof(TableFieldPropertyAttribute), true); if (attribs != null && attribs.Length > 0) { m_strChampOrigineOptim = ((TableFieldPropertyAttribute)attribs[0]).NomChamp; } } } } if (m_strChampOrigineOptim == "") { m_optimiseur = CInterpreteurProprieteDynamique.GetOptimiseur(obj.GetType(), m_champOrigine.NomPropriete); } } if (m_strChampOrigineOptim != "" && obj is CObjetDonnee && obj.GetType() == m_typeOptim) { return(((CObjetDonnee)obj).Row[m_strChampOrigineOptim]); } else if (m_optimiseur != null) { return(m_optimiseur.GetValue(obj)); } else { return(CInterpreteurProprieteDynamique.GetValue(obj, ChampOrigine, cacheValeurs).Data); } }
//------------------------------------------------------------------------------------------------ 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); }
/// /////////////////////////////////////////////////// public void AppliqueRestrictions(CListeRestrictionsUtilisateurSurType restrictions, IGestionnaireReadOnlySysteme gestionnaireReadOnly) { if (restrictions == null || gestionnaireReadOnly == null) { return; } m_listeRestrictions = restrictions.Clone() as CListeRestrictionsUtilisateurSurType; m_gestionnaireReadOnly = gestionnaireReadOnly; //Gère la visibilité des formulaires if (m_elementEdite != null) { CRestrictionUtilisateurSurType rest = m_listeRestrictions.GetRestriction(m_elementEdite.GetType()); rest.ApplyToObjet(m_elementEdite); if (rest.HasRestrictions) { foreach (KeyValuePair <Crownwood.Magic.Controls.TabPage, int> kv in m_tablePageToIdFormulaire) { CFormulaire formulaire = new CFormulaire(m_elementEdite.ContexteDonnee); if (formulaire.ReadIfExists(kv.Value)) { ERestriction r = rest.GetRestriction(formulaire.CleRestriction); if ((r & ERestriction.Hide) == ERestriction.Hide) { if (TabPages.Contains(kv.Key)) { TabPages.Remove(kv.Key); m_tablePagesInit[kv.Key] = false; } } } } } } //Update les pages initialisées foreach (KeyValuePair <Crownwood.Magic.Controls.TabPage, bool> kv in m_tablePagesInit) { if (kv.Value) { CCreateur2iFormulaireObjetDonnee createur = null; if (m_tableCreateurs.TryGetValue(kv.Key, out createur)) { CRestrictionUtilisateurSurType oldRest = null; if (m_elementEdite != null) { CRestrictionUtilisateurSurType restriction = m_listeRestrictions.GetRestriction(m_elementEdite.GetType()); oldRest = m_listeRestrictions.GetRestriction(m_elementEdite.GetType()); restriction.ApplyToObjet(m_elementEdite); int nIdFormulaire; if (m_tablePageToIdFormulaire.TryGetValue(kv.Key, out nIdFormulaire)) { CFormulaire formulaire = new CFormulaire(m_elementEdite.ContexteDonnee); if (formulaire.ReadIfExists(nIdFormulaire)) { ERestriction rest = restriction.GetRestriction(formulaire.CleRestriction); if ((rest & ERestriction.ReadOnly) == ERestriction.ReadOnly) { restriction.AddRestrictionsHorsPriorite(new CRestrictionUtilisateurSurType(restriction.TypeAssocie, ERestriction.ReadOnly)); //force readonly sur tous les contrôles restriction.RestrictionUtilisateur = ERestriction.ReadOnly; m_listeRestrictions.SetRestriction(restriction); } } } } createur.AppliqueRestrictions(m_listeRestrictions, m_gestionnaireReadOnly); if (oldRest != null) { m_listeRestrictions.SetRestriction(oldRest); } } } } }
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); }
//------------------------------------------------------------------------------------------------ public CResultAErreur FillDataSet(DataSet ds) { CResultAErreur result = CResultAErreur.True; if (m_etape == null) { result.EmpileErreur("m_etape is null"); return(result); } if (ObjetEditePrincipal == null) { result.EmpileErreur("ObjetEditePrincipal is null"); return(result); } CBlocWorkflowFormulaire blocFormulaire = m_etape.TypeEtape != null ? m_etape.TypeEtape.Bloc as CBlocWorkflowFormulaire : null; if (blocFormulaire == null) { result.EmpileErreur("m_etape.Id = " + m_etape.Id + ". Cette Etape n'a pas de formulaire associé dans Timos"); return(result); } CListeRestrictionsUtilisateurSurType lstRestrictions = blocFormulaire.Restrictions; CRestrictionUtilisateurSurType restriction = lstRestrictions.GetRestriction(ObjetEditePrincipal.GetType()); // Traite la liste des formulaires associés pour trouver les champs customs foreach (CDbKey keyForm in blocFormulaire.ListeDbKeysFormulaires) { CFormulaire formulaire = new CFormulaire(m_etape.ContexteDonnee); if (formulaire.ReadIfExists(keyForm)) { bool bGroupeEditable = true; if (restriction != null) { ERestriction rest = restriction.GetRestriction(formulaire.CleRestriction); if ((rest & ERestriction.ReadOnly) == ERestriction.ReadOnly) { bGroupeEditable = false; } } CGroupeChamps groupe = new CGroupeChamps(ds, formulaire, this, false, bGroupeEditable); result = groupe.FillDataSet(ds, formulaire.Formulaire, ObjetEditePrincipal, lstRestrictions); } } // Formulaire d'informations secondaires if (ObjetEditeSecondaire != null) { CDbKey keyFormSecondaire = blocFormulaire.DbKeyFormulaireSecondaire; if (keyFormSecondaire != null) { CFormulaire formulaireSecondaire = new CFormulaire(m_etape.ContexteDonnee); if (formulaireSecondaire.ReadIfExists(keyFormSecondaire)) { CGroupeChamps groupe = new CGroupeChamps(ds, formulaireSecondaire, this, true, false); result = groupe.FillDataSet(ds, formulaireSecondaire.Formulaire, ObjetEditeSecondaire, lstRestrictions); } } } // Gestion des documents attendus CCaracteristiqueEntite[] liste = GetDocumentsAttendus(); foreach (CCaracteristiqueEntite caracDoc in liste) { CDocumentAttendu doc = new CDocumentAttendu(ds, caracDoc); result += doc.FillDataSet(ds); } // Gestion des Actions disponibles string strStepId = m_etape.TypeEtape.UniversalId; CProcessInDb[] actionsDisponibles = GetActionsDisponibles(); foreach (CProcessInDb action in actionsDisponibles) { List <string> lstNommages = new List <string>(action.GetSrongNames()); lstNommages = lstNommages.Where(nom => nom.Contains(strStepId)).ToList(); if (lstNommages.Count > 0) { CActionWeb actionWeb = new CActionWeb(ds, action, false); result += actionWeb.FillDataSet(ds); } } return(result); }