/// <summary>
        /// 初始化连接池
        /// </summary>
        private static void InitK2ConnPool(ServiceContext context)
        {

            if (IsConstructed) return;

            SetMaxPoolSize();
            k2ConnWrap = new K2ConnWrap[maxPoolSize];

            for (int i = 0; i < k2ConnWrap.Length; i++)
            {
                k2ConnWrap[i] = new K2ConnWrap();
            }

            //string strK2Server = System.Configuration.ConfigurationManager.AppSettings["K2Server"].ToString();
            string strK2Server = context[SettingVariable.ServerName];
            aryServerName = strK2Server.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);


            //初始化结束
            IsConstructed = true;
        }
        /// <summary>
        /// 连接池无空闲连接,获取新的连接 
        /// </summary>
        /// <returns></returns>
        private static Connection GetNewK2Conn(ServiceContext context)
        {
            InitConfigValue(context);
            Connection k2conn = new Connection();
            ConnectionSetup k2ConSetup = new ConnectionSetup();

            try
            {
                SetK2Param(k2ConSetup, ConnectionSetup.ParamKeys.Host, K2ServerProvider.AvailableServerName);
                SetK2Param(k2ConSetup, ConnectionSetup.ParamKeys.UserID, k2User);
                SetK2Param(k2ConSetup, ConnectionSetup.ParamKeys.Password, k2PassWord);
                SetK2Param(k2ConSetup, ConnectionSetup.ParamKeys.Port, clientPort);
                SetK2Param(k2ConSetup, ConnectionSetup.ParamKeys.Authenticate, "true");
                SetK2Param(k2ConSetup, ConnectionSetup.ParamKeys.IsPrimaryLogin, "true");
                SetK2Param(k2ConSetup, ConnectionSetup.ParamKeys.SecurityLabelName, label);

                SetK2Param(k2ConSetup, ConnectionSetup.ParamKeys.WindowsDomain, domain);
                if (label.ToLower() != "k2")
                    SetK2Param(k2ConSetup, ConnectionSetup.ParamKeys.Integrated, "false");

                k2conn.Open(K2ServerProvider.AvailableServerName, k2ConSetup.ConnectionString);

                lock (oLock)
                {
                    noPoolConnCount++;
                }
            }
            catch (Exception ex)
            {
                K2PoolLogger.logError("得到新连接时出错K2ConnnectionPool.GetNewK2Conn(), \r\n "
                    + "K2ServerProvider.AvailableServerName = " + K2ServerProvider.AvailableServerName + ", \r\n"
                    + "ex.Messagee = " + ex.Message + "\r\n"
                    + "ex.StackTrace = " + ex.StackTrace);
                //2012-2-14 pcitljw
                //得到新连接出错时 重新查找别的主机建立连接
                K2ConnWrap wrap = new K2ConnWrap();
                wrap.K2Conn = k2conn;
                wrap.ReTryConn(context);
                k2conn = wrap.K2Conn;
                //throw;
            }

            return k2conn;
        }
        private static void logReleaseTimeOutConn(K2ConnWrap wrap)
        {
            string userAccount = "未初始化";
            if (wrap.K2Conn != null)
            {
                if (wrap.K2Conn.User != null)
                {
                    userAccount = wrap.K2Conn.User.Name;
                }
                else
                {
                    userAccount = "K2Conn.User==null";
                }
            }

            string msg = " 释放一个连接占用时间超过一分钟的连接。"
                        + "\r\n | K2服务器:" + wrap.K2ServerName
                        + "\r\n | 初始化时间:" + wrap.TimeOfInit.ToString("HH:mm:ss")
                        + "\r\n | 初始化标识:" + wrap.Initialized.ToString()
                        + "\r\n | 上次所有人:" + userAccount
                        + "\r\n | 得到时间:" + wrap.TimeOfGetting.ToString("HH:mm:ss")
                        + "\r\n | 堆栈:" + wrap.StackOfGetting;

            K2PoolLogger.logError(msg);
        }