public static long insObject( string sessionGuid_in, string ip_forLogPurposes_in, SO_NWS_Source source_in, bool selectIdentity_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 source_in, out _sessionguid, out _sessionuser, out _errorlist )) { errors_out = _errorlist.ToArray(); return(_output); } #endregion if (_sessionuser.hasPermission(PermissionType.Source__approve)) { source_in.Approved_date = DateTime.Now; source_in.IFUser__Approved = _sessionuser.IDUser; } else { source_in.Approved_date_isNull = true; source_in.IFUser__Approved_isNull = true; } source_in.IFApplication = _sessionuser.IDApplication; _output = DO_NWS_Source.insObject( source_in, selectIdentity_in, null ); _errorlist.Add(ErrorType.source__successfully_created__WARNING); errors_out = _errorlist.ToArray(); return(_output); }
public static SO_NWS_Source getObject( string sessionGuid_in, string ip_forLogPurposes_in, long idSource_in, out int[] errors_out ) { SO_NWS_Source _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.Source__select ) ) { _errorlist.Add(ErrorType.source__lack_of_permissions_to_read); errors_out = _errorlist.ToArray(); return(_output); } #endregion _output = DO_NWS_Source.getObject( idSource_in, null ); errors_out = _errorlist.ToArray(); return(_output); }
public static void delObject( string sessionGuid_in, string ip_forLogPurposes_in, long idSource_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.Source__delete ) ) { _errorlist.Add(ErrorType.source__lack_of_permissions_to_delete); errors_out = _errorlist.ToArray(); return; } #endregion #region check existence . . . SO_NWS_Source _source; if ( idSource_in <= 0 || ( (_source = DO_NWS_Source.getObject( idSource_in )) == null ) ) { _errorlist.Add(ErrorType.data__not_found); errors_out = _errorlist.ToArray(); return; } #endregion #region check Permissions . . . (more) if ( // is approved ( !_source.IFUser__Approved_isNull || !_source.Approved_date_isNull ) && // and no permission to approve !_sessionuser.hasPermission( PermissionType.Source__approve ) ) { _errorlist.Add(ErrorType.source__lack_of_permissions_to_delete_approved); errors_out = _errorlist.ToArray(); return; } #endregion #region check References . . . if ( (DO_NWS_ContentSource.getCount_inRecord_bySource( idSource_in ) > 0) || (DO_NWS_Source.getCount_inRecord_byParent( idSource_in ) > 0) ) { _errorlist.Add(ErrorType.data__constraint_violation); errors_out = _errorlist.ToArray(); return; } #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(); DO_NWS_Source.delObject( idSource_in, _con ); _errorlist.Add(ErrorType.source__successfully_deleted__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 idSource_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.Source__approve ) ) { _errorlist.Add(ErrorType.source__lack_of_permissions_to_approve); errors_out = _errorlist.ToArray(); return; } #endregion #region check existence . . . SO_NWS_Source _source; if ( idSource_in <= 0 || ( (_source = DO_NWS_Source.getObject( idSource_in )) == null ) ) { _errorlist.Add(ErrorType.data__not_found); errors_out = _errorlist.ToArray(); return; } #endregion _source.Approved_date = DateTime.Now; _source.IFUser__Approved = _sessionuser.IDUser; DO_NWS_Source.updObject( _source, true, null ); _errorlist.Add(ErrorType.source__successfully_approved__WARNING); errors_out = _errorlist.ToArray(); }
public static void updObject( string sessionGuid_in, string ip_forLogPurposes_in, SO_NWS_Source source_in, out int[] errors_out ) { Guid _sessionguid; Sessionuser _sessionuser; #region check... List <int> _errorlist; if (!check( sessionGuid_in, ip_forLogPurposes_in, ref source_in, out _sessionguid, out _sessionuser, out _errorlist )) { errors_out = _errorlist.ToArray(); return; } #endregion #region check existence . . . SO_NWS_Source _source; if ( source_in.IDSource <= 0 || ( (_source = DO_NWS_Source.getObject( source_in.IDSource )) == null ) ) { _errorlist.Add(ErrorType.data__not_found); errors_out = _errorlist.ToArray(); return; } #endregion if ( _source.IFUser__Approved_isNull || _source.Approved_date_isNull ) { if (_sessionuser.hasPermission(PermissionType.Source__approve)) { source_in.Approved_date = DateTime.Now; source_in.IFUser__Approved = _sessionuser.IDUser; } else { source_in.Approved_date_isNull = true; source_in.IFUser__Approved_isNull = true; } } else { source_in.Approved_date = _source.Approved_date; source_in.IFUser__Approved = _source.IFUser__Approved; } source_in.IFApplication = _source.IFApplication; DO_NWS_Source.updObject( source_in, true, null ); _errorlist.Add(ErrorType.source__successfully_updated__WARNING); errors_out = _errorlist.ToArray(); }