Exemplo n.º 1
0
        //处理触发器的执行事件
        private void TriggerRun()
        {
            //无论失败还是成功都要进行触发器的触发
            if (m_pTaskData.IsTrigger == true && m_pTaskData.TriggerType == ((int)cGlobalParas.TriggerType.PublishedRun).ToString())
            {
                cRunTask rt = new cRunTask();
                rt.RunSoukeyTaskEvent += this.onRunSoukeyTask;

                cTaskPlan p;

                for (int i = 0; i < m_pTaskData.TriggerTask.Count; i++)
                {
                    p = new cTaskPlan();

                    p.RunTaskType = m_pTaskData.TriggerTask[i].RunTaskType;
                    p.RunTaskName = m_pTaskData.TriggerTask[i].RunTaskName;
                    p.RunTaskPara = m_pTaskData.TriggerTask[i].RunTaskPara;

                    rt.AddTask(p);
                }

                rt.RunSoukeyTaskEvent -= this.onRunSoukeyTask;
                rt = null;
            }
        }
Exemplo n.º 2
0
        /// 当某个线程采集完成后,会调用任务完成事件进行检测,如果任务完成则触发任务
        /// 完成事件。但在此判断时需要注意,如果任务采集失败的数量和采集数量相等,则判断
        /// 任务失败。且每次调用此事件时,都需要做一次检测,对每个子线程都检测一遍,看是否
        /// 存在已经完成,但未触发完成事件的自线程。
        private void onTaskCompleted()
        {
            if (m_TaskData.UrlCount == (m_TaskData.GatheredUrlCount + m_TaskData.GatherErrUrlCount) && m_State != cGlobalParas.TaskState.Completed)
            {
                if (m_TaskData.TrueUrlCount == m_TaskData.GatherErrUrlCount)
                {
                    //如果全部采集都发生了错误,则此任务为失败
                    State = cGlobalParas.TaskState.Failed;
                }
                else
                {
                    // 设置为完成状态,触发任务完成事件
                    State = cGlobalParas.TaskState.Completed;
                }

                //无论失败还是成功都要进行触发器的触发
                if (m_TaskData.IsTrigger == true && m_TaskData.TriggerType == ((int)cGlobalParas.TriggerType.GatheredRun).ToString())
                {
                    cRunTask rt = new cRunTask();
                    rt.RunSoukeyTaskEvent += this.onRunSoukeyTask;

                    cTaskPlan p;

                    for (int i = 0; i < m_TaskData.TriggerTask.Count; i++)
                    {
                        p = new cTaskPlan();

                        p.RunTaskType = m_TaskData.TriggerTask[i].RunTaskType;
                        p.RunTaskName = m_TaskData.TriggerTask[i].RunTaskName;
                        p.RunTaskPara = m_TaskData.TriggerTask[i].RunTaskPara;

                        rt.AddTask(p);
                    }

                    rt.RunSoukeyTaskEvent -= this.onRunSoukeyTask;
                    rt = null;
                }
            }
        }