Пример #1
0
 ////////////////////////////////////////////////////////////////////////////
 private void FindAllTablesTypes()
 {
     foreach (Assembly ass in CGestionnaireAssemblies.GetAssemblies())
     {
         RegisterAssembly(ass);
     }
 }
Пример #2
0
 //--------------------------------------------------------------------------
 private void m_wndAddItemGenerator_LinkClicked(object sender, EventArgs e)
 {
     if (m_menuNewItem.Items.Count == 0)
     {
         foreach (Assembly ass in CGestionnaireAssemblies.GetAssemblies())
         {
             foreach (Type tp in ass.GetTypes())
             {
                 if (typeof(IMapItemGenerator).IsAssignableFrom(tp) && !tp.IsAbstract)
                 {
                     IMapItemGenerator gen        = (IMapItemGenerator)Activator.CreateInstance(tp, new object[0]);
                     ToolStripMenuItem itemAddGen = new ToolStripMenuItem(gen.GeneratorName);
                     itemAddGen.Tag    = tp;
                     itemAddGen.Click += new EventHandler(itemAddGen_Click);
                     m_menuNewItem.Items.Add(itemAddGen);
                 }
             }
         }
     }
     if (m_menuNewItem.Items.Count == 1)
     {
         AddGenerator(m_menuNewItem.Items[0].Tag as Type);
     }
     else
     {
         m_menuNewItem.Show(m_wndAddItemGenerator, new Point(0, m_wndAddItemGenerator.Height));
     }
 }
Пример #3
0
        public CChercheurDeTypesQuiUtilisentUnType(IEnumerable <Type> typesAPasExplorer)
        {
            TypesAPasExplorer = typesAPasExplorer;

            foreach (Assembly ass in CGestionnaireAssemblies.GetAssemblies())
            {
                foreach (Type tp in ass.GetTypes())
                {
                    IEnumerable <Type> lst = from t in m_typesQuonVeutPasExplorer
                                             where t.IsAssignableFrom(tp)
                                             select t;
                    if (lst.Count() > 0)
                    {
                        continue;
                    }

                    // Cherche dans les Méthodes directes
                    foreach (MethodInfo info in tp.GetMethods())
                    {
                        if (info.IsStatic)
                        {
                            continue;
                        }
                        if (info.GetParameters().Count() > 0)
                        {
                            continue;
                        }

                        Type tpTest = info.ReturnType;
                        if (tpTest.IsArray)
                        {
                            tpTest = tpTest.GetElementType();
                        }
                        if (tpTest != typeof(object))
                        {
                            lst = from t in m_typesQuonVeutPasExplorer
                                  where t.IsAssignableFrom(tpTest)
                                  select t;
                            if (lst.Count() > 0)
                            {
                                continue;
                            }

                            if (typeof(TypeRecherche).IsAssignableFrom(tpTest) || tpTest.IsAssignableFrom(typeof(TypeRecherche)))
                            {
                                Type tpToAdd = tp;
                                while (tpToAdd != typeof(object) && tpToAdd != null)
                                {
                                    m_typesQuiUtilisent.Add(tpToAdd);
                                    tpToAdd = tpToAdd.BaseType;
                                }
                                break;
                            }
                        }
                    }
                }
            }
        }
 //----------------------------------------------------------
 private void RegisterAllTypesInDb()
 {
     foreach (Assembly ass in CGestionnaireAssemblies.GetAssemblies())
     {
         foreach (Type tp in ass.GetTypes())
         {
             if (typeof(CEntiteDeMemoryDb).IsAssignableFrom(tp) && !tp.IsAbstract)
             {
                 m_database.GetTable(tp);
             }
         }
     }
 }
        //----------------------------------------------------------------------------------------------
        private void CPanelEditeActionSurLinkFormulaireStandard_Load(object sender, EventArgs e)
        {
            ArrayList lstForms = new ArrayList();

            //Cherche tous les formulaires connus
            foreach (Assembly ass in CGestionnaireAssemblies.GetAssemblies())
            {
                foreach (Type tp in ass.GetTypes())
                {
                    if (!tp.IsAbstract && tp.IsSubclassOf(typeof(System.Windows.Forms.Form)))
                    {
                        string   strLibelle = "";
                        object[] attribs    = tp.GetCustomAttributes(typeof(ObjectListeur), true);
                        if (attribs.Length > 0)
                        {
                            Type tpListe = ((ObjectListeur)attribs[0]).TypeListe;
                            strLibelle = I.T("List of @1|20862", DynamicClassAttribute.GetNomConvivial(tpListe));
                        }
                        else
                        {
                            attribs = tp.GetCustomAttributes(typeof(DynamicFormAttribute), true);
                            if (attribs.Length > 0)
                            {
                                strLibelle = ((DynamicFormAttribute)attribs[0]).Libelle;
                            }
                        }
                        if (strLibelle != "")
                        {
                            CInfoClasseDynamique info = new CInfoClasseDynamique(tp, strLibelle);
                            lstForms.Add(info);
                        }
                    }
                }
            }
            m_cmbFormulaireStandard.ProprieteAffichee = "Nom";
            m_cmbFormulaireStandard.ListDonnees       = lstForms;
            m_cmbFormulaireStandard.AssureRemplissage();
        }
Пример #6
0
        private void UpdateMenuTypeCalculCout()
        {
            if (DesignMode)
            {
                return;
            }
            if (m_menuTypeDeBesoin.DropDownItems.Count == 0)
            {
                //Crée les items
                //trouve les types implémentant ICalculCoutBesoin
                List <Type> lstTypes = new List <Type>();
                foreach (Assembly ass in CGestionnaireAssemblies.GetAssemblies())
                {
                    foreach (Type tp in ass.GetTypes())
                    {
                        if (typeof(IDonneeBesoin).IsAssignableFrom(tp) &&
                            !tp.IsAbstract)
                        {
                            lstTypes.Add(tp);
                        }
                    }
                }
                foreach (Type tp in lstTypes)
                {
                    try
                    {
                        IDonneeBesoin     c = Activator.CreateInstance(tp, new object[0]) as IDonneeBesoin;
                        ToolStripMenuItem itemTypeCalcul = new ToolStripMenuItem(c.LibelleStatique);
                        if (c.ShortKey != null)
                        {
                            m_dicShortKeysToTypeBesoin[c.ShortKey.Value] = tp;
                            string strLib = c.LibelleStatique;
                            int    nIndex = c.LibelleStatique.ToUpper().IndexOf(c.ShortKey.Value.ToString().ToUpper());
                            if (nIndex >= 0)
                            {
                                strLib = strLib.Insert(nIndex, "&");
                            }
                            itemTypeCalcul.Text = strLib;
                        }
                        itemTypeCalcul.Tag   = c;
                        itemTypeCalcul.Image = CTypeDonneeBesoin.GetImage(c.TypeDonnee);
                        m_menuTypeDeBesoin.DropDownItems.Add(itemTypeCalcul);
                        itemTypeCalcul.Click += new EventHandler(itemTypeCalcul_Click);
                    }
                    catch { }
                }
            }

            m_menuTypeDeBesoin.Enabled = !LockEdition;

            //Met à jour les actions
            CUtilMenuActionSurElement.InitMenuActions(Besoin, m_menuActions.DropDownItems,
                                                      new MenuActionEventHandler(OnActionSurBesoin));


            CBesoin besoin = Besoin;

            if (besoin != null)
            {
                foreach (ToolStripMenuItem item in m_menuTypeDeBesoin.DropDownItems)
                {
                    IDonneeBesoin c = item.Tag as IDonneeBesoin;
                    if (c != null)
                    {
                        item.Visible = c.CanApplyOn(besoin);
                    }
                }
            }
        }
Пример #7
0
        static void Main()
        {
            //Test
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            CFinalCustomerInformations.Init();

            SystemEvents.SessionEnding += SystemEvents_SessionEnding;

            Thread thSplash = new Thread(new ThreadStart(SplashScreen));

            thSplash.Start();
            //new CFormPoissonAvril().ShowDialog();
#if DEBUG
            Thread.Sleep(10000);

            //CRecepteurNotification recepteur = new CRecepteurNotification(-1, typeof(CDonneeNotificationServeurStarted));
            //recepteur.OnReceiveNotification += new NotificationEventHandler(recepteur_OnReceiveNotification);
            //Application.Run();
#endif

            System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
            CTraducteur.ReadFichier("timos.mes");

            //System.Threading.Thread.CurrentThread.ApartmentState = System.Threading.ApartmentState.STA;

            CServicePopupProgressionTimos serviceIndicateur = new CServicePopupProgressionTimos();
            IIndicateurProgression        indicateur        = null;/* = serviceIndicateur.GetNewIndicateurAndPopup();
                                                                    * indicateur.SetInfo("Démarrage");*/
#if DEBUG
#else
            try
            {
#endif

            AppDomain.CurrentDomain.Load("futurocom.win32.sig");
            AppDomain.CurrentDomain.Load("futurocom.win32.chart");
            AppDomain.CurrentDomain.Load("data.hotel.easyquery");
            AppDomain.CurrentDomain.Load("data.hotel.easyquery.win32");

            CTimosAppRegistre timosRegistre = new CTimosAppRegistre();
            CResultAErreur result           = timos.client.CInitialiseurClientTimos.InitClientTimos(timosRegistre, true, indicateur);

            /*GC.Collect();
             * GC.WaitForPendingFinalizers();
             * long nMemo = GC.GetTotalMemory(true);
             * DateTime dtChrono = DateTime.Now;
             * //for (int n = 0; n < 10000; n++)
             * {
             *  using (CContexteDonnee ctx = new CContexteDonnee(0, true, false))
             *  {
             *      for (int n = 0; n < 10000; n++)
             *      {
             *          using (CContexteDonnee ctx2 = ctx.GetContexteEdition())
             *          {
             *              CTypeAlarme tp = new CTypeAlarme(ctx2);
             *              tp.ReadIfExists(129);
             *          }
             *      }
             *  }
             * }
             * GC.Collect();
             * GC.WaitForPendingFinalizers();
             * long nMemo2 = GC.GetTotalMemory(true);
             * System.Threading.Thread.Sleep(10000);
             * TimeSpan sp = DateTime.Now - dtChrono;
             * Console.WriteLine("TEST : " + sp.TotalMilliseconds);*/


            //serviceIndicateur.EndIndicateur(indicateur);
            if (!result)
            {
                thSplash.Abort();
                result.EmpileErreur(I.T("Error while opening application|1219"));
                CFormAlerte.Afficher(result.Erreur, EFormAlerteBoutons.Ok, EFormAlerteType.Exclamation);
            }
            else
            {
                CSc2iWin32DataClient.Init(CFournisseurContexteDonnee.GetInstance());
                CReferenceObjetDonnee.SetFournisseurContexteDonnee(CFournisseurContexteDonnee.GetInstance());

                //Effet Fondu
                CEffetFonduPourFormManager.EffetActif = timosRegistre.OptionsGraphiques_FonduActif;
                if (AuthentifierUtilisateur(thSplash))
                {
                    string strVersionServeur = CTimosApp.SessionClient.SessionSurServeur.GetVersionServeur();
                    string strVersionClient  = Assembly.GetExecutingAssembly().GetName().Version.ToString();
                    if (strVersionClient != strVersionServeur)
                    {
                        result.EmpileErreur(I.T("Server (@2) and client (@1) version doesn't match. Please, update your Timos client version|20144",
                                                strVersionClient, strVersionServeur));
                        CFormAlerte.Afficher(result.Erreur);
                        CTimosApp.SessionClient.CloseSession();
                        return;
                    }
                    //Si le profil affecté n'est pas le même que le profil demandé
                    //pour l'utilisateur, affiche une boite de message indiquant
                    //la différence de profil
                    CDonneesActeurUtilisateur user = CUtilSession.GetUserForSession(CSc2iWin32DataClient.ContexteCourant);
                    if (user != null && user.IdProfilLicence.Length != 0)
                    {
                        CInfoLicenceUserProfil profil = (CInfoLicenceUserProfil)CTimosApp.SessionClient.GetPropriete(CInfoLicenceUserProfil.c_nomIdentification);
                        if (profil != null && profil.Id != user.IdProfilLicence)
                        {
                            CFormAlerte.Afficher(I.T("You are connected as @1|20023", profil.Nom), EFormAlerteType.Info);
                        }
                    }
                    bool bRestart = true;
                    foreach (Assembly ass in CGestionnaireAssemblies.GetAssemblies())
                    {
                        CGestionnaireExtendeurFormEditionStandard.RegisterExtendersInAssembly(ass);
                    }

                    C2iRegistre.InitRegistreApplication(new CTimosAppRegistre());
#if DEBUG
                    //ImporterChamps();

                    CRelationBesoin_Satisfaction.InitCachePourUnClientJamaisCotéServeur();

                    string str = "";
                    foreach (RelationTypeIdAttribute r in CContexteDonnee.RelationsTypeIds)
                    {
                        str += r.TableFille;
                        str += "\t";
                        str += r.ChampType;
                        str += Environment.NewLine;
                    }

                    Application.Run(new CFormMain());
#else
                    while (bRestart)
                    {
                        bRestart = false;

                        try
                        {
                            Application.Run(new CFormMain());
                        }
                        catch (Exception e)
                        {
                            result = CResultAErreur.True;
                            result.EmpileErreur(new CErreurException(e));
                            CFormAfficheErreur.Show(result.Erreur);
                            bRestart = true;
                        }
                    }
#endif
                }
            }
#if DEBUG
#else
        }

        catch (Exception ex)
        {
            StringBuilder bl = new StringBuilder();
            ReflectionTypeLoadException lex = ex as System.Reflection.ReflectionTypeLoadException;
            if (lex != null)
            {
                foreach (Exception ee in lex.LoaderExceptions)
                {
                    bl.Append(ee.Message.ToString());
                    bl.Append("\r\n");
                }
            }
            else
            {
                bl.Append(ex.Message.ToString( ));
            }
            CFormAlerte.Afficher(bl.ToString());
        }
#endif
        }
Пример #8
0
        //-----------------------------------------
        private void FillArbre()
        {
            using (CWaitCursor curseur = new CWaitCursor())
            {
                m_arbre.BeginUpdate();
                m_arbre.Nodes.Clear();

                System.ComponentModel.Design.ITypeDiscoveryService service =
                    (System.ComponentModel.Design.ITypeDiscoveryService)
                    m_provider.GetService(
                        typeof(System.ComponentModel.Design.ITypeDiscoveryService)
                        );

                if (service != null)
                {
                    System.Collections.ICollection coll             = service.GetTypes(typeof(object), true);
                    Dictionary <string, TreeNode>  namespacesToNode = new Dictionary <string, TreeNode>();
                    List <Type> lstTypes = new List <Type>();
                    foreach (Type tp in service.GetTypes(typeof(object), true))
                    {
                        lstTypes.Add(tp);
                    }
                    lstTypes.Sort((x, y) => x.FullName.CompareTo(y.FullName));
                    string strSearch = m_txtSearch.Text.Trim().ToUpper();
                    foreach (Type tp in lstTypes)
                    {
                        if (tp.Namespace != null)
                        {
                            if (strSearch.Length == 0 || tp.FullName.ToUpper().Contains(strSearch))
                            {
                                TreeNode nodeParent = GetNodeNamespace(null, tp.Namespace, namespacesToNode);
                                if (nodeParent != null)
                                {
                                    TreeNode nodeType = new TreeNode(tp.Name);
                                    nodeType.Tag = tp;
                                    nodeParent.Nodes.Add(nodeType);
                                }
                            }
                        }
                    }
                    m_arbre.EndUpdate();
                    return;
                }

                List <Assembly> lstAss = new List <Assembly>();
                foreach (Assembly ass in CGestionnaireAssemblies.GetAssemblies())
                {
                    lstAss.Add(ass);
                }
                lstAss.Sort((x, y) => x.FullName.CompareTo(y.FullName));
                HashSet <string> lstFaits = new HashSet <string>();
                foreach (Assembly ass in CGestionnaireAssemblies.GetAssemblies())
                {
                    if (!lstFaits.Contains(ass.FullName))
                    {
                        string[] strParts = ass.FullName.Split(',');
                        TreeNode node     = new TreeNode(strParts[0]);
                        node.Tag = ass;
                        node.Nodes.Add(new TreeNode(""));
                        m_arbre.Nodes.Add(node);
                        lstFaits.Add(ass.FullName);
                    }
                }
                m_arbre.EndUpdate();
            }
        }
Пример #9
0
        //----------------------------------------------------------------
        public void Init(Type typeObjetPourForm)
        {
            if (typeObjetPourForm == m_typeObjets)
            {
                return;
            }
            m_typeObjets = typeObjetPourForm;
            List <CReferenceTypeForm> lstRefsTypes = new List <CReferenceTypeForm>();

            // Init liste des formulaires standards
            List <CInfoClasseDynamique> lstForms = new List <CInfoClasseDynamique>();

            // Cherche tous les formulaires d'édition correspondants au type
            foreach (Assembly ass in CGestionnaireAssemblies.GetAssemblies())
            {
                foreach (Type tp in ass.GetTypes())
                {
                    if (!tp.IsAbstract && tp.IsSubclassOf(typeof(System.Windows.Forms.Form)))
                    {
                        Type     tpEdite    = null;
                        string   strLibelle = "";
                        object[] attribs    = tp.GetCustomAttributes(typeof(ObjectEditeur), true);
                        if (attribs.Length > 0)
                        {
                            ObjectEditeur attrib = (ObjectEditeur)attribs[0];
                            tpEdite    = attrib.TypeEdite;
                            strLibelle = DynamicClassAttribute.GetNomConvivial(tpEdite) + " - " + attrib.Code;
                        }
                        if (tpEdite == typeObjetPourForm && strLibelle != "")
                        {
                            CReferenceTypeFormBuiltIn refBin = new CReferenceTypeFormBuiltIn(tp);
                            lstRefsTypes.Add(refBin);
                        }
                    }
                }
            }


            // Iinit liste des formulaires custom
            CListeObjetsDonnees lstFormulaires = new CListeObjetsDonnees(CSc2iWin32DataClient.ContexteCourant, typeof(CFormulaire));

            lstFormulaires.Filtre = new CFiltreData(
                CFormulaire.c_champTypeElementEdite + " = @1 AND " +
                CFormulaire.c_champCodeRole + " is null",
                typeObjetPourForm.ToString());
            foreach (CFormulaire formulaire in lstFormulaires)
            {
                //Elimine les formulaires en surimpression
                if (formulaire.Libelle.Contains("."))
                {
                    Type tp = CActivatorSurChaine.GetType(formulaire.Libelle);
                    if (tp != null)
                    {
                        continue;
                    }
                }
                CReferenceTypeFormDynamic refDync = new CReferenceTypeFormDynamic(formulaire);
                lstRefsTypes.Add(refDync);
            }


            m_comboRefTypeForm.Fill(
                lstRefsTypes,
                "Libelle",
                true);
            m_comboRefTypeForm.AssureRemplissage();
            if (m_typeSelectionne != null)
            {
                m_comboRefTypeForm.SelectedValue = m_typeSelectionne;
            }
        }
Пример #10
0
        //------------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Se base sur le champ PRT_COST_TO_RECALCULATE pour savoir ce qu'il faut recalculer
        /// </summary>
        /// <param name="contexte"></param>
        /// <returns></returns>
        public static CResultAErreur RecalculeCoutsARecalculer(CContexteDonnee contexte)
        {
            CResultAErreur result = CResultAErreur.True;

            if (m_listeTypesElementsACouts == null)
            {
                m_listeTypesElementsACouts = new List <Type>();
                foreach (Assembly ass in CGestionnaireAssemblies.GetAssemblies())
                {
                    foreach (Type tp in ass.GetTypes())
                    {
                        if (typeof(IElementACout).IsAssignableFrom(tp))
                        {
                            m_listeTypesElementsACouts.Add(tp);
                        }
                    }
                }
            }
            List <IElementACout> lstARecalculerReel         = new List <IElementACout>();
            List <IElementACout> lstARecalculerPrevisionnel = new List <IElementACout>();

            foreach (Type tp in m_listeTypesElementsACouts)
            {
                string    strNomTable = CContexteDonnee.GetNomTableForType(tp);
                DataTable table       = contexte.Tables[strNomTable];
                if (table != null)
                {
                    DataRow[] rows = table.Select(c_champCoutsParentsARecalculer + "<>0");
                    foreach (DataRow row in rows)
                    {
                        IElementACout elt = Activator.CreateInstance(tp, new object[] { row }) as IElementACout;
                        if ((elt.TypesCoutsParentsARecalculer & ETypeCout.réel) == ETypeCout.réel)
                        {
                            lstARecalculerReel.Add(elt);
                        }
                        if ((elt.TypesCoutsParentsARecalculer & ETypeCout.Prévisionnel) == ETypeCout.Prévisionnel)
                        {
                            lstARecalculerPrevisionnel.Add(elt);
                        }
                    }
                    //Récupère également les lignes supprimées
                    rows = table.Select("", "", DataViewRowState.Deleted);
                    foreach (DataRow row in rows)
                    {
                        IElementACout elt = Activator.CreateInstance(tp, new object[] { row }) as IElementACout;
                        lstARecalculerPrevisionnel.Add(elt);
                        lstARecalculerReel.Add(elt);
                    }
                }
            }
            DataTable tableRels = contexte.Tables[CRelationBesoin_Satisfaction.c_nomTable];

            if (tableRels != null)
            {
                DataRow[] rowsRels = tableRels.Select("", "", DataViewRowState.Added | DataViewRowState.Deleted);
                foreach (DataRow row in rowsRels)
                {
                    CRelationBesoin_Satisfaction rel = new CRelationBesoin_Satisfaction(row);
                    if (row.RowState == DataRowState.Deleted)
                    {
                        rel.VersionToReturn = DataRowVersion.Original;
                    }
                    IElementACout elt = rel.Satisfaction;
                    lstARecalculerPrevisionnel.Add(elt);
                    lstARecalculerReel.Add(elt);
                }
            }



            HashSet <DataRow> setCalcules = new HashSet <DataRow>();

            foreach (IElementACout elt in lstARecalculerPrevisionnel)
            {
                RecalcCoutMontant(elt, false, setCalcules);
            }

            setCalcules = new HashSet <DataRow>();
            foreach (IElementACout elt in lstARecalculerReel)
            {
                RecalcCoutMontant(elt, true, setCalcules);
            }


            return(result);
        }