示例#1
0
 internal bool OpenCon(ConnBean cb)
 {
     try
     {
         if (!isOpenTrans && cb != null && isAllowResetConn && connObject.IsAllowSlave())
         {
             ResetConn(cb);
         }
         Open();
         if (IsAllowRecordSql)
         {
             _watch.Start();
         }
         return(true);
     }
     catch (DbException err)
     {
         if (cb == null && connObject.BackUp != null)
         {
             connObject.InterChange();
             return(OpenCon(connObject.BackUp));
             //if (OpenConBak())
             //{
             //    return true;
             //}
         }
         else
         {
             WriteError("OpenCon():" + err.Message);
         }
     }
     return(false);
 }
示例#2
0
        /// <summary>
        /// 打开链接只切主备
        /// </summary>
        /// <returns></returns>
        internal bool OpenCon()
        {
            ConnBean master = connObject.Master;

            if (!master.IsOK && connObject.BackUp != null && connObject.BackUp.IsOK)
            {
                master = connObject.BackUp;
                connObject.InterChange();//主从换位置
            }
            if (master.IsOK || (connObject.BackUp != null && connObject.BackUp.IsOK))
            {
                bool result = OpenCon(master, AllowConnLevel.MasterBackup);
                if (result && _IsAllowRecordSql)
                {
                    connObject.SetNotAllowSlave();
                    isAllowResetConn = false;
                }
                return(result);
            }
            return(false);
        }