Exemplo n.º 1
0
        //----------------------------------------------------------------------------------
        public CLocalParametrageFiltrageAlarmes GetLocalParametrageForSupervision(CMemoryDb database)
        {
            if (database == null)
            {
                database = CMemoryDbPourSupervision.GetMemoryDb(ContexteDonnee);
            }

            CLocalParametrageFiltrageAlarmes filtrage = new CLocalParametrageFiltrageAlarmes(database);

            if (!filtrage.ReadIfExist(Id.ToString(), false))
            {
                filtrage.CreateNew(Id.ToString());
            }
            else
            if (!filtrage.IsToRead())
            {
                return(filtrage);
            }
            filtrage.Row[CMemoryDb.c_champIsToRead] = false;
            filtrage.Libelle           = Libelle;
            filtrage.Parametre         = Parametre;
            filtrage.Enabled           = Enabled;
            filtrage.IgnorerEnBase     = IgnorerEnBase;
            filtrage.DateDebutValidite = DateDebutValidite;
            filtrage.DateFinValidite   = DateFinValidite;
            if (CategorieMasquage != null)
            {
                filtrage.CategorieMasquage = CategorieMasquage.GetLocalCategorieForSupervision(database);
            }

            return(filtrage);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        //-------------------------------------------------------------
        public CLocalSeveriteAlarme GetTypeForSupervision(CMemoryDb database)
        {
            if (database == null)
            {
                database = CMemoryDbPourSupervision.GetMemoryDb(ContexteDonnee);
            }

            CLocalSeveriteAlarme severite = new CLocalSeveriteAlarme(database);

            if (!severite.ReadIfExist(Id.ToString(), false))
            {
                severite.CreateNew(Id.ToString());
            }
            else
            if (!severite.IsToRead())
            {
                return(severite);
            }
            severite.Row[CMemoryDb.c_champIsToRead] = false;
            severite.Libelle    = Libelle;
            severite.Code       = Code;
            severite.Priorite   = Priorite;
            severite.CouleurInt = CouleurInt;

            return(severite);
        }
Exemplo n.º 4
0
        //-------------------------------------------------------------
        public CLocalCategorieMasquageAlarme GetLocalCategorieForSupervision(CMemoryDb database)
        {
            if (database == null)
            {
                database = CMemoryDbPourSupervision.GetMemoryDb(ContexteDonnee);
            }

            CLocalCategorieMasquageAlarme categorie = new CLocalCategorieMasquageAlarme(database);

            if (!categorie.ReadIfExist(Id.ToString(), false))
            {
                categorie.CreateNew(Id.ToString());
            }
            else
            if (!categorie.IsToRead())
            {
                return(categorie);
            }
            categorie.Row[CMemoryDb.c_champIsToRead] = false;
            categorie.Libelle  = Libelle;
            categorie.Code     = Code;
            categorie.Priorite = Priorite;


            return(categorie);
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 7
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);
        }
Exemplo n.º 8
0
        //-------------------------------------------------------------
        public CLocalTypeAlarme GetTypeForSupervision(CMemoryDb database, bool bWithChilds)
        {
            if (database == null)
            {
                database = CMemoryDbPourSupervision.GetMemoryDb(ContexteDonnee);
            }
            CLocalTypeAlarme typeParent = null;

            if (TypeParent != null)
            {
                typeParent = TypeParent.GetTypeForSupervision(database, false);
            }
            CLocalTypeAlarme typeAlarme = new CLocalTypeAlarme(database);

            if (!typeAlarme.ReadIfExist(Id.ToString(), false))
            {
                typeAlarme.CreateNew(Id.ToString());
            }
            else
            if (!typeAlarme.IsToRead())
            {
                return(typeAlarme);
            }
            typeAlarme.Row[CMemoryDb.c_champIsToRead] = false;
            typeAlarme.Libelle              = Libelle;
            typeAlarme.ModeCalculEtat       = ModeCalculEtatParent.Code;
            typeAlarme.ActionsSurParent     = FormuleCalculActionsSurParent;
            typeAlarme.EtatDefaut           = EtatInitial.Code;
            typeAlarme.TypeParent           = typeParent;
            typeAlarme.RegrouperSurLaCle    = RegrouperSurLaCle;
            typeAlarme.FormuleLibelle       = FormuleCalculLibelle;
            typeAlarme.ActionsSurParent     = FormuleCalculActionsSurParent;
            typeAlarme.AAcquitter           = AAcquitter;
            typeAlarme.TypeElementSupervise = TypeElementSupervise.Code;

            CLocalSeveriteAlarme severite = null;

            if (Severite != null)
            {
                severite = Severite.GetTypeForSupervision(database);
            }
            typeAlarme.Severite = severite;

            foreach (CRelationTypeAlarme_ChampCustom rel in RelationsChampsCustomDefinis)
            {
                if (rel.ChampCustom != null && rel.ChampCustom.Id > 0)
                {
                    CLocalChampTypeAlarme champ = GetChampTypeAlarme(database, rel.ChampCustom);
                    CLocalRelationTypeAlarmeChampAlarme relLocale = new CLocalRelationTypeAlarmeChampAlarme(database);
                    if (!relLocale.ReadIfExist(rel.Id.ToString()))
                    {
                        relLocale.CreateNew(rel.Id.ToString());
                        relLocale.Champ      = champ;
                        relLocale.TypeAlarme = typeAlarme;
                        relLocale.IsKey      = rel.IsKey;
                    }
                }
            }
            if (bWithChilds)
            {
                foreach (CTypeAlarme typeChild in TypesFils)
                {
                    CLocalTypeAlarme typeFils = typeChild.GetTypeForSupervision(database, true);
                    typeFils.TypeParent = typeAlarme;
                }
            }
            return(typeAlarme);
        }