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); }
private void Reconnect(ADSLItem adslItem) { if ((null == adslItem) || string.IsNullOrEmpty(adslItem.EntryName) || string.IsNullOrEmpty(adslItem.User) || string.IsNullOrEmpty(adslItem.Password)) { LogManager.Error("PPPOE 拨号参数不能为空"); return; } IList <string> cmdList = new List <string>(); // string disconnectCmd = string.Format(" rasdial.exe \"{0}\" /DISCONNECT ", adslItem.EntryName); string disconnectCmd = string.Format(" rasdial.exe {0} /DISCONNECT ", adslItem.EntryName); cmdList.Add(disconnectCmd); LogManager.Info(disconnectCmd); LogManager.InfoWithCallback(string.Format("-> 断开ASDL: {0}", adslItem.EntryName)); //string conCmd = string.Format(" rasdial.exe \"{0}\" {1} {2} ", adslItem.EntryName, adslItem.User, adslItem.Password); string conCmd = string.Format(" rasdial.exe {0} {1} {2} ", adslItem.EntryName, adslItem.User, adslItem.Password); cmdList.Add(conCmd); LogManager.Info(conCmd); LogManager.InfoWithCallback(string.Format("-> 重连ASDL:{0}", adslItem.EntryName)); CmdHelper.RunCmd(cmdList, this.LogManager); }
public virtual T GetNextItem() { try { Interlocked.Increment(ref ipAccessCount); if (IsIPLimit) { //ipAccessCount = -1; LogManager.InfoWithCallback(string.Format("当前每IP只允许访问 {0} 个帐号,准备重新连接网络!", IPLimitCount)); return(null); } lock (this.readLockObject) { // if process by custom range ,check it ,if out of range then stop process if ((this.HttperParamsItem.IsSupportedCustomRange)) { if (this.CurrentIndex < this.HttperParamsItem.RangeLower) { this.CurrentIndex = this.HttperParamsItem.RangeLower; if (this.CurrentIndex < 0) { this.CurrentIndex = 0; } } if (this.CurrentIndex > this.HttperParamsItem.RangeUpper) { return(null); } } if (this.CurrentIndex == 0) { queriedCount = 0; } if ((this.accountList.Count > 0) && (this.CurrentIndex >= 0) && (this.CurrentIndex < this.accountList.Count)) { T item = this.accountList[this.CurrentIndex++]; while ((null != item) && queriedIndexList.Contains(item.Index)) { if (this.CurrentIndex < this.accountList.Count) { if (queriedCount++ == 0) { sb.Append(string.Format("Below accounts has been queried:\n")); } sb.Append(string.Format("{0}->:{1}; ", item.Index, item.EMail)); if (queriedCount % 100 == 0) { LogManager.Info(sb.ToString()); sb = new StringBuilder(); queriedCount = 0; } item = this.accountList[this.CurrentIndex++]; } else { return(null); } } return(item); } return(null); } } catch (System.Exception ex) { LogManager.Error(string.Format("HttperManager.GetNextItem() failed:{0}", ex.Message)); } return(null); }