private static DataTable GetDatabases(IMyMetaTestContext criteria, IMyMetaPlugin plugin) { if (_databases == null) { _databases = plugin.Databases; if (criteria.DefaultDatabaseOnly) { List<DataRow> rowsToDelete = new List<DataRow>(); string defaultDb = plugin.DefaultDatabase; if (!string.IsNullOrEmpty(defaultDb)) { defaultDb = defaultDb.Trim(); foreach (DataRow dbRow in _databases.Rows) { string dbname = dbRow["CATALOG_NAME"].ToString(); if (dbname != defaultDb) rowsToDelete.Add(dbRow); } } if (rowsToDelete.Count != (_databases.Rows.Count - 1)) { rowsToDelete.Clear(); for (int i = 1; i < _databases.Rows.Count; i++) rowsToDelete.Add(_databases.Rows[i]); } foreach (DataRow dbRow in rowsToDelete) _databases.Rows.Remove(dbRow); } } return _databases; }
private void MyMetaPluginUtility_Load(object sender, EventArgs e) { //dbRoot root = new dbRoot(); foreach (IMyMetaPlugin plugin in dbRoot.Plugins.Values) { IMyMetaPlugin pluginTest = dbRoot.Plugins[plugin.ProviderUniqueKey] as IMyMetaPlugin; if (pluginTest == plugin) { this.comboBoxPlugins.Items.Add(plugin.ProviderUniqueKey); } } dbRoot root = new dbRoot(); foreach (string dbd in Enum.GetNames(typeof(dbDriver))) { if (!dbd.Equals("Plugin", StringComparison.CurrentCultureIgnoreCase)) { this.comboBoxPlugins.Items.Add(dbd.ToUpper()); } } if (ConfigFile.Exists) { string[] lines = File.ReadAllLines(ConfigFile.FullName); if (lines.Length > 1) { int idx = this.comboBoxPlugins.FindStringExact(lines[0]); if (idx >= 0) { this.comboBoxPlugins.SelectedIndex = idx; } this.textBoxConnectionString.Text = lines[1]; } } }
internal PluginDriver(IMyMetaPlugin plugin) : base(plugin.GetType(), "", false) { this.plugin = plugin; this.IsOleDB = canBrowseDatabase(); }
public static void Test(IMyMetaTestContext criteria) { IMyMetaPlugin plugin = null; try { plugin = dbRoot.Plugins[criteria.ProviderType] as IMyMetaPlugin; IMyMetaPluginContext context = new MyMetaPluginContext(plugin.ProviderUniqueKey, criteria.ConnectionString); plugin.Initialize(context); using (IDbConnection conn = plugin.NewConnection) { conn.Open(); conn.Close(); } criteria.AppendLog("Connection Test Successful."); } catch (Exception ex) { criteria.AppendLog("Error testing connection", ex); } _databases = null; TestDatabases(criteria, plugin); TestTables(criteria, plugin); TestViews(criteria, plugin); TestProcedures(criteria, plugin); _databases = null; }
internal PluginDriver(IMyMetaPlugin plugin) : base(plugin.GetType(),"", false) { this.plugin = plugin; this.IsOleDB = canBrowseDatabase(); }
private void NewAbout_Load(object sender, System.EventArgs e) { this.fun1.Start(); Assembly asmblyMyGen = System.Reflection.Assembly.GetEntryAssembly(); Assembly asmblyZeus = System.Reflection.Assembly.GetAssembly(typeof(Zeus.ZeusTemplate)); Assembly asmblyPlugins = System.Reflection.Assembly.GetAssembly(typeof(Zeus.IZeusCodeSegment)); Assembly asmblyMyMeta = System.Reflection.Assembly.GetAssembly(typeof(MyMeta.Database)); Assembly asmblyScintilla = System.Reflection.Assembly.GetAssembly(typeof(Scintilla.ScintillaControl)); Assembly asmblyWinFormsUI = System.Reflection.Assembly.GetAssembly(typeof(DockContent)); lstBoxProducts.Items.Add("MyGeneration".PadRight(29) + asmblyMyGen.GetName().Version.ToString()); lstBoxProducts.Items.Add("MyMeta".PadRight(29) + asmblyMyMeta.GetName().Version.ToString()); lstBoxProducts.Items.Add("Zeus Parser".PadRight(29) + asmblyZeus.GetName().Version.ToString()); lstBoxProducts.Items.Add("Plug-in Interface".PadRight(29) + asmblyPlugins.GetName().Version.ToString()); lstBoxProducts.Items.Add("ScintillaNet".PadRight(29) + asmblyScintilla.GetName().Version.ToString()); lstBoxProducts.Items.Add("Scintilla".PadRight(29) + "1.60"); lstBoxProducts.Items.Add("DockPanel Suite".PadRight(29) + asmblyWinFormsUI.GetName().Version.ToString()); lstBoxProducts.Items.Add("Npgsql".PadRight(29) + GetAssemblyVersion("Npgsql", "1.0.0.0")); lstBoxProducts.Items.Add("Firebird .Net Data Provider".PadRight(29) + GetAssemblyVersion("FirebirdSql.Data.Firebird", "1.7.1.0")); lstBoxProducts.Items.Add("System.Data.SQLite".PadRight(29) + GetAssemblyVersion("System.Data.SQLite", "1.0.38.0")); #if !IGNORE_VISTA lstBoxProducts.Items.Add("VistaDB 2.0 ADO.NET Provider".PadRight(29) + "2.0.16"); #else lstBoxProducts.Items.Add(""); // number of items must match #endif lstBoxProducts.Items.Add("Dnp.Utils".PadRight(29) + GetAssemblyVersion("Dnp.Utils", "1.0.0.0")); foreach (string pluginName in MyMeta.dbRoot.Plugins.Keys) { IMyMetaPlugin plugin = dbRoot.Plugins[pluginName] as IMyMetaPlugin; int index = lstBoxProducts.Items.Add(plugin.ProviderName.PadRight(29) + plugin.GetType().Assembly.GetName().Version.ToString()); plugins[index] = plugin; } foreach (string pluginName in PluginManager.ContentManagers.Keys) { IContentManager plugin = PluginManager.ContentManagers[pluginName] as IContentManager; int index = lstBoxProducts.Items.Add(plugin.Name.PadRight(29) + plugin.GetType().Assembly.GetName().Version.ToString()); cmPlugins[index] = plugin; } foreach (string pluginName in PluginManager.SimplePluginManagers.Keys) { ISimplePluginManager plugin = PluginManager.SimplePluginManagers[pluginName] as ISimplePluginManager; int index = lstBoxProducts.Items.Add(plugin.Name.PadRight(29) + plugin.GetType().Assembly.GetName().Version.ToString()); smPlugins[index] = plugin; } foreach (string pluginName in PluginManager.EditorManagers.Keys) { IEditorManager plugin = PluginManager.EditorManagers[pluginName] as IEditorManager; int index = lstBoxProducts.Items.Add(plugin.Name.PadRight(29) + plugin.GetType().Assembly.GetName().Version.ToString()); emPlugins[index] = plugin; } lstBoxProducts.SelectedIndex = 0; }
private static void TestDatabases(IMyMetaTestContext criteria, IMyMetaPlugin plugin) { if (!criteria.HasErrors) { try { DataTable dt = GetDatabases(criteria, plugin); criteria.AppendLog(dt.Rows.Count + " databases found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin Databases Error", ex); } } }
private void comboBoxPlugins_SelectedIndexChanged(object sender, EventArgs e) { if (this.comboBoxPlugins.SelectedItem != null) { IMyMetaPlugin plugin = dbRoot.Plugins[this.comboBoxPlugins.SelectedItem.ToString()] as IMyMetaPlugin; if (plugin != null) { this.checkBoxPlugin.Enabled = true; this.checkBoxPlugin.Checked = true; this.textBoxConnectionString.Text = plugin.SampleConnectionString; } else { //dbRoot root = new dbRoot(); this.checkBoxPlugin.Checked = false; this.checkBoxPlugin.Enabled = false; this.textBoxConnectionString.Text = string.Empty; } } }
private static DataTable GetDatabases(IMyMetaTestContext criteria, IMyMetaPlugin plugin) { if (_databases == null) { _databases = plugin.Databases; if (criteria.DefaultDatabaseOnly) { List <DataRow> rowsToDelete = new List <DataRow>(); string defaultDb = plugin.DefaultDatabase; if (!string.IsNullOrEmpty(defaultDb)) { defaultDb = defaultDb.Trim(); foreach (DataRow dbRow in _databases.Rows) { string dbname = dbRow["CATALOG_NAME"].ToString(); if (dbname != defaultDb) { rowsToDelete.Add(dbRow); } } } if (rowsToDelete.Count != (_databases.Rows.Count - 1)) { rowsToDelete.Clear(); for (int i = 1; i < _databases.Rows.Count; i++) { rowsToDelete.Add(_databases.Rows[i]); } } foreach (DataRow dbRow in rowsToDelete) { _databases.Rows.Remove(dbRow); } } } return(_databases); }
public PluginResultColumn(IMyMetaPlugin plugin) { this.plugin = plugin; }
public PluginResultColumns(IMyMetaPlugin plugin) { this.plugin = plugin; }
public PluginDatabases(IMyMetaPlugin plugin) { this.plugin = plugin; }
public PluginTable(IMyMetaPlugin plugin) { this.plugin = plugin; }
public PluginForeignKeys(IMyMetaPlugin plugin) { this.plugin = plugin; }
public PluginParameter(IMyMetaPlugin plugin) { this.plugin = plugin; }
public PluginTables(IMyMetaPlugin plugin) { this.plugin = plugin; }
public PluginProcedures(IMyMetaPlugin plugin) { this.plugin = plugin; }
public PluginColumns(IMyMetaPlugin plugin) { this.plugin = plugin; }
public PluginView(IMyMetaPlugin plugin) { this.plugin = plugin; }
public PluginViews(IMyMetaPlugin plugin) { this.plugin = plugin; }
private static void TestProcedures(IMyMetaTestContext criteria, IMyMetaPlugin plugin) { DataTable dbDt = null; if (!criteria.HasErrors) { try { dbDt = GetDatabases(criteria, plugin); } catch { dbDt = new DataTable(); } } if (criteria.IncludeProcedures && !criteria.HasErrors) { foreach (DataRow dbRow in dbDt.Rows) { string dbname = dbRow["CATALOG_NAME"].ToString(); try { DataTable dt = plugin.GetProcedures(dbname); criteria.AppendLog(dt.Rows.Count + " procedures in database " + dbname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin procedures error in database " + dbname, ex); } } } if (!criteria.HasErrors) { foreach (DataRow dbRow in dbDt.Rows) { string dbname = dbRow["CATALOG_NAME"].ToString(); DataTable procDt = plugin.GetProcedures(dbname); foreach (DataRow procRow in procDt.Rows) { string procedurename = procRow["PROCEDURE_NAME"].ToString(); if (criteria.IncludeParameters) { try { DataTable dt = plugin.GetProcedureParameters(dbname, procedurename); criteria.AppendLog(dt.Rows.Count + " parameters in procedure " + dbname + "." + procedurename + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin procedure parameter error in " + dbname + "." + procedurename, ex); } } if (criteria.IncludeProcOther) { try { DataTable dt = plugin.GetProcedureResultColumns(dbname, procedurename); criteria.AppendLog(dt.Rows.Count + " result columns in procedure " + dbname + "." + procedurename + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin procedure result columns error in " + dbname + "." + procedurename, ex); } } } } } }
public PluginIndexes(IMyMetaPlugin plugin) { this.plugin = plugin; }
/// <summary> /// A Plugin ConnectionString is a special feature for external assemblies. /// </summary> /// <param name="pluginConnectionString">Sample: PluginName;Provider=SQLOLEDB.1;Persist Security Info=True;User ID=sa;Data Source=localhost</param> /// <param name="plugin">Returns the plugin object.</param> /// <returns></returns> private IDbConnection GetConnectionFromPlugin(string providerName, string pluginConnectionString, out IMyMetaPlugin plugin) { MyMetaPluginContext pluginContext = new MyMetaPluginContext(providerName, pluginConnectionString); IDbConnection connection = null; if (!Plugins.ContainsKey(providerName)) { throw new Exception("MyMeta Plugin \"" + providerName + "\" not registered."); } else { plugin = Plugins[providerName] as IMyMetaPlugin; plugin.Initialize(pluginContext); connection = plugin.NewConnection; } return connection; }
private static void TestViews(IMyMetaTestContext criteria, IMyMetaPlugin plugin) { DataTable dbDt = null; if (!criteria.HasErrors) { try { dbDt = GetDatabases(criteria, plugin); } catch { dbDt = new DataTable(); } } if (criteria.IncludeViews && !criteria.HasErrors) { foreach (DataRow dbRow in dbDt.Rows) { string dbname = dbRow["CATALOG_NAME"].ToString(); try { DataTable dt = plugin.GetViews(dbname); criteria.AppendLog(dt.Rows.Count + " views in database " + dbname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin views error in database " + dbname, ex); } } } if (!criteria.HasErrors) { foreach (DataRow dbRow in dbDt.Rows) { string dbname = dbRow["CATALOG_NAME"].ToString(); DataTable viewDt = plugin.GetViews(dbname); foreach (DataRow viewRow in viewDt.Rows) { string viewname = viewRow["TABLE_NAME"].ToString(); if (criteria.IncludeViews) { try { DataTable dt = plugin.GetViewColumns(dbname, viewname); criteria.AppendLog(dt.Rows.Count + " columns in view " + dbname + "." + viewname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin view column error in " + dbname + "." + viewname, ex); } } if (criteria.IncludeViewOther) { try { List <string> list = plugin.GetViewSubTables(dbname, viewname); criteria.AppendLog(list.Count + " sub-tables in view " + dbname + "." + viewname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin view sub-tables error in " + dbname + "." + viewname, ex); } try { List <string> list = plugin.GetViewSubViews(dbname, viewname); criteria.AppendLog(list.Count + " sub-views in view " + dbname + "." + viewname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin view sub-views error in " + dbname + "." + viewname, ex); } } } } } }
public PluginProcedure(IMyMetaPlugin plugin) { this.plugin = plugin; }
public PluginDomains(IMyMetaPlugin plugin) { this.plugin = plugin; }
public PluginDomain(IMyMetaPlugin plugin) { this.plugin = plugin; }
public PluginColumn(IMyMetaPlugin plugin) { this.plugin = plugin; }
private static void TestViews(IMyMetaTestContext criteria, IMyMetaPlugin plugin) { DataTable dbDt = null; if (!criteria.HasErrors) { try { dbDt = GetDatabases(criteria, plugin); } catch { dbDt = new DataTable(); } } if (criteria.IncludeViews && !criteria.HasErrors) { foreach (DataRow dbRow in dbDt.Rows) { string dbname = dbRow["CATALOG_NAME"].ToString(); try { DataTable dt = plugin.GetViews(dbname); criteria.AppendLog(dt.Rows.Count + " views in database " + dbname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin views error in database " + dbname, ex); } } } if (!criteria.HasErrors) { foreach (DataRow dbRow in dbDt.Rows) { string dbname = dbRow["CATALOG_NAME"].ToString(); DataTable viewDt = plugin.GetViews(dbname); foreach (DataRow viewRow in viewDt.Rows) { string viewname = viewRow["TABLE_NAME"].ToString(); if (criteria.IncludeViews) { try { DataTable dt = plugin.GetViewColumns(dbname, viewname); criteria.AppendLog(dt.Rows.Count + " columns in view " + dbname + "." + viewname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin view column error in " + dbname + "." + viewname, ex); } } if (criteria.IncludeViewOther) { try { List<string> list = plugin.GetViewSubTables(dbname, viewname); criteria.AppendLog(list.Count + " sub-tables in view " + dbname + "." + viewname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin view sub-tables error in " + dbname + "." + viewname, ex); } try { List<string> list = plugin.GetViewSubViews(dbname, viewname); criteria.AppendLog(list.Count + " sub-views in view " + dbname + "." + viewname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin view sub-views error in " + dbname + "." + viewname, ex); } } } } } }
public ClassFactory(IMyMetaPlugin plugin) { this.plugin = plugin; }
private static void TestTables(IMyMetaTestContext criteria, IMyMetaPlugin plugin) { DataTable dbDt = null; if (!criteria.HasErrors) { try { dbDt = GetDatabases(criteria, plugin); } catch { dbDt = new DataTable(); } } if (criteria.IncludeTables && !criteria.HasErrors) { foreach (DataRow dbRow in dbDt.Rows) { string dbname = dbRow["CATALOG_NAME"].ToString(); try { DataTable dt = plugin.GetTables(dbname); criteria.AppendLog(dt.Rows.Count + " tables in database " + dbname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin tables error in database " + dbname, ex); } } } if (!criteria.HasErrors) { foreach (DataRow dbRow in dbDt.Rows) { string dbname = dbRow["CATALOG_NAME"].ToString(); DataTable tblDt = plugin.GetTables(dbname); foreach (DataRow tblRow in tblDt.Rows) { string tblname = tblRow["TABLE_NAME"].ToString(); if (criteria.IncludeTableColumns) { try { DataTable dt = plugin.GetTableColumns(dbname, tblname); criteria.AppendLog(dt.Rows.Count + " columns in table " + dbname + "." + tblname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin table column error in " + dbname + "." + tblname, ex); } } if (criteria.IncludeTableOther) { try { List <string> pks = plugin.GetPrimaryKeyColumns(dbname, tblname); criteria.AppendLog(pks.Count + " PK columns in table " + dbname + "." + tblname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin table PK column error in " + dbname + "." + tblname, ex); } try { DataTable dt = plugin.GetForeignKeys(dbname, tblname); criteria.AppendLog(dt.Rows.Count + " FKs in table " + dbname + "." + tblname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin table FK error in " + dbname + "." + tblname, ex); } try { DataTable dt = plugin.GetTableIndexes(dbname, tblname); criteria.AppendLog(dt.Rows.Count + " indexes in table " + dbname + "." + tblname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin table index error in " + dbname + "." + tblname, ex); } } } } } }
private static void TestTables(IMyMetaTestContext criteria, IMyMetaPlugin plugin) { DataTable dbDt = null; if (!criteria.HasErrors) { try { dbDt = GetDatabases(criteria, plugin); } catch { dbDt = new DataTable(); } } if (criteria.IncludeTables && !criteria.HasErrors) { foreach (DataRow dbRow in dbDt.Rows) { string dbname = dbRow["CATALOG_NAME"].ToString(); try { DataTable dt = plugin.GetTables(dbname); criteria.AppendLog(dt.Rows.Count + " tables in database " + dbname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin tables error in database " + dbname, ex); } } } if (!criteria.HasErrors) { foreach (DataRow dbRow in dbDt.Rows) { string dbname = dbRow["CATALOG_NAME"].ToString(); DataTable tblDt = plugin.GetTables(dbname); foreach (DataRow tblRow in tblDt.Rows) { string tblname = tblRow["TABLE_NAME"].ToString(); if (criteria.IncludeTableColumns) { try { DataTable dt = plugin.GetTableColumns(dbname, tblname); criteria.AppendLog(dt.Rows.Count + " columns in table " + dbname + "." + tblname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin table column error in " + dbname + "." + tblname, ex); } } if (criteria.IncludeTableOther) { try { List<string> pks = plugin.GetPrimaryKeyColumns(dbname, tblname); criteria.AppendLog(pks.Count + " PK columns in table " + dbname + "." + tblname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin table PK column error in " + dbname + "." + tblname, ex); } try { DataTable dt = plugin.GetForeignKeys(dbname, tblname); criteria.AppendLog(dt.Rows.Count + " FKs in table " + dbname + "." + tblname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin table FK error in " + dbname + "." + tblname, ex); } try { DataTable dt = plugin.GetTableIndexes(dbname, tblname); criteria.AppendLog(dt.Rows.Count + " indexes in table " + dbname + "." + tblname + " found through Plugin."); } catch (Exception ex) { criteria.AppendLog("Plugin table index error in " + dbname + "." + tblname, ex); } } } } } }