public static void updObject( string sessionGuid_in, string ip_forLogPurposes_in, SO_CRD_Profile profile_in, long[] idProfile_parent_in, // long[] idUser_in, long[] idPermission_in, out int[] errors_out ) { updobject( sessionGuid_in, ip_forLogPurposes_in, profile_in, true, idProfile_parent_in, // idUser_in, idPermission_in, out errors_out ); }
/// <summary> /// Updates CRD_Profile values on Database. /// </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> public static void updObject( SO_CRD_Profile CRD_Profile_in, bool forceUpdate_in, DBConnection dbConnection_in ) { if (forceUpdate_in || CRD_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("IDProfile_", DbType.Int64, ParameterDirection.Input, CRD_Profile_in.IDProfile, 0), _connection.newDBDataParameter("Name_", DbType.AnsiString, ParameterDirection.Input, CRD_Profile_in.Name, 255), _connection.newDBDataParameter("IFApplication_", DbType.Int32, ParameterDirection.Input, CRD_Profile_in.IFApplication_isNull ? null : (object)CRD_Profile_in.IFApplication, 0) }; _connection.Execute_SQLFunction( "sp0_CRD_Profile_updObject", _dataparameters ); if (dbConnection_in == null) { _connection.Dispose(); } CRD_Profile_in.HasChanges = false; } }
/// <summary> /// Inserts CRD_Profile values into Database. /// </summary> /// <param name="selectIdentity_in">assign with True if you wish to retrieve insertion sequence/identity seed and with 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>insertion sequence/identity seed</returns> public static long insObject( SO_CRD_Profile CRD_Profile_in, bool selectIdentity_in, DBConnection dbConnection_in ) { 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("IDProfile_", DbType.Int64, ParameterDirection.Output, null, 0), _connection.newDBDataParameter("Name_", DbType.AnsiString, ParameterDirection.Input, CRD_Profile_in.Name, 255), _connection.newDBDataParameter("IFApplication_", DbType.Int32, ParameterDirection.Input, CRD_Profile_in.IFApplication_isNull ? null : (object)CRD_Profile_in.IFApplication, 0), _connection.newDBDataParameter("SelectIdentity_", DbType.Boolean, ParameterDirection.Input, selectIdentity_in, 1) }; _connection.Execute_SQLFunction( "sp0_CRD_Profile_insObject", _dataparameters ); if (dbConnection_in == null) { _connection.Dispose(); } CRD_Profile_in.IDProfile = (long)_dataparameters[0].Value; CRD_Profile_in.HasChanges = false; return(CRD_Profile_in.IDProfile); }
private static bool check( string sessionGuid_in, string ip_forLogPurposes_in, SO_CRD_Profile profile_in, out Sessionuser sessionUser_out, out List <int> errorlist_out ) { Guid _sessionguid; #region check... int[] _errors_out; if (!SBO_CRD_Authentication.isSessionGuid_valid( sessionGuid_in, ip_forLogPurposes_in, out _sessionguid, out sessionUser_out, out errorlist_out, out _errors_out )) { //// no need! //errors_out = _errors.ToArray(); return(false); } #endregion #region check Permissions... if ( !sessionUser_out.hasPermission( false, PermissionType.Profile__insert, PermissionType.Profile__update ) ) { errorlist_out.Add(ErrorType.profile__lack_of_permissions_to_write); return(false); } #endregion if (profile_in != null) { #region check Profile... if ( (profile_in.Name = profile_in.Name.Trim()).Length == 0 ) { errorlist_out.Add(ErrorType.profile__invalid_name); return(false); } #endregion } return(true); }
/// <summary> /// Inserts CRD_Profile values into Database. /// </summary> /// <param name="selectIdentity_in">assign with True if you wish to retrieve insertion sequence/identity seed and with False if not</param> /// <returns>insertion sequence/identity seed</returns> public static long insObject( SO_CRD_Profile CRD_Profile_in, bool selectIdentity_in ) { return(insObject( CRD_Profile_in, selectIdentity_in, null )); }
/// <summary> /// Updates CRD_Profile values on Database. /// </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> public static void updObject( SO_CRD_Profile CRD_Profile_in, bool forceUpdate_in ) { updObject( CRD_Profile_in, forceUpdate_in, null ); }
public static SO_CRD_Profile getObject( string sessionGuid_in, string ip_forLogPurposes_in, long idProfile_in, out int[] errors_out ) { SO_CRD_Profile _output = null; List <int> _errorlist; Guid _sessionguid; Sessionuser _sessionuser; #region check... if (!SBO_CRD_Authentication.isSessionGuid_valid( sessionGuid_in, ip_forLogPurposes_in, out _sessionguid, out _sessionuser, out _errorlist, out errors_out )) { //// no need! //errors_out = _errors.ToArray(); return(_output); } #endregion #region check Permissions . . . if ( !_sessionuser.hasPermission( PermissionType.Profile__select ) ) { _errorlist.Add(ErrorType.profile__lack_of_permissions_to_read); errors_out = _errorlist.ToArray(); return(_output); } #endregion _output = DO_CRD_Profile.getObject( idProfile_in, null ); errors_out = _errorlist.ToArray(); return(_output); }
private static SO_CRD_Profile[] getRecord( DataTable dataTable_in ) { DataColumn _dc_idprofile = null; DataColumn _dc_name = null; DataColumn _dc_ifapplication = null; SO_CRD_Profile[] _output = new SO_CRD_Profile[dataTable_in.Rows.Count]; for (int r = 0; r < dataTable_in.Rows.Count; r++) { if (r == 0) { _dc_idprofile = dataTable_in.Columns["IDProfile"]; _dc_name = dataTable_in.Columns["Name"]; _dc_ifapplication = dataTable_in.Columns["IFApplication"]; } _output[r] = new SO_CRD_Profile(); if (dataTable_in.Rows[r][_dc_idprofile] == System.DBNull.Value) { _output[r].IDProfile = 0L; } else { _output[r].IDProfile = (long)dataTable_in.Rows[r][_dc_idprofile]; } if (dataTable_in.Rows[r][_dc_name] == System.DBNull.Value) { _output[r].Name = string.Empty; } else { _output[r].Name = (string)dataTable_in.Rows[r][_dc_name]; } if (dataTable_in.Rows[r][_dc_ifapplication] == System.DBNull.Value) { _output[r].IFApplication_isNull = true; } else { _output[r].IFApplication = (int)dataTable_in.Rows[r][_dc_ifapplication]; } _output[r].HasChanges = false; } return(_output); }
/// <summary> /// Selects CRD_Profile values from Database and assigns them to the appropriate DO_CRD_Profile property. /// </summary> /// <param name="IDProfile_in">IDProfile</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 CRD_Profile doesn't exists at Database</returns> public static SO_CRD_Profile getObject( long IDProfile_in, DBConnection dbConnection_in ) { SO_CRD_Profile _output = null; DBConnection _connection = (dbConnection_in == null) ? DO__utils.DBConnection_createInstance( DO__utils.DBServerType, DO__utils.DBConnectionstring, DO__utils.DBLogfile ) : dbConnection_in; IDbDataParameter[] _dataparameters = new IDbDataParameter[] { _connection.newDBDataParameter("IDProfile_", DbType.Int64, ParameterDirection.InputOutput, IDProfile_in, 0), _connection.newDBDataParameter("Name_", DbType.AnsiString, ParameterDirection.Output, null, 255), _connection.newDBDataParameter("IFApplication_", DbType.Int32, ParameterDirection.Output, null, 0) }; _connection.Execute_SQLFunction("sp0_CRD_Profile_getObject", _dataparameters); if (dbConnection_in == null) { _connection.Dispose(); } if (_dataparameters[0].Value != DBNull.Value) { _output = new SO_CRD_Profile(); if (_dataparameters[0].Value == System.DBNull.Value) { _output.IDProfile = 0L; } else { _output.IDProfile = (long)_dataparameters[0].Value; } if (_dataparameters[1].Value == System.DBNull.Value) { _output.Name = string.Empty; } else { _output.Name = (string)_dataparameters[1].Value; } if (_dataparameters[2].Value == System.DBNull.Value) { _output.IFApplication_isNull = true; } else { _output.IFApplication = (int)_dataparameters[2].Value; } _output.haschanges_ = false; return _output; } return null; }
private static SO_CRD_Profile[] getRecord( DataTable dataTable_in ) { DataColumn _dc_idprofile = null; DataColumn _dc_name = null; DataColumn _dc_ifapplication = null; SO_CRD_Profile[] _output = new SO_CRD_Profile[dataTable_in.Rows.Count]; for (int r = 0; r < dataTable_in.Rows.Count; r++) { if (r == 0) { _dc_idprofile = dataTable_in.Columns["IDProfile"]; _dc_name = dataTable_in.Columns["Name"]; _dc_ifapplication = dataTable_in.Columns["IFApplication"]; } _output[r] = new SO_CRD_Profile(); if (dataTable_in.Rows[r][_dc_idprofile] == System.DBNull.Value) { _output[r].idprofile_ = 0L; } else { _output[r].idprofile_ = (long)dataTable_in.Rows[r][_dc_idprofile]; } if (dataTable_in.Rows[r][_dc_name] == System.DBNull.Value) { _output[r].name_ = string.Empty; } else { _output[r].name_ = (string)dataTable_in.Rows[r][_dc_name]; } if (dataTable_in.Rows[r][_dc_ifapplication] == System.DBNull.Value) { _output[r].IFApplication_isNull = true; } else { _output[r].ifapplication_ = (int)dataTable_in.Rows[r][_dc_ifapplication]; } _output[r].haschanges_ = false; } return _output; }
private static void updobject( string sessionGuid_in, string ip_forLogPurposes_in, SO_CRD_Profile profile_in, bool updateObject_in, long[] idProfile_parent_in, // long[] idUser_in, long[] idPermission_in, out int[] errors_out ) { List <int> _errorlist; Sessionuser _sessionuser; // if (idProfile_parent_in == null) nothing is done on CRD_ProfileProfile // if (idProfile_parent_in != null) { // if (idProfile_parent_in.length == 0) all relations are deleted // if (idProfile_parent_in.length != 0) { // all relations are deleted // and new ones are set // } // } // SAME WITH idUser_in and idPermission_in #region check... if (!check( sessionGuid_in, ip_forLogPurposes_in, updateObject_in ? profile_in : null, out _sessionuser, out _errorlist )) { errors_out = _errorlist.ToArray(); return; } #endregion #region check existence... SO_CRD_Profile _profile = DO_CRD_Profile.getObject(profile_in.IDProfile); if (_profile == null) { _errorlist.Add(ErrorType.data__not_found); errors_out = _errorlist.ToArray(); return; } #endregion //profile_in.IFApplication = _profile.IFApplication; if ( (profile_in.IFApplication != _profile.IFApplication) || (_profile.IFApplication != _sessionuser.IDApplication) ) { _errorlist.Add(ErrorType.lack_of_permissions); errors_out = _errorlist.ToArray(); return; } 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 { if ( (idProfile_parent_in != null) || // (idUser_in != null) // || (idPermission_in != null) ) { _con.Open(); _con.Transaction.Begin(); } DO_CRD_Profile.updObject( profile_in, true, _con ); if (idProfile_parent_in != null) { DO_CRD_ProfileProfile.delRecord_byProfile( profile_in.IDProfile, _con ); for (int i = 0; i < idProfile_parent_in.Length; i++) { DO_CRD_ProfileProfile.setObject( new SO_CRD_ProfileProfile( profile_in.IDProfile, idProfile_parent_in[i] ), true, _con ); } } // if (idUser_in != null) { // DO_CRD_UserProfile.delRecord_byProfile( // profile_in.IDProfile, // _con // ); // for (int i = 0; i < idUser_in.Length; i++) { // DO_CRD_UserProfile.setObject( // new SO_CRD_UserProfile( // idUser_in[i], // profile_in.IDProfile // ), // true, // _con // ); // } // } if (idPermission_in != null) { DO_CRD_ProfilePermission.delRecord_byProfile( profile_in.IDProfile, _con ); for (int i = 0; i < idPermission_in.Length; i++) { DO_CRD_ProfilePermission.setObject( new SO_CRD_ProfilePermission( profile_in.IDProfile, idPermission_in[i] ), true, _con ); } } #region _con.Transaction.Commit(); if (_con.Transaction.InTransaction) { _con.Transaction.Commit(); } #endregion _errorlist.Add(ErrorType.profile__successfully_updated__WARNING); } 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(); }
/// <summary> /// Updates CRD_Profile values on Database. /// </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> public static void updObject( SO_CRD_Profile CRD_Profile_in, bool forceUpdate_in, DBConnection dbConnection_in ) { if (forceUpdate_in || CRD_Profile_in.haschanges_) { DBConnection _connection = (dbConnection_in == null) ? DO__utils.DBConnection_createInstance( DO__utils.DBServerType, DO__utils.DBConnectionstring, DO__utils.DBLogfile ) : dbConnection_in; IDbDataParameter[] _dataparameters = new IDbDataParameter[] { _connection.newDBDataParameter("IDProfile_", DbType.Int64, ParameterDirection.Input, CRD_Profile_in.IDProfile, 0), _connection.newDBDataParameter("Name_", DbType.AnsiString, ParameterDirection.Input, CRD_Profile_in.Name, 255), _connection.newDBDataParameter("IFApplication_", DbType.Int32, ParameterDirection.Input, CRD_Profile_in.IFApplication_isNull ? null : (object)CRD_Profile_in.IFApplication, 0) }; _connection.Execute_SQLFunction( "sp0_CRD_Profile_updObject", _dataparameters ); if (dbConnection_in == null) { _connection.Dispose(); } CRD_Profile_in.haschanges_ = false; } }
/// <summary> /// Inserts CRD_Profile values into Database. /// </summary> /// <param name="selectIdentity_in">assign with True if you wish to retrieve insertion sequence/identity seed and with False if not</param> /// <returns>insertion sequence/identity seed</returns> public static long insObject( SO_CRD_Profile CRD_Profile_in, bool selectIdentity_in ) { return insObject( CRD_Profile_in, selectIdentity_in, null ); }
/// <summary> /// Inserts CRD_Profile values into Database. /// </summary> /// <param name="selectIdentity_in">assign with True if you wish to retrieve insertion sequence/identity seed and with 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>insertion sequence/identity seed</returns> public static long insObject( SO_CRD_Profile CRD_Profile_in, bool selectIdentity_in, DBConnection dbConnection_in ) { DBConnection _connection = (dbConnection_in == null) ? DO__utils.DBConnection_createInstance( DO__utils.DBServerType, DO__utils.DBConnectionstring, DO__utils.DBLogfile ) : dbConnection_in; IDbDataParameter[] _dataparameters = new IDbDataParameter[] { _connection.newDBDataParameter("IDProfile_", DbType.Int64, ParameterDirection.Output, null, 0), _connection.newDBDataParameter("Name_", DbType.AnsiString, ParameterDirection.Input, CRD_Profile_in.Name, 255), _connection.newDBDataParameter("IFApplication_", DbType.Int32, ParameterDirection.Input, CRD_Profile_in.IFApplication_isNull ? null : (object)CRD_Profile_in.IFApplication, 0), _connection.newDBDataParameter("SelectIdentity_", DbType.Boolean, ParameterDirection.Input, selectIdentity_in, 1) }; _connection.Execute_SQLFunction( "sp0_CRD_Profile_insObject", _dataparameters ); if (dbConnection_in == null) { _connection.Dispose(); } CRD_Profile_in.IDProfile = (long)_dataparameters[0].Value;CRD_Profile_in.haschanges_ = false; return CRD_Profile_in.IDProfile; }
public static long insObject( string sessionGuid_in, string ip_forLogPurposes_in, SO_CRD_Profile profile_in, long[] idProfile_parent_in, // long[] idUser_in, long[] idPermission_in, out int[] errors_out ) { long _output = -1; List <int> _errorlist; Sessionuser _sessionuser; #region check... if (!check( sessionGuid_in, ip_forLogPurposes_in, profile_in, out _sessionuser, out _errorlist )) { errors_out = _errorlist.ToArray(); return(_output); } #endregion if (profile_in == null) { _errorlist.Add(ErrorType.data__not_found); errors_out = _errorlist.ToArray(); return(_output); } if (profile_in.IFApplication != _sessionuser.IDApplication) { _errorlist.Add(ErrorType.lack_of_permissions); errors_out = _errorlist.ToArray(); return(_output); } 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 { if ( ( (idProfile_parent_in != null) && (idProfile_parent_in.Length > 0) ) || // ( // (idUser_in != null) // && // (idUser_in.Length > 0) // ) // || ( (idPermission_in != null) && (idPermission_in.Length > 0) ) ) { _con.Open(); _con.Transaction.Begin(); } _output = DO_CRD_Profile.insObject( profile_in, // if connection is open that means I'm doing operations on other tables // and I will need the identity seed _con.IsOpen, _con ); if (idProfile_parent_in != null) { for (int i = 0; i < idProfile_parent_in.Length; i++) { DO_CRD_ProfileProfile.setObject( new SO_CRD_ProfileProfile( _output, idProfile_parent_in[i] ), true, _con ); } } // if (idUser_in != null) { // for (int i = 0; i < idUser_in.Length; i++) { // DO_CRD_UserProfile.setObject( // new SO_CRD_UserProfile( // _output, // idUser_in[i] // ), // true, // _con // ); // } // } if (idPermission_in != null) { for (int i = 0; i < idPermission_in.Length; i++) { DO_CRD_ProfilePermission.setObject( new SO_CRD_ProfilePermission( _output, idPermission_in[i] ), true, _con ); } } #region _con.Transaction.Commit(); if (_con.Transaction.InTransaction) { _con.Transaction.Commit(); } #endregion _errorlist.Add(ErrorType.profile__successfully_created__WARNING); } 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); }
/// <summary> /// Selects CRD_Profile values from Database and assigns them to the appropriate DO_CRD_Profile property. /// </summary> /// <param name="IDProfile_in">IDProfile</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 CRD_Profile doesn't exists at Database</returns> public static SO_CRD_Profile getObject( long IDProfile_in, DBConnection dbConnection_in ) { SO_CRD_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("IDProfile_", DbType.Int64, ParameterDirection.InputOutput, IDProfile_in, 0), _connection.newDBDataParameter("Name_", DbType.AnsiString, ParameterDirection.Output, null, 255), _connection.newDBDataParameter("IFApplication_", DbType.Int32, ParameterDirection.Output, null, 0) }; _connection.Execute_SQLFunction("sp0_CRD_Profile_getObject", _dataparameters); if (dbConnection_in == null) { _connection.Dispose(); } if (_dataparameters[0].Value != DBNull.Value) { _output = new SO_CRD_Profile(); if (_dataparameters[0].Value == System.DBNull.Value) { _output.IDProfile = 0L; } else { _output.IDProfile = (long)_dataparameters[0].Value; } if (_dataparameters[1].Value == System.DBNull.Value) { _output.Name = string.Empty; } else { _output.Name = (string)_dataparameters[1].Value; } if (_dataparameters[2].Value == System.DBNull.Value) { _output.IFApplication_isNull = true; } else { _output.IFApplication = (int)_dataparameters[2].Value; } _output.HasChanges = false; return(_output); } return(null); }
private static bool check( string sessionGuid_in, string ip_forLogPurposes_in, SO_CRD_Profile profile_in, out Sessionuser sessionUser_out, out List<int> errorlist_out ) { Guid _sessionguid; #region check... int[] _errors_out; if (!SBO_CRD_Authentication.isSessionGuid_valid( sessionGuid_in, ip_forLogPurposes_in, out _sessionguid, out sessionUser_out, out errorlist_out, out _errors_out )) { //// no need! //errors_out = _errors.ToArray(); return false; } #endregion #region check Permitions... if ( !sessionUser_out.hasPermition( false, PermitionType.Profile__insert, PermitionType.Profile__update ) ) { errorlist_out.Add(ErrorType.profile__lack_of_permitions_to_write); return false; } #endregion if (profile_in != null) { #region check Profile... if ( (profile_in.Name = profile_in.Name.Trim()) == "" ) { errorlist_out.Add(ErrorType.profile__invalid_name); return false; } #endregion } return true; }
public static void updObject( string sessionGuid_in, string ip_forLogPurposes_in, SO_CRD_Profile profile_in, long[] idProfile_parent_in, // long[] idUser_in, long[] idPermition_in, out int[] errors_out ) { updobject( sessionGuid_in, ip_forLogPurposes_in, profile_in, true, idProfile_parent_in, // idUser_in, idPermition_in, out errors_out ); }
private static void updobject( string sessionGuid_in, string ip_forLogPurposes_in, SO_CRD_Profile profile_in, bool updateObject_in, long[] idProfile_parent_in, // long[] idUser_in, long[] idPermition_in, out int[] errors_out ) { List<int> _errorlist; Sessionuser _sessionuser; // if (idProfile_parent_in == null) nothing is done on CRD_ProfileProfile // if (idProfile_parent_in != null) { // if (idProfile_parent_in.length == 0) all relations are deleted // if (idProfile_parent_in.length != 0) { // all relations are deleted // and new ones are set // } // } // SAME WITH idUser_in and idPermition_in #region check... if (!check( sessionGuid_in, ip_forLogPurposes_in, updateObject_in ? profile_in : null, out _sessionuser, out _errorlist )) { errors_out = _errorlist.ToArray(); return; } #endregion #region check existence... SO_CRD_Profile _profile = DO_CRD_Profile.getObject(profile_in.IDProfile); if (_profile == null) { _errorlist.Add(ErrorType.data__not_found); errors_out = _errorlist.ToArray(); return; } #endregion //profile_in.IFApplication = _profile.IFApplication; if ( (profile_in.IFApplication != _profile.IFApplication) || (_profile.IFApplication != _sessionuser.IDApplication) ) { _errorlist.Add(ErrorType.lack_of_permitions); errors_out = _errorlist.ToArray(); return; } Exception _exception = null; #region DBConnection _con = DO__utils.DBConnection_createInstance(...); DBConnection _con = DO__utils.DBConnection_createInstance( DO__utils.DBServerType, DO__utils.DBConnectionstring, DO__utils.DBLogfile ); #endregion try { if ( (idProfile_parent_in != null) || // (idUser_in != null) // || (idPermition_in != null) ) { _con.Open(); _con.Transaction.Begin(); } DO_CRD_Profile.updObject( profile_in, true, _con ); if (idProfile_parent_in != null) { DO_CRD_ProfileProfile.delRecord_byProfile( profile_in.IDProfile, _con ); for (int i = 0; i < idProfile_parent_in.Length; i++) { DO_CRD_ProfileProfile.setObject( new SO_CRD_ProfileProfile( profile_in.IDProfile, idProfile_parent_in[i] ), true, _con ); } } // if (idUser_in != null) { // DO_CRD_UserProfile.delRecord_byProfile( // profile_in.IDProfile, // _con // ); // for (int i = 0; i < idUser_in.Length; i++) { // DO_CRD_UserProfile.setObject( // new SO_CRD_UserProfile( // idUser_in[i], // profile_in.IDProfile // ), // true, // _con // ); // } // } if (idPermition_in != null) { DO_CRD_ProfilePermition.delRecord_byProfile( profile_in.IDProfile, _con ); for (int i = 0; i < idPermition_in.Length; i++) { DO_CRD_ProfilePermition.setObject( new SO_CRD_ProfilePermition( profile_in.IDProfile, idPermition_in[i] ), true, _con ); } } #region _con.Transaction.Commit(); if (_con.Transaction.inTransaction) { _con.Transaction.Commit(); } #endregion _errorlist.Add(ErrorType.profile__successfully_updated__WARNING); } 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.lib.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(); }
public void btn_Save_Click(object sender, EventArgs e) { bool _isInsert_notUpdate; int[] _errors; SO_CRD_Profile _profile; if ( #region ((_profile = ...) != null) (IDProfile > 0) && ( (_profile = BusinessInstances.CRD_Profile.InstanceClient.getObject( utils.User.SessionGuid, utils.ClientIPAddress, IDProfile, out _errors )) != null ) && !Master__base.Error_add(_errors) #endregion ) { _profile.Name = txt_Name.Text; BusinessInstances.CRD_Profile.InstanceClient.updObject( utils.User.SessionGuid, utils.ClientIPAddress, _profile, cbl_ParentProfiles.Kick.SelectedValue__get<long>(), cbl_Permitions.Kick.SelectedValue__get<long>(), out _errors ); _isInsert_notUpdate = false; } else { _profile = new SO_CRD_Profile(); _profile.Name = txt_Name.Text; _profile.IFApplication = utils.IDApplication; BusinessInstances.CRD_Profile.InstanceClient.insObject( utils.User.SessionGuid, utils.ClientIPAddress, _profile, cbl_ParentProfiles.Kick.SelectedValue__get<long>(), cbl_Permitions.Kick.SelectedValue__get<long>(), out _errors ); _isInsert_notUpdate = true; } if (!Master__base.Error_add(_errors) && _isInsert_notUpdate) { Response.Redirect("~/admin/CRD-Profile-list.aspx"); } }
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; }
public static void updObject( string sessionGuid_in, string ip_forLogPurposes_in, SO_vNWS_Profile profile_in, out int[] errors_out ) { 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; } #endregion #region check existence . . . SO_NWS_Profile _nws_profile = DO_NWS_Profile.getObject(...); SO_NWS_Profile _nws_profile; if ( profile_in.IDProfile <= 0 || ( (_nws_profile = DO_NWS_Profile.getObject( profile_in.IDProfile )) == null ) ) { _errorlist.Add(ErrorType.data__not_found); errors_out = _errorlist.ToArray(); return; } #endregion #region _nws_profile.IFUser__Approved = ...; if ( _nws_profile.IFUser__Approved_isNull || _nws_profile.Approved_date_isNull ) { if (_sessionuser.hasPermission(PermissionType.News__Profile__approve)) { _nws_profile.Approved_date = DateTime.Now; _nws_profile.IFUser__Approved = _sessionuser.IDUser; } else { _nws_profile.Approved_date_isNull = true; _nws_profile.IFUser__Approved_isNull = true; } } #endregion #region SO_CRD_Profile _crd_profile = DO_CRD_Profile.getObject(_nws_profile.IFProfile); SO_CRD_Profile _crd_profile = DO_CRD_Profile.getObject( _nws_profile.IFProfile ); #endregion //// preserve, hence comment: //_crd_profile.IFApplication = profile_in.IDApplication; _crd_profile.Name = profile_in.Name; 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(); DO_NWS_Profile.setObject( _nws_profile, true, _con ); DO_CRD_Profile.updObject( _crd_profile, false, // I did getObject prior, so no problem. BE CAREFULL in future updates! _con ); _errorlist.Add(ErrorType.news__profile__successfully_updated__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(); }
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); }
public void BTN_Save_Click(object sender, EventArgs e) { bool _isInsert_notUpdate; int[] _errors; SO_CRD_Profile _profile; if ( #region ((_profile = ...) != null) (this.IDProfile > 0) && ( (_profile = BusinessInstances.CRD_Profile.InstanceClient.getObject( Utilities.User.SessionGuid, Utilities.ClientIPAddress, this.IDProfile, out _errors )) != null ) && !this.Master__base.Error_add(_errors) #endregion ) { _profile.Name = this.TXT_Name.Text; BusinessInstances.CRD_Profile.InstanceClient.updObject( Utilities.User.SessionGuid, Utilities.ClientIPAddress, _profile, this.CBL_ParentProfiles.Kick.SelectedValue__get <long>(), this.CBL_Permissions.Kick.SelectedValue__get <long>(), out _errors ); _isInsert_notUpdate = false; } else { _profile = new SO_CRD_Profile(); _profile.Name = this.TXT_Name.Text; _profile.IFApplication = Utilities.IDApplication; BusinessInstances.CRD_Profile.InstanceClient.insObject( Utilities.User.SessionGuid, Utilities.ClientIPAddress, _profile, this.CBL_ParentProfiles.Kick.SelectedValue__get <long>(), this.CBL_Permissions.Kick.SelectedValue__get <long>(), out _errors ); _isInsert_notUpdate = true; } if (!this.Master__base.Error_add(_errors) && _isInsert_notUpdate) { Response.Redirect("~/admin/CRD-Profile-list.aspx"); } }
public static long insObject( string sessionGuid_in, string ip_forLogPurposes_in, SO_CRD_Profile profile_in, long[] idProfile_parent_in, // long[] idUser_in, long[] idPermition_in, out int[] errors_out ) { long _output = -1; List<int> _errorlist; Sessionuser _sessionuser; #region check... if (!check( sessionGuid_in, ip_forLogPurposes_in, profile_in, out _sessionuser, out _errorlist )) { errors_out = _errorlist.ToArray(); return _output; } #endregion if (profile_in == null) { _errorlist.Add(ErrorType.data__not_found); errors_out = _errorlist.ToArray(); return _output; } if (profile_in.IFApplication != _sessionuser.IDApplication) { _errorlist.Add(ErrorType.lack_of_permitions); errors_out = _errorlist.ToArray(); return _output; } Exception _exception = null; #region DBConnection _con = DO__utils.DBConnection_createInstance(...); DBConnection _con = DO__utils.DBConnection_createInstance( DO__utils.DBServerType, DO__utils.DBConnectionstring, DO__utils.DBLogfile ); #endregion try { if ( ( (idProfile_parent_in != null) && (idProfile_parent_in.Length > 0) ) || // ( // (idUser_in != null) // && // (idUser_in.Length > 0) // ) // || ( (idPermition_in != null) && (idPermition_in.Length > 0) ) ) { _con.Open(); _con.Transaction.Begin(); } _output = DO_CRD_Profile.insObject( profile_in, // if connection is open that means I'm doing operations on other tables // and I will need the identity seed _con.isOpen, _con ); if (idProfile_parent_in != null) { for (int i = 0; i < idProfile_parent_in.Length; i++) { DO_CRD_ProfileProfile.setObject( new SO_CRD_ProfileProfile( _output, idProfile_parent_in[i] ), true, _con ); } } // if (idUser_in != null) { // for (int i = 0; i < idUser_in.Length; i++) { // DO_CRD_UserProfile.setObject( // new SO_CRD_UserProfile( // _output, // idUser_in[i] // ), // true, // _con // ); // } // } if (idPermition_in != null) { for (int i = 0; i < idPermition_in.Length; i++) { DO_CRD_ProfilePermition.setObject( new SO_CRD_ProfilePermition( _output, idPermition_in[i] ), true, _con ); } } #region _con.Transaction.Commit(); if (_con.Transaction.inTransaction) { _con.Transaction.Commit(); } #endregion _errorlist.Add(ErrorType.profile__successfully_created__WARNING); } 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.lib.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; }