예제 #1
0
 //-----------------------------------
 private static void FillListeTables(
     CEasyQuerySource laBase,
     IDefinition definition,
     List <ITableDefinition> lstToFill,
     CEasyQuerySourceFolder folderRacine)
 {
     foreach (IDefinition children in definition.Children)
     {
         if (children.Type == DefinitionType.Table)
         {
             CTableDefinitionSNMP table = FromDefinition(laBase, children, folderRacine);
             if (table != null)
             {
                 lstToFill.Add(table);
                 laBase.AddTable(table);
             }
         }
         else if (children.Type == DefinitionType.OidValueAssignment || children.Type == DefinitionType.Scalar)
         {
             CEasyQuerySourceFolder folder = folderRacine.GetSubFolderWithCreate(children.Name);
             if (folder != null && children.GetNumericalForm().Length > 0)
             {
                 folder.SetExtendedProperty(c_strExtendedPropertyOID, ObjectIdentifier.Convert(children.GetNumericalForm()));
             }
             if (children.Type == DefinitionType.Scalar)
             {
                 folder.SetExtendedProperty(c_strExtendedPropertyValue, new CValeurExtendedProprieteFolderSnmpScalar(ObjectIdentifier.Convert(children.GetNumericalForm())));
                 folder.ImageKey = CValeurExtendedProprieteFolderSnmpScalar.c_strImageScalar;
             }
             FillListeTables(laBase, children, lstToFill, folder);
         }
     }
 }
예제 #2
0
 //-------------------------------------------
 private void FillNodes(
     TreeNodeCollection nodes,
     CEasyQuerySource source,
     CEasyQuerySourceFolder folder)
 {
     foreach (CEasyQuerySourceFolder childFolder in folder.Childs)
     {
         TreeNode node = new TreeNode(childFolder.Name);
         node.Tag = childFolder;
         nodes.Add(node);
         node.ImageIndex         = GetImageNum(childFolder.ImageKey);
         node.SelectedImageIndex = node.ImageIndex;
         node.Nodes.Add(new TreeNode());
     }
     foreach (ITableDefinition table in source.GetTablesForFolder(folder.Id))
     {
         TreeNode node = new TreeNode(table.TableName);
         node.Tag                = table;
         node.ImageIndex         = GetImageNum(table.ImageKey);
         node.SelectedImageIndex = node.ImageIndex;
         if (table.Columns.Count() > 0)
         {
             node.Nodes.Add(new TreeNode());
         }
         nodes.Add(node);
     }
 }
예제 #3
0
        //--------------------------------------------------------------------------------
        protected ITableDefinition GetTableForNode(TreeNode node)
        {
            ITableDefinition table = node.Tag as ITableDefinition;

            if (table == null)
            {
                return(null);

                CEasyQuerySourceFolder folder = node.Tag as CEasyQuerySourceFolder;
                if (folder != null)
                {
                    table = folder.GetDefinitionTable(m_sources.GetSourceFromId(table.SourceId));
                }
            }
            return(table);
        }
예제 #4
0
 //--------------------------------------------------------------------------------
 private void CTreeListeTables_BeforeExpand(object sender, TreeViewCancelEventArgs e)
 {
     if (e.Node.Tag is CEasyQuerySource)
     {
         if (e.Node.Nodes.Count == 1 && e.Node.Nodes[0].Tag == null)
         {
             using (CWaitCursor waiter = new CWaitCursor())
             {
                 e.Node.Nodes.Clear();
                 CEasyQuerySource source = e.Node.Tag as CEasyQuerySource;
                 FillNodes(e.Node.Nodes, source, source.RootFolder);
             }
         }
     }
     else if (e.Node.Tag is ITableDefinition)
     {
         if (e.Node.Nodes.Count == 1 && e.Node.Nodes[0].Tag == null)
         {
             e.Node.Nodes.Clear();
             ITableDefinition table = e.Node.Tag as ITableDefinition;
             foreach (IColumnDefinition col in table.Columns)
             {
                 TreeNode node = new TreeNode(col.ColumnName);
                 node.Tag                = col;
                 node.ImageIndex         = GetImageNum(col.ImageKey);
                 node.SelectedImageIndex = node.ImageIndex;
                 e.Node.Nodes.Add(node);
             }
         }
     }
     else if (e.Node.Tag is CEasyQuerySourceFolder)
     {
         if (e.Node.Nodes.Count == 1 && e.Node.Nodes[0].Tag == null)
         {
             CEasyQuerySourceFolder folder = e.Node.Tag as CEasyQuerySourceFolder;
             e.Node.Nodes.Clear();
             FillNodes(e.Node.Nodes, folder.Source, folder);
             if (Nodes.Count == 1)
             {
                 Nodes[0].Expand();
             }
         }
     }
 }
예제 #5
0
        //-----------------------------------
        public static IEnumerable <ITableDefinition> FromMib(
            CEasyQuerySource laBase,
            IDefinition rootDefinition,
            CEasyQuerySourceFolder folderRacine)
        {
            List <ITableDefinition> lst = new List <ITableDefinition>();

            if (laBase.Tables.FirstOrDefault(t => t.GetType() == typeof(CTableDefinitionStructureSNMP)) == null)
            {
                CTableDefinitionStructureSNMP table = new CTableDefinitionStructureSNMP();
                if (folderRacine != null)
                {
                    table.FolderId = folderRacine.Id;
                }
                lst.Add(table);
                table.Fill(rootDefinition);
                laBase.AddTableUniquementPourObjetConnexion(table);
            }
            FillListeTables(laBase, rootDefinition, lst, folderRacine);
            return(lst.AsReadOnly());
        }
예제 #6
0
        //-----------------------------------
        public static IEnumerable <ITableDefinition> FromMib(
            CEasyQuerySource laBase,
            ObjectRegistryBase mibBase,
            CEasyQuerySourceFolder folderRacine)
        {
            List <ITableDefinition> lst = new List <ITableDefinition>();

            if (laBase.Tables.FirstOrDefault(t => t.GetType() == typeof(CTableDefinitionStructureSNMP)) == null)
            {
                CTableDefinitionStructureSNMP table = new CTableDefinitionStructureSNMP();
                if (folderRacine != null)
                {
                    table.FolderId = folderRacine.Id;
                }
                lst.Add(table);
                table.Fill(mibBase);
                laBase.AddTable(table);
            }
            FillListeTables(laBase, mibBase.Tree.Root, lst, folderRacine);
            return(lst.AsReadOnly());
        }
예제 #7
0
        //-----------------------------------
        public static CTableDefinitionSNMP FromDefinition(
            CEasyQuerySource laBase,
            IDefinition def,
            CEasyQuerySourceFolder folder

            )
        {
            CTableDefinitionSNMP table = null;

            if (def.Type == DefinitionType.Table)
            {
                table           = new CTableDefinitionSNMP(laBase);
                table.TableName = def.Name;
                table.OID       = def.GetNumericalForm();

                if (folder != null)
                {
                    table.FolderId = folder.Id;
                }

                if (def.Children.Count() == 1)
                {
                    CColumnDefinitionSimple colIndex = new CColumnDefinitionSimple("Index", typeof(string));
                    table.AddColumn(colIndex);
                    IDefinition entry = def.Children.ElementAt(0);
                    foreach (IDefinition col in entry.Children)
                    {
                        if (col.Type == DefinitionType.Column)
                        {
                            CColumnDefinitionSNMP newCol = new CColumnDefinitionSNMP();
                            newCol.ColumnName = col.Name;
                            newCol.OID        = col.GetNumericalForm();
                            newCol.DataType   = typeof(string);
                            table.AddColumn(newCol);
                        }
                    }
                }
            }
            return(table);
        }
예제 #8
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;
            }
        }
예제 #9
0
        //-----------------------------------
        public static CTableDefinitionSNMP FromDefinition(
            CEasyQuerySource laBase,
            IDefinition def,
            CEasyQuerySourceFolder folder

            )
        {
            CTableDefinitionSNMP table = null;

            if (def.Type == DefinitionType.Table)
            {
                table           = new CTableDefinitionSNMP(laBase);
                table.TableName = def.Name;
                table.OID       = def.GetNumericalForm();

                if (folder != null)
                {
                    table.FolderId = folder.Id;
                }

                if (def.Children.Count() == 1)
                {
                    CColumnDefinitionSimple colIndex = new CColumnDefinitionSimple("Index", typeof(string));
                    table.AddColumn(colIndex);
                    IDefinition entry = def.Children.ElementAt(0);
                    foreach (IDefinition col in entry.Children)
                    {
                        if (col.Type == DefinitionType.Column)
                        {
                            ObjectType objType = col.Entity as ObjectType;
                            if (objType != null && objType.Access != MaxAccess.notAccessible)
                            {
                                CColumnDefinitionSNMP newCol = new CColumnDefinitionSNMP();
                                newCol.ColumnName  = col.Name;
                                newCol.Description = col.Description;
                                newCol.OID         = col.GetNumericalForm();
                                TextualConvention conv = objType.Syntax as TextualConvention;
                                if (conv != null)
                                {
                                    newCol.SnmpType = conv.Syntax as AbstractTypeAssignment;
                                }
                                else
                                {
                                    newCol.SnmpType = objType.Syntax as AbstractTypeAssignment;
                                }
                                if (newCol.SnmpType == null)
                                {
                                    newCol.DataType   = typeof(string);
                                    newCol.IsReadOnly = true;
                                }
                                switch (objType.Access)
                                {
                                case MaxAccess.accessibleForNotify:
                                case MaxAccess.readOnly:
                                    newCol.IsReadOnly = true;
                                    break;

                                case MaxAccess.readWrite:
                                case MaxAccess.readCreate:
                                    newCol.IsReadOnly = false;
                                    break;
                                }
                                table.AddColumn(newCol);
                            }
                        }
                    }
                }
            }
            return(table);
        }