Exemplo n.º 1
0
 private void button_reconnect_Click(object sender, EventArgs e)
 {
     Disconnect();
     string     msg     = null;
     tagSetting setting = Appinfo.QuerySetting();
     bool       isok    = Connect(define.GetEnumName(setting.connectionType), setting.strUsername.ToString(), setting.strPwd.ToString(), ref msg);
 }
Exemplo n.º 2
0
        private void textBox_Username_Leave(object sender, EventArgs e)
        {
            tagSetting setting = Appinfo.QuerySetting();

            GetSetting(setting);
            Appinfo.UpdateSetting(setting);
        }
Exemplo n.º 3
0
        private void checkBox_work_CheckedChanged(object sender, EventArgs e)
        {
            tagSetting setting = Appinfo.QuerySetting();

            if (setting.strUsername.Trim().Equals("") || setting.strPwd.Trim().Equals(""))
            {
                MessageBox.Show("ADSL拨号未设置账号密码", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (!checkBox_work.Checked)
            {
                checkBox_work.Text = "开始挂机";
                AppUtils.CloseOtherApp("流量精灵助手监控器");
            }
            else
            {
                checkBox_work.Text = "停止挂机";
                if (AppUtils.OpenExternalApp("RankHelperService.exe") == 42)
                {
                }
                else if (AppUtils.OpenExternalApp("RankHelperService") == 42)
                {
                }
            }
            DoAsyncEvent();
            //IAsyncResult result = del.BeginInvoke(new AsyncCallback(CallBack), null);
        }
Exemplo n.º 4
0
        private void checkBox_AutoStart_CheckedChanged(object sender, EventArgs e)
        {
            AppUtils.AutoStart(checkBox_AutoStart.Checked);
            tagSetting setting = Appinfo.QuerySetting();

            GetSetting(setting);
            Appinfo.UpdateSetting(setting);
        }
Exemplo n.º 5
0
        void InitData()
        {
            tagSetting setting = Appinfo.QuerySetting();

            if (setting == null)
            {
                setting = new tagSetting();
            }
            SetSetting(setting);
        }
Exemplo n.º 6
0
        private void textBox_Count_Leave(object sender, EventArgs e)
        {
            TextBox textBox = (TextBox)sender;

            if (textBox.Text.Trim().Equals(""))
            {
                textBox.Text = "9999";
            }
            int nTime = int.Parse(textBox.Text);

            if (nTime < 1)
            {
                textBox.Text = "1";
            }
            else if (nTime > 9999)
            {
                textBox.Text = "9999";
            }

            tagSetting setting = Appinfo.QuerySetting();

            GetSetting(setting);
            Appinfo.UpdateSetting(setting);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 执行方法
        /// </summary>
        /// <returns></returns>
        private int DoAsyncEvent()
        {
            try
            {
                //foreach (var item in Appinfo.listTask)
                //{
                //    if (item.nID.Equals(nTaskID))
                //    {
                //        return item;
                //    }
                //}
                this.taskTimer.Stop();
                this.taskIntervalTimer.Stop();
                this.showTaskTimer.Stop();

                //停止挂机
                if (!checkBox_work.Checked)
                {
                    bWork        = false;
                    bExecuteTask = false;
                    StopTaskEvent(this, new AppEventArgs()
                    {
                    });
                    ShowTaskEvent(this, new AppEventArgs()
                    {
                        message_string = "未开始挂机"
                    });
                }
                else
                {
                    bWork        = true;
                    bExecuteTask = false;

                    //删除缓存、cookie文件
                    //FileUtils.DeleteFolder(System.Environment.CurrentDirectory+"\\"+ "BrowserCache");
                    //清除缓存
                    string cachePath = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
                    //获取缓存路径
                    //DirectoryInfo di = new DirectoryInfo(cachePath);
                    //foreach (FileInfo fi in di.GetFiles("*.*", SearchOption.AllDirectories))//遍历所有的文件夹 删除里面的文件
                    //{
                    //    try
                    //    {
                    //        fi.Delete();
                    //    }
                    //    catch
                    //    {

                    //    }
                    //}
                    //BrowserUtils.ClearCache();
                    ShowTaskEvent(this, new AppEventArgs()
                    {
                        message_string = "删除缓存、cookie文件......"
                    });
                    System.Threading.Thread.Sleep(5000);
                    ShowTaskEvent(this, new AppEventArgs()
                    {
                        message_string = "删除完成"
                    });
                    //更换IP
                    if (!Appinfo.GetIP().Equals(NetworkUtils.GetIpAddress()) || Appinfo.GetIP().Equals(""))
                    {
                        ShowTaskEvent(this, new AppEventArgs()
                        {
                            message_string = "更换IP"
                        });
                        //this.taskIntervalTimer.Start();
                        //return -1;
                        Disconnect();
                        string     msg     = null;
                        tagSetting setting = Appinfo.QuerySetting();
                        bool       isok    = Connect(define.GetEnumName(setting.connectionType), setting.strUsername.ToString(), setting.strPwd.ToString(), ref msg);
                        ShowIPEvent(this, new AppEventArgs()
                        {
                        });
                    }

                    bool bNewTurn = false;
                    foreach (var task in Appinfo.listTask)
                    {
                        if (LastTask != null && LastTask.nID == Appinfo.listTask[Appinfo.listTask.Count - 1].nID)
                        {
                            bNewTurn = true;
                        }
                    }

                    foreach (var task in Appinfo.listTask)
                    {
                        //每轮任务顺序执行
                        if (!task.bCheck)
                        {
                            continue;
                        }
                        if (!bNewTurn && task.nID <= LastTask.nID)
                        {
                            continue;
                        }
                        if (task.nCountExcuteToday >= task.nCountLimit)
                        {
                            continue;
                        }
                        //todo 执行时间检查
                        int nCount       = 0;
                        int nCountExcute = 0;
                        switch (DateTime.Now.Hour)
                        {
                        case 0:
                        {
                            nCount       = task.tagtempleTime.nCount00;
                            nCountExcute = task.tagtempleTime.nCount00_Excute;
                        }
                        break;

                        case 1:
                        {
                            nCount       = task.tagtempleTime.nCount01;
                            nCountExcute = task.tagtempleTime.nCount01_Excute;
                        }
                        break;

                        case 2:
                        {
                            nCount       = task.tagtempleTime.nCount02;
                            nCountExcute = task.tagtempleTime.nCount02_Excute;
                        }
                        break;

                        case 3:
                        {
                            nCount       = task.tagtempleTime.nCount03;
                            nCountExcute = task.tagtempleTime.nCount03_Excute;
                        }
                        break;

                        case 4:
                        {
                            nCount       = task.tagtempleTime.nCount04;
                            nCountExcute = task.tagtempleTime.nCount04_Excute;
                        }
                        break;

                        case 5:
                        {
                            nCount       = task.tagtempleTime.nCount05;
                            nCountExcute = task.tagtempleTime.nCount05_Excute;
                        }
                        break;

                        case 6:
                        {
                            nCount       = task.tagtempleTime.nCount06;
                            nCountExcute = task.tagtempleTime.nCount06_Excute;
                        }
                        break;

                        case 7:
                        {
                            nCount       = task.tagtempleTime.nCount07;
                            nCountExcute = task.tagtempleTime.nCount07_Excute;
                        }
                        break;

                        case 8:
                        {
                            nCount       = task.tagtempleTime.nCount08;
                            nCountExcute = task.tagtempleTime.nCount08_Excute;
                        }
                        break;

                        case 9:
                        {
                            nCount       = task.tagtempleTime.nCount09;
                            nCountExcute = task.tagtempleTime.nCount09_Excute;
                        }
                        break;

                        case 10:
                        {
                            nCount       = task.tagtempleTime.nCount10;
                            nCountExcute = task.tagtempleTime.nCount10_Excute;
                        }
                        break;

                        case 11:
                        {
                            nCount       = task.tagtempleTime.nCount11;
                            nCountExcute = task.tagtempleTime.nCount11_Excute;
                        }
                        break;

                        case 12:
                        {
                            nCount       = task.tagtempleTime.nCount12;
                            nCountExcute = task.tagtempleTime.nCount12_Excute;
                        }
                        break;

                        case 13:
                        {
                            nCount       = task.tagtempleTime.nCount13;
                            nCountExcute = task.tagtempleTime.nCount13_Excute;
                        }
                        break;

                        case 14:
                        {
                            nCount       = task.tagtempleTime.nCount14;
                            nCountExcute = task.tagtempleTime.nCount14_Excute;
                        }
                        break;

                        case 15:
                        {
                            nCount       = task.tagtempleTime.nCount15;
                            nCountExcute = task.tagtempleTime.nCount15_Excute;
                        }
                        break;

                        case 16:
                        {
                            nCount       = task.tagtempleTime.nCount16;
                            nCountExcute = task.tagtempleTime.nCount16_Excute;
                        }
                        break;

                        case 17:
                        {
                            nCount       = task.tagtempleTime.nCount17;
                            nCountExcute = task.tagtempleTime.nCount17_Excute;
                        }
                        break;

                        case 18:
                        {
                            nCount       = task.tagtempleTime.nCount18;
                            nCountExcute = task.tagtempleTime.nCount18_Excute;
                        }
                        break;

                        case 19:
                        {
                            nCount       = task.tagtempleTime.nCount19;
                            nCountExcute = task.tagtempleTime.nCount19_Excute;
                        }
                        break;

                        case 20:
                        {
                            nCount       = task.tagtempleTime.nCount20;
                            nCountExcute = task.tagtempleTime.nCount20_Excute;
                        }
                        break;

                        case 21:
                        {
                            nCount       = task.tagtempleTime.nCount21;
                            nCountExcute = task.tagtempleTime.nCount21_Excute;
                        }
                        break;

                        case 22:
                        {
                            nCount       = task.tagtempleTime.nCount22;
                            nCountExcute = task.tagtempleTime.nCount22_Excute;
                        }
                        break;

                        case 23:
                        {
                            nCount       = task.tagtempleTime.nCount23;
                            nCountExcute = task.tagtempleTime.nCount23_Excute;
                        }
                        break;

                        default: break;
                        }

                        if (nCountExcute >= nCount)
                        {
                            continue;
                        }
                        LastTask.nID = task.nID;
                        bExecuteTask = true;
                        StartTaskEvent(this, new AppEventArgs()
                        {
                            message_task = task
                        });
                        this.taskTimer.Start();

                        return(1);
                    }

                    this.taskIntervalTimer.Start();
                    this.showTaskTimer.Start();
                    ShowTaskEvent(this, new AppEventArgs()
                    {
                        message_string = "未找到可以执行的任务,1分钟后开始查找下一个任务"
                    });
                }
                return(1);
            }
            catch (Exception e)
            {
                Logger.Info(string.Format("方法DoAsyncEvent: "), e);

                return(-1);
            }
        }