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 override CResultAErreur TraitementAvantSauvegarde(CContexteDonnee ds) { CResultAErreur result = base.TraitementAvantSauvegarde(ds); CDonneesActeurUtilisateur userConnecte = CDonneesActeurUtilisateur.GetUserForSession(ds.IdSession, ds); CSessionClient session = CSessionClient.GetSessionForIdSession(IdSession); // Un utilisateur ne peut pas affecter un Profil de Licence à un autre utilisateur, // si ce profil est plus fort que le sien CInfoLicenceUserProfil profil = (CInfoLicenceUserProfil)session.GetPropriete(CInfoLicenceUserProfil.c_nomIdentification); //envoie les notifications sur modification de données utilisateur DataTable table = ds.Tables[GetNomTable()]; foreach (DataRow row in table.Rows) { if (row.RowState != DataRowState.Unchanged) { if (userConnecte != null) { // Vérifie premièrement que l'utilisateur connecté à le droit de gestion de utilisateurs if (userConnecte.GetDonneeDroit(CDroitDeBase.c_droitBaseGestionUtilisateurs) == null) { result.EmpileErreur(I.T("You don't have System Right to Manage Application Users|10012")); return(result); } } } if (row.RowState == DataRowState.Added || row.RowState == DataRowState.Modified) { if (userConnecte != null) { // Verifie ensuite que l'utilisteur connecté tente de donner un droit qu'il n'a pas ! CDonneesActeurUtilisateur user = new CDonneesActeurUtilisateur(row); foreach (CRelationActeurUtilisateur_Droit relDroit in user.RelationsDroits) { if (userConnecte.GetDonneeDroit(relDroit.Droit.Code) == null) { result.EmpileErreur(I.T("You don't have right to affect this system Right : @1|10019", relDroit.Droit.Libelle)); return(result); } } // Vérifie que l'utilisateur connecté ne tente pas d'affecter un profil de licence supérieur au sien string strIdProfil = user.IdProfilLicence; CInfoLicenceUserProfil profilModifie = CGestionnaireProfilLicenceSurClient.GetProfil(strIdProfil); if (profil == null || profilModifie != null && profilModifie.Priorite > profil.Priorite) { result.EmpileErreur(I.T("You can not affect a Licence Profile greater than your Profile : @1|20140", profilModifie.Nom)); } } //TESTDBKEYOK CDonneeNotificationChangementDroitUtilisateur notDroit = new CDonneeNotificationChangementDroitUtilisateur(IdSession, CDbKey.CreateFromStringValue((string)row[CDonneesActeurUtilisateur.c_champIdUniversel])); CEnvoyeurNotification.EnvoieNotifications(new IDonneeNotification[] { notDroit }); } } return(result); }