public void HCPostTest() { _esSession.Open(); JObject result = _esSession.HCPut(ConstMgr.HWESightHost.URL_LOGIN, GetLoginParam()); Console.WriteLine(result); Assert.AreEqual(CoreUtil.GetObjTranNull <int>(result.Property("code")), 0); }
public void QueryForDeviceDetailTest() { _esSession.Open(); QueryListResult <HWDeviceDetail> hwDetails = _esSession.DviWorker.QueryForDeviceDetail("test"); Assert.IsNotNull(hwDetails); }
/// <summary> /// 测试eSight是否能够连通。 /// </summary> /// <param name="hostIP">主机IP</param> /// <param name="port">端口</param> /// <param name="userAccount">用户账户</param> /// <param name="passowrd">密码</param> /// <param name="timeoutSec">超时时间默认为:ConstMgr.HWESightHost.DEFAULT_TIMEOUT_SEC</param> /// <returns>失败返回错误码,成功返回为空字符</returns> public string TestESSession(string hostIP, int port, string userAccount, string passowrd, int timeoutSec = ConstMgr.HWESightHost.DEFAULT_TIMEOUT_SEC) { try { using (ESSession eSSession = new ESSession()) { eSSession.SetHttpMode(_isHttps); eSSession.InitESight(hostIP, port, userAccount, passowrd, timeoutSec); eSSession.Open(); } } catch (ESSessionExpceion ess) { LogUtil.HWLogger.API.Error(ess); if (ess.Code == "1") { return(ConstMgr.ErrorCode.SYS_USER_LOGING); } else { return(ess.Code); } } catch (Exception se) { LogUtil.HWLogger.API.Error(se); return(ConstMgr.ErrorCode.SYS_UNKNOWN_ERR); } return(""); }
/// <summary> /// 返回IESSession /// </summary> /// <param name="hostIP">eSight IP</param> /// <param name="aliasName">别名</param> /// <param name="port">eSight 端口</param> /// <param name="userAccount">对应的账号</param> /// <param name="passowrd">对应的密码</param> /// <param name="timeoutSec">连接超时时间,默认:ConstMgr.HWESightHost.DEFAULT_TIMEOUT_SEC</param> /// <returns></returns> public IESSession SaveNewESSession(string hostIP, string aliasName, int port, string userAccount, string passowrd, int timeoutSec = ConstMgr.HWESightHost.DEFAULT_TIMEOUT_SEC) { //测试连接... using (ESSession eSSession = new ESSession()) { eSSession.SetHttpMode(_isHttps); eSSession.InitESight(hostIP, port, userAccount, passowrd, timeoutSec); eSSession.Open(); } IESSession iESSession = null; iESSession = FindESSession(hostIP); //查找已有的eSesssion,防止重复 if (iESSession == null) //没有找到已有的eSight. { iESSession = new ESSession(); iESSession.SetHttpMode(_isHttps); //设置默认协议为全局。 } iESSession.InitESight(hostIP, port, userAccount, passowrd, timeoutSec); //初始化eSight. iESSession.HWESightHost.AliasName = aliasName; //初始化eSight别名. iESSession.Open(); //尝试打开连接,可能会抛出异常。 iESSession.SaveToDB(); //保存到数据库 lock (eSightSessions) //锁定向量,防止并发 { eSightSessions[iESSession.HWESightHost.HostIP.ToUpper()] = iESSession; //存储到缓存。 } return(iESSession); }
public void DisposeESightTest() { ESSession esSession = new ESSession(); HWESightHost 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); esSession.Open(); bool isSccu = esSession.SaveToDB(); Assert.IsTrue(isSccu); esSession.HClient = null; //esSession.HWESightHost.HostIP = "xxx.xxx.xxx"; esSession.Dispose(); }
public void UploadBasePackageTest() { _esSession.Open(); BasePackage basePackage = new BasePackage(); basePackage.BasepackageName = "basepackage1"; basePackage.BasepackageDescription = "This is a basepackage."; basePackage.BasepackageType = ConstMgr.HWBasePackage.PACKAGE_TYPE_FIRMWARE; basePackage.FileList = "iBMC.zip,iBMC.zip.asc"; basePackage.SftpserverIP = "188.10.18.188"; basePackage.SftpUserName = "******"; basePackage.SftpPassword = "******"; string taskName = _esSession.BasePackageWorker.UploadBasePackage(basePackage); Console.WriteLine(taskName); Assert.IsTrue(!string.IsNullOrEmpty(taskName)); }
public void UploadSoftwareSourceTest() { _esSession.Open(); SoftwareSource softwareSource = new SoftwareSource(); softwareSource.SoftwareName = "OS_Software1"; softwareSource.SoftwareDescription = "“This is a OS template."; softwareSource.SoftwareType = "Windows"; softwareSource.SoftwareVersion = "Windows Server 2008 R2 x64"; softwareSource.SoftwareLanguage = "Chinese"; softwareSource.SourceName = "7601.17514.101119 - 1850_x64fre_server_eval_en - us - GRMSXEVAL_EN_DVD.iso"; softwareSource.SftpserverIP = "188.10.18.188"; softwareSource.SftpUserName = "******"; softwareSource.SftpPassword = "******"; string taskName = _esSession.SoftSourceWorker.UploadSoftwareSource(softwareSource); Console.WriteLine(taskName); Assert.IsTrue(!string.IsNullOrEmpty(taskName)); }