示例#1
0
        /// <summary>
        /// 查找eSight主机信息,并且打开.
        /// </summary>
        /// <param name="hostIP">主机IP</param>
        /// <returns>返回查找到的eSight,没有找到返回为null</returns>
        public IESSession FindAndOpenESSession(string hostIP)
        {
            try
            {
                IESSession iESSession = FindESSession(hostIP);
                //Find eSightHost...
                HWESightHost hwESightHost = HWESightHostDal.Instance.FindByIP(hostIP);

                if (iESSession != null)
                {
                    if (IsSameESightHost(hwESightHost, iESSession.HWESightHost))
                    {
                        iESSession.Open();
                    }
                    else
                    {
                        iESSession.InitESight(hwESightHost, ConstMgr.HWESightHost.DEFAULT_TIMEOUT_SEC);
                        iESSession.Open();
                    }
                }
                return(iESSession);
            }
            catch (Exception se)
            {
                LogUtil.HWLogger.API.Error(se);
                throw;
            }
        }
 public static void ClassInitialize(TestContext context)
 {
     _hwESightHost              = new HWESightHost();
     _hwESightHost.HostIP       = "127.0.0.1";
     _hwESightHost.HostPort     = 32102;
     _hwESightHost.LoginAccount = "test";
     _hwESightHost.LoginPwd     = "test";
     _esSession = new ESSession();
     _esSession.SetHttpMode(true);
     _esSession.InitESight(_hwESightHost, ConstMgr.HWESightHost.DEFAULT_TIMEOUT_SEC);
 }
示例#3
0
        /// <summary>
        /// 查询已有的连接列表
        /// </summary>
        /// <returns>返回已有的连接列表</returns>
        public IList <IESSession> ListESSessions()
        {
            lock (eSightSessions)
            {
                IList <IESSession>   retList  = new List <IESSession>();
                IList <HWESightHost> hostList = ListESHost();
                Dictionary <string, HWESightHost> tmpSessions = new Dictionary <string, HWESightHost>();
                foreach (HWESightHost hwESightHost in hostList)
                {
                    tmpSessions[hwESightHost.HostIP.ToUpper()] = hwESightHost;
                    if (eSightSessions.ContainsKey(hwESightHost.HostIP.ToUpper()))//Already exists...
                    {
                        IESSession iESession = eSightSessions[hwESightHost.HostIP.ToUpper()];
                        if (IsSameESightHost(hwESightHost, iESession.HWESightHost))
                        {
                            retList.Add(eSightSessions[hwESightHost.HostIP.ToUpper()]);
                        }
                        else//If not same reinit. 将list增加给retlist
                        {
                            iESession.InitESight(hwESightHost, ConstMgr.HWESightHost.DEFAULT_TIMEOUT_SEC);
                            retList.Add(iESession);
                        }
                    }
                    else
                    {//Create new...
                        IESSession iESSession = new ESSession();
                        iESSession.SetHttpMode(_isHttps);
                        iESSession.InitESight(hwESightHost, ConstMgr.HWESightHost.DEFAULT_TIMEOUT_SEC);
                        eSightSessions[hwESightHost.HostIP.ToUpper()] = iESSession;

                        retList.Add(iESSession);
                    }
                }
                //Clean unused sessions.
                IList <IESSession> existsList = new List <IESSession>(eSightSessions.Values);
                foreach (IESSession ieSSession in existsList)
                {
                    if (!tmpSessions.ContainsKey(ieSSession.HWESightHost.HostIP.ToUpper()))
                    {
                        eSightSessions.Remove(ieSSession.HWESightHost.HostIP.ToUpper());
                    }
                }
                return(retList);
            }
        }