//--------------------------------------------- /// ///////////////////////////////////////////// public CAgentSnmpPourSupervision GetAgentPourSupervision(CMemoryDb database, bool bAvecEntites) { if (database == null) { database = CMemoryDbPourSupervision.GetMemoryDb(ContexteDonnee); } CAgentSnmpPourSupervision agent = new CAgentSnmpPourSupervision(database); if (!agent.ReadIfExist(Id.ToString(), false)) { agent.CreateNew(Id.ToString()); } else if (!agent.IsToRead()) { return(agent); } agent.Row[CMemoryDb.c_champIsToRead] = false; CTypeAgentPourSupervision typeAgent = TypeAgent.GetTypeAgentPourSupervision(database); agent.TypeAgent = typeAgent; agent.Ip = SnmpIp; agent.Timeout = Timeout; agent.SnmpPort = SnmpPort; agent.SnmpVersion = SnmpVersion; agent.Communaute = SnmpCommunaute; agent.TrapsIpString = TrapsIpsString; foreach (CSnmpPollingSetup setup in ParametresPolling) { CSnmpPollingSetup newSetup = database.ImporteObjet(setup, true, false) as CSnmpPollingSetup; newSetup.Agent = agent; } foreach (CSnmpHotelPollingSetup setup in ParametresHotelPolling) { CSnmpHotelPollingSetup newSetup = database.ImporteObjet(setup, true, false) as CSnmpHotelPollingSetup; newSetup.Agent = agent; } if (bAvecEntites) { foreach (CEntiteSnmp entite in EntitesSnmp) { if (entite.EntiteSnmpParente == null) { CTypeEntiteSnmpPourSupervision typeEntite = typeAgent.TypesEntites.FirstOrDefault(te => te.Id == entite.TypeEntiteSnmp.Id.ToString()); if (typeEntite != null) { CEntiteSnmpPourSupervision ett = entite.GetEntitePourSupervision(typeEntite); if (ett != null) { ett.AgentSnmp = agent; } } } } } return(agent); }
/// ///////////////////////////////////////////////////////// public CTypeAgentPourSupervision GetTypeAgentPourSupervision(CMemoryDb database) { if (database == null) { database = CMemoryDbPourSupervision.GetMemoryDb(ContexteDonnee); } CTypeAgentPourSupervision typeAgent = new CTypeAgentPourSupervision(database); if (!typeAgent.ReadIfExist(Id.ToString(), false)) { typeAgent.CreateNew(Id.ToString()); } else if (!typeAgent.IsToRead()) { return(typeAgent); } typeAgent.Row[CMemoryDb.c_champIsToRead] = false; foreach (CEasyQuery query in Queries) { typeAgent.AddQuery(query); } typeAgent.Fonctions = FonctionsDynamiques; foreach (CTrapHandler handler in TrapHandlers) { database.ImporteObjet(handler, true, false); } foreach (CTypeEntiteSnmp typeEntite in TypesEntites) { if (typeEntite.TypeParent == null) { typeEntite.GetTypeEntitePourSupervision(database, true); } } foreach (CAgentFinderFromKey finder in AgentFinders) { database.ImporteObjet(finder, true, false); } return(typeAgent); }
//-------------------------------------------------------------- public CEntiteDeMemoryDb GetEntite(Type typeEntite, string strId, CMemoryDb db) { if (typeEntite == typeof(CLocalTypeAlarme)) { CLocalTypeAlarme ta = GetTypeAlarme(strId); if (ta != null) { ta = db.ImporteObjet(ta, true, false) as CLocalTypeAlarme; } return(ta); } return(null); }
public void Init( CTrapHandler handler, IBaseTypesAlarmes baseAlarmes, IDefinition rootDefinition) { m_originalHandler = handler; CMemoryDb dbEdition = new CMemoryDb(); m_handler = dbEdition.ImporteObjet(handler, true, true) as CTrapHandler; m_handler.TypeAgent = handler.TypeAgent; m_baseTypesAlarmes = baseAlarmes; InitChamps(); }
public void Init( CAgentFinderFromKey agentFinder, IBaseTypesAlarmes baseAlarmes, IDefinition rootDefinition) { m_originalAgentFinder = agentFinder; CMemoryDb dbEdition = new CMemoryDb(); m_agentFinder = dbEdition.ImporteObjet(agentFinder, true, true) as CAgentFinderFromKey; m_agentFinder.TypeAgent = agentFinder.TypeAgent; m_baseTypesAlarmes = baseAlarmes; InitChamps(); }
//--------------------------------------------------------------------------------- public CEntiteDeMemoryDb GetEntite(Type typeEntite, string strId, CMemoryDb db) { string strTable = DataBase.GetTableNameForType(typeEntite); if (strTable != null && DataBase.Tables[strTable] != null) { CEntiteDeMemoryDb ett = Activator.CreateInstance(typeEntite, DataBase) as CEntiteDeMemoryDb; if (ett.ReadIfExist(strId)) { return(db.ImporteObjet(ett, true, false)); } } return(null); }
//----------------------------------------------------------------------------------- private void TraiteNotification(CNotificationModificationsAlarme notification) { HashSet <string> tableAlarmeAvant = UpdateNombreAlarmesNonAcquittees(); // Mise à jour des Alarmes CListeEntitesDeMemoryDb <CLocalAlarme> listeAlaremsMaj = new CListeEntitesDeMemoryDb <CLocalAlarme>(notification.MemoryDb); m_dataBase.AcceptChanges(); foreach (CLocalAlarme alarmeAjoutModif in listeAlaremsMaj) { if (alarmeAjoutModif.Parent == null) { CLocalAlarme alrm = m_dataBase.ImporteObjet(alarmeAjoutModif, true, true) as CLocalAlarme; /*if (alrm != null) * alrm.Row.Row.SetModified();*/ } } m_tableauAlarmesEnCours.UpdateDataBase(m_dataBase); m_tableauAlarmesRetombees.UpdateDataBase(m_dataBase); HashSet <string> tableAlarmeApres = UpdateNombreAlarmesNonAcquittees(); bool bSonnerie = false; foreach (string strIdAlarme in tableAlarmeApres) { if (!tableAlarmeAvant.Contains(strIdAlarme)) { bSonnerie = true; break; } } if (bSonnerie) { StartSonnerie(); } else { StopSonnerie(); } }
//------------------------------------------------------- public static bool EditeCreateur(CCreateurAlarme createur, IBaseTypesAlarmes baseAlarmes) { CFormEditCreateurAlarme form = new CFormEditCreateurAlarme(); CMemoryDb dbEdition = new CMemoryDb(); form.m_createur = dbEdition.ImporteObjet(createur, true, true) as CCreateurAlarme; //form.m_createur = CCloner2iSerializable.Clone(createur) as CCreateurAlarme; form.m_createur.TrapHandler = createur.TrapHandler; form.m_baseTypesAlarmes = baseAlarmes; bool bResult = false; if (form.ShowDialog() == DialogResult.OK) { createur.Database.ImporteObjet(form.m_createur, true, true); bResult = true; } form.Dispose(); return(bResult); }
public void SendAlarmes() { if (m_traiteurAlarmes == null) { return; } if (m_nWaitingCounter > 5) { return; } m_nWaitingCounter++; lock (typeof(CLockTraiteurAlarmes)) { m_nWaitingCounter--; List <CLocalAlarme> lstToSend = null; lock (typeof(CLockListeAlarmes)) { if (m_listeAlarmesATransmettre.Count < 250 || m_nWaitingCounter == 0) { lstToSend = m_listeAlarmesATransmettre; m_listeAlarmesATransmettre = new List <CLocalAlarme>(); } else { lstToSend = new List <CLocalAlarme>(); for (int n = 0; n < 250; n++) { lstToSend.Add(m_listeAlarmesATransmettre[n]); } m_listeAlarmesATransmettre.RemoveRange(0, 250); } } try { System.Data.DataTable tbl = Database.Tables[CLocalAlarme.c_nomTable]; Console.WriteLine("Nb in db : " + tbl.Rows.Count); if (lstToSend.Count == 0) { return; } using (CMemoryDb memDB = new CMemoryDb()) { memDB.EnforceConstraints = false; lock (typeof(CLockerDatabase)) { foreach (CLocalAlarme alrm in lstToSend) { try { if (alrm.Row.Row.RowState != System.Data.DataRowState.Detached) { memDB.ImporteObjet(alrm, true, false); } } catch (Exception e) { throw e; } } } m_nNbSend += lstToSend.Count; CResultAErreurType <CMappageIdsAlarmes> result = m_traiteurAlarmes.Traite(memDB); if (result) { if (result.DataType != null) { foreach (KeyValuePair <string, string> kv in result.DataType) { if (kv.Value != kv.Key) { CLocalAlarme alarme = GetAlarmFromId(kv.Key); if (alarme != null) { alarme.Id = kv.Key; m_dicAlarmes.Remove(kv.Key); m_dicAlarmes[kv.Value] = alarme; } } } } NettoyageDB(); return; } if (!result) { m_trace.Write("Error while sending to Timos manager", ALTRACE.DEBUG); m_trace.Write(result.Erreur.ToString(), ALTRACE.DEBUG); } } } catch (Exception exep) { } lock (typeof(CLockListeAlarmes)) { for (int n = lstToSend.Count - 1; n >= 0; n--) { if (lstToSend[n].Row.Row.RowState == System.Data.DataRowState.Detached) { lstToSend.RemoveAt(n); } } m_listeAlarmesATransmettre.InsertRange(0, lstToSend); } } }
private void m_lnkEnvoyerReleves_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { DateTime dt = DateTime.Now; List <CReleveSite> lstReleves = new List <CReleveSite>(); foreach (ListViewItem item in m_wndListeReleves.CheckedItems) { CReleveSite rel = item.Tag as CReleveSite; if (rel != null) { lstReleves.Add(rel); } } List <CReleveSite> lstTransmitted = new List <CReleveSite>(); CFormWaiting.DoWork((DoWorkDelegate) delegate(CFormWaiting waiter) { waiter.ReportProgress(I.T("Connecting to Timos|20009")); InventoryService.InventoryService service = new TimosInventory.InventoryService.InventoryService(); service.Url = CTimosInventoryRegistre.TimosServiceURL; int nIdSession; try { nIdSession = service.OpenSession(); foreach (CReleveSite releve in lstReleves) { if (releve != null) { CMemoryDb db = new CMemoryDb(); db.EnforceConstraints = false; db.ImporteObjet(releve, true, false); waiter.ReportProgress(I.T("Send survey @1|20038", releve.Site.Libelle)); bool bResult = service.SendSurvey(nIdSession, db); if (bResult) { lstTransmitted.Add(releve); } } } foreach (CReleveSite releve in lstTransmitted) { releve.ClearRelevesEquipements(); releve.Delete(); } service.CloseSession(nIdSession); TimeSpan sp = DateTime.Now - dt; Console.WriteLine("Transmission relevé : " + sp.TotalMilliseconds); } catch { } }); CTimosInventoryDb.SetDbInventaire(CTimosInventoryDb.GetInventaireDatas()); if (lstTransmitted.Count != lstReleves.Count) { CFormAlerte.Afficher(I.T("Due to unknown error, Some surveys could not be send|20043")); } InitListeReleves(); }