示例#1
0
        public static void hungup()
        {
            DialClass dialClass = new DialClass();
            log       _log      = new log();

            _log.write("正在挂断......");
            Form1.richtextbox.AppendText(">>正在挂断......\r\n");
            dialClass.Hangup();
            _log.write("挂断成功......");
            Form1.richtextbox.AppendText(">>挂断成功......\r\n");
            Form1.label_stat.Text = "状态:断线";
        }
示例#2
0
        private void Form1_Closing(object sender, CancelEventArgs e)
        {
            this.NotifyIcon.Visible = false;
            log _log = new log();

            _log.write("---------------------程序关闭----------------------");
        }
示例#3
0
        private bool IsOnline()
        {
            char[] chrArray = new char[2];
            chrArray[0] = ',';
            chrArray[1] = ';';
            string[] strArrays = this._ip.Split(chrArray);
            log      _log      = new log();

            for (int i = 0; i < 5; i++)
            {
                string[] strArrays1 = strArrays;
                int      num        = 0;
                while (num < (int)strArrays1.Length)
                {
                    string str  = strArrays1[num];
                    bool   flag = false;
                    try
                    {
                        _log.write(string.Format("Ping:<{0}>,Timeout:<{1}>", str.Trim(), this._timeout + i * 0x3e8));
                        flag = this.network.Ping(str.Trim(), this._timeout + i * 0x3e8);
                    }
                    catch (Exception exception1)
                    {
                        Exception exception = exception1;
                        _log.write(string.Format("Ping ERROR:{0}", exception.Message));
                        flag = false;
                    }
                    if (!flag)
                    {
                        _log.write(string.Format("Ping Fail! retry times:{0}", i.ToString()));
                        num++;
                    }
                    else
                    {
                        _log.write("Ping Success");
                        bool flag1 = true;
                        return(flag1);
                    }
                }
            }
            _log.write(string.Format("Retry 4 times,Ping:<{0}>,all is fail", this._ip));
            return(false);
        }
示例#4
0
        public string Dial(string name)
        {
            string str;

            byte[] bytes;
            byte[] numArray;
            this.Hangup();
            byte[] bytes1    = Encoding.Default.GetBytes(name);
            byte[] numArray1 = new byte[0x101];
            if (name != "SaroCDMA")
            {
                if (name != "SaroGPRS")
                {
                    XML xML = XML.LoadFromXML();
                    bytes    = Encoding.Default.GetBytes(xML.username);
                    numArray = Encoding.Default.GetBytes(xML.password);
                }
                else
                {
                    bytes    = Encoding.Default.GetBytes("");
                    numArray = Encoding.Default.GetBytes("");
                }
            }
            else
            {
                bytes    = Encoding.Default.GetBytes("CARD");
                numArray = Encoding.Default.GetBytes("CARD");
            }
            int num = DialClass.DDial(bytes1, bytes, numArray, numArray1);

            if (num == 0)
            {
                str = "TRUE";
                log _log = new log();
                _log.write(string.Format("拨号成功,拨号名:{0}", name));
                XML xML1 = XML.LoadFromXML();
                xML1.ConnectName = name;
                xML1.SaveAsXML();
            }
            else
            {
                str = Encoding.Default.GetString(numArray1);
                if (str.IndexOf("\0") != -1)
                {
                    str = str.Substring(0, str.IndexOf("\0"));
                }
                str = string.Format("{0}错误,{1}", num.ToString(), str);
                log _log1 = new log();
                _log1.write(string.Format("拨号失败,拨号名:{0},错误信息:{1}", name, str));
            }
            return(str);
        }
示例#5
0
        public void Start()
        {
            string str = string.Concat(Environment.CurrentDirectory, "\\settings.xml");

            if (File.Exists(str))
            {
                XML xML = XML.LoadFromXML();
                this._maxcount = xML.times;
                char[] chrArray = new char[1];
                chrArray[0]     = ' ';
                this._ip        = xML.IP.Trim(chrArray);
                this._timeout   = xML.timeout;
                this._interval  = xML.interval;
                this._interval2 = xML.wait;
                this.on         = xML.on;
                if (!this.on || this._isrun)
                {
                    return;
                }
                else
                {
                    this._isrun = true;
                    while (true)
                    {
                        Thread.Sleep(this._interval * 0x3e8);
                        try
                        {
                            if (!this.IsOnline())
                            {
                                Form1.SetText(1, ">>已断线....正准备重拨\r\n");
                                log _log = new log();
                                _log.write("已断线....正准备重拨");
                                Form1.SetText(5, "状态:断线");
                                while (!this.Dial() && !this.IsOnline())
                                {
                                    Thread.Sleep(0xbb8);
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("找不到参数设置文件,请确认当前目录存在settings.xml文件");
                return;
            }
        }
示例#6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            log _log = new log();

            _log.write("---------------------程序启动----------------------");
            this.NotifyIcon               = new NotifyIconEx();
            this.NotifyIcon.Text          = "无线精灵2016";
            this.NotifyIcon.Icon          = base.Icon;
            this.NotifyIcon.Visible       = false;
            this.NotifyIcon.ContextMenu   = this.contextMenu1;
            this.NotifyIcon.Click        += new EventHandler(this.OnClickIcon);
            this.NotifyIcon.DoubleClick  += new EventHandler(this.notifyIcon1_DoubleClick);
            this.NotifyIcon.BalloonClick += new EventHandler(this.OnClickBalloon);
            BackgroundWorker backgroundWorker = new BackgroundWorker();

            backgroundWorker.DoWork += new DoWorkEventHandler(this.BW_DoWork);
            backgroundWorker.RunWorkerAsync();
        }