Example #1
0
        public void HowTo()
        {
//<document>
            long _iduser = 1L;

            OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_User _user
                = OGen.NTier.Kick.Libraries.DataLayer.DO_CRD_User.getObject(_iduser);
            if (_user != null)
            {
                Console.WriteLine(
                    "user found:\nIDUser = {0}\nLogin = {1}",
                    _iduser,
                    _user.Login
                    );
            }
            else
            {
                Console.WriteLine("user not found");
            }
//</document>

            // the only porpuses is to keep documentation code samples updated by:
            // 1) ensure documentation code samples are compiling
            // 2) no exceptions are beeing thrown by documentation code samples
            Assert.IsTrue(
                true,
                "documentation code sample is failing"
                );
        }
		public void HowTo() {

//<document>
OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_User _user 
	= new OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_User();
_user.IDUser = 123L;
_user.Login = "******";
_user.Password = "******";
_user.IFApplication = 123;

System.Reflection.PropertyInfo[] _properties
	= typeof(OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_User).GetProperties(
		System.Reflection.BindingFlags.Public |
		System.Reflection.BindingFlags.Instance
	);
for (int _prop = 0; _prop < _properties.Length; _prop++) {
	if (Attribute.IsDefined(
		_properties[_prop],
		typeof(OGen.NTier.Libraries.DataLayer.DOPropertyAttribute)
	)) {
		Console.Write(
			"{0}: ", 
			_properties[_prop].Name
		);
		Attribute[] _attributes = Attribute.GetCustomAttributes(
			_properties[_prop],
			typeof(OGen.NTier.Libraries.DataLayer.DOPropertyAttribute), 
			true
		);
		for (int _att = 0; _att < _attributes.Length; _att++) {
			//if (_attributes[_att].GetType() == typeof(DOPropertyAttribute)) {
			OGen.NTier.Libraries.DataLayer.DOPropertyAttribute _attribute
					= (OGen.NTier.Libraries.DataLayer.DOPropertyAttribute)_attributes[_att];
				Console.Write(
					"name:{0};  isPK:{1};  isIdentity:{2};  DefaultValue:{3};  ",
					_attribute.Name,
					_attribute.IsPK,
					_attribute.IsIdentity,
					_attribute.DefaultValue
				);
			//}
		}
		Console.Write(
			"value: {0}; ", 
			_properties[_prop].GetValue(_user, null)
		);
		_properties[_prop].SetValue(
			_user, 
			Convert.ChangeType(
				456, 
				_properties[_prop].PropertyType
			), 
			null
		);
		Console.WriteLine(
			"new value: {0}", 
			_properties[_prop].GetValue(_user, null)
		);
	}
}
//</document>

			// the only porpuses is to keep documentation code samples updated by: 
			// 1) ensure documentation code samples are compiling 
			// 2) no exceptions are beeing thrown by documentation code samples
			Assert.IsTrue(
				true,
				"documentation code sample is failing"
			);

		}
Example #3
0
        public void HowTo()
        {
//<document>
            OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_User _user
                                = new OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_User();
            _user.IDUser        = 123L;
            _user.Login         = "******";
            _user.Password      = "******";
            _user.IFApplication = 123;

            System.Reflection.PropertyInfo[] _properties
                = typeof(OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_User).GetProperties(
                      System.Reflection.BindingFlags.Public |
                      System.Reflection.BindingFlags.Instance
                      );
            for (int _prop = 0; _prop < _properties.Length; _prop++)
            {
                if (Attribute.IsDefined(
                        _properties[_prop],
                        typeof(OGen.NTier.Libraries.DataLayer.DOPropertyAttribute)
                        ))
                {
                    Console.Write(
                        "{0}: ",
                        _properties[_prop].Name
                        );
                    Attribute[] _attributes = Attribute.GetCustomAttributes(
                        _properties[_prop],
                        typeof(OGen.NTier.Libraries.DataLayer.DOPropertyAttribute),
                        true
                        );
                    for (int _att = 0; _att < _attributes.Length; _att++)
                    {
                        //if (_attributes[_att].GetType() == typeof(DOPropertyAttribute)) {
                        OGen.NTier.Libraries.DataLayer.DOPropertyAttribute _attribute
                            = (OGen.NTier.Libraries.DataLayer.DOPropertyAttribute)_attributes[_att];
                        Console.Write(
                            "name:{0};  isPK:{1};  isIdentity:{2};  DefaultValue:{3};  ",
                            _attribute.Name,
                            _attribute.IsPK,
                            _attribute.IsIdentity,
                            _attribute.DefaultValue
                            );
                        //}
                    }
                    Console.Write(
                        "value: {0}; ",
                        _properties[_prop].GetValue(_user, null)
                        );
                    _properties[_prop].SetValue(
                        _user,
                        Convert.ChangeType(
                            456,
                            _properties[_prop].PropertyType
                            ),
                        null
                        );
                    Console.WriteLine(
                        "new value: {0}",
                        _properties[_prop].GetValue(_user, null)
                        );
                }
            }
//</document>

            // the only porpuses is to keep documentation code samples updated by:
            // 1) ensure documentation code samples are compiling
            // 2) no exceptions are beeing thrown by documentation code samples
            Assert.IsTrue(
                true,
                "documentation code sample is failing"
                );
        }
		public void HowTo() {

//<document>
string _testid = DateTime.Now.Ticks.ToString();
bool _constraint;
long _iduser;
long _ifprofile;

// we need a shared connection between Data Objects
OGen.Libraries.DataLayer.DBConnection _con = OGen.NTier.Kick.Libraries.DataLayer.DO__Utilities.DBConnection_createInstance(
	OGen.NTier.Kick.Libraries.DataLayer.DO__Utilities.DBServerType,
	OGen.NTier.Kick.Libraries.DataLayer.DO__Utilities.DBConnectionstring,
	string.Empty
);

Exception _exception = null;
try {
	// before beginning a transaction we need to open the connection
	_con.Open();

	// beginning transaction
	_con.Transaction.Begin();

	OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_User _user 
		= new OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_User();
	// performing some operations on User Data Object
	_user.Login = _testid;
	_user.Password = _testid;
	_user.IFApplication_isNull = true;
	// sharing connection with User Data Object
	_iduser = OGen.NTier.Kick.Libraries.DataLayer.DO_CRD_User.insObject(
		_user,
		true,
		out _constraint,
		_con
	);
	// handling constraint code should be added here

	OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_Profile _profile 
		= new OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_Profile();
	// performing some operations on User Data Object
	_profile.Name = _testid;
	_profile.IFApplication_isNull = true;
	// sharing connection with Group Data Object
	_ifprofile = OGen.NTier.Kick.Libraries.DataLayer.DO_CRD_Profile.insObject(
		_profile,
		true,
		_con
	);

	OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_UserProfile _userprofile
		= new OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_UserProfile();
	// performing some operations on User Data Object
	_userprofile.IFProfile = _ifprofile;
	_userprofile.IFUser = _iduser;
	// sharing connection with Group Data Object
	OGen.NTier.Kick.Libraries.DataLayer.DO_CRD_UserProfile.setObject(
		_userprofile,
		false,
		_con
	);

	// commit transaction
	_con.Transaction.Commit();

} catch (Exception _ex) {

	// rollback transaction
	_con.Transaction.Rollback();

	_exception = _ex;

} finally {

	//// terminate transaction
	//if (_con.Transaction.InTransaction) {
	//    _con.Transaction.Terminate();
	//}

	//// closing connection
	//if (_con.IsOpen) {
	//    _con.Close();
	//}

	// no need to (conditionally) terminate transaction and close connection, 
	// simply disposing connection will do all that
	_con.Dispose();
	_con = null;

}
if (_exception != null)
	throw _exception;
//</document>

			// the only porpuses is to keep documentation code samples updated by: 
			// 1) ensure documentation code samples are compiling 
			// 2) no exceptions are beeing thrown by documentation code samples
			Assert.IsTrue(
				true,
				"documentation code sample is failing"
			);

		}
Example #5
0
        public void HowTo()
        {
//<document>
            string _testid = DateTime.Now.Ticks.ToString();
            bool   _constraint;
            long   _iduser;
            long   _ifprofile;

// we need a shared connection between Data Objects
            OGen.Libraries.DataLayer.DBConnection _con = OGen.NTier.Kick.Libraries.DataLayer.DO__Utilities.DBConnection_createInstance(
                OGen.NTier.Kick.Libraries.DataLayer.DO__Utilities.DBServerType,
                OGen.NTier.Kick.Libraries.DataLayer.DO__Utilities.DBConnectionstring,
                string.Empty
                );

            Exception _exception = null;

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

                // beginning transaction
                _con.Transaction.Begin();

                OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_User _user
                    = new OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_User();
                // performing some operations on User Data Object
                _user.Login                = _testid;
                _user.Password             = _testid;
                _user.IFApplication_isNull = true;
                // sharing connection with User Data Object
                _iduser = OGen.NTier.Kick.Libraries.DataLayer.DO_CRD_User.insObject(
                    _user,
                    true,
                    out _constraint,
                    _con
                    );
                // handling constraint code should be added here

                OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_Profile _profile
                    = new OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_Profile();
                // performing some operations on User Data Object
                _profile.Name = _testid;
                _profile.IFApplication_isNull = true;
                // sharing connection with Group Data Object
                _ifprofile = OGen.NTier.Kick.Libraries.DataLayer.DO_CRD_Profile.insObject(
                    _profile,
                    true,
                    _con
                    );

                OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_UserProfile _userprofile
                    = new OGen.NTier.Kick.Libraries.DataLayer.Shared.Structures.SO_CRD_UserProfile();
                // performing some operations on User Data Object
                _userprofile.IFProfile = _ifprofile;
                _userprofile.IFUser    = _iduser;
                // sharing connection with Group Data Object
                OGen.NTier.Kick.Libraries.DataLayer.DO_CRD_UserProfile.setObject(
                    _userprofile,
                    false,
                    _con
                    );

                // commit transaction
                _con.Transaction.Commit();
            } catch (Exception _ex) {
                // rollback transaction
                _con.Transaction.Rollback();

                _exception = _ex;
            } finally {
                //// terminate transaction
                //if (_con.Transaction.InTransaction) {
                //    _con.Transaction.Terminate();
                //}

                //// closing connection
                //if (_con.IsOpen) {
                //    _con.Close();
                //}

                // no need to (conditionally) terminate transaction and close connection,
                // simply disposing connection will do all that
                _con.Dispose();
                _con = null;
            }
            if (_exception != null)
            {
                throw _exception;
            }
//</document>

            // the only porpuses is to keep documentation code samples updated by:
            // 1) ensure documentation code samples are compiling
            // 2) no exceptions are beeing thrown by documentation code samples
            Assert.IsTrue(
                true,
                "documentation code sample is failing"
                );
        }