public Int64 InsertTaskRun(string Path, string File) { ///�����жϴ������ִ�е�Ŀ¼�Ƿ���� ///��Ŀ¼�ǹ̶�Ŀ¼�������ϵͳ\\Task\\run string RunPath = Program.getPrjPath() + "Tasks\\run"; if (!System.IO.Directory.Exists(RunPath)) { System.IO.Directory.CreateDirectory(RunPath); } ///�Ƚ��������ժҪ��Ϣ���ص�TaskRun.xml�ļ��� Task.cTask t = new Task.cTask(); t.LoadTask(Path + "\\" + File); //��ʼ����xml�ڵ����� LoadTaskRunData(); Int64 maxID = GetNewID(); string tRunxml = ""; tRunxml = "<TaskID>" + maxID + "</TaskID>"; tRunxml += "<TaskName>" + t.TaskName + "</TaskName>"; tRunxml += "<TaskState>" + (int)cGlobalParas.TaskState.UnStart + "</TaskState>"; tRunxml += "<TaskType>" + t.TaskType + "</TaskType>"; tRunxml += "<RunType>" + t.RunType + "</RunType>"; tRunxml += "<ExportFile>" + t.ExportFile + "</ExportFile>"; tRunxml += "<tempFile>" + t.SavePath + "\\" + t.TaskName + "-" + maxID + ".xml" + "</tempFile>"; tRunxml += "<StartDate>" + DateTime.Now + "</StartDate>"; tRunxml += "<EndDate></EndDate>"; tRunxml += "<ThreadCount>" + t.ThreadCount + "</ThreadCount>"; tRunxml += "<UrlCount>" + t.UrlCount + "</UrlCount>"; ///TrueUrlCount��ʾ����ɼ�����ַ�д��ڵ�����ַ������Ҫ�ɼ�����ַ�������ݹ�ʽ���˳����� ///��Ҫ�ɼ�����ִ�У����ϸ��ݲɼ��Ĺ�����м���ɼ���ַ��������������Ҫ�ٴμ�¼��ֵ ///��¼��ֵ��Ŀ����Ϊ�˿��Ը��õĸ��ٲɼ��Ľ��ȣ���Urlcount�����ģ���Ϊ��ֵҪ��������ֽ� ///ʹ�ã�����ı���UrlCount����ܵ�������ֽ�ʧ�ܣ�����Ӫ�����ʼ����ʱ��ֵͬUrlCount����ֵ�� ///������������Ӫʱά�� tRunxml += "<TrueUrlCount>" + t.UrlCount + "</TrueUrlCount>"; tRunxml += "<GatheredUrlCount>0</GatheredUrlCount>"; tRunxml += "<GatheredTrueUrlCount>0</GatheredTrueUrlCount>"; tRunxml += "<ErrUrlCount>0</ErrUrlCount>"; tRunxml += "<TrueErrUrlCount>0</TrueErrUrlCount>"; tRunxml += "<IsLogin>" + t.IsLogin + "</IsLogin>"; tRunxml += "<PublishType>" + t.ExportType + "</PublishType>"; xmlConfig.InsertElement("Tasks", "Task", tRunxml); xmlConfig.Save(); xmlConfig = null; ///������������xml�ļ��ĸ�ʽ��Task�����ʽ��ȫһ�۸�����������ʽ��ȫ��ͬ ///������ʽ�ǰ���Task����ǰ�ļ���Taskrun�е�id����������������Ŀ����֧��ͬһ������ ///���Խ����������ʵ����Ҳ���ǵ�����������е�ʱ���û�Ҳ�����Ĵ���������� ///һ��ʵ����ʼ���С� System.IO.File.Copy(Path + "\\" + File, RunPath + "\\" + "Task" + maxID + ".xml", true); //�ļ�������ȥ����Ҫ���ļ��е�TaskID�����Ǻ�TaskRun�е�TaskID���������� //�ڼ����ļ���ʱ������,ϵͳ��ID����Ψһ���� cXmlIO xmlFile; xmlFile = new cXmlIO(RunPath + "\\" + "Task" + maxID + ".xml"); string tID = xmlFile.GetNodeValue("Task/BaseInfo/ID"); xmlFile.EditNode("ID", tID, maxID.ToString()); xmlFile.Save(); xmlFile = null; return maxID ; }
public Int64 InsertTaskRun(string Path, string File) { ///首先判断存放任务执行的目录是否存在 ///此目录是固定目录,存放在系统\\Task\\run string RunPath = Program.getPrjPath() + "Tasks\\run"; if (!System.IO.Directory.Exists(RunPath)) { System.IO.Directory.CreateDirectory(RunPath); } ///先将此任务的摘要信息加载到TaskRun.xml文件中 Task.cTask t = new Task.cTask(); t.LoadTask(Path + "\\" + File); //开始构造xml节点内容 LoadTaskRunData(); Int64 maxID = GetNewID(); string tRunxml = ""; tRunxml = "<TaskID>" + maxID + "</TaskID>"; tRunxml += "<TaskName>" + t.TaskName + "</TaskName>"; tRunxml += "<TaskState>" + (int)cGlobalParas.TaskState.UnStart + "</TaskState>"; tRunxml += "<TaskType>" + t.TaskType + "</TaskType>"; tRunxml += "<RunType>" + t.RunType + "</RunType>"; tRunxml += "<ExportFile>" + t.ExportFile + "</ExportFile>"; tRunxml += "<tempFile>" + t.SavePath + "\\" + t.TaskName + "-" + maxID + ".xml" + "</tempFile>"; tRunxml += "<StartDate>" + DateTime.Now + "</StartDate>"; tRunxml += "<EndDate></EndDate>"; tRunxml += "<ThreadCount>" + t.ThreadCount + "</ThreadCount>"; tRunxml += "<UrlCount>" + t.UrlCount + "</UrlCount>"; ///TrueUrlCount表示如果采集的网址中存在导航网址,则需要采集的网址是无法根据公式极端出来的 ///需要采集任务不断执行,不断根据采集的规则进行计算采集网址的总数,所以需要再次记录此值 ///记录此值的目的是为了可以更好的跟踪采集的进度,但Urlcount不能修改,因为此值要进行任务分解 ///使用,如果改变了UrlCount则可能导致任务分解失败,在运营任务初始化的时候,此值同UrlCount,此值的 ///更改在任务运营时维护 tRunxml += "<TrueUrlCount>" + t.UrlCount + "</TrueUrlCount>"; tRunxml += "<GatheredUrlCount>0</GatheredUrlCount>"; tRunxml += "<GatheredTrueUrlCount>0</GatheredTrueUrlCount>"; tRunxml += "<ErrUrlCount>0</ErrUrlCount>"; tRunxml += "<TrueErrUrlCount>0</TrueErrUrlCount>"; tRunxml += "<IsLogin>" + t.IsLogin + "</IsLogin>"; tRunxml += "<PublishType>" + t.ExportType + "</PublishType>"; xmlConfig.InsertElement("Tasks", "Task", tRunxml); xmlConfig.Save(); xmlConfig = null; ///运行区的任务xml文件的格式与Task任务格式完全一眼个,但命名方式完全不同 ///命名格式是按照Task+当前文件在Taskrun中的id来命名,这样做的目的是支持同一个任务 ///可以建立多个运行实例,也就是当这个任务运行的时候,用户也可以修改此任务后建立另 ///一个实例开始运行。 System.IO.File.Copy(Path + "\\" + File, RunPath + "\\" + "Task" + maxID + ".xml", true); //文件拷贝过去后,需要修改文件中的TaskID,以吻合TaskRun中的TaskID索引,否则 //在加载文件的时候会出错,系统用ID来做唯一索引 cXmlIO xmlFile; xmlFile = new cXmlIO(RunPath + "\\" + "Task" + maxID + ".xml"); string tID = xmlFile.GetNodeValue("Task/BaseInfo/ID"); xmlFile.EditNode("ID", tID, maxID.ToString()); xmlFile.Save(); xmlFile = null; return(maxID); }