コード例 #1
0
        //------------------------------------------------------------
        static CResultAErreur CContexteDonneeServeur_DoTraitementExterneApresSauvegarde(CContexteDonnee contexte, Hashtable tableData)
        {
            CResultAErreur    result = CResultAErreur.True;
            HashSet <DataRow> proxyAMediationModifiee = contexte.ExtendedProperties[c_cleMediationModifiee] as HashSet <DataRow>;

            if (proxyAMediationModifiee == null)
            {
                return(result);
            }
            CSynchroniseurBaseDistante synchro = CSynchroniseurBaseDistante.GetSynchroniseur(contexte.IdSession);

            foreach (DataRow row in proxyAMediationModifiee)
            {
                if (row[CSnmpProxyInDb.c_champSnmpIp] != DBNull.Value)
                {
                    COperationSynchronisationSurAgentSynchronisation op = new COperationSynchronisationSurAgentSynchronisation(
                        typeof(CNotifieurMiseAJourProxySnmp),
                        row[CSnmpProxyInDb.c_champSnmpIp] + "/" +
                        row[CSnmpProxyInDb.c_champId],
                        EOperationSynchronisationSurAgentSynchronisation.CreateOrUpdate,
                        row[CSnmpProxyInDb.c_champId].ToString());
                    synchro.AddOperation(contexte.IdSession,
                                         row[CSnmpProxyInDb.c_champSnmpIp].ToString(), op);
                }
            }
            HashSet <DataRow>        proxyAConfigurationModifee = contexte.ExtendedProperties[c_cleConfigModifiee] as HashSet <DataRow>;
            HashSet <CSnmpProxyInDb> proxysAMettreAJour         = new HashSet <CSnmpProxyInDb>();

            foreach (DataRow row in proxyAConfigurationModifee)
            {
                CSnmpProxyInDb proxy = new CSnmpProxyInDb(contexte);
                try{
                    if (proxy.ReadIfExists((int)row[CSnmpProxyInDb.c_champId]))
                    {
                        FillHashSetProxiesAMettreAJour(proxy, proxysAMettreAJour);
                    }
                }
                catch
                {
                }
            }
            foreach (CSnmpProxyInDb proxy in proxysAMettreAJour)
            {
                CSynchroniseurBaseDistante.GetSynchroniseur(contexte.IdSession).AddOperation(
                    contexte.IdSession,
                    proxy.CleBaseDistante,
                    new COperationSynchronisationSurAgentSynchronisation(
                        typeof(CSnmpConfigurationSynchroniseur),
                        proxy.AdresseIp,
                        EOperationSynchronisationSurAgentSynchronisation.CreateOrUpdate,
                        proxy.Id.ToString()));
            }


            contexte.ExtendedProperties.Remove(c_cleMediationModifiee);
            contexte.ExtendedProperties.Remove(c_cleConfigModifiee);

            return(result);
        }
コード例 #2
0
        //----------------------------------------------------------------------------------
        public void DoOperationAsynchrone(IOperationSynchronisation operation, int nIdSession)
        {
            CSnmpProxyInDb proxy = new CSnmpProxyInDb(CContexteDonneeSysteme.GetInstance());

            if (proxy.ReadIfExists(Int32.Parse(operation.IdElementASynchroniser)))
            {
                CSnmpProxyConfiguration configurationAEnvoyer = proxy.GetConfiguration();
                if (configurationAEnvoyer != null)
                {
                    CAppeleurFonctionAvecDelai.CallFonctionAvecDelai(
                        GetConnexion(),
                        "CreateUpdateObjet", 1,
                        configurationAEnvoyer);
                }
            }
        }
コード例 #3
0
 public CSnmpProxyConfiguration GetConfigurationDeProxy(int nIdProxy)
 {
     using (CSessionClient session = CSessionClient.CreateInstance())
     {
         CResultAErreur result = session.OpenSession(new CAuthentificationSessionProcess());
         if (!result)
         {
             return(null);
         }
         using (CContexteDonnee ctx = new CContexteDonnee(session.IdSession, true, false))
         {
             CSnmpProxyInDb proxy = new CSnmpProxyInDb(ctx);
             if (proxy.ReadIfExists(nIdProxy))
             {
                 return(proxy.GetConfiguration());
             }
         }
     }
     return(null);
 }
コード例 #4
0
        //------------------------------------------------------------
        public static CResultAErreur CContexteDonneeServeur_DoTraitementExterneAvantSauvegarde(CContexteDonnee contexte, Hashtable tableData)
        {
            CResultAErreur    result = CResultAErreur.True;
            HashSet <DataRow> proxyAConfigModifiee   = new HashSet <DataRow>();
            HashSet <DataRow> proxyAMediationModifee = new HashSet <DataRow>();
            bool bAll = false;

            foreach (DataTable table in new ArrayList(contexte.Tables))
            {
                Type tp = CContexteDonnee.GetTypeForTable(table.TableName);
                if (typeof(IElementADonneePourMediationSNMP).IsAssignableFrom(tp))
                {
                    foreach (DataRow row in table.Rows)
                    {
                        if (
                            row.RowState == DataRowState.Added ||
                            row.RowState == DataRowState.Modified ||
                            row.RowState == DataRowState.Deleted)
                        {
                            IElementADonneePourMediationSNMP elt = contexte.GetNewObjetForRow(row) as IElementADonneePourMediationSNMP;
                            if (row.RowState == DataRowState.Deleted)
                            {
                                ((CObjetDonnee)elt).VersionToReturn = DataRowVersion.Original;
                            }
                            try
                            {
                                for (int nPasse = 0; nPasse < 2; nPasse++)
                                {
                                    HashSet <DataRow> dataRows = null;
                                    int[]             elts;
                                    if (nPasse == 0)
                                    {
                                        elts     = elt.IdsProxysConcernesParDonneesMediation;
                                        dataRows = proxyAMediationModifee;
                                    }
                                    else
                                    {
                                        elts     = elt.IdsProxysConcernesParConfigurationProxy;
                                        dataRows = proxyAConfigModifiee;
                                    }
                                    if (elts == null)
                                    {
                                        CListeObjetsDonnees lstProxys = new CListeObjetsDonnees(contexte, typeof(CSnmpProxyInDb));
                                        foreach (CSnmpProxyInDb proxy in lstProxys)
                                        {
                                            dataRows.Add(proxy.Row.Row);
                                        }
                                        bAll = true;
                                        break;
                                    }
                                    else
                                    {
                                        foreach (int nIdProxy in elts)
                                        {
                                            CSnmpProxyInDb proxy = new CSnmpProxyInDb(contexte);
                                            if (proxy.ReadIfExists(nIdProxy))
                                            {
                                                dataRows.Add(proxy.Row);
                                            }
                                        }
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                }
                if (bAll)
                {
                    break;
                }
            }

            if (proxyAMediationModifee.Count > 0 || proxyAConfigModifiee.Count > 0)
            {
                contexte.ExtendedProperties[c_cleMediationModifiee] = proxyAMediationModifee;
                contexte.ExtendedProperties[c_cleConfigModifiee]    = proxyAConfigModifiee;
            }

            return(result);
        }