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 void updObject_Approve( string sessionGuid_in, string ip_forLogPurposes_in, long idProfile_in, out int[] errors_out ) { 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; } #endregion #region check Permissions . . . if ( !_sessionuser.hasPermission( PermissionType.News__Profile__approve ) ) { _errorlist.Add(ErrorType.news__profile__lack_of_permissions_to_approve); errors_out = _errorlist.ToArray(); return; } #endregion #region check existence . . . SO_NWS_Profile _profile; if ( idProfile_in <= 0 || ( (_profile = DO_NWS_Profile.getObject( idProfile_in )) == null ) ) { _errorlist.Add(ErrorType.data__not_found); errors_out = _errorlist.ToArray(); return; } #endregion _profile.Approved_date = DateTime.Now; _profile.IFUser__Approved = _sessionuser.IDUser; DO_NWS_Profile.setObject( _profile, true, null ); _errorlist.Add(ErrorType.news__profile__successfully_approved__WARNING); 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); }