Пример #1
0
        public Int64 InsertTaskComplete(Int64 TaskID, cGlobalParas.GatherResult tSate)
        {
            ///首先判断存放任务执行的目录是否存在
            ///此目录是固定目录,存放在系统\\data
            string cPath = Program.getPrjPath() + "data";

            if (!System.IO.Directory.Exists(cPath))
            {
                System.IO.Directory.CreateDirectory(cPath);
            }

            ///先将此任务的摘要信息加载到index.xml文件中
            Task.cTaskRun t = new Task.cTaskRun();
            t.LoadSingleTask(TaskID);

            //开始构造xml节点内容
            LoadTaskData();
            //int MaxID=GetCount () + 1;

            string txml = "";

            txml  = "<TaskID>" + t.GetTaskID(0) + "</TaskID>";
            txml += "<TaskName>" + t.GetTaskName(0) + "</TaskName>";
            txml += "<TaskState>" + tSate + "</TaskState>";
            txml += "<TaskType>" + (int)t.GetTaskType(0) + "</TaskType>";
            txml += "<RunType>" + (int)t.GetTaskRunType(0) + "</RunType>";
            txml += "<ExportFile>" + t.GetExportFile(0) + "</ExportFile>";
            txml += "<tempFile>" + t.GetTempFile(0) + "</tempFile>";
            txml += "<UrlCount>" + t.GetUrlCount(0) + "</UrlCount>";
            txml += "<GatheredUrlCount>" + t.GetGatheredUrlCount(0) + "</GatheredUrlCount>";
            txml += "<IsLogin>" + t.GetIsLogin(0) + "</IsLogin>";
            txml += "<PublishType>" + (int)t.GetPublishType(0) + "</PublishType>";

            xmlConfig.InsertElement("Tasks", "Task", txml);
            xmlConfig.Save();

            return(TaskID);
        }
        public Int64 InsertTaskComplete(Int64 TaskID,cGlobalParas.GatherResult tSate)
        {
            ///�����жϴ������ִ�е�Ŀ¼�Ƿ����
            ///��Ŀ¼�ǹ̶�Ŀ¼�������ϵͳ\\data
            string cPath = Program.getPrjPath() + "data";

            if (!System.IO.Directory.Exists(cPath))
            {
                System.IO.Directory.CreateDirectory(cPath);
            }

            ///�Ƚ��������ժҪ��Ϣ���ص�index.xml�ļ���
            Task.cTaskRun t = new Task.cTaskRun();
            t.LoadSingleTask(TaskID);

            //��ʼ����xml�ڵ�����
            LoadTaskData();
            //int MaxID=GetCount () + 1;

            string txml="";
            txml = "<TaskID>" + t.GetTaskID (0) + "</TaskID>";
            txml += "<TaskName>" + t.GetTaskName(0) + "</TaskName>";
            txml += "<TaskState>" + tSate + "</TaskState>";
            txml += "<TaskType>" + (int)t.GetTaskType(0) + "</TaskType>";
            txml += "<RunType>" + (int)t.GetTaskRunType(0) + "</RunType>";
            txml += "<ExportFile>" + t.GetExportFile(0) + "</ExportFile>";
            txml += "<tempFile>" + t.GetTempFile(0) + "</tempFile>";
            txml += "<UrlCount>" + t.GetUrlCount(0) + "</UrlCount>";
            txml += "<GatheredUrlCount>" + t.GetGatheredUrlCount(0) + "</GatheredUrlCount>";
            txml += "<IsLogin>" + t.GetIsLogin(0) + "</IsLogin>";
            txml += "<PublishType>" + (int)t.GetPublishType(0) + "</PublishType>";

            xmlConfig.InsertElement("Tasks", "Task", txml);
            xmlConfig.Save ();

            return TaskID;
        }
Пример #3
0
        /// 重置采集任务为未启动状态
        internal void ResetTaskData()
        {
            // 停止任务
            //Stop();

            m_TaskData.GatheredUrlCount  = 0;
            m_TaskData.GatherErrUrlCount = 0;

            m_TaskData.GatheredTrueUrlCount    = 0;
            m_TaskData.GatheredTrueErrUrlCount = 0;

            //修改taskrun文件中,此文件索引的采集地址和出错地址为0
            string runFileindex = Program.getPrjPath() + "tasks\\taskrun.xml";
            cXmlIO cxml         = new cXmlIO(runFileindex);

            cxml = new cXmlIO(runFileindex);

            //还原数据需要将实际需要采集的网址数量初始化为UrlCount
            cxml.EditTaskrunValue(this.TaskID.ToString(), cGlobalParas.TaskState.UnStart, "0", "0", "0", "0", m_TaskData.UrlCount.ToString());
            cxml.Save();
            cxml = null;

            string tXml = "";

            for (int i = 0; i < m_TaskData.Weblink.Count; i++)
            {
                tXml += "<WebLink>";
                tXml += "<Url>" + cTool.ReplaceTrans(m_TaskData.Weblink[i].Weblink.ToString()) + "</Url>";
                tXml += "<IsNag>" + m_TaskData.Weblink[i].IsNavigation + "</IsNag>";
                tXml += "<IsNextPage>" + m_TaskData.Weblink[i].IsNextpage + "</IsNextPage>";
                tXml += "<NextPageRule>" + cTool.ReplaceTrans(m_TaskData.Weblink[i].NextPageRule) + "</NextPageRule>";
                tXml += "<IsGathered>" + (int)cGlobalParas.UrlGatherResult.UnGather + "</IsGathered>";

                if (m_TaskData.Weblink[i].IsNavigation == true)
                {
                    tXml += "<NavigationRules>";
                    for (int j = 0; j < m_TaskData.Weblink[i].NavigRules.Count; j++)
                    {
                        tXml += "<Rule>";
                        tXml += "<Url>" + m_TaskData.Weblink[i].NavigRules[j].Url + "</Url>";
                        tXml += "<Level>" + m_TaskData.Weblink[i].NavigRules[j].Level + "</Level>";
                        tXml += "<NagRule>" + m_TaskData.Weblink[i].NavigRules[j].NavigRule + "</NagRule>";
                        tXml += "</Rule>";
                    }
                    tXml += "</NavigationRules>";
                }

                tXml += "</WebLink>";

                m_TaskData.Weblink[i].IsGathered = (int)cGlobalParas.UrlGatherResult.UnGather;
            }

            string FileName = Program.getPrjPath() + "tasks\\run\\task" + m_TaskData.TaskID + ".xml";
            cXmlIO cxml1    = new cXmlIO(FileName);

            cxml1.DeleteNode("WebLinks");
            cxml1.InsertElement("Task", "WebLinks", tXml);
            cxml1.Save();
            cxml1 = null;

            //删除临时存储的采集数据xml文件
            string tmpFileName = m_TaskData.SavePath + "\\" + m_TaskData.TaskName + "-" + m_TaskData.TaskID + ".xml";

            if (File.Exists(tmpFileName))
            {
                File.Delete(tmpFileName);
            }

            Task.cTaskRun t = new Task.cTaskRun();
            t.LoadSingleTask(m_TaskData.TaskID);
            m_TaskData.UrlCount = t.GetUrlCount(0);
            t = null;

            //m_TaskData.TaskSplitData.Clear ();
            //m_IsDataInitialized = false;
        }