/// <summary>
        /// Saves the new es session.
        /// </summary>
        /// <param name="eSight">The e sight.</param>
        /// <returns>IESSession.</returns>
        public ESightSession SaveSession(HWESightHost eSight)
        {
            // 测试连接...
            using (var eSSession = new ESightSession(eSight))
            {
                eSSession.TestConnection();
            }
            // 查找已有的eSesssion,防止重复
            var iEsSession = this.FindEsSession(eSight.HostIP);

            if (iEsSession == null)
            {
                // 没有找到已有的eSight.
                iEsSession = new ESightSession(eSight);
            }
            iEsSession.ESight = eSight;
            lock (this.eSightSessions)
            {
                // 锁定向量,防止并发
                this.eSightSessions[iEsSession.ESight.HostIP.ToUpper()] = iEsSession; // 存储到缓存。
            }

            HWLogger.UI.Info("SaveSession eSight" + eSight.HostIP);
            return(iEsSession);
        }
        /// <summary>
        /// 测试eSight是否能够连通。
        /// </summary>
        /// <param name="eSight">The e sight.</param>
        /// <returns>失败返回错误码,成功返回为空字符</returns>
        public string TestEsSession(HWESightHost eSight)
        {
            try
            {
                using (var eSSession = new ESightSession(eSight))
                {
                    eSSession.TestConnection();
                }
            }
            catch (ESSessionExpceion ess)
            {
                HWLogger.UI.Error(ess);
                if (ess.Code == "1")
                {
                    return(ConstMgr.ErrorCode.SYS_USER_LOGING);
                }
                return(ess.Code);
            }
            catch (Exception se)
            {
                HWLogger.UI.Error(se);
                return(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR);
            }

            return(string.Empty);
        }
        /// <summary>
        /// 初始化所有的eSight连接的配置信息。
        /// 注意,并没有open。
        /// </summary>
        public void InitEsSessions()
        {
            var hostList = ESightDal.Instance.GetList(); // 获取eSight

            foreach (var hwESightHost in hostList)
            {
                lock (this.eSightSessions)
                {
                    this.eSightSessions.Clear();
                    ESightSession iEsSession = new ESightSession(hwESightHost);
                    this.eSightSessions[hwESightHost.HostIP.ToUpper()] = iEsSession;
                }
            }
        }