public void FillFromTable(ITableDefinition table)
 {
     m_table = table as CTableDefinitionSnmpOfScalar;
     if (m_table != null)
     {
         m_chkOptimiser.Checked = m_table.RemplissageOptimise;
     }
 }
Beispiel #2
0
        //---------------------------------------
        public DataTable GetData(ITableDefinition tableDefinition, params string[] strIdsColonnesSource)
        {
            CTableDefinitionSNMP tableSNMP = tableDefinition as CTableDefinitionSNMP;

            if (tableSNMP != null && m_interrogateur != null)
            {
                return(GetTableSnmp(tableSNMP, strIdsColonnesSource));
            }

            CTableDefinitionSnmpOfScalar tableScalars = tableDefinition as CTableDefinitionSnmpOfScalar;

            if (tableScalars != null && m_interrogateur != null)
            {
                return(GetTableScalars(tableScalars, strIdsColonnesSource));
            }

            return(null);
        }
Beispiel #3
0
        //---------------------------------------
        private DataTable GetTableScalars(CTableDefinitionSnmpOfScalar tableScalar, params string[] strIdsColonnesSource)
        {
            DateTime      dt      = DateTime.Now;
            List <uint[]> lstCols = new List <uint[]>();

            if (strIdsColonnesSource != null)
            {
                foreach (string strIdCol in strIdsColonnesSource)
                {
                    try
                    {
                        lstCols.Add(ObjectIdentifier.Convert(strIdCol));
                    }
                    catch { }
                }
            }

            List <Variable> lstVariables = new List <Variable>();

            if (lstCols.Count == 0)
            {
                foreach (IColumnDefinition col in tableScalar.Columns)
                {
                    CColumnDefinitionSNMP colSnmp = col as CColumnDefinitionSNMP;
                    if (colSnmp != null)
                    {
                        lstVariables.Add(new Variable(ObjectIdentifier.Convert(colSnmp.OIDString + ".0")));
                    }
                }
            }
            else
            {
                foreach (uint[] oid in lstCols)
                {
                    lstVariables.Add(new Variable(new ObjectIdentifier(ObjectIdentifier.Convert(oid) + ".0")));
                }
            }
            IList <Variable> lstRetour = new List <Variable>();

            if (tableScalar.RemplissageOptimise)
            {
                lstRetour = m_interrogateur.Get(lstVariables);
            }
            else
            {
                foreach (Variable v in lstVariables)
                {
                    object res = m_interrogateur.Get(v.Id.ToString());
                    if (res is ISnmpData)
                    {
                        Variable vTmp = new Variable(v.Id, res as ISnmpData);
                        lstRetour.Add(vTmp);
                    }
                }
            }


            DataTable table = new DataTable(tableScalar.TableName);
            Dictionary <DataColumn, string> valeurs = new Dictionary <DataColumn, string>();

            foreach (Variable var in lstRetour)
            {
                DataColumn        col     = new DataColumn();
                IColumnDefinition colSNMP = tableScalar.Columns.FirstOrDefault(
                    c => c is CColumnDefinitionSNMP &&
                    ((CColumnDefinitionSNMP)c).OIDString + ".0" == var.Id.ToString());
                if (colSNMP != null)
                {
                    col.ColumnName = colSNMP.ColumnName;
                }
                else
                {
                    col.ColumnName = var.Id.ToString();
                }
                col.DataType = colSNMP.DataType;
                if (!table.Columns.Contains(col.ColumnName))
                {
                    table.Columns.Add(col);
                }
                valeurs[col] = var.Data == null ? "":var.Data.ToString();
            }
            DataRow row = table.NewRow();

            foreach (KeyValuePair <DataColumn, string> kv in valeurs)
            {
                try
                {
                    row[kv.Key] = kv.Value;
                }
                catch { }
            }
            table.Rows.Add(row);
            return(table);
        }
Beispiel #4
0
        //-----------------------------------
        private static void FillListeTables(
            CEasyQuerySource laBase,
            IDefinition definition,
            List <ITableDefinition> lstToFill,
            CEasyQuerySourceFolder folderRacine)
        {
            CTableDefinitionSnmpOfScalar tableScalars = null;

            if (definition.Entity != null)
            {
                tableScalars           = new CTableDefinitionSnmpOfScalar();
                tableScalars.OIDRacine = definition.GetNumericalForm();
                tableScalars.TableName = folderRacine.Name + "_Scalars";
                tableScalars.FolderId  = folderRacine.Id;
            }
            foreach (IDefinition children in definition.Children)
            {
                if (children.Type == DefinitionType.Table)
                {
                    CTableDefinitionSNMP table = FromDefinition(laBase, children, folderRacine);
                    if (table != null)
                    {
                        lstToFill.Add(table);
                        laBase.AddTableUniquementPourObjetConnexion(table);
                    }
                }
                else if (children.Type == DefinitionType.OidValueAssignment)
                {
                    CEasyQuerySourceFolder folder = folderRacine.GetSubFolderWithCreate(children.Name);
                    FillListeTables(laBase, children, lstToFill, folder);
                }
                else if (children.Type == DefinitionType.Scalar)
                {
                    if (children.Type == DefinitionType.Scalar && tableScalars != null)
                    {
                        CColumnDefinitionSNMP colSnmp = new CColumnDefinitionSNMP();
                        colSnmp.ColumnName = children.Name;
                        colSnmp.OID        = children.GetNumericalForm();
                        Type       tp      = typeof(string);
                        ObjectType objType = children.Entity as ObjectType;
                        if (objType != null)
                        {
                            TextualConvention conv = objType.Syntax as TextualConvention;
                            if (conv != null)
                            {
                                tp = ((AbstractTypeAssignment)conv.Syntax).GetTypeDotNet();
                            }
                            else
                            {
                                AbstractTypeAssignment abs = objType.Syntax as AbstractTypeAssignment;
                                if (abs != null)
                                {
                                    tp = abs.GetTypeDotNet();
                                }
                            }
                        }
                        switch (objType.Access)
                        {
                        case MaxAccess.accessibleForNotify:
                        case MaxAccess.readOnly:
                            colSnmp.IsReadOnly = true;
                            break;

                        case MaxAccess.readWrite:
                        case MaxAccess.readCreate:
                            colSnmp.IsReadOnly = false;
                            break;
                        }
                        colSnmp.DataType = tp;
                        tableScalars.AddColumn(colSnmp);
                    }
                }
            }
            if (tableScalars != null && tableScalars.Columns.Count() > 0)
            {
                laBase.AddTableUniquementPourObjetConnexion(tableScalars);
                tableScalars.Base = laBase;
            }
        }