Exemplo n.º 1
0
        public static SO_NWS_Author getObject(
            string sessionGuid_in,
            string ip_forLogPurposes_in,

            long idAuthor_in,

            out int[] errors_out
            )
        {
            SO_NWS_Author _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.Author__select
                    )
                )
            {
                _errorlist.Add(ErrorType.author__lack_of_permissions_to_read);
                errors_out = _errorlist.ToArray();
                return(_output);
            }
            #endregion

            _output = DO_NWS_Author.getObject(
                idAuthor_in,

                null
                );

            errors_out = _errorlist.ToArray();
            return(_output);
        }
Exemplo n.º 2
0
        public static void delObject(
            string sessionGuid_in,
            string ip_forLogPurposes_in,

            long idAuthor_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.Author__delete
                    )
                )
            {
                _errorlist.Add(ErrorType.author__lack_of_permissions_to_delete);
                errors_out = _errorlist.ToArray();
                return;
            }
            #endregion
            #region check existence...
            SO_NWS_Author _author;
            if (
                idAuthor_in <= 0
                ||
                (
                    (_author = DO_NWS_Author.getObject(
                         idAuthor_in
                         )) == null
                )
                )
            {
                _errorlist.Add(ErrorType.data__not_found);
                errors_out = _errorlist.ToArray();
                return;
            }
            #endregion
            #region check Permissions... (more)
            if (
                // is approved
                (
                    !_author.IFUser__Approved_isNull
                    ||
                    !_author.Approved_date_isNull
                )
                &&
                // and no permission to approve
                !_sessionuser.hasPermission(
                    PermissionType.Author__approve
                    )
                )
            {
                _errorlist.Add(ErrorType.author__lack_of_permissions_to_delete_approved);
                errors_out = _errorlist.ToArray();
                return;
            }
            #endregion
            #region check References...
            if (
                (DO_NWS_ContentAuthor.getCount_inRecord_byAuthor(
                     idAuthor_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_Author.delObject(
                    idAuthor_in,

                    _con
                    );

                _errorlist.Add(ErrorType.author__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();
        }
Exemplo n.º 3
0
        public static void updObject_Approve(
            string sessionGuid_in,
            string ip_forLogPurposes_in,

            long idAuthor_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.Author__approve
                    )
                )
            {
                _errorlist.Add(ErrorType.author__lack_of_permissions_to_approve);
                errors_out = _errorlist.ToArray();
                return;
            }
            #endregion
            #region check existence...
            SO_NWS_Author _author;
            if (
                idAuthor_in <= 0
                ||
                (
                    (_author = DO_NWS_Author.getObject(
                         idAuthor_in
                         )) == null
                )
                )
            {
                _errorlist.Add(ErrorType.data__not_found);
                errors_out = _errorlist.ToArray();
                return;
            }
            #endregion

            _author.Approved_date    = DateTime.Now;
            _author.IFUser__Approved = _sessionuser.IDUser;
            DO_NWS_Author.updObject(
                _author,
                true,

                null
                );
            _errorlist.Add(ErrorType.author__successfully_approved__WARNING);

            errors_out = _errorlist.ToArray();
        }
Exemplo n.º 4
0
        public static void updObject(
            string sessionGuid_in,
            string ip_forLogPurposes_in,

            SO_NWS_Author author_in,

            out int[] errors_out
            )
        {
            Guid        _sessionguid;
            Sessionuser _sessionuser;

            #region check...
            List <int> _errorlist;
            if (!check(
                    sessionGuid_in,
                    ip_forLogPurposes_in,

                    ref author_in,

                    out _sessionguid,
                    out _sessionuser,
                    out _errorlist
                    ))
            {
                errors_out = _errorlist.ToArray();
                return;
            }
            #endregion
            #region check existence...
            SO_NWS_Author _author;
            if (
                author_in.IDAuthor <= 0
                ||
                (
                    (_author = DO_NWS_Author.getObject(
                         author_in.IDAuthor
                         )) == null
                )
                )
            {
                _errorlist.Add(ErrorType.data__not_found);
                errors_out = _errorlist.ToArray();
                return;
            }
            #endregion

            if (
                _author.IFUser__Approved_isNull
                ||
                _author.Approved_date_isNull
                )
            {
                if (_sessionuser.hasPermission(PermissionType.Author__approve))
                {
                    author_in.Approved_date    = DateTime.Now;
                    author_in.IFUser__Approved = _sessionuser.IDUser;
                }
                else
                {
                    author_in.Approved_date_isNull    = true;
                    author_in.IFUser__Approved_isNull = true;
                }
            }
            else
            {
                author_in.Approved_date    = _author.Approved_date;
                author_in.IFUser__Approved = _author.IFUser__Approved;
            }

            author_in.IFApplication = _author.IFApplication;
            DO_NWS_Author.updObject(
                author_in,
                true,

                null
                );
            _errorlist.Add(ErrorType.author__successfully_updated__WARNING);

            errors_out = _errorlist.ToArray();
        }