Exemplo n.º 1
0
        private void UcNetSwitch_Load(object sender, EventArgs e)
        {
            ADSLItem adsl = new ADSLItem();

            //adsl.EntryName = RiftSetConfig.Instance.ADSLName;
            //adsl.Password = RiftSetConfig.Instance.ADSLPwd;
            //adsl.User = RiftSetConfig.Instance.ADSLUser;
            ucAdsl              = new UcAdsl(adsl, CoreGUIManager.Instance);
            ucAdsl.TestChanged += TestChanged;

            RouterItem router = new RouterItem();

            //router.RouterType = RiftSetConfig.Instance.RouterType;
            //router.IP = RiftSetConfig.Instance.RouterIP;
            //router.Password = RiftSetConfig.Instance.RouterPwd;
            //router.User = RiftSetConfig.Instance.RouterUser;
            ucRouter              = new UcRouter(router, CoreGUIManager.Instance);
            ucRouter.TestChanged += TestChanged;

            VPNFile vpn = new VPNFile();

            //vpn.EntryName = RiftSetConfig.Instance.VpnEntryName;
            //vpn.File = RiftSetConfig.Instance.VpnFile;
            ucVpnList              = new UcVpnList(vpn, CoreGUIManager.Instance);
            ucVpnList.TestChanged += TestChanged;
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 3
0
        public RouterItem GetRouterItem()
        {
            #region  Router

            RouterItem    routerItem = new RouterItem();
            StringBuilder sb         = new StringBuilder();
            int           i          = 1;

            RouterType routerType = (RouterType)this.comboRouter.SelectedValue;
            routerItem.RouterType = routerType;

            string routerIp = this.txtRounterIp.Text.Trim();
            if (!string.IsNullOrEmpty(routerIp) && TextHelper.IsIP(routerIp))
            {
                routerItem.IP = routerIp;
            }
            else
            {
                sb.AppendLine(string.Format("{0}、您录入的不是有效的路由器IP地址!", i++));
            }

            string routerUser = this.txtRouterUser.Text.Trim();
            if (!string.IsNullOrEmpty(routerUser))
            {
                routerItem.User = routerUser;
            }
            else
            {
                sb.AppendLine(string.Format("{0}、请录入正确的路由器登录用户名!", i++));
            }

            string routerPwd = this.txtRouterPwd.Text.Trim();
            if (!string.IsNullOrEmpty(routerPwd))
            {
                routerItem.Password = routerPwd;
            }
            else
            {
                sb.AppendLine(string.Format("{0}、请录入正确的路由器登录密码!", i++));
            }

            if (sb.Length > 0)
            {
                MessageBox.Show(sb.ToString());
                return(null);
            }

            return(routerItem);

            #endregion
        }
Exemplo n.º 4
0
        /// <summary>
        /// Is restart rounter ok
        /// </summary>
        /// <param name="ip"></param>
        /// <returns></returns>
        public override bool Reconnect(RouterItem routerItem)
        {
            if (null == routerItem)
            {
                LogManager.Error("Router params can't be null!");
                return(false);
            }

            this.RouterItem = routerItem;
            if (this.IsServerExisted(this.RouterItem.IP))
            {
                LogManager.InfoWithCallback("-> 开始重启 TL-R402系列 SOHO宽带路由器!");
                string content = string.Empty;
                string url     = "http://{0}/userRpm/SysRebootRpm.htm?Reboot=%D6%D8%C6%F4%C2%B7%D3%C9%C6%F7 ";
                content = this.ReadFromUrl(string.Format(url, this.RouterItem.IP));
                bool isRestarted = this.IsContains(content, "LoadMain()");
                return(isRestarted);
            }

            return(false);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
0
 public UcRouter(RouterItem router, LogManagerBase logManager)
 {
     InitializeComponent();
     this.Load      += UcRouter_Load;
     this.LogManager = logManager;
 }
Exemplo n.º 7
0
 public abstract bool Reconnect(RouterItem routerItem);