public void Test_GetOuterTextFromHtml() { string content = "<table>" + "<tr> <td class=\"left-col\">License Status:</td> <td class=\"right-col\"><span class=\'status-active\'>Active (Expires: Jul 4, 2010)</span></td> </tr>" + "<tr> <td class=\"left-col\">Account Level:</td> <td class=\"right-col\">Wrath of the Lich King</td> </tr> " + "<tr><td class=\"left-col\">WoW Remote:</td><td class=\"right-col\"><span class='status-unsubscribed'>Unsubscribed</span></td> </tr></table>"; int index = 0; string subContent = this.GetOuterTextFromHtml("<tr>", "</tr>", 2, out index, content); Trace.Assert(subContent == "<tr> <td class=\"left-col\">Account Level:</td> <td class=\"right-col\">Wrath of the Lich King</td> </tr>", "Get bad sub content"); string innerText = GetInnerTextFromHtml(subContent); Trace.Assert(innerText == "Account Level:\tWrath of the Lich King\t", "Get bad inner content"); CommentAttributeGetter.GetAttribute <GameServerType>(GameServerType.EUBattle); }
private void btnTestRouter_Click(object sender, EventArgs e) { RouterManager routerMgr = new RouterManager(this.LogManager); DetectionParamsItem paramsItem = new DetectionParamsItem(); RouterItem router = this.GetRouterItem(); if (null != router) { paramsItem.ReconnectType = ReconnectType.Router; paramsItem.Router = router; this.OnTestChanged(true); LogManager.InfoWithCallback(string.Format("-> 正在开始对:{0} 进行网络重连测试,请稍等......", CommentAttributeGetter.GetAttribute <RouterType>(router.RouterType))); Thread t = new Thread(new ThreadStart(delegate() { bool isConnected = routerMgr.Reconnect(paramsItem); if (isConnected) { LogManager.InfoWithCallback(string.Format("-> 对:{0} 网络重连测试成功,网络恢复正常", CommentAttributeGetter.GetAttribute <RouterType>(router.RouterType))); } else { LogManager.InfoWithCallback(string.Format("-> 对:{0} 网络重连测试失败,请确保路由器可以正常访问!", CommentAttributeGetter.GetAttribute <RouterType>(router.RouterType))); } this.OnTestChanged(false); })); t.Start(); } }
public string GetAccountState() { string str = "正常"; if (string.IsNullOrEmpty(this.Detail)) { if (TextHelper.IsContains(this.Edition, "Trial", "體驗帳號", "試玩", "已到期", "測試伺服器", "public test realm")) { str = string.Format(" {0}", CommentAttributeGetter.GetAttribute <WowLoginStates>(WowLoginStates.Trial)); } else if (TextHelper.IsContains(this.Edition, "Locked", "Banned", "Cerrada", "Account Banned", "暂时卦号")) { str = string.Format(" {0}", CommentAttributeGetter.GetAttribute <WowLoginStates>(WowLoginStates.TempDisabled)); } else if (TextHelper.IsContains(this.Edition, "EINGEFROREN", "FROZEN", "已凍結")) { str = string.Format(" {0}", CommentAttributeGetter.GetAttribute <WowLoginStates>(WowLoginStates.Frozen)); } else if (TextHelper.IsContains(this.Edition, "Active", "已取消", "啟動")) { str = string.Format(" {0}", CommentAttributeGetter.GetAttribute <WowLoginStates>(WowLoginStates.Active)); } if (TextHelper.IsContains(this.Region, "Americas", "Oceania (US)", "(US)", "美國")) { str += "(US)"; } else if (TextHelper.IsContains(this.Region, "Europe (EU)", "Europe", "(EU)")) { str += "(EU)"; } else if (TextHelper.IsContains(this.Region, "Россия и СНГ (RU)", "(RU)")) { str += "(RU)"; } return(str); } if (TextHelper.IsContains(this.Detail, "( Trial )", "(體驗帳號)", "(試玩)", "(已到期)", "測試伺服器", "public test realm", "新手入門版")) { str = string.Format(" {0}", CommentAttributeGetter.GetAttribute <WowLoginStates>(WowLoginStates.Trial)); } else if (TextHelper.IsContains(this.Detail, "Locked", "Banned", "Cerrada", "Account Banned", "暂时卦号")) { str = string.Format(" {0}", CommentAttributeGetter.GetAttribute <WowLoginStates>(WowLoginStates.TempDisabled)); } else if (TextHelper.IsContains(this.Detail, "EINGEFROREN", "FROZEN", "已凍結")) { str = string.Format(" {0}", CommentAttributeGetter.GetAttribute <WowLoginStates>(WowLoginStates.Frozen)); } else if (TextHelper.IsContains(this.Detail, "Active", "已取消", "啟動")) { str = string.Format(" {0}", CommentAttributeGetter.GetAttribute <WowLoginStates>(WowLoginStates.Active)); } else if (TextHelper.IsContains(this.Detail, "立即購買《暗黑破壞神")) { str = string.Format(" {0}", CommentAttributeGetter.GetAttribute <WowLoginStates>(WowLoginStates.InvalidAccount)); } if (TextHelper.IsContains(this.Detail, "Americas", "Oceania (US)", "(US)", "美國")) { str += "(US)"; } else if (TextHelper.IsContains(this.Detail, "Europe (EU)", "Europe", "(EU)")) { str += "(EU)"; } else if (TextHelper.IsContains(this.Detail, "Россия и СНГ (RU)", "(RU)")) { str += "(RU)"; } return(str); }
public bool Reconnect(DetectionParamsItem detectionItem) { if (null == detectionItem) { LogManager.Error("重连参数不能为空!"); return(false); } try { if (detectionItem.IsSupportedReconnect) { IReconnectManager reconMgr = GetManager(detectionItem.ReconnectType); //LogManager.InfoWithCallback(string.Format("-> 开始重连,连接方式:{0}", CommentAttributeGetter.GetAttribute<ReconnectType>(detectionItem.ReconnectType))); bool isConnected = false; ManualResetEvent reconnectManualReset = new ManualResetEvent(false); Thread t = new Thread(new ThreadStart(delegate() { isConnected = reconMgr.Reconnect(detectionItem); reconnectManualReset.Set(); })); t.Start(); LogManager.InfoWithCallback(string.Format("-> 开始重连,连接方式:{0},请等待", CommentAttributeGetter.GetAttribute <ReconnectType>(detectionItem.ReconnectType))); reconnectManualReset.WaitOne(); reconnectManualReset.Reset(); return(isConnected); } } catch (Exception ex) { LogManager.Error(string.Format("ReconnectManager.Reconnect() error:{0}", ex.Message)); } LogManager.InfoWithCallback("-> 当前网络重连不能正常运行,是否选择网络重连或者参数是否异常,请仔细检查!"); return(false); }