internal void Connection_createInstance() { connection_ = DBConnectionsupport.CreateInstance( dbservertype_, connectionstring_ ); }
internal void Connection_createInstance() { this.connection_ = DBConnectionsupport.CreateInstance( this.dbservertype_, this.connectionstring_ ); }
public HowTo_Execute_SQLFunction_returnDataTable() { long _idgroup_search = 1L; DBConnection _con = DBConnectionsupport.CreateInstance( // set your db server type here DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=OGen-NTier_UTs;" ); // set your function parameters IDbDataParameter[] _dataparameters = new IDbDataParameter[] { _con.newDBDataParameter( "IDGroup_search_", DbType.Int64, ParameterDirection.Input, _idgroup_search, 0 ) }; // you now have a DataTable populated // with results from your sql function DataTable _datatable = _con.Execute_SQLFunction_returnDataTable( "sp0_User_Record_open_byGroup_fullmode", _dataparameters ); _con.Dispose(); _con = null; }
public HowTo_Execute_SQLFunction_returnSomevalue() { long _iduser = 0L; DBConnection _con = DBConnectionsupport.CreateInstance( // set your db server type here DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=OGen-NTier_UTs;" ); // set your function parameters IDbDataParameter[] _dataparameters = new IDbDataParameter[] { _con.newDBDataParameter( "IDUser_", DbType.Int64, ParameterDirection.Input, _iduser, 0 ) }; // call you function and get returning value bool _result = (bool)_con.Execute_SQLFunction( "fnc0_User_isObject", _dataparameters, DbType.Boolean, // returning value db type 0 // returning value size, if applicable ); _con.Dispose(); _con = null; }
public HowTo_List_DB_TableFields() { DBConnection _con = DBConnectionsupport.CreateInstance( // set your db server type here DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=OGen-NTier_UTs;" ); // you now have a cDBTableField array populated with all // field names and other properties for specified table cDBTableField[] _fields = _con.getTableFields("User"); for (int f = 0; f < _fields.Length; f++) { Console.WriteLine( "field name: {0}\nis PK: {1}\nis Identity: {2}\nis nullable: {3}", _fields[f].Name, _fields[f].isPK, _fields[f].isIdentity, _fields[f].isNullable ); } _con.Dispose(); _con = null; }
public HowTo_Execute_SQLFunction() { long _iduser = 0L; DBConnection _con = DBConnectionsupport.CreateInstance( // set your db server type here DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=OGen-NTier_UTs;" ); // set your function parameters IDbDataParameter[] _dataparameters = new IDbDataParameter[] { _con.newDBDataParameter( "IDUser_", DbType.Int64, ParameterDirection.Input, _iduser, 0 ) }; // call you function _con.Execute_SQLFunction( "sp0_User_delObject", _dataparameters ); _con.Dispose(); _con = null; }
public HowTo_List_DBs() { DBConnection _con = DBConnectionsupport.CreateInstance( // set your db server type here DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=OGen-NTier_UTs;" ); // you now have a string array populated with all // databases (except system ones) at you db server string[] _dbs = _con.getDBs(); _con.Dispose(); _con = null; }
public HowTo_Execute_SQLQuery_returnDataTable() { DBConnection _con = DBConnectionsupport.CreateInstance( // set your db server type here DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=OGen-NTier_UTs;" ); // you now have a DataTable populated // with results from your sql query DataTable _datatable = _con.Execute_SQLQuery_returnDataTable( "select * from \"User\"" ); _con.Dispose(); _con = null; }
public HowTo_Execute_SQLQuery() { long _iduser = 0L; DBConnection _con = DBConnectionsupport.CreateInstance( // set your db server type here DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=OGen-NTier_UTs;" ); // executing your sql query _con.Execute_SQLQuery( string.Format( "delete from \"User\" where \"IDUser\" = {0}", _iduser.ToString() ) ); _con.Dispose(); _con = null; }
public HowTo_UseTransactions() { long _iduser = 0L; DBConnection _con = DBConnectionsupport.CreateInstance( // set your db server type here DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=OGen-NTier_UTs;" ); // before beginning a transaction we need to open the connection _con.Open(); // beginning transaction _con.Transaction.Begin(); // performing some operations on db _con.Execute_SQLQuery( string.Format( "delete from \"User\" where \"IDUser\" = {0}", _iduser.ToString() ) ); // rollback transaction, we don't need such data in db, // this is just an how to sample _con.Transaction.Rollback(); // terminate transaction _con.Transaction.Terminate(); // closing connection _con.Close(); _con.Dispose(); _con = null; }
public void TestFixtureSetUp() { this.testid_ = DateTime.Now.Ticks.ToString(); // Guid.NewGuid().ToString(); this.dbname_ = #if NET_1_1 System.Configuration.ConfigurationSettings.AppSettings #else System.Configuration.ConfigurationManager.AppSettings #endif ["DBName"]; //--- DBServerTypes _dbtype; DBServerTypes[] _dbtypes = (DBServerTypes[])Enum.GetValues(typeof(DBServerTypes)); this.dbconnections_ = new DBConnection[_dbtypes.Length - 1]; // exclude DBServerTypes.invalid int _dbconnections_index = 0; for (int d = 0; d < _dbtypes.Length; d++) { if (_dbtypes[d] == DBServerTypes.invalid) { continue; } _dbtype = _dbtypes[d]; this.dbconnections_[_dbconnections_index++] = DBConnectionsupport.CreateInstance( _dbtype, #if NET_1_1 System.Configuration.ConfigurationSettings.AppSettings #else System.Configuration.ConfigurationManager.AppSettings #endif [ string.Format("DBConnectionstring-{0}", _dbtypes[d]) ] ); } }
public HowTo_List_DB_Tables() { DBConnection _con = DBConnectionsupport.CreateInstance( // set your db server type here DBServerTypes.PostgreSQL, // and connectionstring "Server=127.0.0.1;Port=5432;User ID=postgres;Password=passpub;Database=OGen-NTier_UTs;" ); // you now have a cDBTable array populated with all // table names and other properties for your database cDBTable[] _tables = _con.getTables(); for (int t = 0; t < _tables.Length; t++) { Console.WriteLine( "table name: {0}\nis this a view and not a table: {1}", _tables[t].Name, _tables[t].isVirtualTable ); } _con.Dispose(); _con = null; }
public static XS__metadataDB Load_fromDB( XS__metadataDB.Load_fromDBDelegate notifyBack_in, string subAppName_in, XS__RootMetadata root_ref_in, int index_in, params DBSimpleConnectionstring[] dbConnectionParam_in ) { #region XS__metadataDB _output = ...; XS__metadataDB _output = new XS__metadataDB(); _output.root_metadatadb_ = ROOT + "." + METADATADB + "[" + index_in.ToString() + "]"; _output.parent_ref = root_ref_in; // ToDos: now! if (root_ref_in != null) { _output.root_ref = root_ref_in; } #endregion bool _getTables_exists; bool _getTableFields_exists; DBConnection _connection; DBTable[] _tables_aux; DBTableField[] _fields_aux; XS_tableType _table; XS_tableDBType _tabledb; XS_tableFieldType _field; XS_tableFieldDBType _fielddb; int _searchindex; const string OGEN_SP0__GETTABLEFIELDS = "OGen_sp0__getTableFields"; const string OGEN_SP0__GETTABLES = "OGen_sp0__getTables"; for (int c = 0; c < dbConnectionParam_in.Length; c++) { #region notifyBack_in(...); if (notifyBack_in != null) { notifyBack_in( string.Format( "#{0}/{1} - {2}", c + 1, dbConnectionParam_in.Length, dbConnectionParam_in[c].DBServerType.ToString() ), true ); } #endregion _connection = DBConnectionsupport.CreateInstance( dbConnectionParam_in[c].DBServerType, dbConnectionParam_in[c].Connectionstring ); #region _tables_aux = ...; _getTables_exists = _connection.SQLStoredProcedure_exists(OGEN_SP0__GETTABLES); _tables_aux = _connection.getTables( subAppName_in, _getTables_exists ? OGEN_SP0__GETTABLES : string.Empty ); #endregion #region _fields_aux = ...; switch ((DBServerTypes)Enum.Parse(typeof(DBServerTypes), _connection.DBServerType)) { #if PostgreSQL case DBServerTypes.PostgreSQL: _getTableFields_exists = _connection.SQLFunction_exists(OGEN_SP0__GETTABLEFIELDS); break; #endif default: _getTableFields_exists = _connection.SQLStoredProcedure_exists(OGEN_SP0__GETTABLEFIELDS); break; } _fields_aux = _connection.getTableFields( // _tables_aux[t].Name, // get's specific table fields string.Empty, // get's fields for all tables _getTableFields_exists ? OGEN_SP0__GETTABLEFIELDS : string.Empty ); #endregion for (int t = 0; t < _tables_aux.Length; t++) { #region _table = ...; _table.Name = ...; _searchindex = _output.Tables.TableCollection.Search( _tables_aux[t].Name ); if (_searchindex >= 0) { _table = _output.Tables.TableCollection[_searchindex]; } else { _table = new XS_tableType( _tables_aux[t].Name ); _output.Tables.TableCollection.Add(_table); } #endregion _table.isVirtualTable = _tables_aux[t].isVirtualTable; #region _tabledb = ...; _tabledb.DBServerType = ...; _searchindex = _table.TableDBs.TableDBCollection.Search( dbConnectionParam_in[c].DBServerType.ToString() ); if (_searchindex >= 0) { _tabledb = _table.TableDBs.TableDBCollection[_searchindex]; } else { _tabledb = new XS_tableDBType( dbConnectionParam_in[c].DBServerType.ToString() ); _table.TableDBs.TableDBCollection.Add(_tabledb); } #endregion _tabledb.DBTableName = _tables_aux[t].Name; _tabledb.DBDescription = _tables_aux[t].DBDescription; for (int f = 0; f < _fields_aux.Length; f++) { if ( #if MySQL ( (dbConnectionParam_in[c].DBServerType == DBServerTypes.MySQL) && (_tables_aux[t].Name.ToLower() != _fields_aux[f].TableName.ToLower()) ) || #endif (_tables_aux[t].Name != _fields_aux[f].TableName) ) { continue; } #region _field = ...; _field.Name = ...; _searchindex = _table.TableFields.TableFieldCollection.Search( _fields_aux[f].Name ); if (_searchindex >= 0) { _field = _table.TableFields.TableFieldCollection[_searchindex]; } else { _field = new XS_tableFieldType( _fields_aux[f].Name ); _table.TableFields.TableFieldCollection.Add(_field); } #endregion _field.isPK = _fields_aux[f].isPK; _field.isIdentity = _fields_aux[f].isIdentity; _field.isNullable = _fields_aux[f].isNullable; _field.NumericPrecision = _fields_aux[f].Numeric_Precision; _field.NumericScale = _fields_aux[f].Numeric_Scale; _field.Size = _fields_aux[f].Size; #if MySQL if ( (dbConnectionParam_in[c].DBServerType == DBServerTypes.MySQL) && (_field.FKTableName == string.Empty) ) { _field.FKTableName = _fields_aux[f].FK_TableName; } else if ( (dbConnectionParam_in[c].DBServerType != DBServerTypes.MySQL) ) { _field.FKTableName = _fields_aux[f].FK_TableName; } #else _field.FKTableName = _fields_aux[f].FK_TableName; #endif _field.FKFieldName = _fields_aux[f].FK_FieldName; #region _fielddb = ...; _fielddb.DBServerType = ...; _searchindex = _field.TableFieldDBs.TableFieldDBCollection.Search( dbConnectionParam_in[c].DBServerType ); if (_searchindex >= 0) { _fielddb = _field.TableFieldDBs.TableFieldDBCollection[_searchindex]; } else { _fielddb = new XS_tableFieldDBType( dbConnectionParam_in[c].DBServerType.ToString() ); _field.TableFieldDBs.TableFieldDBCollection.Add(_fielddb); } #endregion _fielddb.DBType = _fields_aux[f].DBType_inDB_name; _fielddb.DBDescription = _fields_aux[f].DBDescription; _fielddb.DBDefaultValue = _fields_aux[f].DBDefaultValue; _fielddb.DBCollationName = _fields_aux[f].DBCollationName; _fielddb.DBFieldName = _fields_aux[f].Name; } } } return(_output); }
static void Main(string[] args) { //DO_UserGroup _usergroup_test = new DO_UserGroup( // //new DBConnection( // // DBServerTypes.SQLServer, // // "server=127.0.0.1;uid=sa;pwd=passpub;database=OGen-NTier_UTs;" // //) //); //_usergroup_test.IDGroup = 1; //_usergroup_test.IDUser = 1; //_usergroup_test.Relationdate_isNull = true; //_usergroup_test.Defaultrelation_isNull = true; //_usergroup_test.setObject(true); //OGen.NTier.UTs.lib.datalayer.UTs.UT__utils _ut_utils // = new OGen.NTier.UTs.lib.datalayer.UTs.UT__utils(); //_ut_utils.TestFixtureSetUp(); //_ut_utils.UT_Check_DataObjects_integrity(); //return; //OGen.NTier.UTs.lib.datalayer.UTs.UT_User _ut_user // = new OGen.NTier.UTs.lib.datalayer.UTs.UT_User(); //_ut_user.TestFixtureSetUp(); //_ut_user.UT_hasChanges(); //return; //OGen.NTier.UTs.lib.datalayer.UTs.UT_UserGroup // _ut_usergroup = new OGen.NTier.UTs.lib.datalayer.UTs.UT_UserGroup(); //_ut_usergroup.TestFixtureSetUp(); //_ut_usergroup.UT_bugPostgreSQL_noFunctionMatchesTheGivenNameAndArgumentTypes(); ////_ut_usergroup.UT_NullableFields(); //return; //DO_Config _config_test = new DO_Config(); //_config_test.Connection.Open(); //_config_test.Connection.Transaction.Begin(); //_config_test.Fields.Name = "test"; //_config_test.Fields.Description = "test"; //_config_test.Fields.Config = "test"; //_config_test.Fields.Type = 1; //try { // _config_test.setObject(true); // Console.WriteLine("ok"); //} catch { // Console.WriteLine("ko"); //} //_config_test.Connection.Transaction.Rollback(); //_config_test.Connection.Transaction.Terminate(); //_config_test.Connection.Close(); //_config_test.Dispose(); //return; const int _cycles = 50; DBConnection[] _cons = new DBConnection[] { #region new DBConnection(DBServerTypes.SQLServer, ...), DBConnectionsupport.CreateInstance( DBServerTypes.SQLServer, DBUtilssupport.GetInstance(DBServerTypes.SQLServer).ConnectionString.Build( "127.0.0.1", "sa", "passpub", "OGen-NTier_UTs" ) ), #endregion #region new DBConnection(DBServerTypes.PostgreSQL, ...) DBConnectionsupport.CreateInstance( DBServerTypes.PostgreSQL, DBUtilssupport.GetInstance(DBServerTypes.PostgreSQL).ConnectionString.Build( "127.0.0.1", "postgres", "passpub", "OGen-NTier_UTs" ) ) #endregion }; long _conter = 0L; for (int _compiled = 0; _compiled < 2; _compiled++) { for (int _con = 0; _con < _cons.Length; _con++) { _cons[_con].Open(); _cons[_con].Transaction.Begin(); for (int _cached = 0; _cached < 2; _cached++) { DO_Config _config = new DO_Config(_cons[_con]); #region _config.setObject(); _conter = DateTime.Now.Ticks; for (int c = 0; c < _cycles; c++) { _config.Fields.Name = c.ToString(); _config.Fields.Config = "DELETE THIS, IT IS A TEST"; _config.Fields.Type = 2; _config.setObject(true); } Console.WriteLine( "setObject() \t{0}\tcached:{1}\tcompiled:{2}\t{3}", DBConnectionsupport.GetDBServerType(_cons[_con]), (_cached == 1), (_compiled == 1), (DateTime.Now.Ticks - _conter).ToString() ); #endregion #region _config.Record.Open_...(false); _conter = DateTime.Now.Ticks; _config.Record.Open_all(false); while (_config.Record.Read()) { ; } _config.Record.Close(); Console.WriteLine( "Record.Open() \t{0}\tcached:{1}\tcompiled:{2}\t{3}", DBConnectionsupport.GetDBServerType(_cons[_con]), (_cached == 1), (_compiled == 1), (DateTime.Now.Ticks - _conter).ToString() ); #endregion #region _config.delObject(); _conter = DateTime.Now.Ticks; _config.Record.Open_all(true); while (_config.Record.Read()) { if (_config.Fields.Config == "DELETE THIS, IT IS A TEST") { _config.delObject(); } } _config.Record.Close(); Console.WriteLine( "delObject() \t{0}\tcached:{1}\tcompiled:{2}\t{3}", DBConnectionsupport.GetDBServerType(_cons[_con]), (_cached == 1), (_compiled == 1), (DateTime.Now.Ticks - _conter).ToString() ); #endregion #region _config.getObject(); _conter = DateTime.Now.Ticks; _config.Fields.Name = "SomeIntConfig"; _config.Fields.Config = "1245"; _config.Fields.Type = 4; _config.setObject(true); for (int c = 0; c < _cycles; c++) { _config.getObject("SomeIntConfig"); } Console.WriteLine( "getObject() \t{0}\tcached:{1}\tcompiled:{2}\t{3}", DBConnectionsupport.GetDBServerType(_cons[_con]), (_cached == 1), (_compiled == 1), (DateTime.Now.Ticks - _conter).ToString() ); #endregion _config.Dispose(); _config = null; //--- DO_User _user = new DO_User(_cons[_con]); #region _user.insObject(); _conter = DateTime.Now.Ticks; for (int c = 0; c < _cycles; c++) { bool _constraint; _user.Fields.Login = c.ToString(); _user.Fields.Password = "******"; _user.insObject(true, out _constraint); } _user.Record.Open_all(true); while (_user.Record.Read()) { if (_user.Fields.Password == "DELETE THIS, IT IS A TEST") { _user.delObject(); } } _user.Record.Close(); Console.WriteLine( "insObject() \t{0}\tcached:{1}\tcompiled:{2}\t{3}", DBConnectionsupport.GetDBServerType(_cons[_con]), (_cached == 1), (_compiled == 1), (DateTime.Now.Ticks - _conter).ToString() ); #endregion _conter = DateTime.Now.Ticks; for (int c = 0; c < _cycles; c++) { if (!_user.isObject_byLogin("fmonteiro")) { bool _constraint; _user.Fields.Login = "******"; _user.Fields.Password = "******"; _user.insObject(true, out _constraint); } _user.getObject_byLogin("fmonteiro"); } Console.WriteLine( "getObject_by() \t{0}\tcached:{1}\tcompiled:{2}\t{3}", DBConnectionsupport.GetDBServerType(_cons[_con]), (_cached == 1), (_compiled == 1), (DateTime.Now.Ticks - _conter).ToString() ); _user.Dispose(); _user = null; } _cons[_con].Transaction.Rollback(); _cons[_con].Transaction.Terminate(); _cons[_con].Close(); } } Console.WriteLine("Press any key to continue..."); Console.ReadLine(); }
static void Main(string[] args) { IBO_Authentication _authentication; IBO_User _user; string _login; for (int _provider = 0; _provider < 3; _provider++) { switch (_provider) { case 0: Console.WriteLine("--- remoting..."); _authentication = new RC_Authentication( "tcp://127.0.0.1:8085/OGen.NTier.UTs.distributedlayer.remoting.server.RS_Authentication.remoting" //"http://127.0.0.1:8085/OGen.NTier.UTs.distributedlayer.remoting.server.RS_Authentication.soap" ); _user = new RC_User( "tcp://127.0.0.1:8085/OGen.NTier.UTs.distributedlayer.remoting.server.RS_User.remoting" //"http://127.0.0.1:8085/OGen.NTier.UTs.distributedlayer.remoting.server.RS_User.soap" ); break; case 1: Console.WriteLine("--- webservices..."); _authentication = new WC_Authentication.WC_Authentication( "http://127.0.0.1:2937/WS_Authentication.asmx" ); _user = new WC_User.WC_User( "http://127.0.0.1:2937/WS_User.asmx" ); break; default: Console.WriteLine("--- direct assembly..."); _authentication = new BC_Authentication( ); _user = new BC_User( ); break; } Console.WriteLine( "authentication string: {0}\n", _login = _authentication.Login( "fmonteiro", "passpub" ) ); OGen.NTier.UTs.lib.datalayer.proxy.ISO_User _so_user = new OGen.NTier.UTs.lib.datalayer.proxy.SO_User( 0L, string.Format( "login-{0}", Guid.NewGuid().ToString() ), "password", 0 ); _so_user.SomeNullValue_isNull = true; Console.WriteLine( "IDUser: {0}; Login: {1}; Password: {2}; SomeNullValue: {3} (is null: {4})", _so_user.IDUser, _so_user.Login, _so_user.Password, _so_user.SomeNullValue, _so_user.SomeNullValue_isNull ); long _iduser; bool _constraintExists; Console.WriteLine( "IDUser: {0}; Constraint Exists: {1}", _iduser = _user.insObject( (SO_User)_so_user, true, _login, out _constraintExists ), _constraintExists ); bool _exists; _so_user = _user.getObject( _iduser, _login, out _exists ); Console.WriteLine( "Exists: {5}; IDUser: {0}; Login: {1}; Password: {2}; SomeNullValue: {3} (is null: {4})", _so_user.IDUser, _so_user.Login, _so_user.Password, _so_user.SomeNullValue, _so_user.SomeNullValue_isNull, _exists ); long _recordLength; SO_User[] _users = _user.Record_Open_byGroup( 3L, 1, 4, _login, out _recordLength ); Console.WriteLine( "Record Length: {0}", _recordLength ); for (int i = 0; i < _users.Length; i++) { Console.WriteLine( //"IDUser: {0}; Login: {1}", "IDUser: {0}; Login: {1}; Password: {2}; SomeNullValue: {3} (is null: {4})", _users[i].IDUser, _users[i].Login, _users[i].Password, _users[i].SomeNullValue, _users[i].SomeNullValue_isNull ); } _authentication.Logout(); } return; //OGen.NTier.UTs.lib.businesslayer-2.0 Assembly _assembly = Assembly.Load( #if NET_1_1 "OGen.NTier.UTs.lib.businesslayer-1.1" #elif NET_2_0 "OGen.NTier.UTs.lib.businesslayer-2.0" #endif ); if (_assembly != null) { Type[] _types = _assembly.GetTypes(); for (int t = 0; t < _types.Length; t++) { Type _type = (Type)_types[t]; object[] _attibutes = _type.GetCustomAttributes( typeof(BOClassAttribute), true //false ); if ( (_attibutes.Length > 0) && (_type.Name.IndexOf("BO0_") != 0) && (_type.Name.IndexOf("BBO0_") != 0) ) { Console.Write("{0}; ", _type.Name); for (int c = 0; c < _attibutes.Length; c++) { BOClassAttribute _attribute = (BOClassAttribute)_attibutes[c]; Console.WriteLine( "name:{0};", _attribute.Name ); MethodInfo[] _methods = _type.GetMethods( BindingFlags.Public | BindingFlags.Instance ); for (int m = 0; m < _methods.Length; m++) { if (Attribute.IsDefined( _methods[m], typeof(BOMethodAttribute) )) { Attribute[] _attributes = Attribute.GetCustomAttributes( _methods[m], typeof(BOMethodAttribute), true ); for (int a = 0; a < _attributes.Length; a++) { //if (_attributes[a].GetType() == typeof(BOMethodAttribute)) { BOMethodAttribute _propertyattribute = (BOMethodAttribute)_attributes[a]; Console.WriteLine( "\tname:{0}; distribute:{1};", _propertyattribute.Name, _propertyattribute.Distribute ); //} } Console.WriteLine( "\t.{0}:{1}.{2}(", _methods[m].Name, _methods[m].ReturnType.Namespace, _methods[m].ReturnType.Name ); ParameterInfo[] _parameterinfo = _methods[m].GetParameters(); for (int p = 0; p < _parameterinfo.Length; p++) { Console.WriteLine( "\t\tname:{0}; type:{1}; isOut:{2}; isByRef:{3}; isEnum:{4}; isClass:{5}; isValueType:{6}", _parameterinfo[p].Name, _parameterinfo[p].ParameterType, _parameterinfo[p].IsOut, _parameterinfo[p].ParameterType.IsByRef, _parameterinfo[p].ParameterType.IsEnum, _parameterinfo[p].ParameterType.IsClass, _parameterinfo[p].ParameterType.IsValueType ); } Console.WriteLine("\t)"); } } Console.WriteLine(); } } } } return; //DO_UserGroup _usergroup_test = new DO_UserGroup( // //new DBConnection( // // DBServerTypes.SQLServer, // // "server=127.0.0.1;uid=sa;pwd=passpub;database=OGen-NTier_UTs;" // //) //); //_usergroup_test.IDGroup = 1; //_usergroup_test.IDUser = 1; //_usergroup_test.Relationdate_isNull = true; //_usergroup_test.Defaultrelation_isNull = true; //_usergroup_test.setObject(true); //OGen.NTier.UTs.lib.datalayer.UTs.UT__utils _ut_utils // = new OGen.NTier.UTs.lib.datalayer.UTs.UT__utils(); //_ut_utils.TestFixtureSetUp(); //_ut_utils.UT_Check_DataObjects_integrity(); //return; //OGen.NTier.UTs.lib.datalayer.UTs.UT_User _ut_user // = new OGen.NTier.UTs.lib.datalayer.UTs.UT_User(); //_ut_user.TestFixtureSetUp(); //_ut_user.UT_hasChanges(); //return; //OGen.NTier.UTs.lib.datalayer.UTs.UT_UserGroup // _ut_usergroup = new OGen.NTier.UTs.lib.datalayer.UTs.UT_UserGroup(); //_ut_usergroup.TestFixtureSetUp(); //_ut_usergroup.UT_bugPostgreSQL_noFunctionMatchesTheGivenNameAndArgumentTypes(); ////_ut_usergroup.UT_NullableFields(); //return; //DO_Config _config_test = new DO_Config(); //_config_test.Connection.Open(); //_config_test.Connection.Transaction.Begin(); //_config_test.Fields.Name = "test"; //_config_test.Fields.Description = "test"; //_config_test.Fields.Config = "test"; //_config_test.Fields.Type = 1; //try { // _config_test.setObject(true); // Console.WriteLine("ok"); //} catch { // Console.WriteLine("ko"); //} //_config_test.Connection.Transaction.Rollback(); //_config_test.Connection.Transaction.Terminate(); //_config_test.Connection.Close(); //_config_test.Dispose(); //return; const int _cycles = 50; DBConnection[] _cons = new DBConnection[] { #region new DBConnection(DBServerTypes.SQLServer, ...), DBConnectionsupport.CreateInstance( DBServerTypes.SQLServer, DBUtilssupport.GetInstance(DBServerTypes.SQLServer).ConnectionString.Build( "127.0.0.1", "sa", "passpub", "OGen-NTier_UTs" ) ), #endregion #region new DBConnection(DBServerTypes.PostgreSQL, ...) DBConnectionsupport.CreateInstance( DBServerTypes.PostgreSQL, DBUtilssupport.GetInstance(DBServerTypes.PostgreSQL).ConnectionString.Build( "127.0.0.1", "postgres", "passpub", "OGen-NTier_UTs" ) ) #endregion //#region new DBConnection(DBServerTypes.MySQL, ...) //, DBConnectionsupport.CreateInstance( // DBServerTypes.MySQL, // DBUtilssupport.GetInstance(DBServerTypes.MySQL).ConnectionString.Build( // "127.0.0.1", // "root", // "passpub", // "OGen-NTier_UTs" // ) //) //#endregion }; long _conter = 0L; for (int _compiled = 0; _compiled < 2; _compiled++) { for (int _con = 0; _con < _cons.Length; _con++) { _cons[_con].Open(); _cons[_con].Transaction.Begin(); for (int _cached = 0; _cached < 2; _cached++) { DO_Config _config = new DO_Config(_cons[_con]); #region _config.setObject(); _conter = DateTime.Now.Ticks; for (int c = 0; c < _cycles; c++) { _config.Fields.Name = c.ToString(); _config.Fields.Config = "DELETE THIS, IT IS A TEST"; _config.Fields.Type = 2; _config.setObject(true); } Console.WriteLine( "setObject() \t{0}\tcached:{1}\tcompiled:{2}\t{3}", DBConnectionsupport.GetDBServerType(_cons[_con]), (_cached == 1), (_compiled == 1), (DateTime.Now.Ticks - _conter).ToString() ); #endregion #region _config.Record.Open_...(false); _conter = DateTime.Now.Ticks; _config.Record.Open_all(); while (_config.Record.Read()) { ; } _config.Record.Close(); Console.WriteLine( "Record.Open() \t{0}\tcached:{1}\tcompiled:{2}\t{3}", DBConnectionsupport.GetDBServerType(_cons[_con]), (_cached == 1), (_compiled == 1), (DateTime.Now.Ticks - _conter).ToString() ); #endregion #region _config.delObject(); _conter = DateTime.Now.Ticks; _config.Record.Open_all(); while (_config.Record.Read()) { if (_config.Fields.Config == "DELETE THIS, IT IS A TEST") { _config.delObject(); } } _config.Record.Close(); Console.WriteLine( "delObject() \t{0}\tcached:{1}\tcompiled:{2}\t{3}", DBConnectionsupport.GetDBServerType(_cons[_con]), (_cached == 1), (_compiled == 1), (DateTime.Now.Ticks - _conter).ToString() ); #endregion #region _config.getObject(); _conter = DateTime.Now.Ticks; _config.Fields.Name = "SomeIntConfig"; _config.Fields.Config = "1245"; _config.Fields.Type = 4; _config.setObject(true); for (int c = 0; c < _cycles; c++) { _config.getObject("SomeIntConfig"); } Console.WriteLine( "getObject() \t{0}\tcached:{1}\tcompiled:{2}\t{3}", DBConnectionsupport.GetDBServerType(_cons[_con]), (_cached == 1), (_compiled == 1), (DateTime.Now.Ticks - _conter).ToString() ); #endregion _config.Dispose(); _config = null; //--- DO_User _do_user = new DO_User(_cons[_con]); #region _do_user.insObject(); _conter = DateTime.Now.Ticks; for (int c = 0; c < _cycles; c++) { bool _constraint; _do_user.Fields.Login = c.ToString(); _do_user.Fields.Password = "******"; _do_user.insObject(true, out _constraint); } _do_user.Record.Open_all(); while (_do_user.Record.Read()) { if (_do_user.Fields.Password == "DELETE THIS, IT IS A TEST") { _do_user.delObject(); } } _do_user.Record.Close(); Console.WriteLine( "insObject() \t{0}\tcached:{1}\tcompiled:{2}\t{3}", DBConnectionsupport.GetDBServerType(_cons[_con]), (_cached == 1), (_compiled == 1), (DateTime.Now.Ticks - _conter).ToString() ); #endregion _conter = DateTime.Now.Ticks; for (int c = 0; c < _cycles; c++) { if (!_do_user.isObject_byLogin("fmonteiro")) { bool _constraint; _do_user.Fields.Login = "******"; _do_user.Fields.Password = "******"; _do_user.insObject(true, out _constraint); } _do_user.getObject_byLogin("fmonteiro"); } Console.WriteLine( "getObject_by() \t{0}\tcached:{1}\tcompiled:{2}\t{3}", DBConnectionsupport.GetDBServerType(_cons[_con]), (_cached == 1), (_compiled == 1), (DateTime.Now.Ticks - _conter).ToString() ); _do_user.Dispose(); _do_user = null; } _cons[_con].Transaction.Rollback(); _cons[_con].Transaction.Terminate(); _cons[_con].Close(); } } Console.WriteLine("Press any key to continue..."); Console.ReadLine(); }
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 }