示例#1
0
        //-------------------------------------------------------
        public void CreateAlarme(CAlarmeACreer alarmeACreer, EModeRemonteeAlarmes modeRemontee)
        {
            bool bGerer = false;

            lock (typeof(CLockerDatabase))
            {
                string strParentKey = alarmeACreer.Alarme.CalcParentKey();

                switch (alarmeACreer.OptionCreation)
                {
                case EOptionCreationAlarme.Always:
                    bGerer = true;
                    break;

                case EOptionCreationAlarme.SiPasDeParentActif:
                    if (strParentKey == null)
                    {
                        bGerer = true;
                    }
                    else
                    {
                        bGerer = !m_dicCurrent.ContainsKey(strParentKey);
                    }
                    break;

                case EOptionCreationAlarme.SiParentActif:
                    if (strParentKey == null)
                    {
                        bGerer = true;
                    }
                    else
                    {
                        bGerer = m_dicCurrent.ContainsKey(strParentKey);
                    }
                    break;

                default:
                    break;
                }
                if (alarmeACreer.Alarme.TypeAlarme.RegrouperSurLaCle &&
                    m_dicCurrent.ContainsKey(alarmeACreer.Alarme.GetKey()))
                {
                    CLocalAlarme alrmExistante = m_dicCurrent[alarmeACreer.Alarme.GetKey()];
                    if (alrmExistante.EtatCode == alarmeACreer.Alarme.EtatCode)
                    {
                        m_trace.Write("Alarm already exists", ALTRACE.DEBUG);
                        return;
                    }
                }
            }
            if (bGerer)
            {
                GereAlarme(alarmeACreer.Alarme, modeRemontee);
            }
        }
示例#2
0
        //-------------------------------------------------------
        public void GereAlarme(CLocalAlarme alarme, EModeRemonteeAlarmes modeRemontee)
        {
            CResultAErreur result = CResultAErreur.True;

            DateTime dtChrono = DateTime.Now;

            lock (typeof(CLockerDatabase))
            {
                if (alarme.Database != Database)
                {
                    CLocalAlarme tmpAlarme = new CLocalAlarme(Database);
                    if (!tmpAlarme.ReadIfExist(alarme.Id))
                    {
                        m_dicCurrent.TryGetValue(alarme.GetKey(), out tmpAlarme);
                        if (tmpAlarme == null)
                        {
                            tmpAlarme = Database.ImporteObjet(alarme, false, false) as CLocalAlarme;
                        }
                    }

                    //Reprend l'état de l'alarme qui vient d'arriver. Le reste ne bouge pas
                    tmpAlarme.EtatCode = alarme.EtatCode;//Mise à jour de l'état
                    alarme             = tmpAlarme;
                }

                TimeSpan sp = DateTime.Now - dtChrono;

                string strKey = alarme.GetKey();
                if (alarme.Etat.Code == EEtatAlarme.Open && alarme.DateFin == null)
                {
                    IntegreAlarmeAListeOuvertes(alarme);
                }
                else
                {
                    IntegreAlarmeAListeFermees(alarme);
                }

                m_dicAlarmes[alarme.Id] = alarme;
                if (modeRemontee != EModeRemonteeAlarmes.NePasRemonter)
                {
                    AddAlarmeAEnvoyer(alarme);
                }
            }

            GereParent(alarme);
            GereMasquage(alarme);


            if (modeRemontee == EModeRemonteeAlarmes.RemonterEnFin && m_traiteurAlarmes != null)
            {
                SendAlarmes();
            }
        }