Beispiel #1
0
        public BaseDTO UpdateNoEF(BaseDTO baseDTO)
        {
            connectionStringEF           = baseDTO.ConnectTo.GetDescription().GetConnectionStringEF("AATEntities");
            _DBMangerNoEF                = new SqlDBManger();
            _DBMangerNoEF.ConnectionName = baseDTO.ConnectTo.GetDescription();
            baseDTO = SetStandardLog(baseDTO, "Before");
            try
            {
                if (baseDTO.IsTransaction)
                {
                    _DBMangerNoEF.BeginTransaction();
                }
                baseDTO = DoUpdate(baseDTO);
            }
            catch (Exception ex)
            {
                baseDTO.Result.IsResult     = false;
                baseDTO.Result.ActionResult = -1;
                baseDTO.Result.ResultMsg    = ex.Message;
            }
            finally
            {
                if (baseDTO.IsTransaction)
                {
                    if (baseDTO.Result.ActionResult >= 0)
                    {
                        _DBMangerNoEF.CommitTransaction();
                    }
                    else
                    {
                        _DBMangerNoEF.RollbackTransaction();
                    }
                }
            }
            try
            {
                if (baseDTO.Result.IsResult)
                {
                    baseDTO = DoAfterUpdate(baseDTO);
                }
            }
            catch (Exception ex)
            {
                baseDTO.Result.IsResult     = false;
                baseDTO.Result.ActionResult = -1;
                baseDTO.Result.ResultMsg    = ex.Message;
            }
            baseDTO = SetStandardLog(baseDTO, "After");
            baseDTO = SaveStandardLog(baseDTO);

            _DBManger = new AATEntities(connectionStringEF);
            baseDTO   = SaveMessageError(baseDTO);
            if (_DBManger != null)
            {
                _DBManger.Dispose();
                _DBManger = null;
            }
            return(baseDTO);
        }
Beispiel #2
0
        public BaseDTO SelectNoEF(BaseDTO baseDTO)
        {
            connectionStringEF           = baseDTO.ConnectTo.GetDescription().GetConnectionStringEF("AATEntities");
            _DBMangerNoEF                = new SqlDBManger();
            _DBMangerNoEF.ConnectionName = baseDTO.ConnectTo.GetDescription();
            try
            {
                baseDTO = DoSelect(baseDTO);
            }
            catch (Exception ex)
            {
                baseDTO.Result.IsResult  = false;
                baseDTO.Result.ResultMsg = ex.Message;
            }
            _DBManger = new AATEntities(connectionStringEF);
            baseDTO   = SaveMessageError(baseDTO);
            if (_DBManger != null)
            {
                _DBManger.Dispose();
                _DBManger = null;
            }

            return(baseDTO);
        }
Beispiel #3
0
        public BaseDTO Insert(BaseDTO baseDTO)
        {
            connectionStringEF = baseDTO.ConnectTo.GetDescription().GetConnectionStringEF("AATEntities");
            _DBManger          = new AATEntities(connectionStringEF);
            DbContextTransaction _Transaction = null;

            try
            {
                if (baseDTO.IsTransaction)
                {
                    _Transaction = _DBManger.Database.BeginTransaction();
                }
                baseDTO = DoInsert(baseDTO);
                _DBManger.SaveChanges();
            }
            catch (Exception ex)
            {
                baseDTO.Result.IsResult     = false;
                baseDTO.Result.ActionResult = -1;
                baseDTO.Result.ResultMsg    = ex.Message;
                if (ex.InnerException != null)
                {
                    baseDTO.Result.ResultMsg = ex.InnerException.Message;
                    if (ex.InnerException.InnerException != null)
                    {
                        baseDTO.Result.ResultMsg = ex.InnerException.InnerException.Message;
                    }
                }
            }
            finally
            {
                if (baseDTO.IsTransaction)
                {
                    if (baseDTO.Result.ActionResult >= 0)
                    {
                        _Transaction.Commit();
                    }
                    else
                    {
                        _Transaction.Rollback();
                    }
                }
            }
            try
            {
                if (baseDTO.Result.IsResult)
                {
                    baseDTO = DoAfterInsert(baseDTO);
                }
            }
            catch (Exception ex)
            {
                baseDTO.Result.IsResult     = false;
                baseDTO.Result.ActionResult = -1;
                baseDTO.Result.ResultMsg    = ex.Message;
            }
            _DBMangerNoEF = new SqlDBManger();
            _DBMangerNoEF.ConnectionName = baseDTO.ConnectTo.GetDescription();
            baseDTO = SetStandardLog(baseDTO, "After");
            baseDTO = SaveStandardLog(baseDTO);

            _DBManger = new AATEntities(connectionStringEF);
            baseDTO   = SaveMessageError(baseDTO);
            if (_DBManger != null)
            {
                _DBManger.Dispose();
                _DBManger = null;
            }
            return(baseDTO);
        }