/// <summary> /// Gets information about publishable (<see cref="M:Ferda.Modules.Helpers.Data.Database.IsTableTypePublishable(System.String)"/>) tables in database given by <c>odbcConnectionString</c>. /// </summary> /// <param name="odbcConnectionString">An ODBC connection string for test.</param> /// <param name="acceptableTypesOfTables">The acceptable types of the tables. Iff <c>null</c> than system and temporary tables are not accepted.</param> /// <param name="boxIdentity">An identity of BoxModule.</param> /// <returns> /// Array of <see cref="T:Ferda.Modules.Boxes.DataMiningCommon.Database.DataMatrixInfo"/>. /// </returns> /// <exception cref="T:Ferda.Modules.BadParamsError"/> public static DataMatrixSchemaInfo[] Explain(string odbcConnectionString, string[] acceptableTypesOfTables, string boxIdentity) { //get connection OdbcConnection conn = Ferda.Modules.Helpers.Data.OdbcConnections.GetConnection(odbcConnectionString, boxIdentity); //get schema DataTable schema = conn.GetSchema("TABLES"); //prepare OdbcCommand for "SELECT COUNT(1) FROM ..." query OdbcCommand odbcCommand = new OdbcCommand(); odbcCommand.Connection = conn; //result variable List<DataMatrixSchemaInfo> result = new List<DataMatrixSchemaInfo>(); foreach (DataRow row in schema.Rows) { //only publishable tables or views are added to result if (IsTableTypePublishable(row["TABLE_TYPE"].ToString(), acceptableTypesOfTables)) { DataMatrixSchemaInfo dataMatrixSchemaInfo = new DataMatrixSchemaInfo(); dataMatrixSchemaInfo.name = row["TABLE_NAME"].ToString(); dataMatrixSchemaInfo.type = row["TABLE_TYPE"].ToString(); dataMatrixSchemaInfo.remarks = row["REMARKS"].ToString(); //complete OdbcCommand and execute odbcCommand.CommandText = "SELECT COUNT(1) FROM " + "`" + dataMatrixSchemaInfo.name + "`"; dataMatrixSchemaInfo.rowCount = Convert.ToInt32(odbcCommand.ExecuteScalar()); result.Add(dataMatrixSchemaInfo); } } return result.ToArray(); }
/// <summary> /// Class constructor /// </summary> /// <param name="localePrefs">localeprefs</param> /// <param name="dataMatrix">Datamatrix</param> public DataBaseInfo(string[] localePrefs, DataMatrixSchemaInfo[] dataMatrix, IOwnerOfAddIn ownerOfAddIn) { //setting the ResManager resource manager and localization string string locale; try { locale = localePrefs[0]; localizationString = locale; locale = "Ferda.FrontEnd.AddIns.DataBaseInfo.Localization_" + locale; resManager = new ResourceManager(locale, Assembly.GetExecutingAssembly()); } catch { resManager = new ResourceManager("Ferda.FrontEnd.AddIns.DataBaseInfo.Localization_en-US", Assembly.GetExecutingAssembly()); localizationString = "en-US"; } this.ownerOfAddIn = ownerOfAddIn; comparer.column = 0; this.dataMatrix = dataMatrix; InitializeComponent(); this.ListViewInit(); this.FillDBInfoListView(); this.ToolStripMenuItemCopyAll.Click += new EventHandler(ToolStripMenuItemCopyAll_Click); this.ToolStripMenuItemCopySelected.Click += new EventHandler(ToolStripMenuItemCopySelected_Click); }