Exemple #1
0
        public bool Reconnect(DetectionParamsItem detectionItem)
        {
            if ((null == detectionItem) || (null == detectionItem.VpnList))
            {
                LogManager.Error("VPN parameters can't be empty");
                return(false);
            }

            bool isConnected = false;
            int  i           = 0;

            do
            {
                this.GetVpnItem(detectionItem);
                if (null == this.CurrentVpnItem)
                {
                    LogManager.Error("VPN服务器参数获取出错!");
                    return(false);
                }
                LogManager.InfoWithCallback(string.Format("-> 正在开始对VPN: 名称={0},IP={1} 进行网络重连测试,请稍等......", CurrentVpnItem.EntryName, CurrentVpnItem.IP));

                isConnected = Reconnect(this.CurrentVpnItem);
                if (isConnected)
                {
                    LogManager.InfoWithCallback(string.Format("-> 对VPN: 名称={0},IP={1} 网络重连成功,网络恢复正常", CurrentVpnItem.EntryName, CurrentVpnItem.IP));
                }
                else
                {
                    LogManager.InfoWithCallback(string.Format("-> 对VPN: 名称={0},IP={1} 网络重连失败,请检查IP,用户名或者密码是否正确!", CurrentVpnItem.EntryName, CurrentVpnItem.IP));
                }
            } while ((i++ < 10) && !isConnected);
            return(isConnected);
        }
Exemple #2
0
        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();
            }
        }
Exemple #3
0
        public void Dial()
        {
            ADSLManager         adslMgr    = new ADSLManager(this.LogManager);
            DetectionParamsItem paramsItem = new DetectionParamsItem();
            ADSLItem            adsl       = this.GetADSLItem();

            if (null != adsl)
            {
                paramsItem.ReconnectType = ReconnectType.ADSL;
                paramsItem.ADSL          = adsl;
                this.OnTestChanged(true);
                Thread t = new Thread(new ThreadStart(delegate()
                {
                    LogManager.InfoWithCallback(string.Format("-> 正在开始对PPPOE: 名称='{0}' 进行网络重连测试,请稍等......", adsl.EntryName));
                    bool isConnected = adslMgr.Reconnect(paramsItem);
                    if (isConnected)
                    {
                        LogManager.InfoWithCallback(string.Format("-> 对PPPOE: 名称='{0}' 网络重连成功,网络恢复正常", adsl.EntryName));
                    }
                    else
                    {
                        LogManager.InfoWithCallback(string.Format("-> 对PPPOE: 名称='{0}' 网络重连失败,请检查名称,用户名或者密码是否正确!", adsl.EntryName));
                    }
                    this.OnTestChanged(false);
                }));
                t.Start();
            }
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        public void Test()
        {
            IList <VPNItem> vpnList = this.GetVpnList();

            if ((null != vpnList) && (vpnList.Count > 0))
            {
                VPNManager          vpnMgr     = new VPNManager(this.LogManager);
                DetectionParamsItem paramsItem = new DetectionParamsItem();
                //VPNItem vpnItem = vpnList[0];
                paramsItem.ReconnectType = ReconnectType.VPN;
                paramsItem.VpnList       = vpnList;
                //paramsItem.VpnList.Add(vpnItem);
                this.OnTestChanged(true);

                Thread t = new Thread(new ThreadStart(delegate()
                {
                    //LogManager.InfoWithCallback(string.Format("-> 正在开始对VPN: 名称={0},IP={1} 进行网络重连测试,请稍等......", vpnItem.EntryName, vpnItem.IP));

                    bool isConnected = vpnMgr.Reconnect(paramsItem);

                    //if (isConnected)
                    //{
                    //    LogManager.InfoWithCallback(string.Format("-> 对VPN: 名称={0},IP={1} 网络重连成功,网络恢复正常", vpnItem.EntryName, vpnItem.IP));
                    //}
                    //else
                    //{
                    //    LogManager.InfoWithCallback(string.Format("-> 对VPN: 名称={0},IP={1} 网络重连失败,请检查IP,用户名或者密码是否正确!", vpnItem.EntryName, vpnItem.IP));
                    //}
                    this.OnTestChanged(false);
                }));

                t.Start();
            }
        }
Exemple #6
0
        public void Output(UserAccountItem userItem, DetectionParamsItem paramsItem)
        {
            if ((null == userItem) || (null == paramsItem))
            {
                LogManager.ErrorWithCallback("FileExportManager.Output error, parameters has null");
                return;
            }

            this.CreateFileExporter(paramsItem);
            this.fileExporter.Output(userItem);
        }
Exemple #7
0
 public void OuputCharacter(string content, CharacterType charType, DetectionParamsItem paramsItem)
 {
     lock (this)
     {
         if (string.IsNullOrEmpty(content))
         {
             return;
         }
         this.CreateFileExporter(paramsItem);
         fileExporter.OutputChars(charType, content);
     }
 }
Exemple #8
0
 private void CreateFileExporter(DetectionParamsItem paramsItem)
 {
     lock (this)
     {
         //this.DisposeLastFileExporter();
         if (null == this.fileExporter)
         {
             this.fileExporter = new BattleExportBase(paramsItem.DataFilePath, paramsItem.IsAppended);
             this.LoadLastStopCount();
         }
     }
 }
        public static bool Reconnect(DetectionParamsItem detectionItem)
        {
            lock (lockObj)
            {
                try
                {
                    lastNetItem = detectionItem;
                    IsConnected = false;
                    IsConnected = ReconnectManager.Instance.Reconnect(detectionItem);
                }
                finally
                {
                    ClearAll();
                }

                return(IsConnected);
            }
        }
Exemple #10
0
        private void GetVpnItem(DetectionParamsItem detectionItem)
        {
            if ((null == detectionItem) || (null == detectionItem.VpnList))
            {
                return;
            }
            if (vpnList != detectionItem.VpnList)
            {
                this.vpnList = detectionItem.VpnList;
            }

            if ((null == this.CurrentVpnItem) && (this.vpnList.Count > 0))
            {
                this.CurrentVpnItem = this.vpnList[0];
                return;
            }

            if (null != this.CurrentVpnItem)
            {
                if (this.vpnList.Contains(this.CurrentVpnItem))
                {
                    int index = this.vpnList.IndexOf(this.CurrentVpnItem);
                    if (index < (this.vpnList.Count - 2))
                    {
                        this.CurrentVpnItem = this.vpnList[++index];
                        return;
                    }
                }

                //if ((this.vpnList.Count > 0))
                //{
                //    this.CurrentVpnItem = this.vpnList[0];
                //}
            }

            this.CurrentVpnItem = null;
        }
Exemple #11
0
        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);
            }
        }
Exemple #12
0
        /// <summary>
        /// Start all threads for get account info
        /// </summary>
        public virtual void Start(DetectionParamsItem detectionItem)
        {
            if (null == detectionItem)
            {
                return;
            }

            this.HttperParamsItem    = detectionItem;
            this.CurrentIndex        = 0;
            this.isSetAutoResetEvent = false;

            LogManager.InfoWithCallback(string.Format("-> 正在开始初始化对文件:{0} 在服务器:{1} 上的查询,请稍等.....\r\n",
                                                      detectionItem.DataFilePath, detectionItem.CurrentGameServer.Header));
            Application.DoEvents();
            Thread thread = new Thread(new ThreadStart(this.LoadFile));

            thread.Name = "Load data thread";
            thread.Start();
            this.WaitOneAutoResetEvent();

            this.SetProcessByCustomRange();
            this.ContinueFromLastStopped();
            this.StartProcess();
        }
Exemple #13
0
        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);
        }
Exemple #14
0
 public GameHttperBase(DetectionParamsItem paramsItem, LogManagerBase logManager)
     : base(logManager)
 {
     this.DetectionParamsItem = paramsItem;
 }