Exemplo n.º 1
0
        //初始化运行区的采集任务信息.
        public void LoadTaskRunData()
        {
            Task.cTaskRun t = new Task.cTaskRun();
            t.LoadTaskRunData();
            cTaskData tData;

            for (int i = 0; i < t.GetCount(); i++)
            {
                tData                         = new cTaskData();
                tData.TaskID                  = t.GetTaskID(i);
                tData.TaskName                = t.GetTaskName(i);
                tData.TaskType                = t.GetTaskType(i);
                tData.RunType                 = t.GetTaskRunType(i);
                tData.tempFileName            = t.GetTempFile(i);
                tData.TaskState               = t.GetTaskState(i);
                tData.ThreadCount             = t.GetThreadCount(i);
                tData.UrlCount                = t.GetUrlCount(i);
                tData.TrueUrlCount            = t.GetTrueUrlCount(i);
                tData.GatheredUrlCount        = 0;
                tData.GatheredTrueUrlCount    = t.GetGatheredTrueUrlCount(i);
                tData.GatherErrUrlCount       = 0;
                tData.GatheredTrueErrUrlCount = t.GetTrueErrUrlCount(i);
                m_TaskDataList.Add(tData);
                tData = null;
            }

            m_TaskCount = t.GetCount();
            t           = null;
        }
Exemplo n.º 2
0
        /// 向采集任务队列中增加一个采集任务
        public void Add(cTaskData tData)
        {
            try
            {
                //新建一个采集任务,并把采集任务的数据传入此采集任务中
                cGatherTask gTask = new cGatherTask(this, tData);

                //初始化此采集任务,主要是注册此任务的相关事件
                TaskInit(gTask);

                //判断此任务是否已经加入此任务数据集合,如果没有加入,则加入集合
                if (!m_TaskDataList.TaskDataList.Contains(tData))
                {
                    m_TaskDataList.TaskDataList.Add(tData);
                }

                //将此采集任务添加到采集任务队列中
                m_list_Task.Add(gTask);

                //根据添加的任务状态,自动维护队列的信息
                m_GatherTaskList.AutoList(gTask);

                //如果任务增加后就是完成的任务,则需要出发完成的
                //事件
                if (gTask.TaskState == cGlobalParas.TaskState.Completed)
                {
                    e_TaskCompleted(gTask, new cTaskEventArgs(gTask.TaskID, gTask.TaskName, false));
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
        //��ʼ���������IJɼ�������Ϣ.
        public void LoadTaskRunData()
        {
            Task.cTaskRun t = new Task.cTaskRun();
            t.LoadTaskRunData();
            cTaskData tData;
            for (int i = 0; i < t.GetCount(); i++)
            {
                tData = new cTaskData();
                tData.TaskID = t.GetTaskID(i);
                tData.TaskName = t.GetTaskName(i);
                tData.TaskType = t.GetTaskType(i);
                tData.RunType = t.GetTaskRunType(i);
                tData.tempFileName = t.GetTempFile(i);
                tData.TaskState = t.GetTaskState(i);
                tData.ThreadCount = t.GetThreadCount(i);
                tData.UrlCount = t.GetUrlCount(i);
                tData.TrueUrlCount = t.GetTrueUrlCount(i);
                tData.GatheredUrlCount = 0;
                tData.GatheredTrueUrlCount = t.GetGatheredTrueUrlCount(i);
                tData.GatherErrUrlCount = 0;
                tData.GatheredTrueErrUrlCount = t.GetTrueErrUrlCount(i);
                m_TaskDataList.Add(tData);
                tData = null;
            }

            m_TaskCount = t.GetCount();
            t = null;
        }
Exemplo n.º 4
0
        /// 初始化采集任务对象,并根据任务数据确定此任务是否
        /// 由多个线程来完成,如果是,则进行任务分解
        internal cGatherTask(cGatherManage taskManage, cTaskData taskData)
        {
            m_TaskManage = taskManage;
            m_TaskData   = taskData;
            m_State      = TaskData.TaskState;

            m_list_GatherTaskSplit = new List <cGatherTaskSplit>();

            //当任务数据传进来之后,直接对当前任务进行任务分解,
            //是否需要多线程进行,并初始化相关数据内容
            SplitTask();

            //开始初始化任务
            TaskInit();
        }
        /// ��ɼ��������������һ���ɼ�����
        public void Add(cTaskData tData)
        {
            try
            {
                //�½�һ���ɼ�����,���Ѳɼ���������ݴ���˲ɼ�������
                cGatherTask gTask = new cGatherTask(this, tData);

                //��ʼ���˲ɼ�����,��Ҫ��ע������������¼�
                TaskInit(gTask);

                //�жϴ������Ƿ��Ѿ�������������ݼ���,���û�м���,����뼯��
                if (!m_TaskDataList.TaskDataList.Contains(tData))
                {
                    m_TaskDataList.TaskDataList.Add(tData);
                }

                //���˲ɼ�������ӵ��ɼ����������
                m_list_Task.Add(gTask);

                //������ӵ�����״̬,�Զ�ά�����е���Ϣ
                m_GatherTaskList.AutoList(gTask);

                //����������Ӻ������ɵ���������Ҫ������ɵ�
                //�¼�
                if (gTask.TaskState == cGlobalParas.TaskState.Completed)
                {
                    e_TaskCompleted(gTask, new cTaskEventArgs(gTask.TaskID, gTask.TaskName, false));
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 6
0
        //����ɼ�����
        private cGatherTask AddRunTask(string tClassName, string tName)
        {
            //��ѡ���������ӵ�������
            //�����жϴ������Ƿ��Ѿ���ӵ�������,
            //����Ѿ���ӵ�����������Ҫѯ���Ƿ�����һ������ʵ��
            bool IsExist = false;

            //��ʼ��ʼ���������е�����
            Task.cTaskRun xmlTasks = new Task.cTaskRun();
            xmlTasks.LoadTaskRunData();
            for (int i=0 ;i<xmlTasks.GetCount() ;i++)
            {
                if (xmlTasks.GetTaskName(i) == tName)
                {
                    IsExist = true;
                    break;
                }
            }
            xmlTasks = null;

            if (IsExist == true)
            {
                //if (MessageBox.Show("��ѡ������������Ѿ������������ڻ�������ͬ���Ƶ������Ѿ��������������Ƿ�ȷ�ϴ�������Ҫ���л���Ҫ���������еڶ���ʵ����",
                //    "ϵͳѯ��", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                //{
                //    return null;
                //}

                if (cTool.MyMessageBox(rm.GetString("Quaere12"), rm.GetString("MessageboxQuaere"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    return null;
                }

            }

            cTaskRun tr = new cTaskRun();
            cTaskClass tc = new cTaskClass();
            cTaskData tData=new cTaskData ();

            string tPath="";

            if (tClassName == "")
            {
                tPath = Program.getPrjPath() + "tasks";
            }
            else
            {
                tPath = tc.GetTaskClassPathByName(tClassName);
            }

            tc=null;

            string tFileName = tName + ".xml";

            //��ȡ����ִ��ID
            Int64 NewID = tr.InsertTaskRun(tPath, tFileName);

            tr.LoadSingleTask(NewID);

            tData = new cTaskData();
            tData.TaskID = tr.GetTaskID(0);
            tData.TaskName = tr.GetTaskName(0);
            tData.TaskType = tr.GetTaskType(0);
            tData.RunType = tr.GetTaskRunType(0);
            tData.tempFileName = tr.GetTempFile(0);
            tData.TaskState = tr.GetTaskState(0);
            tData.UrlCount = tr.GetUrlCount(0);
            tData.TrueUrlCount = tr.GetTrueUrlCount(0);
            tData.ThreadCount = tr.GetThreadCount(0);
            tData.GatheredUrlCount = tr.GetGatheredUrlCount(0);
            tData.GatherErrUrlCount = tr.GetErrUrlCount(0);

            //�������������
            m_GatherControl.AddGatherTask(tData);

            tData = null;

            //������ӵ���������,��Ҫ����ӵ�����ִ���б���
            tr = null;

            return  m_GatherControl.TaskManage.FindTask(NewID);
        }
 //���ӵ�������
 public void AddGatherTask(cTaskData task)
 {
     m_TaskManage.Add(task);
 }
Exemplo n.º 8
0
 //增加单个任务
 public void AddGatherTask(cTaskData task)
 {
     m_TaskManage.Add(task);
 }