Beispiel #1
0
 //-------------------------------------------------
 public CConfigTextBoxSelectMemoryDb(Type typeObjets,
                                     CFiltreMemoryDb filtreDeBase,
                                     CFiltreMemoryDb filtreRapide,
                                     string strPropriete)
     : this(null, typeObjets, filtreDeBase, filtreRapide, strPropriete)
 {
 }
        private CFiltreMemoryDb GetFiltreAlarmesParDefaut()
        {
            CFiltreMemoryDb filtre = null;

            // Par défaut, Filtrer les alarmes masquées
            filtre = new CFiltreMemoryDb(
                CLocalAlarme.c_champIdMasquageHerite + " is null");

            return(filtre);
        }
Beispiel #3
0
        //-------------------------------------------------------------------------------------
        private HashSet <string> UpdateNombreAlarmesNonAcquittees()
        {
            HashSet <string> tableIdAlarmes = new HashSet <string>();
            int nHashCode = 0;

            // Affiche le nombre d'Alarmes non aqcuittées
            if (m_dataBase != null)
            {
                CListeEntitesDeMemoryDb <CLocalTypeAlarme> listeTypesAlarme = new CListeEntitesDeMemoryDb <CLocalTypeAlarme>(m_dataBase);
                listeTypesAlarme.Filtre = new CFiltreMemoryDb(
                    CLocalTypeAlarme.c_champAAcquitter + " = @1",
                    true);
                List <string> lstIdString = new List <string>();
                foreach (CLocalTypeAlarme typeAlarme in listeTypesAlarme)
                {
                    lstIdString.Add(typeAlarme.Id);
                }
                string strListeIdTypes = string.Join(",", lstIdString.ToArray());

                CListeEntitesDeMemoryDb <CLocalAlarme> listeAlarmes = new CListeEntitesDeMemoryDb <CLocalAlarme>(m_dataBase);
                CFiltreMemoryDb filtre = new CFiltreMemoryDb(
                    CLocalAlarme.c_champIdParent + " is null and " +
                    CLocalAlarme.c_champDateFin + " is null and " +
                    CLocalAlarme.c_champDateAcquittement + " is null and " +
                    CLocalAlarme.c_champIdMasquageHerite + " is null");
                if (strListeIdTypes != "")
                {
                    filtre = CFiltreMemoryDb.GetAndFiltre(filtre, new CFiltreMemoryDb(
                                                              CLocalTypeAlarme.c_champId + " in(" + strListeIdTypes + ")"));
                }
                else
                {
                    filtre = new CFiltreMemoryDBImpossible();
                }
                listeAlarmes.Filtre = filtre;
                listeAlarmes.Sort   = CLocalAlarme.c_champId;

                int nCompteur = listeAlarmes.Count();
                m_lblCompteurNouvellesAlarmes.Text = nCompteur.ToString();

                // Calcul du Hash Code
                StringBuilder sb = new StringBuilder();
                foreach (CLocalAlarme alarme in listeAlarmes)
                {
                    tableIdAlarmes.Add(alarme.Id);
                }
            }

            return(tableIdAlarmes);
        }
Beispiel #4
0
 //-------------------------------------------------
 public CConfigTextBoxSelectMemoryDb(
     string strLibelleConfig,
     Type typeObjets,
     CFiltreMemoryDb filtreDeBase,
     CFiltreMemoryDb filtreRapide,
     string strPropriete)
 {
     if (strLibelleConfig == null || strLibelleConfig.Trim().Length == 0)
     {
         strLibelleConfig = DynamicClassAttribute.GetNomConvivial(typeObjets);
     }
     m_strLibelleConfig = strLibelleConfig;
     m_typeObjets       = typeObjets;
     m_filtreDeBase     = filtreDeBase;
     m_filtreRapide     = filtreRapide;
     m_strPropriete     = strPropriete;
 }
        public static CEntiteDeMemoryDb SelectionRechercheRapide(
            CMemoryDb dbMemory,
            string strInstructions,
            Type type,
            CFiltreMemoryDb filtreDeBase,
            CFiltreMemoryDb filtreRapide,
            string strTexteRechercheRapide,
            string strChampAffiche,
            string strContexte)
        {
            if (type == null || !type.IsSubclassOf(typeof(CEntiteDeMemoryDb)))
            {
                CFormAlerte.Afficher(I.T("Can not select an element from this type|30035"), EFormAlerteType.Erreur);
                return(null);
            }
            CFormSelectUneEntiteMemoryDb form = new CFormSelectUneEntiteMemoryDb();

            form.m_filtre                = filtreDeBase;
            form.m_strInstructions       = strInstructions;
            form.m_contexteMemoire       = dbMemory;
            form.m_txtRecherche.Text     = strTexteRechercheRapide;
            form.TypeObjets              = type;
            form.m_filtreRechercheRapide = filtreRapide;
            if (strChampAffiche == "")
            {
                strChampAffiche = DescriptionFieldAttribute.GetDescriptionField(type, "Libelle", true);
            }
            form.m_strProprieteAffichee = strChampAffiche;
            form.m_wndListeElements.Columns[0].Propriete = form.m_strProprieteAffichee;
            CEntiteDeMemoryDb objet = null;

            form.RefreshListe();
            bool bOk = true;

            if (form.m_listeObjets == null || form.m_listeObjets.Count() != 1)
            {
                bOk = form.ShowDialog() == DialogResult.OK;
            }
            if (bOk)
            {
                objet = form.ObjetDonnee;
            }
            form.Dispose();
            return(objet);
        }
Beispiel #6
0
        private CFiltreMemoryDb GetFiltreMasquage(CLocalCategorieMasquageAlarme categorieNiveauMax)
        {
            CFiltreMemoryDb nouveauFiltre = null;

            if (categorieNiveauMax != null)
            {
                int nNiveau = categorieNiveauMax.Priorite;
                nouveauFiltre = new CFiltreMemoryDb(
                    CLocalAlarme.c_champIdMasquageHerite + " is null OR (" +
                    CLocalAlarme.c_champIdMasquageHerite + " is not null AND " +
                    CLocalAlarme.c_champNiveauMasquage + " <= @1)", nNiveau);
            }
            else
            {
                nouveauFiltre = new CFiltreMemoryDb(
                    CLocalAlarme.c_champIdMasquageHerite + " is null");
            }

            return(nouveauFiltre);
        }
        /// ////////////////////////////////////////////
        private void RefreshListe()
        {
            CFiltreMemoryDb filtre = null;

            if (m_txtRecherche.Text != null)
            {
                filtre = m_filtreRechercheRapide;
                if (filtre != null)
                {
                    if (filtre.Parametres.Count == 0)
                    {
                        filtre.Parametres.Add(m_txtRecherche.Text);
                    }
                    else
                    {
                        filtre.Parametres[0] = "%" + m_txtRecherche.Text + "%";
                    }
                }
            }
            filtre = CFiltreMemoryDb.GetAndFiltre(filtre, m_filtre);

            if (m_listeObjets == null)
            {
                m_listeObjets        = new CListeEntitesDeMemoryDbBase(m_contexteMemoire, m_typeObjets);
                m_listeObjets.Filtre = filtre;
            }
            else
            {
                m_listeObjets.Filtre = filtre;
            }

            m_wndListeElements.ListeSource = m_listeObjets;
            m_wndListeElements.Refresh();

            if (m_listeObjets.Count() == 1)
            {
                m_objetSelectionne = (CEntiteDeMemoryDb)m_listeObjets[0];
            }
        }
Beispiel #8
0
        private void m_btnAficherMasque_Click(object sender, EventArgs e)
        {
            CListeEntitesDeMemoryDb <CLocalCategorieMasquageAlarme> listeCategoriesMask = new CListeEntitesDeMemoryDb <CLocalCategorieMasquageAlarme>(m_dataBase);

            listeCategoriesMask.Sort = CLocalCategorieMasquageAlarme.c_champPriorite;
            CFiltreMemoryDb filtre = GetFiltreMasquage(null);

            CFormSelectNiveauMasquagePopup form = new CFormSelectNiveauMasquagePopup();

            form.Init(listeCategoriesMask.ToArray(), m_lastCategorieMasquage);
            form.Left = MousePosition.X;
            form.Top  = MousePosition.Y;
            DialogResult reponse = form.ShowDialog();

            switch (reponse)
            {
            case DialogResult.OK:
                m_lastCategorieMasquage = form.ElementSelectionne;
                filtre = GetFiltreMasquage(m_lastCategorieMasquage);
                m_btnAficherMasque.Text = m_lastCategorieMasquage.Libelle;
                break;

            case DialogResult.No:
                m_lastCategorieMasquage = null;
                filtre = GetFiltreMasquage(null);
                m_btnAficherMasque.Text = I.T("Masked Alarms|10312");
                break;

            case DialogResult.Cancel:
                return;

            default:
                return;
            }
            m_tableauAlarmesEnCours.FiltreAlarmes   = filtre;
            m_tableauAlarmesRetombees.FiltreAlarmes = filtre;
        }
Beispiel #9
0
        private void InitIntellisense()
        {
            if (m_dicIntellisense == null)
            {
                m_dicIntellisense = new Dictionary <string, HashSet <CReferenceEntiteMemoryDb> >();
                HashSet <string> setMots = new HashSet <string>();
                try
                {
                    if (m_listeConfigs != null && m_bUseIntellisense)
                    {
                        foreach (CConfigTextBoxSelectMemoryDb config in m_listeConfigs)
                        {
                            try
                            {
                                CListeEntitesDeMemoryDbBase lstObjs = new CListeEntitesDeMemoryDbBase(m_currentMemoryDb, config.TypeObjets);
                                CFiltreMemoryDb             filtre  = config.FiltreDeBase;
                                lstObjs.Filtre = filtre;

                                if (lstObjs.Count() < 4000)
                                {
                                    foreach (CEntiteDeMemoryDb obj in lstObjs)
                                    {
                                        string strText = CInterpreteurTextePropriete.GetStringValue(obj, config.ProprieteAffichee, "");
                                        if (strText.Trim().Length > 0)
                                        {
                                            strText = strText.Trim();
                                            HashSet <string> lstStrings = new HashSet <string>();
                                            lstStrings.Add(strText);
                                            int nIndex = strText.IndexOf(' ');
                                            while (nIndex >= 0)
                                            {
                                                strText = strText.Substring(nIndex + 1).Trim();
                                                lstStrings.Add(strText);
                                                nIndex = strText.IndexOf(' ');
                                            }

                                            foreach (string strMotTmp in strText.Split(' '))
                                            {
                                                if (strMotTmp.Length > 2)
                                                {
                                                    if (strMotTmp.Trim().Length > 0)
                                                    {
                                                        lstStrings.Add(strMotTmp);
                                                    }
                                                }
                                            }
                                            CReferenceEntiteMemoryDb refObj = new CReferenceEntiteMemoryDb(obj);
                                            foreach (string strMot in lstStrings)
                                            {
                                                HashSet <CReferenceEntiteMemoryDb> lst = null;
                                                foreach (string strMotToutSeul in strMot.Split(' '))
                                                {
                                                    if (!m_dicIntellisense.TryGetValue(strMotToutSeul.ToUpper(), out lst))
                                                    {
                                                        lst = new HashSet <CReferenceEntiteMemoryDb>();
                                                        m_dicIntellisense[strMotToutSeul.ToUpper()] = lst;
                                                    }
                                                    lst.Add(refObj);
                                                }
                                                if (!m_dicIntellisense.TryGetValue(strMot.ToUpper(), out lst))
                                                {
                                                    lst = new HashSet <CReferenceEntiteMemoryDb>();
                                                    m_dicIntellisense[strMot.ToUpper()] = lst;
                                                }
                                                lst.Add(refObj);
                                                setMots.Add(strMot);
                                            }
                                        }
                                    }
                                }
                            }
                            catch { }
                        }
                    }
                    m_textBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
                    m_textBox.AutoCompleteMode   = AutoCompleteMode.Suggest;
                    m_textBox.AutoCompleteCustomSource.Clear();
                    m_textBox.AutoCompleteCustomSource.AddRange(setMots.ToArray());
                }
                catch { }
            }
        }
Beispiel #10
0
 //------------------------------------------------------------------
 public void InitAvecFiltreDeBase(CMemoryDb dbMemory, Type typeObjets, string strProprieteAffichee, CFiltreMemoryDb filtreDeBase, CFiltreMemoryDb filtreRapide, bool bForceInit)
 {
     if (!bForceInit && m_bIsInit)
     {
         return;
     }
     m_listeIntellisense = null;
     m_currentMemoryDb   = dbMemory;
     m_listeConfigs.Clear();
     m_listeConfigs.Add(new CConfigTextBoxSelectMemoryDb(
                            typeObjets,
                            filtreDeBase,
                            filtreRapide,
                            strProprieteAffichee));
     m_bIsInit = true;
     UpdateImage();
 }
Beispiel #11
0
 //------------------------------------------------------------------
 public void InitAvecFiltreDeBase(CMemoryDb dbMemory, Type typeObjets, string strProprieteAffichee, CFiltreMemoryDb filtreDeBase, bool bForceInit)
 {
     InitAvecFiltreDeBase(dbMemory, typeObjets, strProprieteAffichee, filtreDeBase, null, bForceInit);
 }
        public static CEntiteDeMemoryDb SelectObjetDonnee(CMemoryDb dbMemory, string strInstructions, Type type, CFiltreMemoryDb filtre, string strPropriete)
        {
            if (!type.IsSubclassOf(typeof(CEntiteDeMemoryDb)))
            {
                CFormAlerte.Afficher(I.T("Impossible to select an element from this type|30035"), EFormAlerteType.Erreur);
                return(null);
            }
            CFormSelectUneEntiteMemoryDb form = new CFormSelectUneEntiteMemoryDb();

            form.m_filtre               = filtre;
            form.m_strInstructions      = strInstructions;
            form.TypeObjets             = type;
            form.m_strProprieteAffichee = strPropriete;
            form.m_contexteMemoire      = dbMemory;
            form.m_wndListeElements.Columns[0].Propriete = strPropriete;
            CEntiteDeMemoryDb objet = null;

            if (form.ShowDialog() == DialogResult.OK)
            {
                objet = form.ObjetDonnee;
            }
            form.Dispose();
            return(objet);
        }
 public static CEntiteDeMemoryDb SelectObjetDonnee(CMemoryDb dbMemory, string strInstructions, Type type, CFiltreMemoryDb filtre)
 {
     return(SelectObjetDonnee(dbMemory, strInstructions, type, filtre, "DescriptionElement"));
 }