Ejemplo n.º 1
0
        private static System.ComponentModel.BindingList <AQBTest.MetadataItemFQN> BuildBindingList(
            ActiveQueryBuilder.View.WinForms.QueryBuilder qb
            )
        {
            System.ComponentModel.BindingList <AQBTest.MetadataItemFQN> list = new System.ComponentModel.BindingList <AQBTest.MetadataItemFQN>( );
            using (var sqlContext = new ActiveQueryBuilder.Core.SQLContext( ))
            {
                sqlContext.Assign(qb.SQLContext);
                //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(...)
Ejemplo n.º 2
0
        } // createQueryBuilder(...)

        #endregion

        private static void Dump(ActiveQueryBuilder.View.WinForms.QueryBuilder qb, AQBTest.DataStore ds)
        {
            string fnAqbQbFilename = TS_STR + "." + ds.AqbQbFilename;
            string fnMiFqnFilename = TS_STR + "." + ds.MiFqnFilename;
            {
                // Export AQB's Query Builder XML Structures...
                //string xmlStr = qb.MetadataContainer.XML;
                qb.MetadataContainer.ExportToXML(fnAqbQbFilename);
                // qb.MetadataContainer.ImportFromXML( filename );
            }
            {
                // Export MetadataItem FQN Collection...
                AQBTest.MetadataItemFQNCollection o = new AQBTest.MetadataItemFQNCollection( );
                o.List = BuildBindingList(qb);
                o.Save(fnMiFqnFilename);
            }
        }
Ejemplo n.º 3
0
        }             // public static void f( ... ) ...

        private static void Dump(ActiveQueryBuilder.View.WinForms.QueryBuilder qb, DataStore ds)
        {
            string TS_STR = @"D:\TEMP\SQLite\" + DataStore.TS_STR.Replace(":", "");

            {
                // Export AQB's Query Builder XML Structures...
                //string xmlStr = qb.MetadataContainer.XML;
                string filename = TS_STR + "." + ds.AqbQbFilename;
                qb.MetadataContainer.ExportToXML(filename);
                // qb.MetadataContainer.ImportFromXML( filename );
            }
            {
                // Export MetadataItem FQN Collection...
                MetadataItemFQNCollection o = new MetadataItemFQNCollection( );
                o.List = ExtractMetadataValues.BuildBindingList(qb);
                string filename = TS_STR + "." + ds.MiFqnFilename;
                o.Save(filename);
            }
            tnm.ShowNotification(tnm.Notifications[0]);
        }
Ejemplo n.º 4
0
 public static ActiveQueryBuilder.View.WinForms.QueryBuilder CreateQueryBuilderSQLite(
     string connectionString,
     bool loadDefaultDatabaseOnly,
     bool loadSystemObjects,
     bool withFields
     )
 {
     ActiveQueryBuilder.View.WinForms.QueryBuilder qb = new ActiveQueryBuilder.View.WinForms.QueryBuilder( )
     {
         SyntaxProvider   = new ActiveQueryBuilder.Core.SQLiteSyntaxProvider( ),
         MetadataProvider = new ActiveQueryBuilder.Core.SQLiteMetadataProvider( )
     };
     qb.MetadataProvider.Connection = new System.Data.SQLite.SQLiteConnection(connectionString);
     {
         ActiveQueryBuilder.Core.MetadataLoadingOptions loadingOptions = qb.SQLContext.MetadataContainer.LoadingOptions;
         loadingOptions.LoadDefaultDatabaseOnly = loadDefaultDatabaseOnly;
         loadingOptions.LoadSystemObjects       = loadSystemObjects;
         //loadingOptions.IncludeFilter.Types = MetadataType.Field;
         //loadingOptions.ExcludeFilter.Schemas.Add("dbo");
     }
     qb.InitializeDatabaseSchemaTree( );
     qb.MetadataContainer.LoadAll(withFields);
     return(qb);
 } // createQueryBuilder(...)
Ejemplo n.º 5
0
        } // createQueryBuilder(...)

        #endregion

        #region --- SQLite... ---
        private static ActiveQueryBuilder.View.WinForms.QueryBuilder DumpSQLite(AQBTest.DataStore ds)
        {
            ActiveQueryBuilder.View.WinForms.QueryBuilder qb = CreateQueryBuilderSQLite(ds);
            Dump(qb, ds);
            return(qb);
        }
Ejemplo n.º 6
0
 private static ActiveQueryBuilder.View.WinForms.QueryBuilder DumpMSSQL(DataStore ds)
 {
     ActiveQueryBuilder.View.WinForms.QueryBuilder qb = CreateQueryBuilderMSSQL(ds);
     Dump(qb, ds);
     return(qb);
 }
        public MetadataItemFQNForm(string connectionString, string aqbQbXmlFilename, bool loadDefaultDatabaseOnly = true, bool loadSystemObjects = false, bool withFields = true)
        {
            bool isToPullRemotelly = false;
            bool isMSSQL           = false;

            InitializeComponent( );
            {
                if (!isMSSQL)
                { // IT IS A SQLITE DBMS...
                    //connectionString = @"Data Source=D:\TEMP\SQLite\SQLITEDB1.db3;";
                    connectionString = @"Data Source=D:\TEMP\SQLite\chinook\chinook.db;";
                    aqbQbXmlFilename = @"D:\TEMP\SQLite\MetadataSQLiteTestWithFields.xml";
                    string miFqnXmlFilename = @"D:\TEMP\SQLite\SqliteMiFqn.xml";
                    if (isToPullRemotelly)
                    {
                        this.qb = CreateQueryBuilderSQLite(connectionString, loadDefaultDatabaseOnly, loadSystemObjects, withFields);
                        { // Export AQB's Query Builder XML Structures...
                            ExtractMetadataValues.SerializeQueryBuilder(this.qb, aqbQbXmlFilename);
                        }
                        MetadataItemFQNCollection o = new MetadataItemFQNCollection( );
                        o.List = ExtractMetadataValues.BuildBindingList(this.qb);
                        { // Export MetadataItem FQN Collection...
                            o.Save(miFqnXmlFilename);
                        }
                        this.gridControl1.DataSource = o.List;
                    }
                    else
                    {
                        MetadataItemFQNCollection p = MetadataItemFQNCollection.Load(miFqnXmlFilename);
                        this.gridControl1.DataSource = p.List;
                    }
                }
                else
                { // IS MSSQL DBMS...
                    connectionString = @"Data Source=DBSRV\QWERTY;Database=Sales;User Id=user02;Password=8a0IucJ@Nx1Qy5HfFrX0Ob3m;";
                    aqbQbXmlFilename = @"D:\TEMP\SQLite\MetadataMSSQLTestWithFields.xml";
                    string miFqnXmlFilename = @"D:\TEMP\SQLite\MssqlMiFqn.xml";
                    if (isToPullRemotelly)
                    {
                        this.qb = CreateQueryBuilderMSSQL(connectionString, loadDefaultDatabaseOnly, loadSystemObjects, withFields);
                        { // Export AQB's Query Builder XML Structures...
                            ExtractMetadataValues.SerializeQueryBuilder(this.qb, aqbQbXmlFilename);
                        }
                        MetadataItemFQNCollection o = new MetadataItemFQNCollection( );
                        o.List = ExtractMetadataValues.BuildBindingList(this.qb);
                        { // Export MetadataItem FQN Collection...
                            o.Save(miFqnXmlFilename);
                        }
                        this.gridControl1.DataSource = o.List;
                    }
                    else
                    {
                        MetadataItemFQNCollection p = MetadataItemFQNCollection.Load(miFqnXmlFilename);
                        this.gridControl1.DataSource = p.List;
                    }
                }
            }
            ExtractMetadataValues.ConfigGridControl(this.gridControl1, this.gridView1);
            // QueryBuilder.ShowMetadataContainerLoadWizard( this.qb.MetadataContainer, this.qb.MetadataLoadingOptions );
            // MetadataEditorOptions o = MetadataEditorOptions.HideLoadDatabaseButton;
            // QueryBuilder.EditMetadataContainer( this.qb.MetadataContainer, this.qb.MetadataStructure, this.qb.MetadataLoadingOptions );
        }
        public MetadataItemFQNForm(DataStoreCollection dsColl)
            : this()
        {
            this.dsColl = dsColl ?? throw new System.ArgumentNullException(nameof(dsColl));
            for (int i = 0; i < this.dsColl.List.Count; i++)
            {
                DataStore ds = this.dsColl.List[i];
                if (!ds.IsActive)
                {
                    continue;
                }
                if (ds.IsToPullRemotely)
                {
                    DataStore.SyntaxProviderEnum x = (DataStore.SyntaxProviderEnum)ds.SyntaxProvider;
                    switch (x)
                    {
                    case DataStore.SyntaxProviderEnum.SQLITE:
                        this.qb = CreateQueryBuilderSQLite(ds);
                        break;

                    case DataStore.SyntaxProviderEnum.MS_SQL_SERVER_2014:
                        this.qb = CreateQueryBuilderMSSQL(ds);
                        break;

                    case DataStore.SyntaxProviderEnum.AUTO:
                        break;

                    case DataStore.SyntaxProviderEnum.GENERIC:
                        break;

                    case DataStore.SyntaxProviderEnum.ANSI_SQL_2003:
                    case DataStore.SyntaxProviderEnum.ANSI_SQL_89:
                    case DataStore.SyntaxProviderEnum.ANSI_SQL_92:
                    case DataStore.SyntaxProviderEnum.FIREBIRD_1_0:
                    case DataStore.SyntaxProviderEnum.FIREBIRD_1_5:
                    case DataStore.SyntaxProviderEnum.FIREBIRD_2_0:
                    case DataStore.SyntaxProviderEnum.FIREBIRD_2_5:
                    case DataStore.SyntaxProviderEnum.IBM_DB2:
                    case DataStore.SyntaxProviderEnum.IBM_INFORMIX_10:
                    case DataStore.SyntaxProviderEnum.IBM_INFORMIX_8:
                    case DataStore.SyntaxProviderEnum.IBM_INFORMIX_9:
                    case DataStore.SyntaxProviderEnum.MS_ACCESS_2000_:
                    case DataStore.SyntaxProviderEnum.MS_ACCESS_2003_:
                    case DataStore.SyntaxProviderEnum.MS_ACCESS_97_:
                    case DataStore.SyntaxProviderEnum.MS_ACCESS_XP_:
                    case DataStore.SyntaxProviderEnum.MS_SQL_SERVER_2000:
                    case DataStore.SyntaxProviderEnum.MS_SQL_SERVER_2005:
                    case DataStore.SyntaxProviderEnum.MS_SQL_SERVER_2008:
                    case DataStore.SyntaxProviderEnum.MS_SQL_SERVER_2012:
                    case DataStore.SyntaxProviderEnum.MS_SQL_SERVER_7:
                    case DataStore.SyntaxProviderEnum.MS_SQL_SERVER_COMPACT_EDITION:
                    case DataStore.SyntaxProviderEnum.MYSQL_3_XX:
                    case DataStore.SyntaxProviderEnum.MYSQL_4_0:
                    case DataStore.SyntaxProviderEnum.MYSQL_4_1:
                    case DataStore.SyntaxProviderEnum.MYSQL_5_0:
                    case DataStore.SyntaxProviderEnum.ORACLE_10:
                    case DataStore.SyntaxProviderEnum.ORACLE_11:
                    case DataStore.SyntaxProviderEnum.ORACLE_7:
                    case DataStore.SyntaxProviderEnum.ORACLE_8:
                    case DataStore.SyntaxProviderEnum.ORACLE_9:
                    case DataStore.SyntaxProviderEnum.POSTGRESQL:
                    case DataStore.SyntaxProviderEnum.SYBASE_ASE:
                    case DataStore.SyntaxProviderEnum.SYBASE_SQL_ANYWHERE:
                    case DataStore.SyntaxProviderEnum.TERADATA:
                    case DataStore.SyntaxProviderEnum.VISTADB:
                    default:
                        break;
                    }
                    { // Export AQB's Query Builder XML Structures...
                        ExtractMetadataValues.SerializeQueryBuilder(this.qb, ds.AqbQbFilename);
                    }
                    MetadataItemFQNCollection o = new MetadataItemFQNCollection( );
                    o.List = ExtractMetadataValues.BuildBindingList(this.qb);
                    { // Export MetadataItem FQN Collection...
                        o.Save(ds.MiFqnFilename);
                    }
                    this.gridControl1.DataSource = o.List;
                }
                else
                {
                    MetadataItemFQNCollection o = MetadataItemFQNCollection.Load(ds.MiFqnFilename);
                    this.gridControl1.DataSource = o.List;
                }
            }
        }