Ejemplo n.º 1
0
        public HowTo_delObject()
        {
//<document>
            long _iduser = 1L;

            OGen.NTier.UTs.lib.datalayer.DO_User _user = new OGen.NTier.UTs.lib.datalayer.DO_User();
            if (_user.getObject(_iduser))
            {
                Console.Write(
                    "deleting user {0} ... ",
                    _user.Fields.Login
                    );

                //--- if parameter not specified uses object property _user.IDUser
                //_user.delObject(_iduser);

                //-- so in the case no need to provide IDUser
                _user.delObject();

                Console.WriteLine("DONE!");
            }
            else
            {
                Console.WriteLine("user not found");
            }
            _user.Dispose(); _user = null;
//</document>
        }
		public HowTo_getObject() {
//<document>
long _iduser = 1L;

OGen.NTier.UTs.lib.datalayer.DO_User _user = new OGen.NTier.UTs.lib.datalayer.DO_User();
if (_user.getObject(_iduser))
	Console.WriteLine(
	  "user found:\nIDUser = {0}\nLogin = {1}", 
	  _iduser, 
	  _user.Fields.Login
	);
else
	Console.WriteLine("user not found");
_user.Dispose(); _user = null;
//</document>
		}
Ejemplo n.º 3
0
        public HowTo_getObject()
        {
//<document>
            long _iduser = 1L;

            OGen.NTier.UTs.lib.datalayer.DO_User _user = new OGen.NTier.UTs.lib.datalayer.DO_User();
            if (_user.getObject(_iduser))
            {
                Console.WriteLine(
                    "user found:\nIDUser = {0}\nLogin = {1}",
                    _iduser,
                    _user.Fields.Login
                    );
            }
            else
            {
                Console.WriteLine("user not found");
            }
            _user.Dispose(); _user = null;
//</document>
        }
Ejemplo n.º 4
0
        public HowTo_UseTransactions_inDOs()
        {
//<document>
            string _testid = DateTime.Now.Ticks.ToString();
            bool   _constraint;
            long   _iduser;
            long   _idgroup;

            OGen.NTier.UTs.lib.datalayer.DO_User _user
                = new OGen.NTier.UTs.lib.datalayer.DO_User();

// before beginning a transaction we need to open the connection
            _user.Connection.Open();
            try {
                // beginning transaction
                _user.Connection.Transaction.Begin();

                // performing some operations on User Data Object
                _user.Fields.Login    = _testid;
                _user.Fields.Password = _testid;
                _iduser = _user.insObject(true, out _constraint);
                // handling constraint code should be added here

                // commit transaction
                _user.Connection.Transaction.Commit();
            } catch (Exception _ex) {
                // rollback transaction
                _user.Connection.Transaction.Rollback();
            } finally {
                // terminate transaction
                _user.Connection.Transaction.Terminate();
            }
// closing connection
            _user.Connection.Close();
            _user.Dispose(); _user = null;
//</document>
        }
		public HowTo_UseTransactions_inDOs() {
//<document>
string _testid = DateTime.Now.Ticks.ToString();
bool _constraint;
long _iduser;
long _idgroup;

OGen.NTier.UTs.lib.datalayer.DO_User _user 
	= new OGen.NTier.UTs.lib.datalayer.DO_User();

// before beginning a transaction we need to open the connection
_user.Connection.Open();
try {
	// beginning transaction
	_user.Connection.Transaction.Begin();

	// performing some operations on User Data Object
	_user.Fields.Login = _testid;
	_user.Fields.Password = _testid;
	_iduser = _user.insObject(true, out _constraint);
	// handling constraint code should be added here

	// commit transaction
	_user.Connection.Transaction.Commit();
} catch (Exception _ex) {
	// rollback transaction
	_user.Connection.Transaction.Rollback();
} finally {
	// terminate transaction
	_user.Connection.Transaction.Terminate();
}
// closing connection
_user.Connection.Close();
_user.Dispose(); _user = null;
//</document>
		}
		public HowTo_delObject() {
//<document>
long _iduser = 1L;

OGen.NTier.UTs.lib.datalayer.DO_User _user = new OGen.NTier.UTs.lib.datalayer.DO_User();
if (_user.getObject(_iduser)) {
	Console.Write(
	  "deleting user {0} ... ",
	  _user.Fields.Login
	);

	//--- if parameter not specified uses object property _user.IDUser
	//_user.delObject(_iduser);

	//-- so in the case no need to provide IDUser
	_user.delObject();

	Console.WriteLine("DONE!");
} else {
	Console.WriteLine("user not found");
}
_user.Dispose(); _user = null;
//</document>
		}
		public HowTo_UseTransactions_betweenDOs_operations() {
//<document>
string _testid = DateTime.Now.Ticks.ToString();
bool _constraint;
long _iduser;
long _idgroup;

// we need a shared connection between Data Objects
OGen.lib.datalayer.DBConnection _con = OGen.NTier.UTs.lib.datalayer.DO__utils.DBConnection_createInstance(
	OGen.NTier.UTs.lib.datalayer.DO__utils.DBServerType,
	OGen.NTier.UTs.lib.datalayer.DO__utils.DBConnectionstring, 
	string.Empty
);

// before beginning a transaction we need to open the connection
_con.Open();
try {
	// beginning transaction
	_con.Transaction.Begin();

	// sharing connection with User Data Object
	OGen.NTier.UTs.lib.datalayer.DO_User _user 
		= new OGen.NTier.UTs.lib.datalayer.DO_User(_con);
	// performing some operations on User Data Object
	_user.Fields.Login = _testid;
	_user.Fields.Password = _testid;
	_iduser = _user.insObject(true, out _constraint);
	// handling constraint code should be added here
	_user.Dispose(); _user = null;

	// sharing connection with Group Data Object
	OGen.NTier.UTs.lib.datalayer.DO_Group _group 
		= new OGen.NTier.UTs.lib.datalayer.DO_Group(_con);
	// performing some operations on User Data Object
	_group.Fields.Name = _testid;
	_idgroup = _group.insObject(true);
	_group.Dispose(); _group = null;

	// sharing connection with Group Data Object
	OGen.NTier.UTs.lib.datalayer.DO_UserGroup _usergroup
		= new OGen.NTier.UTs.lib.datalayer.DO_UserGroup(_con);
	// performing some operations on User Data Object
	_usergroup.Fields.IDGroup = _idgroup;
	_usergroup.Fields.IDUser = _iduser;
	_usergroup.Fields.Relationdate = DateTime.Now;
	_usergroup.Fields.Defaultrelation = false;
	_usergroup.setObject(false);
	_usergroup.Dispose(); _usergroup = null;

	// commit transaction
	_con.Transaction.Commit();
} catch (Exception _ex) {
	// rollback transaction
	_con.Transaction.Rollback();
} finally {
	// terminate transaction
	_con.Transaction.Terminate();
}
// closing connection
_con.Close();
_con.Dispose(); _con = null;
//</document>
		}
Ejemplo n.º 8
0
        public HowTo_UseTransactions_betweenDOs_operations()
        {
//<document>
            string _testid = DateTime.Now.Ticks.ToString();
            bool   _constraint;
            long   _iduser;
            long   _idgroup;

// we need a shared connection between Data Objects
            OGen.lib.datalayer.DBConnection _con = OGen.NTier.UTs.lib.datalayer.DO__utils.DBConnection_createInstance(
                OGen.NTier.UTs.lib.datalayer.DO__utils.DBServerType,
                OGen.NTier.UTs.lib.datalayer.DO__utils.DBConnectionstring,
                string.Empty
                );

// before beginning a transaction we need to open the connection
            _con.Open();
            try {
                // beginning transaction
                _con.Transaction.Begin();

                // sharing connection with User Data Object
                OGen.NTier.UTs.lib.datalayer.DO_User _user
                    = new OGen.NTier.UTs.lib.datalayer.DO_User(_con);
                // performing some operations on User Data Object
                _user.Fields.Login    = _testid;
                _user.Fields.Password = _testid;
                _iduser = _user.insObject(true, out _constraint);
                // handling constraint code should be added here
                _user.Dispose(); _user = null;

                // sharing connection with Group Data Object
                OGen.NTier.UTs.lib.datalayer.DO_Group _group
                    = new OGen.NTier.UTs.lib.datalayer.DO_Group(_con);
                // performing some operations on User Data Object
                _group.Fields.Name       = _testid;
                _idgroup                 = _group.insObject(true);
                _group.Dispose(); _group = null;

                // sharing connection with Group Data Object
                OGen.NTier.UTs.lib.datalayer.DO_UserGroup _usergroup
                    = new OGen.NTier.UTs.lib.datalayer.DO_UserGroup(_con);
                // performing some operations on User Data Object
                _usergroup.Fields.IDGroup         = _idgroup;
                _usergroup.Fields.IDUser          = _iduser;
                _usergroup.Fields.Relationdate    = DateTime.Now;
                _usergroup.Fields.Defaultrelation = false;
                _usergroup.setObject(false);
                _usergroup.Dispose(); _usergroup = null;

                // commit transaction
                _con.Transaction.Commit();
            } catch (Exception _ex) {
                // rollback transaction
                _con.Transaction.Rollback();
            } finally {
                // terminate transaction
                _con.Transaction.Terminate();
            }
// closing connection
            _con.Close();
            _con.Dispose(); _con = null;
//</document>
        }