public void LoadState_fromDB( dLoadState_fromDB notifyBack_in, DBServerTypes DBServerType_in, string Connectionstring_in, string subAppName_in, bool clear_in ) { const string OGEN_SP0__GETTABLEFIELDS = "OGen_sp0__getTableFields"; const string OGEN_SP0__GETTABLES = "OGen_sp0__getTables"; bool _exist_getTables = false; bool _exist_getTableFields = false; // #region for (...) Tables.Add(); DBConnection _connection = DBConnectionsupport.CreateInstance( DBServerType_in, Connectionstring_in ); _exist_getTables = _connection.SQLStoredProcedure_exists(OGEN_SP0__GETTABLES); _exist_getTableFields = _connection.SQLStoredProcedure_exists(OGEN_SP0__GETTABLEFIELDS); cDBTable[] _tables_aux = _connection.getTables( subAppName_in, _exist_getTables ? OGEN_SP0__GETTABLES : string.Empty ); cDBTableField[] _fields_aux = _connection.getTableFields( // _tables_aux[t].Name, // get's specific table fields string.Empty, // get's fields for all tables _exist_getTableFields//_exist_getTables ? OGEN_SP0__GETTABLEFIELDS : string.Empty ); if (clear_in) tables_.Clear(); for (int t = 0; t < _tables_aux.Length; t++) { // ToDos: here! virtual names //for (int ) { //} int T = tables_.Add(_tables_aux[t].Name, true); if (notifyBack_in != null) notifyBack_in(string.Format("#{0}/{1} - {2}", t + 1, _tables_aux.Length, _tables_aux[t].Name), true); tables_[T].isVirtualTable = _tables_aux[t].isVirtualTable; tables_[T].DBDescription = _tables_aux[t].DBDescription; // ToDos: here! virtual names //int TD = tables_[T].DBs.Add( // _connection.DBServerType, // _tables_aux[t].Name, // true //); if (clear_in) tables_[T].Fields.Clear(); for (int f = 0; f < _fields_aux.Length; f++) { if (_tables_aux[t].Name != _fields_aux[f].TableName) { continue; } int F = tables_[T].Fields.Add(_fields_aux[f].Name, true); tables_[T].Fields[F].Name = _fields_aux[f].Name; tables_[T].Fields[F].isIdentity = _fields_aux[f].isIdentity; tables_[T].Fields[F].isPK = _fields_aux[f].isPK; tables_[T].Fields[F].FK_TableName = _fields_aux[f].FK_TableName; tables_[T].Fields[F].FK_FieldName = _fields_aux[f].FK_FieldName; tables_[T].Fields[F].isNullable = _fields_aux[f].isNullable; tables_[T].Fields[F].Size = _fields_aux[f].Size; tables_[T].Fields[F].Numeric_Precision = _fields_aux[f].Numeric_Precision; tables_[T].Fields[F].Numeric_Scale = _fields_aux[f].Numeric_Scale; //tables_[T].Fields[F].DBDescription = _fields_aux[f].DBDescription; //tables_[T].Fields[F].DBDefaultValue = _fields_aux[f].DBDefaultValue; //tables_[T].Fields[F].DBCollationName = _fields_aux[f].DBCollationName; //--- int FD = tables_[T].Fields[F].DBs.Add( DBConnectionsupport.GetDBServerType(_connection), true ); tables_[T].Fields[F].DBs[FD].DBType_inDB_name = _fields_aux[f].DBType_inDB_name; tables_[T].Fields[F].DBs[FD].DBDescription = _fields_aux[f].DBDescription; tables_[T].Fields[F].DBs[FD].DBDefaultValue = _fields_aux[f].DBDefaultValue; tables_[T].Fields[F].DBs[FD].DBCollationName = _fields_aux[f].DBCollationName; #region //oldstuff... //tables_[T].Fields[F].DBType_inDB_name = _fields_aux[f].DBType_inDB_name; //tables_[T].Fields[F].Size = _fields_aux[f].Size; #endregion } } _fields_aux = null; _tables_aux = null; // #endregion }
public void LoadState_fromDB( dLoadState_fromDB notifyBack_in, DBServerTypes DBServerType_in, string Connectionstring_in, string subAppName_in, bool clear_in ) { const string OGEN_SP0__GETTABLEFIELDS = "OGen_sp0__getTableFields"; const string OGEN_SP0__GETTABLES = "OGen_sp0__getTables"; bool _exist_getTables = false; bool _exist_getTableFields = false; // #region for (...) Tables.Add(); DBConnection _connection = DBConnectionsupport.CreateInstance( DBServerType_in, Connectionstring_in ); _exist_getTables = _connection.SQLStoredProcedure_exists(OGEN_SP0__GETTABLES); _exist_getTableFields = _connection.SQLStoredProcedure_exists(OGEN_SP0__GETTABLEFIELDS); cDBTable[] _tables_aux = _connection.getTables( subAppName_in, _exist_getTables ? OGEN_SP0__GETTABLES : string.Empty ); cDBTableField[] _fields_aux = _connection.getTableFields( // _tables_aux[t].Name, // get's specific table fields string.Empty, // get's fields for all tables _exist_getTableFields //_exist_getTables ? OGEN_SP0__GETTABLEFIELDS : string.Empty ); if (clear_in) { tables_.Clear(); } for (int t = 0; t < _tables_aux.Length; t++) { // ToDos: here! virtual names //for (int ) { //} int T = tables_.Add(_tables_aux[t].Name, true); if (notifyBack_in != null) { notifyBack_in(string.Format("#{0}/{1} - {2}", t + 1, _tables_aux.Length, _tables_aux[t].Name), true); } tables_[T].isVirtualTable = _tables_aux[t].isVirtualTable; tables_[T].DBDescription = _tables_aux[t].DBDescription; // ToDos: here! virtual names //int TD = tables_[T].DBs.Add( // _connection.DBServerType, // _tables_aux[t].Name, // true //); if (clear_in) { tables_[T].Fields.Clear(); } for (int f = 0; f < _fields_aux.Length; f++) { if (_tables_aux[t].Name != _fields_aux[f].TableName) { continue; } int F = tables_[T].Fields.Add(_fields_aux[f].Name, true); tables_[T].Fields[F].Name = _fields_aux[f].Name; tables_[T].Fields[F].isIdentity = _fields_aux[f].isIdentity; tables_[T].Fields[F].isPK = _fields_aux[f].isPK; tables_[T].Fields[F].FK_TableName = _fields_aux[f].FK_TableName; tables_[T].Fields[F].FK_FieldName = _fields_aux[f].FK_FieldName; tables_[T].Fields[F].isNullable = _fields_aux[f].isNullable; tables_[T].Fields[F].Size = _fields_aux[f].Size; tables_[T].Fields[F].Numeric_Precision = _fields_aux[f].Numeric_Precision; tables_[T].Fields[F].Numeric_Scale = _fields_aux[f].Numeric_Scale; //tables_[T].Fields[F].DBDescription = _fields_aux[f].DBDescription; //tables_[T].Fields[F].DBDefaultValue = _fields_aux[f].DBDefaultValue; //tables_[T].Fields[F].DBCollationName = _fields_aux[f].DBCollationName; //--- int FD = tables_[T].Fields[F].DBs.Add( DBConnectionsupport.GetDBServerType(_connection), true ); tables_[T].Fields[F].DBs[FD].DBType_inDB_name = _fields_aux[f].DBType_inDB_name; tables_[T].Fields[F].DBs[FD].DBDescription = _fields_aux[f].DBDescription; tables_[T].Fields[F].DBs[FD].DBDefaultValue = _fields_aux[f].DBDefaultValue; tables_[T].Fields[F].DBs[FD].DBCollationName = _fields_aux[f].DBCollationName; #region //oldstuff... //tables_[T].Fields[F].DBType_inDB_name = _fields_aux[f].DBType_inDB_name; //tables_[T].Fields[F].Size = _fields_aux[f].Size; #endregion } } _fields_aux = null; _tables_aux = null; // #endregion }