static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); AppDomain.CurrentDomain.Load("TimosInventory.data"); CTraducteur.ReadFichier("TimosInventory.mes"); CAutoexecuteurClasses.RunAllAutoexecs(); Application.Run(new CFormMain()); }
/// <summary> /// Traduit le contrôle et tous les contrôles contenus /// </summary> /// <param name="typePourMessages"></param> /// <param name="ctrl"></param> public static void Translate(Type typePourMessages, object obj) { try { if (obj == null) { return; } TraducMessages(typePourMessages, obj); Type tp = typePourMessages; if ((obj is UserControl || obj is Form) && obj.GetType() != typePourMessages && CTraducteur.HasTraductionsForType(obj.GetType())) { tp = obj.GetType(); } TraducFils(tp, obj); } catch { } }
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 }
public static CResultAErreur Init( string strEventJournalName, string strEventJournalTexte, IIndicateurProgression indicateurProgress) { CResultAErreur result = CResultAErreur.True; try { int nValeurIndicateur = 0; C2iEventLog.Init(strEventJournalName, strEventJournalTexte, NiveauBavardage.VraiPiplette); CConteneurIndicateurProgression indicateur = CConteneurIndicateurProgression.GetConteneur(indicateurProgress); if (indicateur != null) { indicateur.PushSegment(0, 13); } CTraducteur.ReadFichier(""); #region Configuration du remoting indicateur.SetValue(nValeurIndicateur++); AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); C2iSponsor.EnableSecurite(); #endregion #region Configuration de l'allocateur d'objets Dictionary <string, MarshalByRefObject> dicLocalSingleton = new Dictionary <string, MarshalByRefObject>(); dicLocalSingleton["sc2i.multitiers.client.IGestionnaireSessions"] = new CGestionnaireSessionSagexProSolo(); C2iFactory.InitEnLocal(new C2iObjetServeurFactory(), dicLocalSingleton); indicateur.SetValue(nValeurIndicateur++); CSessionClient session = CSessionClient.CreateInstance(); result = session.OpenSession(new CAuthentificationSessionServer(), "SagexProSolo", ETypeApplicationCliente.Service); if (!result) { result.EmpileErreur(I.T("Opening session error|30010")); return(result); } CSc2iDataServer.AddDefinitionConnexion( new CDefinitionConnexionDataSource( c_droitsDataSource, typeof(CGestionnaireDroitsUtilisateurs), "")); CSc2iDataServer.SetIdConnexionForClasse(typeof(CDroitUtilisateurServeur), c_droitsDataSource); #endregion #region Configuration de la base de données indicateur.SetValue(nValeurIndicateur++); Type typeConnexion = typeof(CAccess97DatabaseConnexion); //Récuperation du type de connection CSc2iDataServer.Init( new CDefinitionConnexionDataSource( c_mainDataSource, typeConnexion, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"C:\\Documents and Settings\\GENERIC\\Mes documents\\BASEVIDE2000.MDB\"", "")); #endregion #region Ajout des références DLL indicateur.SetValue(nValeurIndicateur++); AppDomain.CurrentDomain.Load("sc2i.data.client"); AppDomain.CurrentDomain.Load("sc2i.data.serveur"); AppDomain.CurrentDomain.Load("sc2i.data.dynamic"); AppDomain.CurrentDomain.Load("sc2i.data.dynamic.loader"); AppDomain.CurrentDomain.Load("sc2i.process"); AppDomain.CurrentDomain.Load("sc2i.process.serveur"); AppDomain.CurrentDomain.Load("sc2i.expression"); AppDomain.CurrentDomain.Load("sc2i.Formulaire"); AppDomain.CurrentDomain.Load("futurocom.vectordb.data"); AppDomain.CurrentDomain.Load("futurocom.vectordb.data.server"); AppDomain.CurrentDomain.Load("futurocomapp.data"); AppDomain.CurrentDomain.Load("futurocomapp.data.server"); AppDomain.CurrentDomain.Load("sagexpro.data"); AppDomain.CurrentDomain.Load("sagexpro.data.serveur"); foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) { CContexteDonnee.AddAssembly(ass); } #endregion #region Teste la connexion indicateur.SetValue(nValeurIndicateur++); IDatabaseConnexion cnx = CSc2iDataServer.GetInstance().GetDatabaseConnexion(session.IdSession, c_mainDataSource); //Attend la connexion pendant au max 5 minutes pour que ça démarre DateTime dtStartAttente = DateTime.Now; TimeSpan delaiAttente = DateTime.Now - dtStartAttente; result = cnx.IsConnexionValide(); while (!result && delaiAttente.TotalSeconds < 5 * 60) { C2iEventLog.WriteErreur(result.MessageErreur); delaiAttente = DateTime.Now - dtStartAttente; C2iEventLog.WriteErreur(I.T("Connection not availiable(@1)|30014", delaiAttente.TotalSeconds.ToString() + " s)") + Environment.NewLine); string messageErreur = I.T("The connection with the database could not have been established. Verify the connection string and check if the database has been started|30015"); C2iEventLog.WriteErreur(messageErreur); result.EmpileErreur(messageErreur); return(result); } if (typeof(CSqlDatabaseConnexion).IsAssignableFrom(typeConnexion)) { cnx.RunStatement("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED"); } #endregion //Initialisation des classes autoexecutables CAutoexecuteurClasses.RunAutoexecs(); //Initialisation du serveur de documents GED //Initialise les restrictions standards #region Vérifie que les champs des tables font bien moins de 25 cars indicateur.SetValue(nValeurIndicateur++); DateTime dt = DateTime.Now; foreach (Type tp in CContexteDonnee.GetAllTypes()) { CStructureTable structure = CStructureTable.GetStructure(tp); if (structure.NomTable.Length > 25) { result.EmpileErreur("Table " + structure.NomTable + " (" + tp.ToString() + ")=" + structure.NomTable.Length + "cars"); } if (structure.NomTable.ToUpper() != structure.NomTable) { result.EmpileErreur(I.T("Table name @1 must be uppercase|30018", structure.NomTable)); } foreach (CInfoChampTable champ in structure.Champs) { if (champ.NomChamp.Length > 25) { result.EmpileErreur("Table " + structure.NomTable + " (" + tp.ToString() + ")\t champ " + champ.NomChamp + "=" + champ.NomChamp.Length + "cars"); } if (champ.NomChamp.ToUpper() != champ.NomChamp) { result.EmpileErreur(I.T("The name of the field '@1' of the field '@2' must be uppercase|30019", champ.NomChamp, structure.NomTable)); } } } TimeSpan sp = DateTime.Now - dt; Console.WriteLine(I.T("Table name verification |30020") + sp.TotalMilliseconds); if (!result) { return(result); } #endregion #region Mise à jour de la structure de la base indicateur.SetValue(nValeurIndicateur++); CUpdaterDataBase updaterDataBase = CUpdaterDataBase.GetInstance(cnx, new CSagexproStructureBase()); //S'assure que la gestion des éléments est initialisé dans les licences //CLicenceCheckElementNb.GetInstance(); result = updaterDataBase.UpdateStructureBase(indicateur); if (!result) { return(result); } #endregion //Restrictions sur applications //Initialisation du serveur de documents GED //Initialisation de la base d'utilisateurs AD //CAdBase.Init(CfuturocomappServeurRegistre.RacineAd,"",""); //Initialise les fournisseurs de services //CSessionClientSurServeur.RegisterFournisseur( new CFournisseurFiltresForSynchronisation() ); CGestionnaireEvenements.Init(); if (!result) { return(result); } //CGestionnaireObjetsAttachesASession.OnAttacheObjet += new LinkObjectEventHandler(CGestionnaireObjetsAttachesASession_OnAttacheObjet); } catch (Exception e) { result.EmpileErreur(new CErreurException(e)); } return(result); }
/// <summary> /// Applique les traductions spécifiques suivant le type de contrôle /// </summary> /// <param name="ctrl"></param> private static void TraducMessages(Type typePourMessages, object ctrl) { if (!m_bTableProprietesIsInit) { InitTableProprietes(); } Type tpControle = ctrl.GetType(); List <PropertyInfo> lst = (List <PropertyInfo>)m_tableGetPropATraduire[tpControle]; if (lst == null) { //créé la liste de propriétés spécifiques à traduire pour ce type de contrôle lst = new List <PropertyInfo>(); Type tp = tpControle; while (tp != null) { List <PropertyInfo> lstPropsType = (List <PropertyInfo>)m_tableGetPropATraduire[tp]; if (lstPropsType != null) { lst.AddRange(lstPropsType); } tp = tp.BaseType; } if (ctrl is IControlTraductible) { List <string> lstProps = ((IControlTraductible)ctrl).GetListeProprietesATraduire(); if (lstProps != null) { foreach (string strPropriete in lstProps) { PropertyInfo info = tpControle.GetProperty(strPropriete); if (info != null && typeof(string).IsAssignableFrom(info.PropertyType) && info.GetGetMethod() != null && info.GetSetMethod() != null) { if (!lst.Contains(info)) { lst.Add(info); } } } } } m_tableGetPropATraduire[tpControle] = lst; } foreach (PropertyInfo prop in lst.ToArray()) { try { string strVal = (string)prop.GetValue(ctrl, null); if (strVal.Contains("|")) { Type tp = typePourMessages; if (ctrl.GetType() != typePourMessages && CTraducteur.HasTraductionsForType(ctrl.GetType())) { tp = ctrl.GetType(); } prop.SetValue(ctrl, I.TT(tp, strVal), null); } } catch { } } //Traduction de variables membres Type tpTmp = tpControle; List <FieldInfo> lstFields = null; m_tableFieldATraduire.TryGetValue(tpControle, out lstFields); if (lstFields == null) { lstFields = new List <FieldInfo>(); Dictionary <Type, bool> dicTypesMembresATraduire = new Dictionary <Type, bool>(); while (tpTmp != null) { List <Type> lstTypesVariablesMembres = (List <Type>)m_tableVariablesMembresATraduire[tpTmp]; if (lstTypesVariablesMembres != null) { foreach (Type tp in lstTypesVariablesMembres) { dicTypesMembresATraduire[tp] = true; } } tpTmp = tpTmp.BaseType; } FieldInfo[] fields = tpControle.GetFields(BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); foreach (FieldInfo field in fields) { Type tp = field.FieldType; if (dicTypesMembresATraduire.ContainsKey(tp)) { lstFields.Add(field); } } m_tableFieldATraduire[tpControle] = lstFields; } foreach (FieldInfo field in lstFields) { try { object obj = field.GetValue(ctrl); if (obj != null) { Translate(field.DeclaringType, obj); } } catch { } } }