public static CListeRestrictionsUtilisateurSurType GetRestrictionsClient(CConfigModulesTimos configModules)
        {
            CListeRestrictionsUtilisateurSurType liste = new CListeRestrictionsUtilisateurSurType();

            if (configModules == null)
            {
                return(liste);
            }

            List <Type> tps = new List <Type>(CContexteDonnee.GetAllTypes());

            foreach (Type tp in tps)
            {
                object[] atts = tp.GetCustomAttributes(typeof(AModulesClient), false);
                if (atts.Length == 1)
                {
                    AModulesClient att = (AModulesClient)atts[0];

                    List <CLicenceModuleClientPrtct> modulesDuType = new List <CLicenceModuleClientPrtct>();
                    foreach (string strIdModule in att.IdsModulesClient)
                    {
                        CLicenceModuleClientPrtct modulePresent = configModules.GetModuleClient(strIdModule);
                        if (modulePresent != null)
                        {
                            modulesDuType.Add(modulePresent);
                        }
                    }

                    if (modulesDuType.Count == 0)
                    {
                        CRestrictionUtilisateurSurType restriction = new CRestrictionUtilisateurSurType(tp);
                        foreach (string strIdModule in att.IdsModulesClient)
                        {
                            CRestrictionUtilisateurSurType restric = new CRestrictionUtilisateurSurType(tp);
                            restric.RestrictionSysteme = configModules.GetRestrictionSiModuleAbsent(strIdModule);
                            restriction.Combine(restric);
                        }
                        liste.AddRestriction(restriction);
                    }
                    else
                    {
                        CRestrictionUtilisateurSurType restriction = new CRestrictionUtilisateurSurType(tp);
                        foreach (CLicenceModuleClientPrtct module in modulesDuType)
                        {
                            CRestrictionUtilisateurSurType restric = new CRestrictionUtilisateurSurType(tp);
                            restric.RestrictionSysteme = module.Restriction;
                            restriction.Combine(restric);
                        }
                        if (!restriction.HasRestrictions)
                        {
                            restriction = new CRestrictionUtilisateurSurType(restriction.TypeAssocie);
                            restriction.RestrictionUtilisateur = restriction.RestrictionGlobale;
                        }
                        liste.AddRestriction(restriction);
                    }
                }
            }
            CompleteRestrictionsClient(configModules, liste);
            return(liste);
        }
        //---------------------------------------------------------------
        private static void CompleteRestrictionsProcessEtAutres(CConfigModulesTimos configModules, CListeRestrictionsUtilisateurSurType listeRestrictions)
        {
            CLicenceModuleClientPrtct module = configModules.GetModuleClient(CConfigModulesTimos.c_clientModule_ProcessEtAutres_ID);
            ERestriction rest = ERestriction.Hide;

            if (module != null)
            {
                rest = module.Restriction;
            }
            if (rest != ERestriction.Aucune)
            {
                CRestrictionUtilisateurSurType restriction = new CRestrictionUtilisateurSurType(typeof(CVariableSurObjet), rest);
                listeRestrictions.AddRestriction(restriction);
                restriction = new CRestrictionUtilisateurSurType(typeof(CEvenement), rest);
                listeRestrictions.AddRestriction(restriction);
                restriction = new CRestrictionUtilisateurSurType(typeof(CGroupeParametrage), rest);
                listeRestrictions.AddRestriction(restriction);
                restriction = new CRestrictionUtilisateurSurType(typeof(CProcessInDb), rest);
                listeRestrictions.AddRestriction(restriction);
                restriction = new CRestrictionUtilisateurSurType(typeof(CRelationDefinisseurComportementInduit), rest);
                listeRestrictions.AddRestriction(restriction);
                restriction = new CRestrictionUtilisateurSurType(typeof(CRelationElementComportement), rest);
                listeRestrictions.AddRestriction(restriction);
                restriction = new CRestrictionUtilisateurSurType(typeof(CComportementGenerique), rest);
                listeRestrictions.AddRestriction(restriction);
            }
        }
        //---------------------------------------------------------------
        private static void CompleteRestrictionsChampsCalcules(CConfigModulesTimos configModules, CListeRestrictionsUtilisateurSurType listeRestrictions)
        {
            CLicenceModuleClientPrtct module = configModules.GetModuleClient(CConfigModulesTimos.c_clientModule_ChampsCalc_Id);
            ERestriction rest = ERestriction.Hide;

            if (module != null)
            {
                rest = module.Restriction;
            }
            if (rest != ERestriction.Aucune)
            {
                CRestrictionUtilisateurSurType restriction = new CRestrictionUtilisateurSurType(typeof(CChampCalcule), rest);
                listeRestrictions.AddRestriction(restriction);
            }
        }
        //---------------------------------------------------------------
        private static void CompleteRestrictionsStructuresExport(CConfigModulesTimos configModules, CListeRestrictionsUtilisateurSurType listeRestrictions)
        {
            CLicenceModuleClientPrtct module = configModules.GetModuleClient(CConfigModulesTimos.c_clientModule_StructuresExport_ID);
            ERestriction rest = ERestriction.Hide;

            if (module != null)
            {
                rest = module.Restriction;
            }
            if (rest != ERestriction.Aucune)
            {
                CRestrictionUtilisateurSurType restriction = new CRestrictionUtilisateurSurType(typeof(C2iStructureExportInDB), rest);
                listeRestrictions.AddRestriction(restriction);
            }
        }
        //---------------------------------------------------------------
        private static void CompleteRestrictionsDonneesPrecalculees(CConfigModulesTimos configModules, CListeRestrictionsUtilisateurSurType listeRestrictions)
        {
            CLicenceModuleClientPrtct moduleDonnees = configModules.GetModuleClient(CConfigModulesTimos.c_clientModule_DonneesPrecalculees_ID);
            ERestriction rest = ERestriction.Hide;

            if (moduleDonnees != null)
            {
                rest = moduleDonnees.Restriction;
            }
            if (rest != ERestriction.Aucune)
            {
                CRestrictionUtilisateurSurType restriction = new CRestrictionUtilisateurSurType(typeof(CTypeDonneeCumulee), rest);
                listeRestrictions.AddRestriction(restriction);
            }
        }
        //---------------------------------------------------------------
        private static void CompleteRestrictionsClientWorkflows(CConfigModulesTimos configModules, CListeRestrictionsUtilisateurSurType listeRestrictions)
        {
            CLicenceModuleClientPrtct moduleClientTypeWorkflow = configModules.GetModuleClient(CConfigModulesTimos.c_clientModule_ParametrageWorkflow);
            ERestriction rest = ERestriction.Hide;

            rest = ERestriction.Hide;
            if (moduleClientTypeWorkflow != null)
            {
                rest = moduleClientTypeWorkflow.Restriction;
            }
            if (rest != ERestriction.Aucune)
            {
                CRestrictionUtilisateurSurType restriction = new CRestrictionUtilisateurSurType(typeof(CTypeWorkflow), rest);
                listeRestrictions.AddRestriction(restriction);
            }
        }
        private static void CompleteRestrictionsModeletesEtats(CConfigModulesTimos configModules, CListeRestrictionsUtilisateurSurType listeRestrictions)
        {
            CLicenceModuleClientPrtct module = configModules.GetModuleClient(CConfigModulesTimos.c_clientModule_RapportsCrystal_ID);
            ERestriction rest = ERestriction.Hide;

            if (module != null)
            {
                rest = module.Restriction;
            }
            if (rest != ERestriction.Aucune)
            {
                CRestrictionUtilisateurSurType restriction = new CRestrictionUtilisateurSurType(typeof(C2iRapportCrystal), rest);
                listeRestrictions.AddRestriction(restriction);
                restriction = new CRestrictionUtilisateurSurType(typeof(C2iCategorieRapportCrystal), rest);
                listeRestrictions.AddRestriction(restriction);
            }
        }
        //--------------------------------------------------------------------------------
        private static void CompleteRestrictionsTypesCaracteristiquesEntite(CConfigModulesTimos configModules, CListeRestrictionsUtilisateurSurType listeRestrictions)
        {
            CLicenceModuleClientPrtct module = configModules.GetModuleClient(CConfigModulesTimos.c_clientModule_TypeCaracteristiques_ID);
            ERestriction rest = ERestriction.Hide;

            if (module != null)
            {
                rest = module.Restriction;
            }
            if (rest != ERestriction.Aucune)
            {
                CRestrictionUtilisateurSurType restriction = new CRestrictionUtilisateurSurType(typeof(CTypeCaracteristiqueEntite), rest);
                listeRestrictions.AddRestriction(restriction);
                restriction = new CRestrictionUtilisateurSurType(typeof(CRelationTypeCaracteristiqueEntite_ChampCustom), rest);
                listeRestrictions.AddRestriction(restriction);
                restriction = new CRestrictionUtilisateurSurType(typeof(CRelationTypeCaracteristiqueEntite_Formulaire), rest);
                listeRestrictions.AddRestriction(restriction);
            }
        }
        //---------------------------------------------------------------
        private static void CompleteRestrictionsFiltresEtListes(CConfigModulesTimos configModules, CListeRestrictionsUtilisateurSurType listeRestrictions)
        {
            CLicenceModuleClientPrtct module = configModules.GetModuleClient(CConfigModulesTimos.c_clientModule_Filtres_ID);
            ERestriction rest = ERestriction.Hide;

            if (module != null)
            {
                rest = module.Restriction;
            }
            if (rest != ERestriction.Aucune)
            {
                CRestrictionUtilisateurSurType restriction = new CRestrictionUtilisateurSurType(typeof(CFiltreDynamiqueInDb), rest);
                listeRestrictions.AddRestriction(restriction);
                restriction = new CRestrictionUtilisateurSurType(typeof(CListeEntites), rest);
                listeRestrictions.AddRestriction(restriction);
                restriction = new CRestrictionUtilisateurSurType(typeof(CRelationListeEntites_Entite), rest);
                listeRestrictions.AddRestriction(restriction);
            }
        }
        //-------------------------------------------------------------------------------------------------------------
        private static void CompleteRestrictionsConfigurationCompteMail(CConfigModulesTimos configModules, CListeRestrictionsUtilisateurSurType listeRestrictions)
        {
            CLicenceModuleClientPrtct module = configModules.GetModuleClient(CConfigModulesTimos.c_clientModule_ConfigurationCompteMail_ID);
            ERestriction rest = ERestriction.Hide;

            if (module != null)
            {
                rest = module.Restriction;
            }
            if (rest != ERestriction.Aucune)
            {
                CRestrictionUtilisateurSurType restriction = new CRestrictionUtilisateurSurType(typeof(CCompteMail), rest);
                listeRestrictions.AddRestriction(restriction);

                restriction = new CRestrictionUtilisateurSurType(typeof(CDossierMail), rest);
                listeRestrictions.AddRestriction(restriction);

                restriction = new CRestrictionUtilisateurSurType(typeof(CRegleMail), rest);
                listeRestrictions.AddRestriction(restriction);
            }
        }
Beispiel #11
0
        public void AppliquerConfiguration(CConfigModulesTimos configuration)
        {
            if (!DesignMode && configuration != null)
            {
                if (LancementApplication != null)
                {
                    EventArgConfigureControl arg = new EventArgConfigureControl();
                    LancementApplication(arg);
                    if (arg.Cancel)
                    {
                        if (FinApplication != null)
                        {
                            FinApplication(this, new EventArgs());
                        }
                        return;
                    }
                }

                ClearSurveillance();

                foreach (Control ctrl in m_associations.Keys)
                {
                    string association = m_associations[ctrl];
                    if (association == null || association == "")
                    {
                        continue;
                    }

                    #region Recuperation de la restriction a Appliquer
                    ERestriction restriction = ERestriction.Aucune;

                    //Combinaison des restrictions
                    List <string> strIdsModulesApp = CSerializerModulesLicence.GetIdsModulesApp(association);
                    bool          bFind            = strIdsModulesApp.Count == 0;
                    foreach (string strIdApp in strIdsModulesApp)
                    {
                        CLicenceModuleAppPrtct mApp = configuration.GetModuleApp(strIdApp);
                        if (mApp != null)
                        {
                            restriction = restriction | mApp.Restriction;
                            bFind       = true;
                            if (restriction == ERestriction.Hide)
                            {
                                break;
                            }
                        }
                    }

                    if (bFind && restriction != ERestriction.Hide)
                    {
                        List <string> strIdsModulesClient = CSerializerModulesLicence.GetIdsModulesClient(association);
                        bFind = strIdsModulesClient.Count == 0;
                        foreach (string strId in strIdsModulesClient)
                        {
                            CLicenceModuleClientPrtct mCli = configuration.GetModuleClient(strId);
                            if (mCli != null)
                            {
                                restriction = restriction | mCli.Restriction;
                                bFind       = true;
                                if (restriction == ERestriction.Hide)
                                {
                                    break;
                                }
                            }
                        }
                    }

                    if (!bFind)
                    {
                        restriction = ERestriction.Hide;
                    }
                    #endregion

                    if (ApplicationConfiguration != null)
                    {
                        EventArgConfigureControl arg = new EventArgConfigureControl();
                        ApplicationConfiguration(ctrl, restriction, arg);
                        if (arg.Cancel)
                        {
                            return;
                        }
                    }

                    #region Affectation du controle et mise sous surveillance
                    switch (restriction)
                    {
                    case ERestriction.Hide:
                        ctrl.Visible = false;

                        if (ctrl is Crownwood.Magic.Controls.TabPage)
                        {
                            DetacheC2iTabPage((Crownwood.Magic.Controls.TabPage)ctrl);
                            AjouterControleParentChangedNonAutorise(ctrl);
                        }
                        else if (ctrl is TabPage)
                        {
                            TabPage tbp = (TabPage)ctrl;
                            //if (tbp.Parent != null && tbp.Parent is TabControl)
                            //{
                            //    AjouterControleAddedNonAutorise(tbp.Parent);
                            //    tbp.Parent = null;
                            //}
                            tbp.Parent = null;
                            AjouterControleParentChangedNonAutorise(tbp);
                        }
                        AjouterControleVisibleChangedNonAutorise(ctrl);
                        break;

                    case ERestriction.ReadOnly:
                        if (typeof(IControlALockEdition).IsAssignableFrom(ctrl.GetType()))
                        {
                            IControlALockEdition ctrlALock = (IControlALockEdition)ctrl;
                            ctrlALock.LockEdition = true;
                            AjouterControleLockEditionChangedNonAutorise(ctrlALock);
                        }
                        else
                        {
                            ctrl.Enabled = false;
                            AjouterControleEnableChangedNonAutorise(ctrl);
                        }
                        break;

                    case ERestriction.NoCreate:
                        break;

                    case ERestriction.NoDelete:
                        break;

                    case ERestriction.NoCreate | ERestriction.NoDelete:
                    case ERestriction.Aucune:
                    default:
                        break;
                    }
                    #endregion
                }
                if (FinApplication != null)
                {
                    FinApplication(this, new EventArgs());
                }
            }
        }