Example #1
0
 public static bool TestAqbSqlContext4SQLiteConnection(string cs)
 {
     ActiveQueryBuilder.Core.SQLContext sc = new ActiveQueryBuilder.Core.SQLContext( )
     {
         SyntaxProvider   = new ActiveQueryBuilder.Core.SQLiteSyntaxProvider( ),
         MetadataProvider = new ActiveQueryBuilder.Core.SQLiteMetadataProvider( )
         {
             Connection = new System.Data.SQLite.SQLiteConnection( )
             {
                 ConnectionString = cs
             }
         }
     };
     {
         // sc.MetadataContainer.LoadingOptions.OfflineMode = false;
         // sc.MetadataContainer.LoadingOptions.LoadSystemObjects = false;
         // sc.MetadataContainer.LoadingOptions.LoadDefaultDatabaseOnly = true;
         sc.LoadingOptions.OfflineMode             = false;
         sc.LoadingOptions.LoadSystemObjects       = false;
         sc.LoadingOptions.LoadDefaultDatabaseOnly = true;
         sc.MetadataContainer.LoadAll(false);
     }
     ActiveQueryBuilder.Core.MetadataList items = sc.MetadataContainer.Items;
     return(items == null ? false : true);
 }
Example #2
0
        private static System.ComponentModel.BindingList <DataModel.MetadataItem> BuildBindingList(
            ActiveQueryBuilder.Core.SQLContext sc
            )
        {
            System.ComponentModel.BindingList <DataModel.MetadataItem> list = new System.ComponentModel.BindingList <DataModel.MetadataItem>( );
            using (var sqlContext = new ActiveQueryBuilder.Core.SQLContext( ))
            {
                sqlContext.Assign(sc);
                //sqlContext.MetadataContainer.LoadingOptions.LoadDefaultDatabaseOnly = false;
                //sqlContext.MetadataContainer.LoadingOptions.LoadSystemObjects = false;

                using (ActiveQueryBuilder.Core.MetadataList miList = new ActiveQueryBuilder.Core.MetadataList(sqlContext.MetadataContainer))
                {
                    miList.Load(ActiveQueryBuilder.Core.MetadataType.All, true);
                    System.Collections.Generic.Stack <StackItem> stack = new System.Collections.Generic.Stack <StackItem>( );
                    stack.Push(new StackItem {
                        list = miList, index = 0, parentID = -1, grandParentID = -1
                    });
                    do
                    {
                        StackItem si = stack.Pop( );
                        ActiveQueryBuilder.Core.MetadataList actualMIList = si.list;
                        int actualIndex    = si.index;
                        int actualParentID = si.grandParentID; // IMPORTANT!!!
                        {
                            for ( ; actualIndex < actualMIList.Count; actualIndex++)
                            {
                                ExtractMetadataItem(list, actualMIList[actualIndex], actualParentID);
                                if (actualMIList[actualIndex].Items.Count > 0) // branch...
                                {
                                    // Push the "next" Item...
                                    stack.Push(new StackItem
                                    {
                                        list          = actualMIList,
                                        index         = actualIndex + 1,
                                        parentID      = list[list.Count - 1].ID,
                                        grandParentID = actualParentID
                                    });
                                    // Reset the loop to process the "actual" Item...
                                    actualParentID = list[list.Count - 1].ID;
                                    actualMIList   = actualMIList[actualIndex].Items;
                                    actualIndex    = -1;
                                }
                            } // for(;;)...
                        }
                    } while(stack.Count > 0);
                } // using()...
            }     // using()...
            return(list);
        }         // buildBindingList(...)
Example #3
0
 public static void DrillDownAqbSqlContext(
     ActiveQueryBuilder.Core.SQLContext sc
     , System.Data.DataTable tbl
     , string dataStoreName
     )
 {
     ActiveQueryBuilder.Core.MetadataList items = sc.MetadataContainer.Items;
     //
     System.Collections.Generic.Stack <StackItem> stack = new System.Collections.Generic.Stack <StackItem>( );
     stack.Push(new StackItem {
         list = items, index = 0, parentID = -1, grandParentID = -1
     });
     do
     {
         StackItem si = stack.Pop( );
         ActiveQueryBuilder.Core.MetadataList actualMIList = si.list;
         int actualIndex    = si.index;
         int actualParentID = si.grandParentID; // IMPORTANT!!!
         for ( ; actualIndex < actualMIList.Count; actualIndex++)
         {
             System.Data.DataRow row = tbl.NewRow( );
             row["DataStoreName"] = dataStoreName;
             ExtractMetadataItem(row, actualMIList[actualIndex], actualParentID, tbl);
             tbl.Rows.Add(row);
             if (actualMIList[actualIndex].Items.Count > 0) // branch...
             {
                 int count = tbl.Rows.Count;
                 System.Data.DataRowCollection rows = tbl.Rows;
                 int parentId = (int)rows[count - 1]["ID"];
                 // Push the "next" Item...
                 stack.Push(new StackItem
                 {
                     list          = actualMIList,
                     index         = actualIndex + 1,
                     parentID      = parentId,
                     grandParentID = actualParentID
                 });
                 // Reset the loop to process the "actual" Item...
                 actualParentID = parentId;
                 actualMIList   = actualMIList[actualIndex].Items;
                 actualIndex    = -1;
             }
         } // for(;;)...
     } while(stack.Count > 0);
 }