Esempio n. 1
0
        //--------------------------------------------------------------------------
        public CResultAErreur CreateUpdateObjet(object objet)
        {
            CResultAErreur result = CResultAErreur.True;

            if (!IsMySelf())
            {
                ISnmpConnexion cnxDisttante = GetConnexionDistante();
                if (cnxDisttante != null)
                {
                    return(cnxDisttante.CreateUpdateObjet(objet));
                }
                result.EmpileErreur(I.T("Can not reach host @1|20009", EndPoint.Address.ToString()));
                return(result);
            }
            if (objet is CSnmpProxyConfiguration)
            {
                CSnmpProxyConfiguration.SetDefaultInstance((CSnmpProxyConfiguration)objet);
            }
            if (objet is CValiseEntiteDeMemoryDb)
            {
                objet = ((CValiseEntiteDeMemoryDb)objet).Entite;
            }
            if (objet is CEntiteDeMemoryDb)
            {
                result = CServiceMediation.GetDefaultInstance().Configuration.UpdateEntite(objet as sc2i.common.memorydb.CEntiteDeMemoryDb);
            }

            return(result);
        }
Esempio n. 2
0
 //---------------------------------------------------
 public void SetConfigurationDeSnmpProxy(CSnmpProxyConfiguration config)
 {
     if (IsMySelf())
     {
         if (config != null)
         {
             CSnmpProxyConfiguration.SetDefaultInstance(config);
         }
     }
     else
     {
         ISnmpConnexion cnx = GetConnexionDistante();
         if (cnx != null)
         {
             cnx.SetConfigurationDeSnmpProxy(config);
         }
     }
 }
Esempio n. 3
0
        /// ///////////////////////////////////////////////////////////
        public static CResultAErreur InitClientTimos(
            string strServeurUrl,
            int nTcpChannel,
            string strBindTo,
            IIndicateurProgression indicateurProgression)
        {
            CResultAErreur result = CResultAErreur.True;

            try
            {
                AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

                //SUPPRIMé journal d'évenements: sur les postes clients qui ne sont pas autorisés
                //à créer un journal d'évenements, ça bloque, et comme ce n'est pas
                //très important sur un poste client, il n'y a plus
                //de journal d'évenements TIMOS sur les postes clients.
                //C2iEventLog.Init("", "Client Timos", NiveauBavardage.VraiPiplette);

                m_strUrlServeurMain = strServeurUrl;
                m_nPortServeur      = nTcpChannel;
                result = CSC2iMultitiersClient.Init(m_nPortServeur, m_strUrlServeurMain, strBindTo);

                LifetimeServices.LeaseTime            = new TimeSpan(0, 5, 0);
                LifetimeServices.LeaseManagerPollTime = new TimeSpan(0, 5, 0);
                LifetimeServices.SponsorshipTimeout   = new TimeSpan(0, 3, 0);
                LifetimeServices.RenewOnCallTime      = new TimeSpan(0, 8, 0);

                /*LifetimeServices.LeaseTime = new TimeSpan(0, 0, 3);
                 * LifetimeServices.LeaseManagerPollTime = new TimeSpan(0, 0, 10);
                 * LifetimeServices.SponsorshipTimeout = new TimeSpan(0, 0, 10);
                 * LifetimeServices.RenewOnCallTime = new TimeSpan(0, 0, 5);*/

                /*if ( !result )
                 * {
                 *      //On ne parvient pas à contacter le serveur primaire, s'adresse au serveur secondaire
                 *      result = CSC2iMultitiersClient.Init (
                 *              m_nPortServeur,
                 *              m_strUrlServeurSecondaire);
                 *      if ( result )
                 *              CSessionClient.AfterOpenSession += new SessionEventHandler(AfterOpenSessionModeDeconnecte);
                 * }
                 * else
                 * {
                 *      if ( bAvecSynchronisation && m_strUrlServeurSecondaire != "")
                 *      {
                 *              //On a contacté le serveur primaire, tente une synchronisation
                 *              result = SynchroniseSecondaireToMain( indicateurProgression );
                 *              if ( !result )
                 *                      return result;
                 *              CSessionClient.BeforeClosingSession += new SessionEventHandler(BeforeCloseSessionModeConnecte);
                 *      }
                 * }*/
                if (!result)
                {
                    return(result);
                }


                C2iSponsor.EnableSecurite();
                //			System.Runtime.Remoting.RemotingConfiguration.Configure (strFichierConfig);
                //			sc2i.multitiers.client.C2iFactory.InitFromFile(strFichierConfig);

                AppDomain.CurrentDomain.Load("sc2i.data.client");
                AppDomain.CurrentDomain.Load("sc2i.data.dynamic");
                AppDomain.CurrentDomain.Load("timos.data");
                AppDomain.CurrentDomain.Load("sc2i.process");
                AppDomain.CurrentDomain.Load("sc2i.documents");
                AppDomain.CurrentDomain.Load("futurocom.sig");
                AppDomain.CurrentDomain.Load("data.hotel.client");

                #region Chargement des plugins

                CGestionnairePlugins.InitPlugins(AppDomain.CurrentDomain.BaseDirectory, "plg");
                // Initialilsation des plugins à partir de TIMOS_REGISTRY
                CDataBaseRegistrePourClient registre = new CDataBaseRegistrePourClient(0);
                string strFUT_CLT = registre.GetValeurString("FUT_CLT", "");
                if (strFUT_CLT.Trim() != string.Empty)
                {
                    List <string> listPluginFiles = new List <string>();
                    foreach (string strNomPlg in strFUT_CLT.Split(';'))
                    {
                        string strTmp = AppDomain.CurrentDomain.BaseDirectory + strNomPlg;
                        if (File.Exists(strTmp))
                        {
                            listPluginFiles.Add(strTmp);
                        }
                    }
                    CGestionnairePlugins.LoadPlugins(listPluginFiles.ToArray());
                }


                #endregion

                foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies())
                {
                    CContexteDonnee.AddAssembly(ass);
                }

                AppDomain.CurrentDomain.AssemblyLoad += new AssemblyLoadEventHandler(OnLoadAssembly);

                CGestionnaireObjetsAttachesASession.OnAttacheObjet += new LinkObjectEventHandler(OnAttacheObjectASession);

                CAutoexecuteurClasses.RunAllAutoexecs();

                CVersionDonneesObjet.EnableJournalisation = true;

                // Création d'une Configuration SNMP par défaut
                // Redirige tout vers le Serveur Timos (entant que Proxy par défaut)
                CSnmpProxyConfiguration configurationDefaut = new CSnmpProxyConfiguration();
                CPlageIP plageToutes = new CPlageIP("255.255.255.255", 32);

                CSnmpProxy proxyDefaut = new CSnmpProxy(configurationDefaut.Database);
                proxyDefaut.CreateNew();
                string strIp   = strServeurUrl.Substring(strServeurUrl.IndexOf("//") + 2);
                string strPort = strIp.Substring(strIp.IndexOf(':') + 1);
                strIp = strIp.Substring(0, strIp.IndexOf(':'));
                try
                {
                    proxyDefaut.AdresseIP = new IP(strIp).ToIPAddress();
                }
                catch
                {
                    try
                    {
                        IPHostEntry entry = Dns.GetHostEntry(strIp);
                        if (entry != null)
                        {
                            foreach (IPAddress adr in entry.AddressList)
                            {
                                //Cherche une IP V4 dans les paramètres
                                string strIpTest = adr.ToString();
                                Regex  ex        = new Regex(@"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b");
                                if (ex.IsMatch(strIpTest))
                                {
                                    proxyDefaut.AdresseIP = adr;
                                    break;
                                }
                            }
                        }
                    }
                    catch { }
                }
                proxyDefaut.Port = Int32.Parse(strPort);
                proxyDefaut.AddPlage(plageToutes);

                CDataHotelClient.InitForUseProxy(m_strUrlServeurMain);

                CSnmpProxyConfiguration.SetDefaultInstance(configurationDefaut);
                CSnmpConnexion.ToutPasserParDesProxies = true;
            }
            catch (ReflectionTypeLoadException loadex)
            {
                result.EmpileErreur(new CErreurException(loadex));
                StringBuilder bl = new StringBuilder();
                foreach (Exception exSub in loadex.LoaderExceptions)
                {
                    bl.AppendLine(exSub.Message);
                    FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
                    if (exFileNotFound != null && !string.IsNullOrEmpty(exFileNotFound.FusionLog))
                    {
                        bl.AppendLine("Not found : " + exFileNotFound.FusionLog);
                    }
                }
                result.EmpileErreur(bl.ToString());
            }
            catch (Exception e)
            {
                StringBuilder bl = new StringBuilder();
                ReflectionTypeLoadException lex = e 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(e.Message.ToString());
                }
                result.EmpileErreur(bl.ToString());
            }

            return(result);
        }