Esempio n. 1
0
        //-------------------------------------------------------------------------
        public CResultAErreur RetombageManuel(string strIdAlarme, int nIdSession)
        {
            CResultAErreur result = CResultAErreur.True;

            using (CContexteDonnee context = new CContexteDonnee(nIdSession, true, false))
            {
                CAlarme alarmeARetomber = new CAlarme(context);
                if (alarmeARetomber.ReadIfExists(new CFiltreData(
                                                     CAlarme.c_champAlarmId + " = @1",
                                                     strIdAlarme)))
                {
                    CMemoryDb    db     = CMemoryDbPourSupervision.GetMemoryDb(context);
                    CLocalAlarme alarme = alarmeARetomber.GetLocalAlarme(db, true);
                    if (alarme.EtatCode != EEtatAlarme.Close)
                    {
                        alarme.EtatCode = EEtatAlarme.Close;
                    }
                    result = CAlarme.TraiteAlarmesManuellement(nIdSession, db);
                    if (result)
                    {
                        CSnmpConnexion.DefaultInstance.RedescendAlarmes(db);
                    }
                }
                else
                {
                    result.EmpileErreur(I.T("Alarm Id @1 not found|10022", strIdAlarme));
                }
            }

            return(result);
        }
Esempio n. 2
0
            public CMenuItemAvecAlarme(CLocalAlarme infoAlarme)
            {
                Text = infoAlarme.Libelle;//17082011 +" / " + infoAlarme.ElementGereType + "-" + infoAlarme.ElementGereName;
                CLocalSeveriteAlarme sev = infoAlarme.TypeAlarme.Severite;

                BackColor    = sev != null ? sev.Couleur : Color.White;
                m_infoAlarme = infoAlarme;
            }
Esempio n. 3
0
        //----------------------------------------------------------------------------------------------
        private void StopAlarme(CLocalAlarme alarme)
        {
            // Traitement de l'état opérationnel des schémas
            List <CElementDeArbreOperationnel> listeNoeudsConcernes = new List <CElementDeArbreOperationnel>();

            if (alarme.EquipementId != null)
            {
                m_dicEquipementToNoeudArbreOp.TryGetValue(alarme.EquipementId, out listeNoeudsConcernes);
            }
            else if (alarme.SiteId != null)
            {
                m_dicSiteToNoeudArbreOp.TryGetValue(alarme.SiteId, out listeNoeudsConcernes);
            }
            else if (alarme.LienId != null)
            {
                m_dicLiaisonToNoeudArbreOp.TryGetValue(alarme.LienId, out listeNoeudsConcernes);
            }

            // Passe tous les coef opérationnels à 1 = OK
            PropageCoefOperationnel(listeNoeudsConcernes, 1.0);


            List <CInfoElementDeSchemaSupervise> lst = null;

            if (m_dicAlarmeToElementsConcernes.TryGetValue(alarme.Id, out lst))
            {
                List <CInfoElementDeSchemaSupervise> lstAPrevenir = new List <CInfoElementDeSchemaSupervise>(lst);
                while (lstAPrevenir.Count != 0)
                {
                    lstAPrevenir.Sort();
                    CInfoElementDeSchemaSupervise[] infos = lstAPrevenir.ToArray();
                    lstAPrevenir.Clear();
                    foreach (CInfoElementDeSchemaSupervise info in infos)
                    {
                        info.StopAlarme(alarme.Id);
                        CInfoElementDeSchemaSupervise parent = info.Parent;
                        if (parent != null)
                        {
                            lstAPrevenir.Add(parent);
                        }
                    }
                }
            }

            if (lst != null && lst.Count > 0)
            {
                Refresh();
            }
        }
Esempio n. 4
0
        //------------------------------------
        internal void StartAlarme(CLocalAlarme alarme, bool bIsFromChild)
        {
            CDonneesSupervisionAlarme data = null;

            if (m_dicAlarmesEnCours.TryGetValue(alarme.Id, out data))
            {
                if (bIsFromChild)  //Si c'est une alarme fille, pas besoin d'écraser l'actuelle,
                {
                    return;
                }
            }
            data = new CDonneesSupervisionAlarme(alarme, bIsFromChild);
            m_dicAlarmesEnCours[alarme.Id] = data;
            RecalculeGraviteEtMasquage();
            List <CInfoElementDeSchemaSupervise> lstTmp = new List <CInfoElementDeSchemaSupervise>();
            //RecalculeToutLeMasquage(lstTmp);
        }
Esempio n. 5
0
        public List <CLocalAlarme> GetAlarmesPourElement(CElementDeSchemaReseau element)
        {
            List <CLocalAlarme>           lst  = new List <CLocalAlarme>();
            CInfoElementDeSchemaSupervise info = null;

            if (m_dicElementDeSchemaToInfoSupervision.TryGetValue(element.Id, out info))
            {
                foreach (string strId in info.GetIdsAlarmesEnCours())
                {
                    CLocalAlarme alarme = null;
                    if (m_dicAlarmes.TryGetValue(strId, out alarme))
                    {
                        lst.Add(alarme);
                    }
                }
            }
            return(lst);
        }
Esempio n. 6
0
        //-----------------------------------------------------------------------------------
        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();
            }
        }
Esempio n. 7
0
        public bool Clear()
        {
            CResultAErreur result = CResultAErreur.True;

            CMemoryDb    db     = CMemoryDbPourSupervision.GetMemoryDb(this.ContexteDonnee);
            CLocalAlarme alarme = GetLocalAlarme(db, true);

            if (alarme.EtatCode != EEtatAlarme.Close)
            {
                alarme.EtatCode = EEtatAlarme.Close;
            }
            result = CAlarme.TraiteAlarmesManuellement(this.ContexteDonnee.IdSession, db);
            if (result)
            {
                CSnmpConnexion.DefaultInstance.RedescendAlarmes(db);
            }

            return(result.Result);
        }
        public static CMemoryDb GetAlarmesAAfficher(int nIdSession)
        {
            using (CContexteDonnee ctx = new CContexteDonnee(nIdSession, true, false))
            {
                CMemoryDb db = CMemoryDbPourSupervision.GetMemoryDb(ctx);
                //Catégories de masquage
                CListeObjetDonneeGenerique <CCategorieMasquageAlarme> lstCat = new CListeObjetDonneeGenerique <CCategorieMasquageAlarme>(ctx);
                foreach (CCategorieMasquageAlarme cat in lstCat)
                {
                    CLocalCategorieMasquageAlarme local = cat.GetLocalCategorieForSupervision(db);
                }

                CListeObjetDonneeGenerique <CAlarme> lst = new CListeObjetDonneeGenerique <CAlarme>(ctx);
                lst.Filtre = new CFiltreData(CAlarme.c_champDateFin + " is null and " +
                                             CAlarme.c_champIdParent + " is null");
                int nCount = 0;
                if (lst.Count == 0)
                {
                    return(db);
                }
                CListeObjetsDonnees lstFilles = lst;
                while (ctx.Tables[CAlarme.c_nomTable].Rows.Count != nCount)
                {
                    nCount    = ctx.Tables[CAlarme.c_nomTable].Rows.Count;
                    lstFilles = lstFilles.GetDependances("AlarmesFilles");
                }
                lst = new CListeObjetDonneeGenerique <CAlarme>(ctx);
                lst.InterditLectureInDB = true;
                lst.ReadDependances("RelationsChampsCustom");
                lst.Filtre = new CFiltreData(CAlarme.c_champIdParent + " is null");
                CListeObjetDonneeGenerique <CTypeAlarme> lstTypes = new CListeObjetDonneeGenerique <CTypeAlarme>(ctx);
                lstTypes.AssureLectureFaite();

                foreach (CAlarme alrm in lst)
                {
                    CLocalAlarme newAlrm = alrm.GetLocalAlarme(db, true);
                }
                return(db);
            }
        }
Esempio n. 9
0
        public void AddAlarm(string strCodeCreateur, int nCondition, CFuturocomTrace trace)
        {
            CCreateurAlarme createur = m_trapHandler.GetCreateur(strCodeCreateur);

            if (createur != null)
            {
                CLocalTypeAlarme typeAl = createur.TypeAlarme;
                if (typeAl != null)
                {
                    CLocalAlarme alarme = new CLocalAlarme(m_dbPourAlarmes);
                    alarme.CreateNew();
                    alarme.TypeAlarme         = typeAl;
                    alarme.EntiteDeclencheuse = EntiteAssociee;
                    alarme.EtatCode           = typeAl.EtatDefaut;
                    CResultAErreur result = createur.FillAlarm(this, alarme);
                    if (!result && trace != null)
                    {
                        trace.Write("Creator fill alarm error " + result.Erreur.ToString(), ALTRACE.DEBUG);
                    }
                    if (m_listeAlarmesACreer.FirstOrDefault(ac => ac.Alarme.GetKey() == alarme.GetKey()) == null)
                    {
                        CAlarmeACreer create = new CAlarmeACreer(alarme, (EOptionCreationAlarme)nCondition);
                        m_listeAlarmesACreer.Add(create);
                    }
                }
                else if (trace != null)
                {
                    trace.Write(createur.Libelle + " alarm type is null");
                }
            }
            else
            {
                if (trace != null)
                {
                    trace.Write(
                        "Can not find creator " + strCodeCreateur,
                        ALTRACE.DEBUG);
                }
            }
        }
Esempio n. 10
0
        //------------------------------------------------------------------
        public CResultAErreur FillAlarm(CTrapInstance trap, CLocalAlarme alarme)
        {
            CContexteEvaluationExpression ctx = new CContexteEvaluationExpression(TrapHandler.TypeAgent);
            CDefinitionProprieteDynamiqueVariableFormule def = AssureVariableTrap(FormuleActions);

            if (def != null)
            {
                ctx.SetValeurVariable(def, trap);
            }
            def = AssureVariableAlarme(FormuleActions);
            if (def != null)
            {
                ctx.SetValeurVariable(def, alarme);
            }

            CResultAErreur result = FormuleActions.Eval(ctx);

            if (!result)
            {
                return(result);
            }

            return(result);
        }
Esempio n. 11
0
        //---------------------------------------------------------------------
        public CLocalAlarme GetLocalAlarme(CMemoryDb database, bool bAvecFils)
        {
            if (database == null)
            {
                database = CMemoryDbPourSupervision.GetMemoryDb(ContexteDonnee);
            }
            CAlarme      alarmeParente = AlarmeParente;
            CLocalAlarme localParent   = null;

            if (alarmeParente != null)
            {
                localParent = alarmeParente.GetLocalAlarme(database, false);
            }
            CLocalAlarme alarme = new CLocalAlarme(database);

            if (!alarme.ReadIfExist(AlarmId.ToString(), false))
            {
                alarme.CreateNew(AlarmId.ToString());
            }
            else
            if (!alarme.IsToRead())
            {
                return(alarme);
            }
            alarme.PreventPropagationsAutomatiques = true;
            alarme.Row[CMemoryDb.c_champIsToRead]  = false;
            alarme.DateDebut        = DateDebut;
            alarme.DateFin          = DateFin;
            alarme.TypeAlarme       = TypeAlarme.GetTypeForSupervision(database, false);
            alarme.Severite         = Severite.GetTypeForSupervision(database);
            alarme.Parent           = localParent;
            alarme.EtatCode         = (EEtatAlarme)EtatCode;
            alarme.Libelle          = Libelle;
            alarme.DateAcquittement = DateAcquittement;
            alarme.SiteId           = SiteId;
            alarme.EquipementId     = EquipementId;
            alarme.LienId           = LienId;
            alarme.EntiteSnmpId     = EntiteSnmpId;
            alarme.IsHS             = IsHS;
            alarme.NiveauMasquage   = NiveauMasquage;

            if (Severite != null)
            {
                CLocalSeveriteAlarme sev = Severite.GetTypeForSupervision(database);
                if (sev != null)
                {
                    alarme.Severite = sev;
                }
            }

            if (MasquagePropre != null)
            {
                alarme.MasquagePropre = MasquagePropre.GetLocalParametrageForSupervision(database);
            }
            if (MasquageHerite != null)
            {
                alarme.MasquageHerite = MasquageHerite.GetLocalParametrageForSupervision(database);
            }

            // Recupère les valeurs de champs
            foreach (CRelationAlarme_ChampCustom rel in RelationsChampsCustom)
            {
                object val = rel.Valeur;
                if (val != null)
                {
                    if (val is CObjetDonneeAIdNumerique)
                    {
                        val = ((CObjetDonneeAIdNumerique)val).Id;
                    }
                    alarme.SetValeurChamp(rel.ChampCustom.Id.ToString(), val);
                }
            }
            alarme.PreventPropagationsAutomatiques = false;
            if (bAvecFils)
            {
                foreach (CAlarme fille in AlarmesFilles)
                {
                    fille.GetLocalAlarme(database, true);
                }
            }
            return(alarme);
        }
Esempio n. 12
0
        //----------------------------------------------------
        /// <summary>
        /// Remplit ou met à jour l'alarme à partir de données
        /// issues d'un service de médiation
        /// </summary>
        /// <param name="alarme"></param>
        public void FillFromLocalAlarmeFromMediation(CLocalAlarme alarme)
        {
            Libelle   = alarme.Libelle;
            Cle       = alarme.GetKey();
            AlarmId   = alarme.Id;
            EtatCode  = (int)alarme.EtatCode;
            DateDebut = alarme.DateDebut;
            DateFin   = alarme.DateFin;
            CTypeAlarme ta = new CTypeAlarme(ContexteDonnee);

            if (ta.ReadIfExists(Int32.Parse(alarme.TypeAlarme.Id)))
            {
                TypeAlarme = ta;
            }
            else
            {
                throw new Exception(I.T("Alarm type @1 doesn't exists|20104", alarme.TypeAlarme.Libelle));
            }

            Site = null;
            EquipementLogique = null;
            LienReseau        = null;
            EntiteSnmp        = null;
            //Site
            if (alarme.SiteId != null)
            {
                /*int? nId = CDbKeyAddOn.GetIdFromUniverselId(typeof(CSite), alarme.SiteId);
                 * if (nId != null)
                 *  Row[CSite.c_champId] = nId.Value;*/
                CSite site = new CSite(ContexteDonnee);
                if (site.ReadIfExists(alarme.SiteId))
                {
                    Site = site;
                }
            }
            if (alarme.EquipementId != null)
            {
                /*int? nId = CDbKeyAddOn.GetIdFromUniverselId(typeof(CEquipementLogique), alarme.EquipementId);
                 * if (nId != null)
                 *  Row[CEquipementLogique.c_champId] = nId.Value;*/
                CEquipementLogique eqt = new CEquipementLogique(ContexteDonnee);
                if (eqt.ReadIfExists(alarme.EquipementId))
                {
                    EquipementLogique = eqt;
                }
            }
            if (alarme.LienId != null)
            {
                /*int? nId = CDbKeyAddOn.GetIdFromUniverselId(typeof(CLienReseau), alarme.LienId);
                 * if (nId != null)
                 *  Row[CLienReseau.c_champId] = nId.Value;*/
                CLienReseau lien = new CLienReseau(ContexteDonnee);
                if (lien.ReadIfExists(alarme.LienId))
                {
                    LienReseau = lien;
                }
            }
            if (alarme.EntiteSnmpId != null)
            {
                /*int? nId = CDbKeyAddOn.GetIdFromUniverselId(typeof(CEntiteSnmp), alarme.EntiteSnmpId);
                 * if (nId != null)
                 *  Row[CEntiteSnmp.c_champId] = nId.Value;*/
                CEntiteSnmp entite = new CEntiteSnmp(ContexteDonnee);
                if (entite.ReadIfExists(alarme.EntiteSnmpId))
                {
                    EntiteSnmp = entite;
                }
            }
            IsHS = alarme.IsHS;
            if (alarme.IdSeverite != null)
            {
                CSeveriteAlarme severite = new CSeveriteAlarme(ContexteDonnee);
                if (severite.ReadIfExists(Int32.Parse(alarme.IdSeverite)))
                {
                    Severite = severite;
                }
            }
            if (alarme.MasquagePropre != null)
            {
                CParametrageFiltrageAlarmes parametreFiltre = new CParametrageFiltrageAlarmes(ContexteDonnee);
                if (parametreFiltre.ReadIfExists(Int32.Parse(alarme.MasquagePropre.Id)))
                {
                    MasquagePropre = parametreFiltre;
                }
            }
            else
            {
                MasquagePropre = null;
            }
            foreach (CChampCustom champ in ta.TousLesChampsAssocies)
            {
                object val = alarme.GetValeurChamp(champ.Id.ToString());
                if (val != null)
                {
                    SetValeurChamp(champ.Id, val);
                }
            }
        }
Esempio n. 13
0
 public CDonneesSupervisionAlarme(CLocalAlarme info, bool bIsFromChild)
 {
     LocalAlarme = info;
     IsFromChild = bIsFromChild;
 }
Esempio n. 14
0
        //----------------------------------------------------
        private void GereHierarchie(
            CContexteDonnee ctxEdit,
            CLocalAlarme alarme,
            CMappageIdsAlarmes dicMapIds,
            HashSet <string> alarmesTraitees,
            CAlarme alarmeParente)
        {
            if (alarmesTraitees.Contains(alarme.Id))
            {
                return;
            }

            CAlarme alarmeInDb  = new CAlarme(ctxEdit);
            bool    bExiste     = false;
            string  strIdAlarme = alarme.Id;

            if (alarmeInDb.ReadIfExists(new CFiltreData(CAlarme.c_champAlarmId + "=@1", strIdAlarme)))
            {
                bExiste = true;
            }
            else if (dicMapIds.TryGetValue(alarme.Id, out strIdAlarme))
            {
                if (alarmeInDb.ReadIfExists(new CFiltreData(CAlarme.c_champAlarmId + "=@1", strIdAlarme)))
                {
                    bExiste = true;
                }
            }
            else
            {
                strIdAlarme = alarme.Id;
            }
            if (!bExiste)
            {
                if (alarmeInDb.ReadIfExists(
                        new CFiltreData(CAlarme.c_champCle + "=@1 and " +
                                        CAlarme.c_champDateFin + " is null",
                                        alarme.GetKey())))
                {
                    bExiste = true;
                }
            }
            if (!bExiste)
            {
                alarmeInDb.CreateNewInCurrentContexte();
            }
            else
            {
                strIdAlarme = alarmeInDb.AlarmId;
            }
            alarmesTraitees.Add(alarme.Id);
            alarmeInDb.AlarmeParente = alarmeParente;
            alarmeInDb.FillFromLocalAlarmeFromMediation(alarme);
            alarmeInDb.AlarmId = strIdAlarme;

            if (alarmeInDb.AlarmId != alarme.Id)
            {
                dicMapIds[alarme.Id] = alarmeInDb.AlarmId;
                alarme.Id            = alarmeInDb.AlarmId;
            }
            foreach (CLocalAlarme alarmeFille in alarme.Childs)
            {
                GereHierarchie(ctxEdit, alarmeFille, dicMapIds, alarmesTraitees, alarmeInDb);
            }
        }
Esempio n. 15
0
        //Initialise la base des alarmes en cours avec les alarmes de la base
        private void LoadAlarmesForElement(string strChampDansAlarme, CDictionnaireConcerne dicConcernes)
        {
            List <CDbKey> lstKeysElements = new List <CDbKey>();

            lstKeysElements.AddRange(dicConcernes.Keys);
            int nSizePaquet = 100;

            for (int nPaquet = 0; nPaquet < lstKeysElements.Count; nPaquet += nSizePaquet)
            {
                int           nMax = Math.Min(nPaquet + nSizePaquet, lstKeysElements.Count);
                StringBuilder bl   = new StringBuilder();
                for (int nId = 0; nId < nMax; nId++)
                {
                    bl.Append(lstKeysElements[nId]);
                    bl.Append(',');
                }
                if (bl.Length > 0)
                {
                    bl.Remove(bl.Length - 1, 1);
                    //Charge tous les Liens d'alarme pour les éléments
                    CListeObjetsDonnees lstAlarmes = new CListeObjetsDonnees(m_contexteDonnee, typeof(CAlarme));
                    lstAlarmes.Filtre = new CFiltreData(strChampDansAlarme + " in (" +
                                                        bl.ToString() + ") and " +
                                                        CAlarme.c_champDateFin + " is null");

                    lstAlarmes.AssureLectureFaite();

                    //CMemoryDb database =  new CMemoryDb();

                    foreach (CAlarme alarme in lstAlarmes)
                    {
                        if (alarme != null && alarme.AlarmesFilles.Count == 0)
                        {
                            CLocalAlarme locAlrm = alarme.GetLocalAlarme(m_database, true);
                            //m_dicAlarmes[info.IdSpvEvtAlarme] = info;
                            m_dicAlarmes[locAlrm.Id] = locAlrm;
                            StartAlarme(locAlrm);
                        }
                    }

                    /*
                     * foreach ( CSpvLienAccesAlarme lienAlarme in lstAlarmes )
                     * {
                     *  CSpvAcces acces = lienAlarme.AccesAlarmeOne;
                     *  if ( acces != null )
                     *  {
                     *      int? nId = acces.Row[strChampDansAcces] as int?;
                     *      if (nId != null)
                     *      {
                     *          List<CInfoElementDeSchemaSupervise> lst = null;
                     *          if (dicConcernes.TryGetValue(nId.Value, out lst))
                     *          {
                     *              foreach (CInfoElementDeSchemaSupervise info in lst)
                     *              {
                     *                  info.SetConcerneParAlarmes();
                     *                  if (lienAlarme.MaskAdminDateMin != null && lienAlarme.MaskBriDateMin > DateTime.Now)
                     *                  {
                     *                      if (lienAlarme.MaskAdminDateMax == null || lienAlarme.MaskAdminDateMax < DateTime.Now)
                     *                          info.SetMasquageAdministrateur(lienAlarme.Id, true);
                     *                  }
                     *                  if (lienAlarme.MaskBriDateMin != null && lienAlarme.MaskBriDateMin > DateTime.Now)
                     *                      if (lienAlarme.MaskBriDateMax == null || lienAlarme.MaskBriDateMax < DateTime.Now)
                     *                          info.SetMasquageBrigadier(lienAlarme.Id, true);
                     *              }
                     *          }
                     *      }
                     *  }
                     * }*/
                    /*if (m_infoSchemaRacine != null)
                     * {
                     *  List<CInfoElementDeSchemaSupervise> lstTmp = new List<CInfoElementDeSchemaSupervise>();
                     *  m_infoSchemaRacine.RecalculeToutLeMasquage(lstTmp);
                     * }*/
                }
            }
        }
Esempio n. 16
0
        //----------------------------------------------------------------------------------------------
        private void StartAlarme(CLocalAlarme infoAlarme)
        {
            m_dicAlarmes[infoAlarme.Id] = infoAlarme;

            // Traitement de l'état opérationnel des schémas
            List <CElementDeArbreOperationnel> listeNoeudsConcernes = new List <CElementDeArbreOperationnel>();

            if (infoAlarme.EquipementId != null)
            {
                m_dicEquipementToNoeudArbreOp.TryGetValue(infoAlarme.EquipementId, out listeNoeudsConcernes);
            }
            else if (infoAlarme.SiteId != null)
            {
                m_dicSiteToNoeudArbreOp.TryGetValue(infoAlarme.SiteId, out listeNoeudsConcernes);
            }
            else if (infoAlarme.LienId != null)
            {
                m_dicLiaisonToNoeudArbreOp.TryGetValue(infoAlarme.LienId, out listeNoeudsConcernes);
            }

            if (infoAlarme.MasquageApplique == null || infoAlarme.MasquageHerite.Priorite <= this.NiveauMasquageMaxAffiche)
            {
                PropageCoefOperationnel(listeNoeudsConcernes, infoAlarme.IsHS ? 0 : 0.5);
            }
            else
            {
                PropageCoefOperationnel(listeNoeudsConcernes, 1);
            }


            List <CInfoElementDeSchemaSupervise> lstConcernes = new List <CInfoElementDeSchemaSupervise>();
            List <CInfoElementDeSchemaSupervise> lst          = null;

            if (infoAlarme.EquipementId != null)
            {
                m_dicDirectementConcernesParEquipement.TryGetValue(infoAlarme.EquipementId, out lst);
                if (lst != null)
                {
                    lstConcernes.AddRange(lst);
                }
            }
            if (infoAlarme.LienId != null)
            {
                m_dicDirectementConcernesParLiaison.TryGetValue(infoAlarme.LienId, out lst);
                if (lst != null)
                {
                    lstConcernes.AddRange(lst);
                }
            }
            if (infoAlarme.EntiteSnmpId != null)
            {
                m_dicDirectementConcernesParEntiteSnmp.TryGetValue(infoAlarme.EntiteSnmpId, out lst);
                if (lst != null)
                {
                    lstConcernes.AddRange(lst);
                }
            }
            if (infoAlarme.SiteId != null && infoAlarme.EquipementId == null && infoAlarme.EntiteSnmpId == null)
            {
                m_dicDirectementConcernesParSite.TryGetValue(infoAlarme.SiteId, out lst);
                if (lst != null)
                {
                    lstConcernes.AddRange(lst);
                }
            }

            Dictionary <CInfoElementDeSchemaSupervise, bool> dicConcernes = new Dictionary <CInfoElementDeSchemaSupervise, bool>();

            if (lstConcernes != null)
            {
                List <CInfoElementDeSchemaSupervise> lstAPrevenir = new List <CInfoElementDeSchemaSupervise>(lstConcernes);
                bool bFirstNiveau = true;
                while (lstAPrevenir.Count != 0)
                {
                    lstAPrevenir.Sort();
                    CInfoElementDeSchemaSupervise[] infos = lstAPrevenir.ToArray();
                    lstAPrevenir.Clear();
                    foreach (CInfoElementDeSchemaSupervise info in infos)
                    {
                        if (bFirstNiveau)
                        {
                            dicConcernes[info] = true;
                        }
                        info.StartAlarme(infoAlarme, !bFirstNiveau);
                        CInfoElementDeSchemaSupervise parent = info.Parent;
                        if (parent != null)
                        {
                            lstAPrevenir.Add(parent);
                        }
                    }
                    bFirstNiveau = false;
                }
                if (lstConcernes.Count > 0)
                {
                    Refresh();
                }
            }
            lst = new List <CInfoElementDeSchemaSupervise>();
            lst.AddRange(dicConcernes.Keys);
            m_dicAlarmeToElementsConcernes[infoAlarme.Id] = lst;
        }
Esempio n. 17
0
        //-------------------------------------------------------------------------------
        public void UpdateAlarmDataBase(CMemoryDb dbMaj)
        {
            List <COperationSurAlarmeAffichee> listeTampon = new List <COperationSurAlarmeAffichee>();

            Dictionary <CLocalAlarme, bool> dicAlarmesTraitees = new Dictionary <CLocalAlarme, bool>();

            m_database = dbMaj;
            CListeEntitesDeMemoryDb <CLocalAlarme> listeMaj = new CListeEntitesDeMemoryDb <CLocalAlarme>(m_database, m_filtreAlarmes);
            HashSet <string> lstAlarmesNonMasquees          = new HashSet <string>();

            foreach (CLocalAlarme alrm in listeMaj)
            {
                lstAlarmesNonMasquees.Add(alrm.Id);
            }
            listeMaj = new CListeEntitesDeMemoryDb <CLocalAlarme>(m_database);

            foreach (CLocalAlarme alarmeMaj in listeMaj)
            {
                // Traite uniquement les alarmes ajoutées ou modifiées
                if (alarmeMaj.Row.Row.RowState == System.Data.DataRowState.Modified ||
                    alarmeMaj.Row.Row.RowState == System.Data.DataRowState.Added)
                {
                    // Recherche l'alarme racine
                    CLocalAlarme alarmeParente = alarmeMaj;
                    while (alarmeParente.Parent != null)
                    {
                        alarmeParente = alarmeParente.Parent;
                    }

                    if (dicAlarmesTraitees.Keys.Contains(alarmeParente))
                    {
                        continue;
                    }

                    if (!lstAlarmesNonMasquees.Contains(alarmeMaj.Id))
                    {
                        listeTampon.Add(new COperationSurAlarmeAffichee(
                                            new CLocalAlarmeAffichee(alarmeParente.Row.Row),
                                            EOperationSurAlarme.Delete));
                        continue;
                    }

                    if (m_bTraiteAlarmesEnCours)
                    {
                        if (alarmeParente.DateFin == null)
                        {
                            //UpdateNode(new CLocalAlarmeAffichee(alarmeParente.Row.Row));
                            listeTampon.Add(new COperationSurAlarmeAffichee(
                                                new CLocalAlarmeAffichee(alarmeParente.Row.Row),
                                                EOperationSurAlarme.CreateUpdate));
                        }
                        else
                        {
                            //RemoveNode(new CLocalAlarmeAffichee(alarmeParente.Row.Row));
                            listeTampon.Add(new COperationSurAlarmeAffichee(
                                                new CLocalAlarmeAffichee(alarmeParente.Row.Row),
                                                EOperationSurAlarme.Delete));
                        }
                    }
                    else // Traite alarmes retombées
                    {
                        if (alarmeParente.DateFin != null)
                        {
                            //UpdateNode(new CLocalAlarmeAffichee(alarmeParente.Row.Row));
                            listeTampon.Add(new COperationSurAlarmeAffichee(
                                                new CLocalAlarmeAffichee(alarmeParente.Row.Row),
                                                EOperationSurAlarme.CreateUpdate));
                        }
                        else
                        {
                            //RemoveNode(new CLocalAlarmeAffichee(alarmeParente.Row.Row));
                            listeTampon.Add(new COperationSurAlarmeAffichee(
                                                new CLocalAlarmeAffichee(alarmeParente.Row.Row),
                                                EOperationSurAlarme.Delete));
                        }
                    }
                    dicAlarmesTraitees[alarmeParente] = true;
                }
            }

            lock (m_listeOperationsSurAlarme)
            {
                m_listeOperationsSurAlarme.AddRange(listeTampon);
            }

            BeginInvoke(new EventHandler(DelayUpdate), null, null);
        }
Esempio n. 18
0
        public CResultAErreurType <CMappageIdsAlarmes> Traite(CMemoryDb dbContenantLesAlarmesATraiter)
        {
            CResultAErreurType <CMappageIdsAlarmes> result = new CResultAErreurType <CMappageIdsAlarmes>();

            result.SetTrue();
            CResultAErreur resErreur = CResultAErreur.True;

            try
            {
                lock (typeof(CLockerTraitementAlarme))
                {
                    resErreur = AssureSessionEtContexte();
                    if (!resErreur)
                    {
                        result.EmpileErreur(resErreur.Erreur);
                        return(result);
                    }

                    CListeEntitesDeMemoryDb <CLocalAlarme> lstAlarmes = new CListeEntitesDeMemoryDb <CLocalAlarme>(dbContenantLesAlarmesATraiter);
                    lstAlarmes.Filtre = new CFiltreMemoryDb(CMemoryDb.c_champIsToRead + "=@1", false);
                    lstAlarmes.Sort   = CLocalAlarme.c_champDateDebut;
                    //Mappage des ids pour les alarmes qui changent d'ID
                    m_nNbAlarmesTraitees += lstAlarmes.Count();
                    CMappageIdsAlarmes dicMapIds       = new CMappageIdsAlarmes();
                    HashSet <string>   alarmesTraitees = new HashSet <string>();
                    using (CContexteDonnee ctxEdit = m_contexteDonnee.GetContexteEdition())
                    {
                        ctxEdit.EnableTraitementsExternes = false;
                        ctxEdit.DisableHistorisation      = true;
                        try
                        {
                            foreach (CLocalAlarme alrm in lstAlarmes)
                            {
                                if (!alarmesTraitees.Contains(alrm.Id))
                                {
                                    CLocalAlarme root = alrm;
                                    while (root.Parent != null && !root.Parent.IsToRead())
                                    {
                                        root = root.Parent;
                                    }
                                    GereHierarchie(ctxEdit, root, dicMapIds, alarmesTraitees, null);
                                }
                            }
                            result.DataType = dicMapIds;
                        }
                        catch (Exception e)
                        {
                            result.EmpileErreur(new CErreurException(e));
                        }
                        finally
                        {
                            if (result)
                            {
                                resErreur = SauvegardeOptimisee(ctxEdit);
                                if (!resErreur)
                                {
                                    result.EmpileErreur(resErreur.Erreur);
                                }
                            }
                            else
                            {
                                ctxEdit.CancelEdit();
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                {
                    C2iEventLog.WriteErreur(I.T("Error in Alarms @1|20156", e.ToString()));
                }
            }
            finally
            {
            }
            Console.WriteLine("Alarmes traitées : " + m_nNbAlarmesTraitees + " à " + DateTime.Now.ToString("HH:mm:ss"));
            return(result);
        }