Beispiel #1
0
        /// <summary>
        /// 自动重拨,无需密码
        /// </summary>
        public static void ReConn2()
        {
            var    lines   = File.ReadAllLines("config//adslconfig.txt");
            string name    = lines[0];
            string pwd     = lines[1];
            int    seconds = Convert.ToInt32(lines[2]); //6
            int    time    = Convert.ToInt32(lines[3]); //5

            cRASDisplay cRas = new cRASDisplay();

            LogManager.WriteLog("当前连接状态" + cRas.IsConnected);
            bool ipisok = false;

            if (cRas.IsConnected)
            {
                cRas.Disconnect();
                LogManager.WriteLog("Disconnect");
            }
            do
            {
                AdslConn(cRas, seconds, time);
                string key = RasApi.GetIP("宽带连接");
                LogManager.WriteLog("ip =" + key);
                ipisok = checkIpisOKBylocal(key);
            } while (!ipisok);

            LogManager.WriteLog(cRas.Duration);
        }
Beispiel #2
0
        private static void KeepAlive()
        {
            new Thread(
                () => {
                bool isDisConn = false;
                int count      = 0;
                Common.ADSL1.cRASDisplay cRas = new cRASDisplay();
                while (true)
                {
                    Thread.Sleep(1000 * 10);

                    if (cRas.IsConnected)
                    {
                        count = 0;
                    }
                    else
                    {
                        count++;
                        if (count > 6)
                        {
                            AdslHelper.ReConn();
                            Process.Start("restart.bat");
                        }
                    }
                }
            }).Start();
        }
Beispiel #3
0
        private static bool AdslConn(cRASDisplay cRas, int seconds, int time)
        {
            bool isok = false;
            int  res1 = -1;

            for (int i = 0; i < time; i++)
            {
                Thread.Sleep(seconds * 1000);
                if (isok)
                {
                    LogManager.WriteLog("Connected");
                    break;
                }

                res1 = cRas.Connect("宽带连接");
                isok = (res1 == 0);
                LogManager.WriteLog("宽带连接重试 第" + (time - i) + " 次 上次拨号返回 " + res1);
            }
            return(isok);
        }
Beispiel #4
0
        private static bool AdslConn(cRASDisplay cRas, int seconds, int time)
        {
            bool isok = false;

            for (int i = 0; i < time; i++)
            {
                Thread.Sleep(seconds * 1000);
                if (cRas.IsConnected)
                {
                    isok = true;
                    break;
                }
                else
                {
                    isok = false;
                    cRas.Connect("宽带连接");
                    //   LogManager.WriteLog("宽带连接" + (6 - i) + " 重试 倒计次数");
                }
            }
            return(isok);
        }
Beispiel #5
0
        public static void ReConn()
        {
            var    lines   = File.ReadAllLines("config//adslconfig.txt");
            string name    = lines[0];
            string pwd     = lines[1];
            int    seconds = Convert.ToInt32(lines[2]); //6
            int    time    = Convert.ToInt32(lines[3]); //5


            Common.ADSL1.cRASDisplay cRas = new cRASDisplay();
            //   LogManager.WriteLog("当前连接状态" + cRas.IsConnected);
            if (cRas.IsConnected)
            {
                cRas.Disconnect();
                //      LogManager.WriteLog("Disconnect");
                Thread.Sleep(5000);
                cRas.Connect("宽带连接");
                AdslConn(cRas, seconds, time);
            }
            else
            {
                AdslConn(cRas, seconds, time);
            }
        }