Esempio n. 1
0
        /// <summary>
        /// 查询故障转移
        /// </summary>
        /// <param name="ormDataBase"></param>
        /// <returns></returns>
        protected virtual T TryGetConnection <T>(OrmDataBaseInfo ormDataBase) where T : DbConnection
        {
            var sqlcon = CreateTryConnection <T>(ormDataBase);

            try
            {
                if (sqlcon.State != ConnectionState.Open)
                {
                    sqlcon.Open();
                }
                ormDataBase.UseConnect();
                return(sqlcon);
            }
            catch (Exception)
            {
                ormDataBase.IsException = true;
                return(null);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 查询故障转移
        /// </summary>
        /// <param name="ormDataBase"></param>
        /// <returns></returns>
        protected virtual T TryGetConnection <T>(OrmDataBaseInfo ormDataBase) where T : DbConnection
        {
            var sqlcon = CreateTryConnection <T>(ormDataBase);

            try
            {
                if (sqlcon.State != ConnectionState.Open)
                {
                    sqlcon.Open();
                }
                ormDataBase.UseConnect();
                return(sqlcon);
            }
            catch (Exception ex)
            {
                Log.AddException(ex);
                ormDataBase.IsException = true;
                Action <OrmDataBaseInfo> action = CheckConnectionAlive <T>;
                action.BeginInvoke(ormDataBase, null, null);
                return(null);
            }
        }