protected bool IsServerExisted(string ip) { if (string.IsNullOrEmpty(ip)) { LogManager.Error("Router ip can't be empty"); return(false); } bool isPinged = CmdHelper.Ping(ip); if (isPinged) { LogManager.Info(string.Format("Ping reply from router:{0}", ip)); } else { LogManager.Info(string.Format("Can't ping reply from router:{0}", ip)); } return(isPinged); }
public bool Reconnect(DetectionParamsItem detectionItem) { lock (lockObj) { if ((null == detectionItem) || (null == detectionItem.ADSL)) { LogManager.Error("ADSL parameters can't be empty"); return(false); } for (int i = 0; i < 3; i++) { using (AdslDialer dialer = new AdslDialer(detectionItem.ADSL, this.LogManager)) { if (dialer.Dial()) { break; } } Thread.Sleep(3 * 1000); } //this.Reconnect(detectionItem.ADSL); //ReconnectManager.Sleep(); Thread.Sleep(2 * 1000); int t = 0; while (t++ < ReconnectManager.TRYCOUNT) { if (CmdHelper.PingBaidu() || CmdHelper.Ping163()) { return(true); } Thread.Sleep(2 * 1000); } return(false); } }
public bool Reconnect(DetectionParamsItem detectionItem) { if ((null != detectionItem) && (detectionItem.ReconnectType == ReconnectType.Router)) { RouterItem routerItem = detectionItem.Router; LogManager.Info(string.Format("start restart router:{0}", routerItem.IP)); RouterBase router = this.GetRouter(routerItem.RouterType); router.Reconnect(routerItem); ReconnectManager.Sleep(); int i = 0; while (i++ < ReconnectManager.TRYCOUNT) { if (CmdHelper.PingBaidu() || CmdHelper.Ping163()) { return(true); } Thread.Sleep(2 * 1000); } return(false); } return(false); }