/// <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> /// 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); }