예제 #1
0
        void BackstageRun <T>(object param) where T : Quartz.IJob
        {
            QuartzJobParam p = param as QuartzJobParam;

            job.CreateJobWithParam <T>(p.JobExecutionContextJobDataMap, p.StartTime, p.TrigggerInterval, p.TriggerRepeat);
        }
예제 #2
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Cookie))
            {
                rtbTip.Text = "please  login,and get cookie,and continue";
                return;
            }
            //
            int    interval = 0;
            string inter    = txtTimeSpan.Text;

            int.TryParse(inter, out interval);
            if (interval > 0)
            {
                intervalSec = interval;
            }
            else
            {
                interval = intervalSec;
            }
            int    repeact = 0;
            string rep     = txtRepeact.Text;

            int.TryParse(rep, out repeact);
            QQDataDA das  = new QQDataDA();
            string   path = LogPrepare.GetLogPath();

            LoggerWriter.CreateLogFile(Cookie, das.GeneratePathTimeSpan(Cookie), ELogType.SessionOrCookieLog);
            Uin = das.GetUinFromCookie(Cookie);//当前登录的账户
            //useralias  这是提取账户名称的元素
            QueryQQParam             param = GetBaseQueryParam();
            ParameterizedThreadStart pth;

            if (!ckStartQuartz.Checked)
            {//不进行轮询
                JustQuery(param);
            }
            else if (!ckBackGroundCall.Checked)
            {
                #region 进行的是quartz.net轮询调度
                if (ckStartQuartz.Checked && rbGuid.Checked)
                {//开启随机轮询
                    DelegateData.BaseDelegate del = QuartzGuidForach;
                    QuartzJobParam            p   = new QuartzJobParam()
                    {
                        JobExecutionContextJobDataMap = new object[] { del, param, null },
                        StartTime        = DateTime.Now.AddSeconds(interval),
                        TriggerRepeat    = repeact,
                        TrigggerInterval = interval
                    };
                    pth = new ParameterizedThreadStart(BackstageRun <JobDelegateFunction>);
                    Thread th = new Thread(pth);
                    th.Start(p);
                    // job.CreateJobWithParam<JobDelegateFunction>(new object[] { del, param,null }, DateTime.Now.AddSeconds(interval), interval, repeact);
                }
                else if (ckStartQuartz.Checked && rbDepth.Checked)
                {//该查询结果页轮询
                    DelegateData.BaseDelegate del = QuartzForeachPage;
                    QuartzJobParam            p   = new QuartzJobParam()
                    {
                        JobExecutionContextJobDataMap = new object[] { del, null, null },
                        StartTime        = DateTime.Now.AddSeconds(interval),
                        TriggerRepeat    = repeact,
                        TrigggerInterval = interval
                    };
                    pth = new ParameterizedThreadStart(BackstageRun <JobDelegateFunction>);
                    Thread th = new Thread(pth);
                    th.Start(p);
                    //job.CreateJobWithParam<JobDelegateFunction>(new object[] { del, null,null }, DateTime.Now.AddSeconds(interval), interval, repeact);
                }
                else if (ckStartQuartz.Checked)
                {
                    DelegateData.BaseDelegate del = QuartzCallBack;
                    QuartzJobParam            p   = new QuartzJobParam()
                    {
                        JobExecutionContextJobDataMap = new object[] { Cookie, param, del },
                        StartTime        = DateTime.Now.AddSeconds(interval),
                        TriggerRepeat    = repeact,
                        TrigggerInterval = interval
                    };
                    pth = new ParameterizedThreadStart(BackstageRun <JobAction <QQDataDA> >);
                    Thread th = new Thread(pth);
                    th.Start(p);
                    // job.CreateJobWithParam<JobAction<QQDataDA>>(new object[] { Cookie, param, del }, DateTime.Now, interval, repeact);
                }
                else
                {
                    JustQuery(param);
                }
                #endregion
            }
            else if (ckBackGroundCall.Checked && ckStartQuartz.Checked)
            {//轮询但是使用的是后台进程
                #region 使用的是后台进程
                BackGrounForeachCallType(param);
                #endregion
            }
            #region 数据同步到核心库
            if (ckSyncUin.Checked)
            { //同步数据
                string key = ForachCallEvent.SyncUinToCodeDB.ToString();
                if (BackGroundCallRunEvent.ContainsKey(key))
                {
                    BackGroundCallRunEvent.Remove(key);
                }
                DelegateData del = new DelegateData()
                {
                    BaseDel = BackGrounSyncUinToCoreDB, BaseDelegateParam = null
                };
                BackGroundCallRunEvent.Add(key, del);
            }
            #endregion
            if (!backRun.IsBusy)
            {
                backRun.RunWorkerAsync();
            }
        }