Example #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;
        }
Example #2
0
        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);
        }
Example #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();
            }
        }
Example #4
0
 public UcAdsl(ADSLItem adsl, LogManagerBase logManager)
 {
     InitializeComponent();
     this.Load      += UcAdsl_Load;
     this.adslItem   = adsl;
     this.LogManager = logManager;
 }
Example #5
0
        public AdslDialer(ADSLItem adslItem, LogManagerBase logManager)
        {
            this.LogManager = logManager;
            if (null == adslItem)
            {
                LogManager.Error("ADSL dialer parameters can't be null!");
            }

            this.ADSLItem = adslItem;
            this.Timeout  = 5 * 60 * 1000;

            this.rasDialer.StateChanged  += RasDialer_StateChanged;
            this.rasDialer.DialCompleted += RasDialer_DialCompleted;
        }
Example #6
0
        public ADSLItem GetADSLItem()
        {
            #region  Router

            ADSLItem      adslItem = new ADSLItem();
            StringBuilder sb       = new StringBuilder();
            int           i        = 1;

            string adslName = this.txtADSLName.Text.Trim();
            if (!string.IsNullOrEmpty(adslName))
            {
                adslItem.EntryName = adslName;
            }
            else
            {
                sb.AppendLine(string.Format("{0}、请录入正确的ADSL拨号连接名称!", i++));
            }

            string adslUser = this.txtADSLUser.Text.Trim();
            if (!string.IsNullOrEmpty(adslUser))
            {
                adslItem.User = adslUser;
            }
            else
            {
                sb.AppendLine(string.Format("{0}、请录入正确的ADSL拨号用户名!", i++));
            }

            string adslPwd = this.txtADSLPwd.Text.Trim();
            if (!string.IsNullOrEmpty(adslPwd))
            {
                adslItem.Password = adslPwd;
            }
            else
            {
                sb.AppendLine(string.Format("{0}、请录入正确的ADSL拨号密码!!", i++));
            }

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

            #endregion
        }