/// <summary> /// Selects NWS_Profile values from Database and assigns them to the appropriate DO_NWS_Profile property. /// </summary> /// <param name="IFProfile_in">IFProfile</param> /// <param name="dbConnection_in">Database connection, making the use of Database Transactions possible on a sequence of operations across the same or multiple DataObjects</param> /// <returns>null if NWS_Profile doesn't exists at Database</returns> public static SO_NWS_Profile getObject( long IFProfile_in, DBConnection dbConnection_in ) { SO_NWS_Profile _output = null; DBConnection _connection = (dbConnection_in == null) ? DO__Utilities.DBConnection_createInstance( DO__Utilities.DBServerType, DO__Utilities.DBConnectionstring, DO__Utilities.DBLogfile ) : dbConnection_in; IDbDataParameter[] _dataparameters = new IDbDataParameter[] { _connection.newDBDataParameter("IFProfile_", DbType.Int64, ParameterDirection.InputOutput, IFProfile_in, 0), _connection.newDBDataParameter("IFUser__Approved_", DbType.Int64, ParameterDirection.Output, null, 0), _connection.newDBDataParameter("Approved_date_", DbType.DateTime, ParameterDirection.Output, null, 0) }; _connection.Execute_SQLFunction("sp0_NWS_Profile_getObject", _dataparameters); if (dbConnection_in == null) { _connection.Dispose(); } if (_dataparameters[0].Value != DBNull.Value) { _output = new SO_NWS_Profile(); if (_dataparameters[0].Value == System.DBNull.Value) { _output.IFProfile = 0L; } else { _output.IFProfile = (long)_dataparameters[0].Value; } if (_dataparameters[1].Value == System.DBNull.Value) { _output.IFUser__Approved_isNull = true; } else { _output.IFUser__Approved = (long)_dataparameters[1].Value; } if (_dataparameters[2].Value == System.DBNull.Value) { _output.Approved_date_isNull = true; } else { _output.Approved_date = (DateTime)_dataparameters[2].Value; } _output.HasChanges = false; return _output; } return null; }
public static DataTable getDataTable( SO_NWS_Profile[] serializableObjects_in ) { DataTable _output = new DataTable(); _output.Locale = System.Globalization.CultureInfo.CurrentCulture; DataRow _dr; DataColumn _dc_ifprofile = new DataColumn("IFProfile", typeof(long)); _output.Columns.Add(_dc_ifprofile); DataColumn _dc_ifuser__approved = new DataColumn("IFUser__Approved", typeof(long)); _output.Columns.Add(_dc_ifuser__approved); DataColumn _dc_approved_date = new DataColumn("Approved_date", typeof(DateTime)); _output.Columns.Add(_dc_approved_date); foreach (SO_NWS_Profile _serializableObject in serializableObjects_in) { _dr = _output.NewRow(); _dr[_dc_ifprofile] = _serializableObject.IFProfile; _dr[_dc_ifuser__approved] = _serializableObject.IFUser__Approved; _dr[_dc_approved_date] = _serializableObject.Approved_date; _output.Rows.Add(_dr); } return _output; }
/// <summary> /// Inserts/Updates NWS_Profile values into/on Database. Inserts if NWS_Profile doesn't exist or Updates if NWS_Profile already exists. /// </summary> /// <param name="forceUpdate_in">assign with True if you wish to force an Update (even if no changes have been made since last time getObject method was run) and False if not</param> /// <returns>True if it didn't exist (INSERT), and False if it did exist (UPDATE)</returns> public static bool setObject( SO_NWS_Profile NWS_Profile_in, bool forceUpdate_in ) { return setObject( NWS_Profile_in, forceUpdate_in, null ); }
/// <summary> /// Inserts/Updates NWS_Profile values into/on Database. Inserts if NWS_Profile doesn't exist or Updates if NWS_Profile already exists. /// </summary> /// <param name="forceUpdate_in">assign with True if you wish to force an Update (even if no changes have been made since last time getObject method was run) and False if not</param> /// <param name="dbConnection_in">Database connection, making the use of Database Transactions possible on a sequence of operations across the same or multiple DataObjects</param> /// <returns>True if it didn't exist (INSERT), and False if it did exist (UPDATE)</returns> public static bool setObject( SO_NWS_Profile NWS_Profile_in, bool forceUpdate_in, DBConnection dbConnection_in ) { bool ConstraintExist_out; if (forceUpdate_in || NWS_Profile_in.HasChanges) { DBConnection _connection = (dbConnection_in == null) ? DO__Utilities.DBConnection_createInstance( DO__Utilities.DBServerType, DO__Utilities.DBConnectionstring, DO__Utilities.DBLogfile ) : dbConnection_in; IDbDataParameter[] _dataparameters = new IDbDataParameter[] { _connection.newDBDataParameter("IFProfile_", DbType.Int64, ParameterDirection.Input, NWS_Profile_in.IFProfile, 0), _connection.newDBDataParameter("IFUser__Approved_", DbType.Int64, ParameterDirection.Input, NWS_Profile_in.IFUser__Approved_isNull ? null : (object)NWS_Profile_in.IFUser__Approved, 0), _connection.newDBDataParameter("Approved_date_", DbType.DateTime, ParameterDirection.Input, NWS_Profile_in.Approved_date_isNull ? null : (object)NWS_Profile_in.Approved_date, 0), //_connection.newDBDataParameter("Exists", DbType.Boolean, ParameterDirection.Output, 0, 1) _connection.newDBDataParameter("Output_", DbType.Int32, ParameterDirection.Output, null, 0) }; _connection.Execute_SQLFunction( "sp0_NWS_Profile_setObject", _dataparameters ); if (dbConnection_in == null) { _connection.Dispose(); } ConstraintExist_out = (((int)_dataparameters[3].Value & 2) == 1); if (!ConstraintExist_out) { NWS_Profile_in.HasChanges = false; } return (((int)_dataparameters[3].Value & 1) != 1); } else { ConstraintExist_out = false; return false; } }
public static long insObject( string sessionGuid_in, string ip_forLogPurposes_in, SO_vNWS_Profile profile_in, out int[] errors_out ) { long _output = -1L; Guid _sessionguid; Sessionuser _sessionuser; #region check... List<int> _errorlist; if (!check( sessionGuid_in, ip_forLogPurposes_in, ref profile_in, out _sessionguid, out _sessionuser, out _errorlist )) { errors_out = _errorlist.ToArray(); return _output; } #endregion #region SO_CRD_Profile _crd_profile = new SO_CRD_Profile(...); SO_CRD_Profile _crd_profile = new SO_CRD_Profile( -1L, profile_in.Name, //profile_in.IDApplication _sessionuser.IDApplication ); #endregion #region _crd_profile.IFApplication = ...; //if ( // (profile_in.IDApplication_isNull) // || // (profile_in.IDApplication <= 0) //) { // _crd_profile.IFApplication_isNull = true; //} else { // _crd_profile.IFApplication = profile_in.IDApplication; //} _crd_profile.IFApplication = _sessionuser.IDApplication; #endregion _crd_profile.Name = profile_in.Name; #region SO_NWS_Profile _nws_profile = new SO_NWS_Profile(...); SO_NWS_Profile _nws_profile = new SO_NWS_Profile( ); #endregion #region _nws_profile.IFUser__Approved = ...; if (_sessionuser.hasPermission(PermissionType.News__Profile__approve)) { _nws_profile.Approved_date = DateTime.Now; _nws_profile.IFUser__Approved = _sessionuser.IDUser; } else { //// ALREADY CHECKED!!! //if ( // !profile_in.Approved_date_isNull // || // !profile_in.IFUser__Approved_isNull //) { // _errorlist.Add(ErrorType.news__profile__lack_of_permissions_to_approve); // errors_out = _errorlist.ToArray(); // return _output; //} else { _nws_profile.Approved_date_isNull = true; _nws_profile.IFUser__Approved_isNull = true; //} } #endregion Exception _exception = null; #region DBConnection _con = DO__Utilities.DBConnection_createInstance(...); DBConnection _con = DO__Utilities.DBConnection_createInstance( DO__Utilities.DBServerType, DO__Utilities.DBConnectionstring, DO__Utilities.DBLogfile ); #endregion try { _con.Open(); _con.Transaction.Begin(); _output = DO_CRD_Profile.insObject( _crd_profile, true, _con ); _nws_profile.IFProfile = _output; DO_NWS_Profile.setObject( _nws_profile, true, _con ); _errorlist.Add(ErrorType.news__profile__successfully_created__WARNING); #region _con.Transaction.Commit(); if ( _con.IsOpen && _con.Transaction.InTransaction ) { _con.Transaction.Commit(); } #endregion } catch (Exception _ex) { #region _con.Transaction.Rollback(); if ( _con.IsOpen && _con.Transaction.InTransaction ) { _con.Transaction.Rollback(); } #endregion _exception = _ex; } finally { #region _con.Transaction.Terminate(); _con.Close(); _con.Dispose(); if (_con.IsOpen) { if (_con.Transaction.InTransaction) { _con.Transaction.Terminate(); } _con.Close(); } _con.Dispose(); #endregion } if (_exception != null) { #region SBO_LOG_Log.Log(ErrorType.data); OGen.NTier.Kick.Libraries.BusinessLayer.SBO_LOG_Log.log( _sessionuser, LogType.error, ErrorType.data, -1L, _sessionuser.IDApplication, "{0}", new string[] { _exception.Message } ); #endregion _errorlist.Add(ErrorType.data); } errors_out = _errorlist.ToArray(); return _output; }