//--------------------------------------------------------------
        public CLocalTypeAlarme GetTypeAlarme(string strIdTypeAlarme)
        {
            AssureTypes();
            CLocalTypeAlarme tp = null;

            m_dicTypesAlarmes.TryGetValue(strIdTypeAlarme, out tp);
            return(tp);
        }
 //--------------------------------------------------------------
 private void AddType(CLocalTypeAlarme tpSup)
 {
     m_listeTypes.Add(tpSup);
     m_dicTypesAlarmes[tpSup.Id] = tpSup;
     foreach (CLocalTypeAlarme tpFils in tpSup.TypesFils)
     {
         AddType(tpFils);
     }
 }
Exemple #3
0
 private void FillBuilder(StringBuilder bl, CLocalTypeAlarme ta, int nTab)
 {
     bl.Append("\t\t\t\t\t\t\t\t\t\t\t\t".Substring(0, nTab));
     bl.AppendLine(ta.Libelle);
     foreach (CLocalTypeAlarme tpFils in ta.TypesFils)
     {
         FillBuilder(bl, tpFils, nTab + 1);
     }
 }
 //--------------------------------------------------------------
 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);
 }
        //--------------------------------------------------------------
        private void AssureTypes()
        {
            if (m_dicTypesAlarmes != null)
            {
                return;
            }
            m_dicTypesAlarmes = new Dictionary <string, CLocalTypeAlarme>();
            CListeObjetDonneeGenerique <CTypeAlarme> lstTypes = new CListeObjetDonneeGenerique <CTypeAlarme>(m_contexteDonnee);

            lstTypes.Filtre = new CFiltreData(CTypeAlarme.c_champIdTypeParent + " is null");
            foreach (CTypeAlarme tp in lstTypes)
            {
                CLocalTypeAlarme tpSup = tp.GetTypeForSupervision(m_database, true);
                AddType(tpSup);
            }
            m_listeTypes.Sort((t1, t2) => t1.Libelle.CompareTo(t2.Libelle));
        }
Exemple #6
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);
                }
            }
        }
Exemple #7
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);
        }