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); }
private static void NewMethod() { ds = new System.Data.DataSet("X"); { ds.Tables.Add(Class1.CreateDataStoreConfigTable( )); ds.Tables.Add(Class1.CreateDataStoreSnapshotFileTable( )); ds.Tables.Add(Class1.CreateMetadataItemTable( )); } Class1.LoadDataStoreSnapshotFilesTable(ds); { ActiveQueryBuilder.Core.SQLContext sc = Class1.CreateAqbSqlContext4SQLiteOffline(filepath); Class1.DrillDownAqbSqlContext(sc, ds.Tables[Class1.MetadataItem_TblName], "Ale"); } //ds.Tables.Add( Class1.CreateDataSetSnapshotTable( ) ); //ds.Tables.Add( Class1.CreateMetadataItemTable( ) ); //Class1.ZZZZZZZZ( ds ); //// //// ds.WriteXml(filepath2); //{ // ds.RemotingFormat = System.Data.SerializationFormat.Binary; // using( System.IO.FileStream fs = new System.IO.FileStream( filepath3, System.IO.FileMode.Create ) ) // { // System.Runtime.Serialization.Formatters.Binary.BinaryFormatter fmt = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter( ); // fmt.Serialize( fs, ds ); // fs.Close( ); // } //} //{ // System.Data.DataSet o = new System.Data.DataSet( ); // o.ReadXml( filepath2 ); //} }
private void testAQBMsssAutoConnectionBarButtonItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { using (ActiveQueryBuilder.Core.SQLContext sqlContext = MetadataPullerXtraUserControl.CreateAqbQbMSSS(this.msssCSBuilder.ConnectionString)) { this.dataTable = MetadataPullerXtraUserControl.CreateMetadataItemTable(); MetadataPullerXtraUserControl.DrillDownAqbSqlContext(sqlContext, this.dataTable, "XPTO"); this.aqbGridControl.DataSource = this.dataTable; } }
private static ActiveQueryBuilder.Core.SQLContext CreateAqbQbMSSS(DataModel.DataStore ds) { ActiveQueryBuilder.Core.SQLContext sc = new ActiveQueryBuilder.Core.SQLContext( ) { SyntaxProvider = new ActiveQueryBuilder.Core.MSSQLSyntaxProvider( ), MetadataProvider = new ActiveQueryBuilder.Core.MSSQLMetadataProvider( ) }; sc.MetadataProvider.Connection = new System.Data.SqlClient.SqlConnection(ds.ConnectionString); //qb.MetadataProvider.Connection = new System.Data.SQLite.SQLiteConnection( ds.ConnectionString ); return(sc); }
private static ActiveQueryBuilder.Core.SQLContext CreateAqbQbAuto(DataModel.DataStore ds) { ActiveQueryBuilder.Core.SQLContext qb = new ActiveQueryBuilder.Core.SQLContext( ) { SyntaxProvider = new ActiveQueryBuilder.Core.AutoSyntaxProvider( ), MetadataProvider = new ActiveQueryBuilder.Core.UniversalMetadataProvider( ) }; //qb.MetadataProvider.Connection = new System.Data.SqlClient.SqlConnection( ds.ConnectionString ); qb.MetadataProvider.Connection = new System.Data.SQLite.SQLiteConnection(ds.ConnectionString); return(qb); }
private static void DumpAqbQb(ActiveQueryBuilder.Core.SQLContext sc, DataModel.DataStore ds) { string path = Global.DataStoreCollectionPathName + Global.TS_STR; { // Export AQB’s Query Builder XML Structures… string xmlStr = sc.MetadataContainer.XML; sc.MetadataContainer.ExportToXML(ds.TempFileFullPathName); // SQLite From TMP to "USER PATH" System.IO.File.Copy(ds.TempFileFullPathName, ds.AqbQbFilename, true); // qb.MetadataContainer.ImportFromXML( filename ); } //tnm.ShowNotification( tnm.Notifications[ 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(...)
/* * https://support.activequerybuilder.com/hc/en-us/articles/115001055349-Getting-started-with-AQB-NET-3-in-the-Separated-Controls-UI-or-Non-visual-mode * * Your initialization code will look as follows: * * // Non-visual objects * _sqlContext = new SQLContext * { * SyntaxProvider = new MSSQLSyntaxProvider * { * ServerVersion = MSSQLServerVersion.MSSQL2012 * }, * MetadataProvider = new OLEDBMetadataProvider * { * Connection = new OleDbConnection() * { * ConnectionString = "" * } * } * }; * * _sqlQuery = new SQLQuery(_sqlContext); * * Sergey Smagin * Ok, then you need only the SQLContext object. * * sqlContext.MetadataContainer.ExportToXML(); * */ private static ActiveQueryBuilder.Core.SQLContext CreateAqbQbSQLite(DataModel.DataStore ds) { 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 = ds.ConnectionString } } }; return(sc); }
public static ActiveQueryBuilder.Core.SQLContext CreateAqbQbMSSS(string connectionString) { ActiveQueryBuilder.Core.SQLContext sc = new ActiveQueryBuilder.Core.SQLContext( ) { SyntaxProvider = new ActiveQueryBuilder.Core.MSSQLSyntaxProvider( ), MetadataProvider = new ActiveQueryBuilder.Core.MSSQLMetadataProvider( ) }; //qb.MetadataProvider.Connection = new System.Data.SQLite.SQLiteConnection( ds.ConnectionString ); sc.MetadataProvider.Connection = new System.Data.SqlClient.SqlConnection(connectionString); { sc.LoadingOptions.OfflineMode = false; sc.LoadingOptions.LoadSystemObjects = false; sc.LoadingOptions.LoadDefaultDatabaseOnly = true; sc.MetadataContainer.LoadAll(true); } return(sc); }
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); }
public static ActiveQueryBuilder.Core.SQLContext CreateAqbSqlContext4SQLiteOffline(string filepath) { 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.ConnectionString // } //} }; { sc.MetadataContainer.LoadingOptions.OfflineMode = true; sc.MetadataContainer.ImportFromXML(filepath); } return(sc); }
public static ActiveQueryBuilder.Core.SQLContext CreateAqbSqlContext4SQLiteOnline(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.LoadAll( WithField ); // sc.MetadataContainer.LoadingOptions.OfflineMode = true; // sc.MetadataContainer.ImportFromXML( filepath ); //} return(sc); }
private static void PullAndDump(DataModel.DataStore ds) { try { ActiveQueryBuilder.Core.SQLContext qb = PullMetadata(ds); if (qb == null) { return; } DumpAqbQb(qb, ds); DataModel.MetadataItemCollection miColl = DumpMetadataItem(ds, qb); // publish( qb, ds ); // push( qb, ds ); // baseline( qb, ds ); // diff( qb, ds ); // thesaurus( qb, ds ); // watchers( qb, ds ); // log( qb, ds ); } catch (System.Exception ex) { } }
static void Main() { try { DataPhilosophiaeSection dps = cm.GetSection("DataPhilosophiaeSection") as DataPhilosophiaeSection; if (dps != null) { System.Console.WriteLine(dps.Stage.PathDir); foreach (DataStoreElement ds in dps.DataStores) { System.Console.WriteLine(ds.Name); System.Console.WriteLine(ds.LoadDefaultDatabaseOnly); System.Console.WriteLine(ds.LoadSystemObjects); System.Console.WriteLine(ds.WithFields); if (string.IsNullOrWhiteSpace(ds.PathDir)) { ds.PathDir = System.IO.Path.Combine(dps.Stage.PathDir, ds.Name); cm.Save(System.Configuration.ConfigurationSaveMode.Minimal, true); } System.Console.WriteLine(ds.PathDir); } } //DataStoreElement dse = new DataStoreElement( ); //cm.Save( System.Configuration.ConfigurationSaveMode.Minimal, false ); } catch (System.Configuration.ConfigurationErrorsException ex) { System.Console.WriteLine(ex.Message); } try { System.Configuration.ConnectionStringSettingsCollection settings = System.Configuration.ConfigurationManager.ConnectionStrings; if (settings != null) { foreach (System.Configuration.ConnectionStringSettings cs in settings) { System.Console.WriteLine(" Name:" + cs.Name); System.Console.WriteLine(" ProviderName:" + cs.ProviderName); System.Console.WriteLine("ConnectionString:" + cs.ConnectionString); } } } catch (System.Configuration.ConfigurationErrorsException ex) { System.Console.WriteLine(ex.Message); } { DataPhilosophiaeSection dps = cm.GetSection("DataPhilosophiaeSection") as DataPhilosophiaeSection; DataStoreElement ds = dps.DataStores[0]; System.Configuration.ConnectionStringSettingsCollection settings = System.Configuration.ConfigurationManager.ConnectionStrings; System.Configuration.ConnectionStringSettings cs = settings[ds.ConnectionStringName]; // ActiveQueryBuilder.Core.SyntaxProviderList syntaxProviderList = new ActiveQueryBuilder.Core.SyntaxProviderList( ); ActiveQueryBuilder.Core.SQLContext sc = new ActiveQueryBuilder.Core.SQLContext( ) { SyntaxProvider = new ActiveQueryBuilder.Core.AutoSyntaxProvider( ), MetadataProvider = new ActiveQueryBuilder.Core.OLEDBMetadataProvider { Connection = new System.Data.OleDb.OleDbConnection( ) { ConnectionString = cs.ConnectionString } } }; } { DataPhilosophiaeSection dps = cm.GetSection("DataPhilosophiaeSection") as DataPhilosophiaeSection; DataStoreElement ds = dps.DataStores[0]; System.Configuration.ConnectionStringSettingsCollection settings = System.Configuration.ConfigurationManager.ConnectionStrings; System.Configuration.ConnectionStringSettings cs = settings[ds.ConnectionStringName]; // ActiveQueryBuilder.Core.SyntaxProviderList syntaxProviderList = new ActiveQueryBuilder.Core.SyntaxProviderList( ); 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.ConnectionString } } }; ActiveQueryBuilder.Core.MetadataLoadingOptions loadingOptions = sc.MetadataContainer.LoadingOptions; loadingOptions.LoadDefaultDatabaseOnly = ds.LoadDefaultDatabaseOnly == 1 ? true : false; loadingOptions.LoadSystemObjects = ds.LoadSystemObjects == 1 ? true : false; //loadingOptions.IncludeFilter.Types = MetadataType.Field; //loadingOptions.ExcludeFilter.Schemas.Add(“dbo”); sc.MetadataContainer.LoadAll(ds.WithFields == 1 ? true : false); } //TunnelSection ts = System.Configuration.ConfigurationManager.GetSection( "TunnelSection" ) as TunnelSection; TunnelSection ts = cm.GetSection("TunnelSection") as TunnelSection; int count1 = ts.Tunnels.Count; HostConfigElement hc = ts.Tunnels[0]; string sSHServerHostname = hc.SSHServerHostname; string username = hc.Username; TunnelCollection tunnels = hc.Tunnels; int count2 = tunnels.Count; TunnelConfigElement tce = tunnels[0]; string name = tce.Name; int localPort = tce.LocalPort; //ProductSettings productSettings = System.Configuration.ConfigurationManager.GetSection( "ProductSettings" ) as ProductSettings; //ConfigurationClassLoader x = System.Configuration.ConfigurationManager.GetSection( "Plugins" ) as ConfigurationClassLoader; // System.Configuration.ConfigurationSectionGroup a = cm.GetSectionGroup("DataStoreGroup"); System.Configuration.ConfigurationSectionCollection sections = a.Sections; int count = sections.Count; System.Configuration.ConfigurationSection get = sections.Get(0); // NewMethod( ); // System.Windows.Forms.Application.EnableVisualStyles( ); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Application.Run(new Form1( )); }
private static DataModel.MetadataItemCollection DumpMetadataItem(DataModel.DataStore ds, ActiveQueryBuilder.Core.SQLContext sc) { DataModel.MetadataItemCollection o = new DataModel.MetadataItemCollection( ); o.List = BuildBindingList(sc); // Export MetadataItem FQN Collection... string TempFileFullPathName = System.IO.Path.GetTempFileName( ); o.Save(TempFileFullPathName); // SQLite From TMP to "USER PATH" System.IO.File.Copy(TempFileFullPathName, ds.MiFqnFilename, true); // return(o); }