//修改制定计划的名称 public bool RenamePlanName(string OldPlanName, string NewPlanName) { //判断计划文件是否存在,如果不存在则新建 if (!IsExist()) { NewIndexFile(); } //判断计划是否重名,如果重名则需要进行名称修改 cXmlIO xmlPlan = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\plan.xml"); DataView d = xmlPlan.GetData("descendant::Plans"); if (d != null) { for (int i = 0; i < d.Count; i++) { if (NewPlanName == d[i].Row["PlanName"].ToString()) { xmlPlan = null; throw new cSoukeyException("已经存在此计划,重命名失败"); return(false); } } } xmlPlan.EditNodeValue("Plans", "PlanName", OldPlanName, "PlanName", NewPlanName); xmlPlan.Save(); xmlPlan = null; return(true); }
//public int GetPlanCount() //{ // return 0; //} //插入一个计划,计划不能重名 public void InsertPlan(cPlan NewPlan) { //判断计划文件是否存在,如果不存在则新建 if (!IsExist()) { NewIndexFile(); } //判断计划是否重名,如果重名则需要进行名称修改 cXmlIO xmlConfig = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\plan.xml"); DataView d = xmlConfig.GetData("descendant::Plans"); if (d != null) { for (int i = 0; i < d.Count; i++) { if (NewPlan.PlanName == d[i].Row["PlanName"].ToString()) { xmlConfig = null; throw new cSoukeyException("已经存在此计划,请修改计划名称,计划名称不能重复!"); } } } string pXml = CreatePlanXml(NewPlan); xmlConfig.InsertElement("Plans", "Plan", pXml); xmlConfig.Save(); xmlConfig = null; }
//根据计划的状态获取计划 public void GetPlanByState(cGlobalParas.PlanState pState) { string PlanPath = Program.getPrjPath() + "tasks\\plan"; xmlConfig = new cXmlIO(PlanPath + "\\index.xml"); //获取TaskClass节点 Plans = xmlConfig.GetData("TaskIndex"); }
//获取任务分类根目录下的任务索引,此目录为应用程序路径\\tasks, //此分类为固定内容,不提供用户可操作的任何处理。 public void GetTaskDataByClass() { string ClassPath = Program.getPrjPath() + "tasks"; m_TaskPath = ClassPath; xmlConfig = new cXmlIO(ClassPath + "\\index.xml"); //获取TaskClass节点 Tasks = xmlConfig.GetData("TaskIndex"); }
public void LoadLog() { if (!IsExist()) { return; } cXmlIO xmlConfig = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\RunLog.xml"); m_dataLog = xmlConfig.GetData("descendant::Logs"); xmlConfig = null; }
public cTaskClass() { try { xmlConfig = new cXmlIO(Program.getPrjPath () + "TaskClass.xml"); //��ȡTaskClass�ڵ� TaskClass = xmlConfig.GetData("descendant::TaskClasses"); } catch (System.Exception ex) { throw ex; } }
//返回的是已经完成的任务的集合信息 public void LoadTaskData() { try { xmlConfig = new cXmlIO(Program.getPrjPath() + "Data\\index.xml"); } catch (System.Exception ex) { throw ex; } //获取TaskClass节点 Tasks = xmlConfig.GetData("Tasks"); }
public cTaskClass() { try { xmlConfig = new cXmlIO(Program.getPrjPath() + "TaskClass.xml"); //获取TaskClass节点 TaskClass = xmlConfig.GetData("descendant::TaskClasses"); } catch (System.Exception ex) { throw ex; } }
//获取一个执行的计划 public cPlan GetSinglePlan(Int64 PlanID) { //判断计划文件是否存在,如果不存在则新建 if (!IsExist()) { NewIndexFile(); } //判断计划是否重名,如果重名则需要进行名称修改 cXmlIO xmlConfig = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\plan.xml"); DataView d = xmlConfig.GetData("Plans", "ID", PlanID.ToString()); DataView t = d[0].CreateChildView("Plan_Tasks")[0].CreateChildView("Tasks_Task"); cPlan p = new cPlan(); p.PlanID = Int64.Parse(d[0].Row["ID"].ToString()); p.PlanName = d[0].Row["PlanName"].ToString(); p.PlanRemark = d[0].Row["PlanRemark"].ToString(); p.PlanState = int.Parse(d[0].Row["PlanState"].ToString()); p.IsOverRun = d[0].Row["IsOverRun"].ToString() == "True" ? true : false; p.IsDisabled = d[0].Row["IsDisabled"].ToString() == "True" ? true : false; p.DisabledType = int.Parse(d[0].Row["DisabledType"].ToString()); p.DisabledTime = int.Parse(d[0].Row["DisabledTime"].ToString()); p.DisabledDateTime = DateTime.Parse(d[0].Row["DisabledDateTime"].ToString()); p.RunTaskPlanType = int.Parse(d[0].Row["RunTaskPlanType"].ToString()); p.EnabledDateTime = d[0].Row["EnabledDateTime"].ToString(); p.RunOnesTime = d[0].Row["RunOnesTime"].ToString(); p.RunDayTime = d[0].Row["RunDayTime"].ToString(); p.RunAMTime = d[0].Row["RunAMTime"].ToString(); p.RunPMTime = d[0].Row["RunPMTime"].ToString(); p.RunWeeklyTime = d[0].Row["RunWeeklyTime"].ToString(); p.RunWeekly = d[0].Row["RunWeekly"].ToString(); p.RunTimeCount = d[0].Row["RunTimeCount"].ToString(); p.FirstRunTime = d[0].Row["FirstRunTime"].ToString(); p.RunInterval = d[0].Row["RunInterval"].ToString(); cTaskPlan tp; for (int i = 0; i < t.Count; i++) { tp = new cTaskPlan(); tp.RunTaskType = int.Parse(t[i].Row["RunTaskType"].ToString()); tp.RunTaskName = t[i].Row["RunTaskName"].ToString(); tp.RunTaskPara = t[i].Row["RunTaskPara"].ToString(); p.RunTasks.Add(tp); } xmlConfig = null; return(p); }
//根据完成任务ID加载任务信息 public void LoadSingleTask(Int64 TaskID) { try { xmlConfig = new cXmlIO(Program.getPrjPath() + "Data\\index.xml"); } catch (System.Exception ex) { throw ex; } //获取TaskClass节点,尽管返回的也是DataView,但其中只包含一条记录 //这样做是为了更好的兼容访问操作 Tasks = xmlConfig.GetData("Tasks", "TaskID", TaskID.ToString()); }
public void GetTaskDataByClass(int ClassID) { Task.cTaskClass tClass = new Task.cTaskClass(); string ClassPath = tClass.GetTaskClassPathByID(ClassID); m_TaskPath = ClassPath; tClass = null; xmlConfig = new cXmlIO(ClassPath + "\\index.xml"); //获取TaskClass节点 Tasks = xmlConfig.GetData("TaskIndex"); }
//加载计划 //只加载计划的摘要信息,即只会从文件中加载需要列表显示的 //计划内容,不会完整的加载计划信息 public void LoadPlans() { cXmlIO xmlConfig = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\plan.xml"); DataView d = xmlConfig.GetData("descendant::Plans"); if (d == null) { return; } cPlan p; for (int i = 0; i < d.Count; i++) { p = new cPlan(); p.PlanID = Int64.Parse(d[i].Row["ID"].ToString()); p.PlanName = d[i].Row["PlanName"].ToString(); p.PlanState = int.Parse(d[i].Row["PlanState"].ToString()); p.IsOverRun = d[i].Row["IsOverRun"].ToString() == "True" ? true : false; p.IsDisabled = d[i].Row["IsDisabled"].ToString() == "True" ? true : false; p.DisabledType = int.Parse(d[i].Row["DisabledType"].ToString()); p.DisabledTime = int.Parse(d[i].Row["DisabledTime"].ToString()); p.DisabledDateTime = DateTime.Parse(d[i].Row["DisabledDateTime"].ToString()); p.RunTaskPlanType = int.Parse(d[i].Row["RunTaskPlanType"].ToString()); p.EnabledDateTime = d[i].Row["EnabledDateTime"].ToString(); p.RunOnesTime = d[i].Row["RunOnesTime"].ToString(); p.RunDayTime = d[i].Row["RunDayTime"].ToString(); p.RunAMTime = d[i].Row["RunAMTime"].ToString(); p.RunPMTime = d[i].Row["RunPMTime"].ToString(); p.RunWeeklyTime = d[i].Row["RunWeeklyTime"].ToString(); p.RunWeekly = d[i].Row["RunWeekly"].ToString(); p.RunTimeCount = d[i].Row["RunTimeCount"].ToString(); p.FirstRunTime = d[i].Row["FirstRunTime"].ToString(); p.RunInterval = d[i].Row["RunInterval"].ToString(); m_Plans.Add(p); } p = null; }
public void GetTaskDataByClass(string ClassName) { string ClassPath; if (ClassName == "") { ClassPath = Program.getPrjPath() + "Tasks"; } else { Task.cTaskClass tClass = new Task.cTaskClass(); ClassPath = tClass.GetTaskClassPathByName(ClassName); tClass = null; } m_TaskPath = ClassPath; xmlConfig = new cXmlIO(ClassPath + "\\index.xml"); //获取TaskClass节点 Tasks = xmlConfig.GetData("TaskIndex"); }
//���ƶ��ƻ������� public bool RenamePlanName(string OldPlanName, string NewPlanName) { //�жϼƻ��ļ��Ƿ���ڣ�������������½� if (!IsExist()) NewIndexFile(); //�жϼƻ��Ƿ������������������Ҫ���������� cXmlIO xmlPlan = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\plan.xml"); DataView d = xmlPlan.GetData("descendant::Plans"); if (d != null) { for (int i = 0; i < d.Count; i++) { if (NewPlanName == d[i].Row["PlanName"].ToString()) { xmlPlan = null; throw new cSoukeyException("�Ѿ����ڴ˼ƻ���������ʧ��"); return false; } } } xmlPlan.EditNodeValue("Plans", "PlanName", OldPlanName, "PlanName", NewPlanName); xmlPlan.Save(); xmlPlan = null; return true; }
//���ؼƻ� //ֻ���ؼƻ���ժҪ��Ϣ����ֻ����ļ��м�����Ҫ�б���ʾ�� //�ƻ����ݣ����������ļ��ؼƻ���Ϣ public void LoadPlans() { cXmlIO xmlConfig = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\plan.xml"); DataView d = xmlConfig.GetData("descendant::Plans"); if (d == null) { return; } cPlan p; for (int i = 0; i < d.Count; i++) { p = new cPlan(); p.PlanID =Int64.Parse ( d[i].Row["ID"].ToString()); p.PlanName = d[i].Row["PlanName"].ToString(); p.PlanState =int.Parse (d[i].Row["PlanState"].ToString()); p.IsOverRun = d[i].Row["IsOverRun"].ToString() == "True" ? true : false; p.IsDisabled = d[i].Row["IsDisabled"].ToString() == "True" ? true : false; p.DisabledType =int.Parse ( d[i].Row["DisabledType"].ToString()); p.DisabledTime = int.Parse ( d[i].Row["DisabledTime"].ToString()); p.DisabledDateTime = DateTime.Parse ( d[i].Row["DisabledDateTime"].ToString()); p.RunTaskPlanType = int.Parse ( d[i].Row["RunTaskPlanType"].ToString()); p.EnabledDateTime = d[i].Row["EnabledDateTime"].ToString(); p.RunOnesTime = d[i].Row["RunOnesTime"].ToString(); p.RunDayTime =d[i].Row["RunDayTime"].ToString(); p.RunAMTime = d[i].Row["RunAMTime"].ToString(); p.RunPMTime =d[i].Row["RunPMTime"].ToString(); p.RunWeeklyTime = d[i].Row["RunWeeklyTime"].ToString(); p.RunWeekly = d[i].Row["RunWeekly"].ToString(); p.RunTimeCount = d[i].Row["RunTimeCount"].ToString(); p.FirstRunTime = d[i].Row["FirstRunTime"].ToString(); p.RunInterval = d[i].Row["RunInterval"].ToString(); m_Plans.Add(p); } p = null; }
//public int GetPlanCount() //{ // return 0; //} //����һ���ƻ�,�ƻ��������� public void InsertPlan(cPlan NewPlan) { //�жϼƻ��ļ��Ƿ���ڣ�������������½� if (!IsExist()) NewIndexFile(); //�жϼƻ��Ƿ������������������Ҫ���������� cXmlIO xmlConfig = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\plan.xml"); DataView d = xmlConfig.GetData("descendant::Plans"); if (d != null) { for (int i = 0; i < d.Count; i++) { if (NewPlan.PlanName == d[i].Row["PlanName"].ToString()) { xmlConfig = null; throw new cSoukeyException("�Ѿ����ڴ˼ƻ������ļƻ����ƣ��ƻ����Ʋ����ظ���"); } } } string pXml = CreatePlanXml(NewPlan); xmlConfig.InsertElement("Plans", "Plan", pXml); xmlConfig.Save(); xmlConfig = null; }
//加载指定任务的信息 private void LoadTaskInfo(string FileName) { //根据一个任务名称装载一个任务 try { xmlConfig = new cXmlIO(FileName); //获取TaskClass节点 //TaskClass = xmlConfig.GetData("descendant::TaskClasses"); } catch (System.Exception ex) { if (!File.Exists(FileName)) { throw new System.IO.IOException("您指定的任务文件不存在!"); } else { throw ex; } } //加载任务信息 this.TaskID = Int64.Parse(xmlConfig.GetNodeValue("Task/BaseInfo/ID")); this.TaskName = xmlConfig.GetNodeValue("Task/BaseInfo/Name"); ///加载任务版本信息,注意:1.0中是不存在版本信息描述的,所以如果加载1.0的任务 ///会出错 try { this.TaskVersion = Single.Parse(xmlConfig.GetNodeValue("Task/BaseInfo/Version")); } catch (System.Exception) { this.TaskVersion = Single.Parse("1.0"); } if (TaskVersion != SupportTaskVersion) { throw new cSoukeyException("您加载任务的版本低于系统要求的版本,请对任务进行升级后重试!"); } this.TaskDemo = xmlConfig.GetNodeValue("Task/BaseInfo/TaskDemo"); this.TaskClass = xmlConfig.GetNodeValue("Task/BaseInfo/Class"); this.TaskType = xmlConfig.GetNodeValue("Task/BaseInfo/Type"); this.RunType = xmlConfig.GetNodeValue("Task/BaseInfo/RunType"); //因存的是相对路径,所以要加上系统路径 this.SavePath = Program.getPrjPath() + xmlConfig.GetNodeValue("Task/BaseInfo/SavePath"); this.UrlCount = int.Parse(xmlConfig.GetNodeValue("Task/BaseInfo/UrlCount").ToString()); this.ThreadCount = int.Parse(xmlConfig.GetNodeValue("Task/BaseInfo/ThreadCount")); this.Cookie = xmlConfig.GetNodeValue("Task/BaseInfo/Cookie"); this.DemoUrl = xmlConfig.GetNodeValue("Task/BaseInfo/DemoUrl"); this.StartPos = xmlConfig.GetNodeValue("Task/BaseInfo/StartPos"); this.EndPos = xmlConfig.GetNodeValue("Task/BaseInfo/EndPos"); this.WebCode = xmlConfig.GetNodeValue("Task/BaseInfo/WebCode"); this.IsLogin = (xmlConfig.GetNodeValue("Task/BaseInfo/IsLogin") == "True"? true :false); this.LoginUrl = xmlConfig.GetNodeValue("Task/BaseInfo/LoginUrl"); this.IsUrlEncode = (xmlConfig.GetNodeValue("Task/BaseInfo/IsUrlEncode") == "True" ? true : false); this.UrlEncode = xmlConfig.GetNodeValue("Task/BaseInfo/UrlEncode"); this.ExportType = xmlConfig.GetNodeValue("Task/Result/ExportType"); this.ExportFile = xmlConfig.GetNodeValue("Task/Result/ExportFileName"); this.DataSource = xmlConfig.GetNodeValue("Task/Result/DataSource"); this.DataTableName = xmlConfig.GetNodeValue("Task/Result/DataTableName"); this.InsertSql = xmlConfig.GetNodeValue("Task/Result/InsertSql"); this.ExportUrl = xmlConfig.GetNodeValue("Task/Result/ExportUrl"); this.ExportUrlCode = xmlConfig.GetNodeValue("Task/Result/ExportUrlCode"); this.ExportCookie = xmlConfig.GetNodeValue("Task/Result/ExportCookie"); //加载高级配置信息 this.GatherAgainNumber = int.Parse(xmlConfig.GetNodeValue("Task/Advance/GatherAgainNumber")); this.IsIgnore404 = (xmlConfig.GetNodeValue("Task/Advance/IsIgnore404") == "True" ? true : false); this.IsErrorLog = (xmlConfig.GetNodeValue("Task/Advance/IsErrorLog") == "True" ? true : false); this.IsDelRepRow = (xmlConfig.GetNodeValue("Task/Advance/IsDelRepeatRow") == "True" ? true : false); this.IsExportHeader = (xmlConfig.GetNodeValue("Task/Advance/IsExportHeader") == "True" ? true : false); this.IsTrigger = (xmlConfig.GetNodeValue("Task/Advance/IsTrigger") == "True" ? true : false); this.TriggerType = xmlConfig.GetNodeValue("Task/Advance/TriggerType"); DataView dw = new DataView(); int i; //加载Trigger信息 dw = xmlConfig.GetData("descendant::Trigger"); cTriggerTask tt; if (dw != null) { for (i = 0; i < dw.Count; i++) { tt = new cTriggerTask(); tt.RunTaskType = int.Parse(dw[i].Row["RunTaskType"].ToString()); tt.RunTaskName = dw[i].Row["RunTaskName"].ToString(); tt.RunTaskPara = dw[i].Row["RunTaskPara"].ToString(); this.TriggerTask.Add(tt); } } dw = null; dw = new DataView(); dw = xmlConfig.GetData("descendant::WebLinks"); cWebLink w; DataView dn; if (dw != null) { for (i = 0; i < dw.Count; i++) { w = new cWebLink(); w.id = i; w.Weblink = dw[i].Row["Url"].ToString(); if (dw[i].Row["IsNag"].ToString() == "True") { w.IsNavigation = true; } else { w.IsNavigation = false; } if (dw[i].Row["IsNextPage"].ToString() == "True") { w.IsNextpage = true; } else { w.IsNextpage = false; } w.NextPageRule = dw[i].Row["NextPageRule"].ToString(); w.IsGathered = int.Parse((dw[i].Row["IsGathered"].ToString() == null || dw[i].Row["IsGathered"].ToString() == "") ? "2031" : dw[i].Row["IsGathered"].ToString()); //加载导航规则 if (w.IsNavigation == true) { dn = dw[i].CreateChildView("WebLink_NavigationRules")[0].CreateChildView("NavigationRules_Rule"); cNavigRule nRule; for (int m = 0; m < dn.Count; m++) { nRule = new cNavigRule(); nRule.Url = dn[m].Row["Url"].ToString(); nRule.Level = int.Parse(dn[m].Row["Level"].ToString()); nRule.NavigRule = dn[m].Row["NagRule"].ToString(); w.NavigRules.Add(nRule); } } this.WebpageLink.Add(w); w = null; } } dw = null; dw = new DataView(); dw = xmlConfig.GetData("descendant::GatherRule"); Task.cWebpageCutFlag c; if (dw != null) { for (i = 0; i < dw.Count; i++) { c = new Task.cWebpageCutFlag(); c.Title = dw[i].Row["Title"].ToString(); c.DataType = int.Parse((dw[i].Row["DataType"].ToString() == null || dw[i].Row["DataType"].ToString() == "") ? "0" : dw[i].Row["DataType"].ToString()); c.StartPos = dw[i].Row["StartFlag"].ToString(); c.EndPos = dw[i].Row["EndFlag"].ToString(); c.LimitSign = int.Parse((dw[i].Row["LimitSign"].ToString() == null || dw[i].Row["LimitSign"].ToString() == "") ? "0" : dw[i].Row["LimitSign"].ToString()); //处理版本不同时造成的错误,捕获不处理 try { c.RegionExpression = dw[i].Row["RegionExpression"].ToString(); c.ExportLimit = int.Parse((dw[i].Row["ExportLimit"].ToString() == null || dw[i].Row["ExportLimit"].ToString() == "") ? "0" : dw[i].Row["ExportLimit"].ToString()); c.ExportExpression = dw[i].Row["ExportExpression"].ToString(); } catch (System.Exception) { } this.WebpageCutFlag.Add(c); c = null; } } dw = null; }
//���ص�������������ļ�����Ϣ public void LoadTaskRunData() { try { xmlConfig = new cXmlIO(Program.getPrjPath() + "Tasks\\TaskRun.xml"); } catch (System.Exception ex) { throw ex; } //��ȡTaskClass�ڵ� Tasks = xmlConfig.GetData("Tasks"); }
//����ִ�е�����ID����������Ϣ public void LoadSingleTask(Int64 TaskID) { try { xmlConfig = new cXmlIO(Program.getPrjPath() + "Tasks\\TaskRun.xml"); } catch (System.Exception ex) { throw ex; } //��ȡTaskClass�ڵ�,���ܷ��ص�Ҳ��DataView,������ֻ����һ����¼ //��������Ϊ�˸��õļ��ݷ��ʲ��� Tasks = xmlConfig.GetData("Tasks","TaskID",TaskID.ToString () ); }
public void GetTaskDataByClass(string ClassName) { string ClassPath ; if (ClassName == "") { ClassPath = Program.getPrjPath() + "Tasks"; } else { Task.cTaskClass tClass = new Task.cTaskClass(); ClassPath = tClass.GetTaskClassPathByName(ClassName) ; tClass = null; } m_TaskPath = ClassPath; xmlConfig = new cXmlIO(ClassPath + "\\index.xml"); //��ȡTaskClass�ڵ� Tasks = xmlConfig.GetData("TaskIndex"); }
//��ȡ��������Ŀ¼�µ�������������Ŀ¼ΪӦ�ó���·��\\tasks�� //�˷���Ϊ�̶����ݣ����ṩ�û��ɲ������κδ���� public void GetTaskDataByClass() { string ClassPath = Program.getPrjPath() + "tasks"; m_TaskPath = ClassPath; xmlConfig = new cXmlIO(ClassPath + "\\index.xml"); //��ȡTaskClass�ڵ� Tasks = xmlConfig.GetData("TaskIndex"); }
//����ָ���������Ϣ private void LoadTaskInfo(string FileName) { //����һ����������װ��һ������ try { xmlConfig = new cXmlIO(FileName); //��ȡTaskClass�ڵ� //TaskClass = xmlConfig.GetData("descendant::TaskClasses"); } catch (System.Exception ex) { if (!File.Exists(FileName)) { throw new System.IO.IOException("��ָ���������ļ������ڣ�"); } else { throw ex; } } //����������Ϣ this.TaskID =Int64.Parse ( xmlConfig.GetNodeValue("Task/BaseInfo/ID")); this.TaskName = xmlConfig.GetNodeValue("Task/BaseInfo/Name"); ///��������汾��Ϣ��ע�⣺1.0���Dz����ڰ汾��Ϣ�����ģ������������1.0������ ///����� try { this.TaskVersion = Single.Parse(xmlConfig.GetNodeValue("Task/BaseInfo/Version")); } catch (System.Exception ) { this.TaskVersion =Single.Parse ("1.0"); } if (TaskVersion != SupportTaskVersion) { throw new cSoukeyException("����������İ汾����ϵͳҪ��İ汾���������������������ԣ�"); } this.TaskDemo = xmlConfig.GetNodeValue("Task/BaseInfo/TaskDemo"); this.TaskClass = xmlConfig.GetNodeValue("Task/BaseInfo/Class"); this.TaskType=xmlConfig.GetNodeValue("Task/BaseInfo/Type"); this.RunType = xmlConfig.GetNodeValue("Task/BaseInfo/RunType"); //���������·��������Ҫ����ϵͳ·�� this.SavePath = Program.getPrjPath () + xmlConfig.GetNodeValue("Task/BaseInfo/SavePath"); this.UrlCount =int.Parse (xmlConfig.GetNodeValue("Task/BaseInfo/UrlCount").ToString ()); this.ThreadCount = int.Parse (xmlConfig.GetNodeValue("Task/BaseInfo/ThreadCount")); this.Cookie = xmlConfig.GetNodeValue("Task/BaseInfo/Cookie"); this.DemoUrl = xmlConfig.GetNodeValue("Task/BaseInfo/DemoUrl"); this.StartPos = xmlConfig.GetNodeValue("Task/BaseInfo/StartPos"); this.EndPos = xmlConfig.GetNodeValue("Task/BaseInfo/EndPos"); this.WebCode = xmlConfig.GetNodeValue("Task/BaseInfo/WebCode"); this.IsLogin =( xmlConfig.GetNodeValue("Task/BaseInfo/IsLogin")=="True"? true :false ); this.LoginUrl = xmlConfig.GetNodeValue("Task/BaseInfo/LoginUrl"); this.IsUrlEncode = (xmlConfig.GetNodeValue("Task/BaseInfo/IsUrlEncode") == "True" ? true : false); this.UrlEncode = xmlConfig.GetNodeValue("Task/BaseInfo/UrlEncode"); this.ExportType =xmlConfig.GetNodeValue("Task/Result/ExportType") ; this.ExportFile = xmlConfig.GetNodeValue("Task/Result/ExportFileName"); this.DataSource = xmlConfig.GetNodeValue("Task/Result/DataSource"); this.DataTableName = xmlConfig.GetNodeValue("Task/Result/DataTableName"); this.InsertSql = xmlConfig.GetNodeValue("Task/Result/InsertSql"); this.ExportUrl = xmlConfig.GetNodeValue("Task/Result/ExportUrl"); this.ExportUrlCode = xmlConfig.GetNodeValue("Task/Result/ExportUrlCode"); this.ExportCookie = xmlConfig.GetNodeValue("Task/Result/ExportCookie"); //���ظ�������Ϣ this.GatherAgainNumber= int.Parse (xmlConfig.GetNodeValue("Task/Advance/GatherAgainNumber")); this.IsIgnore404 = (xmlConfig.GetNodeValue("Task/Advance/IsIgnore404") == "True" ? true : false); this.IsErrorLog = (xmlConfig.GetNodeValue("Task/Advance/IsErrorLog") == "True" ? true : false); this.IsDelRepRow = (xmlConfig.GetNodeValue("Task/Advance/IsDelRepeatRow") == "True" ? true : false); this.IsExportHeader =( xmlConfig.GetNodeValue("Task/Advance/IsExportHeader") == "True" ? true : false); this.IsTrigger =( xmlConfig.GetNodeValue("Task/Advance/IsTrigger") == "True" ? true : false); this.TriggerType = xmlConfig.GetNodeValue("Task/Advance/TriggerType"); DataView dw = new DataView(); int i; //����Trigger��Ϣ dw = xmlConfig.GetData("descendant::Trigger"); cTriggerTask tt; if (dw != null) { for (i = 0; i < dw.Count; i++) { tt = new cTriggerTask(); tt.RunTaskType = int.Parse ( dw[i].Row["RunTaskType"].ToString()); tt.RunTaskName = dw[i].Row["RunTaskName"].ToString(); tt.RunTaskPara = dw[i].Row["RunTaskPara"].ToString(); this.TriggerTask.Add(tt); } } dw = null; dw = new DataView(); dw = xmlConfig.GetData("descendant::WebLinks"); cWebLink w; DataView dn; if (dw!=null) { for (i = 0; i < dw.Count; i++) { w = new cWebLink(); w.id = i; w.Weblink = dw[i].Row["Url"].ToString(); if (dw[i].Row["IsNag"].ToString() == "True") w.IsNavigation = true; else w.IsNavigation = false; if (dw[i].Row["IsNextPage"].ToString() == "True") w.IsNextpage = true; else w.IsNextpage = false; w.NextPageRule = dw[i].Row["NextPageRule"].ToString(); w.IsGathered = int.Parse((dw[i].Row["IsGathered"].ToString() == null || dw[i].Row["IsGathered"].ToString() == "") ? "2031" : dw[i].Row["IsGathered"].ToString()); //���ص������� if (w.IsNavigation == true) { dn = dw[i].CreateChildView("WebLink_NavigationRules")[0].CreateChildView("NavigationRules_Rule"); cNavigRule nRule; for (int m = 0; m < dn.Count; m++) { nRule = new cNavigRule(); nRule.Url = dn[m].Row["Url"].ToString(); nRule.Level = int.Parse(dn[m].Row["Level"].ToString()); nRule.NavigRule = dn[m].Row["NagRule"].ToString(); w.NavigRules.Add(nRule); } } this.WebpageLink.Add(w); w = null; } } dw = null; dw = new DataView(); dw = xmlConfig.GetData("descendant::GatherRule"); Task.cWebpageCutFlag c; if (dw != null) { for (i = 0; i < dw.Count; i++) { c = new Task.cWebpageCutFlag(); c.Title = dw[i].Row["Title"].ToString(); c.DataType = int.Parse((dw[i].Row["DataType"].ToString() == null || dw[i].Row["DataType"].ToString() == "") ? "0" : dw[i].Row["DataType"].ToString()); c.StartPos = dw[i].Row["StartFlag"].ToString(); c.EndPos = dw[i].Row["EndFlag"].ToString(); c.LimitSign = int.Parse((dw[i].Row["LimitSign"].ToString() == null || dw[i].Row["LimitSign"].ToString() == "") ? "0" : dw[i].Row["LimitSign"].ToString()); //����汾��ͬʱ��ɵĴ������� try { c.RegionExpression = dw[i].Row["RegionExpression"].ToString(); c.ExportLimit = int.Parse((dw[i].Row["ExportLimit"].ToString() == null || dw[i].Row["ExportLimit"].ToString() == "") ? "0" : dw[i].Row["ExportLimit"].ToString()); c.ExportExpression = dw[i].Row["ExportExpression"].ToString(); } catch (System.Exception) { } this.WebpageCutFlag.Add(c); c = null; } } dw=null; }
public void GetTaskDataByClass(int ClassID) { Task.cTaskClass tClass = new Task.cTaskClass(); string ClassPath = tClass.GetTaskClassPathByID(ClassID); m_TaskPath = ClassPath; tClass = null; xmlConfig = new cXmlIO(ClassPath + "\\index.xml"); //��ȡTaskClass�ڵ� Tasks = xmlConfig.GetData("TaskIndex"); }
//ָ����������������� /// <summary> /// ����������� /// </summary> /// <param name="FileName">�������������ļ�</param> /// <param name="IsBackup">�Ƿ�</param> /// <param name="IsTask">�Ƿ�Ϊϵͳ���������ϵͳ��������Ҫά��������Ϣ��������Ǿ�ֻ�����ļ�</param> public void UpdradeTask(string FileName ,bool IsBackup,bool IsSystemTask) { //�ж��Ƿ���б��� if (IsBackup == true) { if (File.Exists(FileName + ".bak")) File.Delete(FileName + ".bak"); File.Copy(FileName, FileName + ".bak"); } //���������ļ� cXmlIO Old_Task = new cXmlIO(FileName); Single TaskVersion =Single.Parse ("0"); cTask t = new cTask(); //�ж�����汾�� try { TaskVersion = Single.Parse(Old_Task.GetNodeValue("Task/BaseInfo/Version")); } catch (System.Exception) { TaskVersion = Single.Parse("1.0"); } if (TaskVersion >= this.SupportTaskVersion) { Old_Task = null; return; } //��ʼ�½�һ������ t.New(); #region �˲����������κΰ汾�����ڵ� t.TaskID = Int64.Parse(Old_Task.GetNodeValue("Task/BaseInfo/ID")); t.TaskName = Old_Task.GetNodeValue("Task/BaseInfo/Name"); t.TaskVersion = this.SupportTaskVersion; t.TaskDemo = Old_Task.GetNodeValue("Task/BaseInfo/TaskDemo"); t.TaskClass = Old_Task.GetNodeValue("Task/BaseInfo/Class"); t.TaskType = Old_Task.GetNodeValue("Task/BaseInfo/Type"); t.RunType = Old_Task.GetNodeValue("Task/BaseInfo/RunType"); //���������·��������Ҫ����ϵͳ·�� t.SavePath = Program.getPrjPath() + Old_Task.GetNodeValue("Task/BaseInfo/SavePath"); t.UrlCount = int.Parse(Old_Task.GetNodeValue("Task/BaseInfo/UrlCount").ToString()); t.ThreadCount = int.Parse(Old_Task.GetNodeValue("Task/BaseInfo/ThreadCount")); t.Cookie = Old_Task.GetNodeValue("Task/BaseInfo/Cookie"); t.DemoUrl = Old_Task.GetNodeValue("Task/BaseInfo/DemoUrl"); t.StartPos = Old_Task.GetNodeValue("Task/BaseInfo/StartPos"); t.EndPos = Old_Task.GetNodeValue("Task/BaseInfo/EndPos"); t.WebCode = Old_Task.GetNodeValue("Task/BaseInfo/WebCode"); t.IsLogin = (Old_Task.GetNodeValue("Task/BaseInfo/IsLogin") == "True" ? true : false); t.LoginUrl = Old_Task.GetNodeValue("Task/BaseInfo/LoginUrl"); t.IsUrlEncode = (Old_Task.GetNodeValue("Task/BaseInfo/IsUrlEncode") == "True" ? true : false); t.UrlEncode = Old_Task.GetNodeValue("Task/BaseInfo/UrlEncode"); #endregion //����������ݿ�ʼ�п��ܾͳ���������ش��� //����������1.2�汾�����ӵģ������á���㵼������������1.3�汾�г��ֵ� // if (Old_Task.GetNodeValue("Task/Result/ExportType") == "") t.ExportType = ((int)cGlobalParas.PublishType.PublishTxt).ToString(); else t.ExportType = Old_Task.GetNodeValue("Task/Result/ExportType"); if (Old_Task.GetNodeValue("Task/Result/ExportFileName") == "") t.ExportFile = Program.getPrjPath() + "data\\" + t.TaskName + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + ".txt"; else t.ExportFile = Old_Task.GetNodeValue("Task/Result/ExportFileName"); if (Old_Task.GetNodeValue("Task/Result/DataSource") == "") t.DataSource = ""; else t.DataSource = Old_Task.GetNodeValue("Task/Result/DataSource"); if (Old_Task.GetNodeValue("Task/Result/DataTableName") == "") t.DataTableName = ""; else t.DataTableName = Old_Task.GetNodeValue("Task/Result/DataTableName"); if (Old_Task.GetNodeValue("Task/Result/InsertSql") == "") t.InsertSql = ""; else t.InsertSql = Old_Task.GetNodeValue("Task/Result/InsertSql"); if (Old_Task.GetNodeValue("Task/Result/ExportUrl") == "") t.ExportUrl = ""; else t.ExportUrl = Old_Task.GetNodeValue("Task/Result/ExportUrl"); if (Old_Task.GetNodeValue("Task/Result/ExportUrlCode") == "") t.ExportUrlCode = ""; else t.ExportUrlCode = Old_Task.GetNodeValue("Task/Result/ExportUrlCode"); if (Old_Task.GetNodeValue("Task/Result/ExportCookie") == "") t.ExportCookie = ""; else t.ExportCookie = Old_Task.GetNodeValue("Task/Result/ExportCookie"); //�˲�����1.3�汾�д��ڵģ���Ҫ���� //���ظ�������Ϣ if (Old_Task.GetNodeValue("Task/Advance/GatherAgainNumber") == "") t.GatherAgainNumber = 3; else t.GatherAgainNumber = int.Parse(Old_Task.GetNodeValue("Task/Advance/GatherAgainNumber")); if (Old_Task.GetNodeValue("Task/Advance/IsIgnore404") == "") t.IsIgnore404 = true; else t.IsIgnore404 = (Old_Task.GetNodeValue("Task/Advance/IsIgnore404") == "True" ? true : false); if (Old_Task.GetNodeValue("Task/Advance/IsErrorLog") == "") t.IsErrorLog = false; else t.IsErrorLog = (Old_Task.GetNodeValue("Task/Advance/IsErrorLog") == "True" ? true : false); if (Old_Task.GetNodeValue("Task/Advance/IsDelRepeatRow") == "") t.IsDelRepRow = false; else t.IsDelRepRow = (Old_Task.GetNodeValue("Task/Advance/IsDelRepeatRow") == "True" ? true : false); if (Old_Task.GetNodeValue("Task/Advance/IsExportHeader") == "") t.IsExportHeader = true; else t.IsExportHeader = (Old_Task.GetNodeValue("Task/Advance/IsExportHeader") == "True" ? true : false); if (Old_Task.GetNodeValue("Task/Advance/IsTrigger") == "") t.IsTrigger = false; else t.IsTrigger = (Old_Task.GetNodeValue("Task/Advance/IsTrigger") == "True" ? true : false); if (Old_Task.GetNodeValue("Task/Advance/TriggerType")=="") t.TriggerType = ((int)cGlobalParas.TriggerType.GatheredRun).ToString(); else t.TriggerType = Old_Task.GetNodeValue("Task/Advance/TriggerType"); DataView dw = new DataView(); int i; //�˴������У�����Ҫ����Trigger��Ϣ����ǰ����汾�в����ڣ����������п��Բ����� //dw = Old_Task.GetData("descendant::Trigger"); //cTriggerTask tt; //if (dw != null) //{ // for (i = 0; i < dw.Count; i++) // { // tt = new cTriggerTask(); // tt.RunTaskType = int.Parse(dw[i].Row["RunTaskType"].ToString()); // tt.RunTaskName = dw[i].Row["RunTaskName"].ToString(); // tt.RunTaskPara = dw[i].Row["RunTaskPara"].ToString(); // t.TriggerTask.Add(tt); // } //} ////dw = null; ////dw = new DataView(); dw = Old_Task.GetData("descendant::WebLinks"); cWebLink w; DataView dn; if (dw != null) { for (i = 0; i < dw.Count; i++) { w = new cWebLink(); w.id = i; w.Weblink = dw[i].Row["Url"].ToString(); if (dw[i].Row["IsNag"].ToString() == "True") w.IsNavigation = true; else w.IsNavigation = false; if (dw[i].Row["IsNextPage"].ToString() == "True") w.IsNextpage = true; else w.IsNextpage = false; w.NextPageRule = dw[i].Row["NextPageRule"].ToString(); w.IsGathered = int.Parse((dw[i].Row["IsGathered"].ToString() == null || dw[i].Row["IsGathered"].ToString() == "") ? "2031" : dw[i].Row["IsGathered"].ToString()); if (dw[i].Row["IsNag"].ToString() == "True") { //�ڴ˴�����������������������ǰ�汾�д��ڵ���������ֻ��һ�㵼�� cNavigRule nRule = new cNavigRule(); nRule.Url = dw[i].Row["Url"].ToString(); nRule.Level =1; nRule.NavigRule = dw[i].Row["NagRule"].ToString(); w.NavigRules.Add(nRule); } else { } t.WebpageLink.Add(w); w = null; } } dw = null; dw = new DataView(); dw = Old_Task.GetData("descendant::GatherRule"); Task.cWebpageCutFlag c; if (dw != null) { for (i = 0; i < dw.Count; i++) { c = new Task.cWebpageCutFlag(); c.Title = dw[i].Row["Title"].ToString(); c.DataType = int.Parse((dw[i].Row["DataType"].ToString() == null || dw[i].Row["DataType"].ToString() == "") ? "0" : dw[i].Row["DataType"].ToString()); c.StartPos = dw[i].Row["StartFlag"].ToString(); c.EndPos = dw[i].Row["EndFlag"].ToString(); c.LimitSign = int.Parse((dw[i].Row["LimitSign"].ToString() == null || dw[i].Row["LimitSign"].ToString() == "") ? "0" : dw[i].Row["LimitSign"].ToString()); //����汾��ͬʱ��ɵĴ������� try { c.RegionExpression = dw[i].Row["RegionExpression"].ToString(); c.ExportLimit = int.Parse((dw[i].Row["ExportLimit"].ToString() == null || dw[i].Row["ExportLimit"].ToString() == "") ? "0" : dw[i].Row["ExportLimit"].ToString()); c.ExportExpression = dw[i].Row["ExportExpression"].ToString(); } catch (System.Exception) { } t.WebpageCutFlag.Add(c); c = null; } } dw = null; Old_Task = null; //��ȡ���ļ���Ŀ¼���� string FilePath = Path.GetDirectoryName(FileName); if (IsSystemTask == true) { t.DeleTask(FilePath, t.TaskName); t.Save(FilePath + "\\"); } else { t.SaveTaskFile(FilePath); } t = null; }
//指定任务进行升级操作 /// <summary> /// 升级任务操作 /// </summary> /// <param name="FileName">待升级的任务文件</param> /// <param name="IsBackup">是否备份</param> /// <param name="IsTask">是否为系统任务,如果是系统任务则需要维护分类信息,如果不是就只保存文件</param> public void UpdradeTask(string FileName, bool IsBackup, bool IsSystemTask) { //判断是否进行备份 if (IsBackup == true) { if (File.Exists(FileName + ".bak")) { File.Delete(FileName + ".bak"); } File.Copy(FileName, FileName + ".bak"); } //加载任务文件 cXmlIO Old_Task = new cXmlIO(FileName); Single TaskVersion = Single.Parse("0"); cTask t = new cTask(); //判断任务版本号 try { TaskVersion = Single.Parse(Old_Task.GetNodeValue("Task/BaseInfo/Version")); } catch (System.Exception) { TaskVersion = Single.Parse("1.0"); } if (TaskVersion >= this.SupportTaskVersion) { Old_Task = null; return; } //开始新建一个任务 t.New(); #region 此部分内容是任何版本都存在的 t.TaskID = Int64.Parse(Old_Task.GetNodeValue("Task/BaseInfo/ID")); t.TaskName = Old_Task.GetNodeValue("Task/BaseInfo/Name"); t.TaskVersion = this.SupportTaskVersion; t.TaskDemo = Old_Task.GetNodeValue("Task/BaseInfo/TaskDemo"); t.TaskClass = Old_Task.GetNodeValue("Task/BaseInfo/Class"); t.TaskType = Old_Task.GetNodeValue("Task/BaseInfo/Type"); t.RunType = Old_Task.GetNodeValue("Task/BaseInfo/RunType"); //因存的是相对路径,所以要加上系统路径 t.SavePath = Program.getPrjPath() + Old_Task.GetNodeValue("Task/BaseInfo/SavePath"); t.UrlCount = int.Parse(Old_Task.GetNodeValue("Task/BaseInfo/UrlCount").ToString()); t.ThreadCount = int.Parse(Old_Task.GetNodeValue("Task/BaseInfo/ThreadCount")); t.Cookie = Old_Task.GetNodeValue("Task/BaseInfo/Cookie"); t.DemoUrl = Old_Task.GetNodeValue("Task/BaseInfo/DemoUrl"); t.StartPos = Old_Task.GetNodeValue("Task/BaseInfo/StartPos"); t.EndPos = Old_Task.GetNodeValue("Task/BaseInfo/EndPos"); t.WebCode = Old_Task.GetNodeValue("Task/BaseInfo/WebCode"); t.IsLogin = (Old_Task.GetNodeValue("Task/BaseInfo/IsLogin") == "True" ? true : false); t.LoginUrl = Old_Task.GetNodeValue("Task/BaseInfo/LoginUrl"); t.IsUrlEncode = (Old_Task.GetNodeValue("Task/BaseInfo/IsUrlEncode") == "True" ? true : false); t.UrlEncode = Old_Task.GetNodeValue("Task/BaseInfo/UrlEncode"); #endregion //从下面的内容开始有可能就出现任务加载错误, //导出部分是1.2版本中增加的,高级设置、多层导航及触发器是1.3版本中出现的 // if (Old_Task.GetNodeValue("Task/Result/ExportType") == "") { t.ExportType = ((int)cGlobalParas.PublishType.PublishTxt).ToString(); } else { t.ExportType = Old_Task.GetNodeValue("Task/Result/ExportType"); } if (Old_Task.GetNodeValue("Task/Result/ExportFileName") == "") { t.ExportFile = Program.getPrjPath() + "data\\" + t.TaskName + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + ".txt"; } else { t.ExportFile = Old_Task.GetNodeValue("Task/Result/ExportFileName"); } if (Old_Task.GetNodeValue("Task/Result/DataSource") == "") { t.DataSource = ""; } else { t.DataSource = Old_Task.GetNodeValue("Task/Result/DataSource"); } if (Old_Task.GetNodeValue("Task/Result/DataTableName") == "") { t.DataTableName = ""; } else { t.DataTableName = Old_Task.GetNodeValue("Task/Result/DataTableName"); } if (Old_Task.GetNodeValue("Task/Result/InsertSql") == "") { t.InsertSql = ""; } else { t.InsertSql = Old_Task.GetNodeValue("Task/Result/InsertSql"); } if (Old_Task.GetNodeValue("Task/Result/ExportUrl") == "") { t.ExportUrl = ""; } else { t.ExportUrl = Old_Task.GetNodeValue("Task/Result/ExportUrl"); } if (Old_Task.GetNodeValue("Task/Result/ExportUrlCode") == "") { t.ExportUrlCode = ""; } else { t.ExportUrlCode = Old_Task.GetNodeValue("Task/Result/ExportUrlCode"); } if (Old_Task.GetNodeValue("Task/Result/ExportCookie") == "") { t.ExportCookie = ""; } else { t.ExportCookie = Old_Task.GetNodeValue("Task/Result/ExportCookie"); } //此部分是1.3版本中存在的,需要升级 //加载高级配置信息 if (Old_Task.GetNodeValue("Task/Advance/GatherAgainNumber") == "") { t.GatherAgainNumber = 3; } else { t.GatherAgainNumber = int.Parse(Old_Task.GetNodeValue("Task/Advance/GatherAgainNumber")); } if (Old_Task.GetNodeValue("Task/Advance/IsIgnore404") == "") { t.IsIgnore404 = true; } else { t.IsIgnore404 = (Old_Task.GetNodeValue("Task/Advance/IsIgnore404") == "True" ? true : false); } if (Old_Task.GetNodeValue("Task/Advance/IsErrorLog") == "") { t.IsErrorLog = false; } else { t.IsErrorLog = (Old_Task.GetNodeValue("Task/Advance/IsErrorLog") == "True" ? true : false); } if (Old_Task.GetNodeValue("Task/Advance/IsDelRepeatRow") == "") { t.IsDelRepRow = false; } else { t.IsDelRepRow = (Old_Task.GetNodeValue("Task/Advance/IsDelRepeatRow") == "True" ? true : false); } if (Old_Task.GetNodeValue("Task/Advance/IsExportHeader") == "") { t.IsExportHeader = true; } else { t.IsExportHeader = (Old_Task.GetNodeValue("Task/Advance/IsExportHeader") == "True" ? true : false); } if (Old_Task.GetNodeValue("Task/Advance/IsTrigger") == "") { t.IsTrigger = false; } else { t.IsTrigger = (Old_Task.GetNodeValue("Task/Advance/IsTrigger") == "True" ? true : false); } if (Old_Task.GetNodeValue("Task/Advance/TriggerType") == "") { t.TriggerType = ((int)cGlobalParas.TriggerType.GatheredRun).ToString(); } else { t.TriggerType = Old_Task.GetNodeValue("Task/Advance/TriggerType"); } DataView dw = new DataView(); int i; //此次升级中,不需要加载Trigger信息,以前任务版本中不存在,升级过程中可以不考虑 //dw = Old_Task.GetData("descendant::Trigger"); //cTriggerTask tt; //if (dw != null) //{ // for (i = 0; i < dw.Count; i++) // { // tt = new cTriggerTask(); // tt.RunTaskType = int.Parse(dw[i].Row["RunTaskType"].ToString()); // tt.RunTaskName = dw[i].Row["RunTaskName"].ToString(); // tt.RunTaskPara = dw[i].Row["RunTaskPara"].ToString(); // t.TriggerTask.Add(tt); // } //} ////dw = null; ////dw = new DataView(); dw = Old_Task.GetData("descendant::WebLinks"); cWebLink w; DataView dn; if (dw != null) { for (i = 0; i < dw.Count; i++) { w = new cWebLink(); w.id = i; w.Weblink = dw[i].Row["Url"].ToString(); if (dw[i].Row["IsNag"].ToString() == "True") { w.IsNavigation = true; } else { w.IsNavigation = false; } if (dw[i].Row["IsNextPage"].ToString() == "True") { w.IsNextpage = true; } else { w.IsNextpage = false; } w.NextPageRule = dw[i].Row["NextPageRule"].ToString(); w.IsGathered = int.Parse((dw[i].Row["IsGathered"].ToString() == null || dw[i].Row["IsGathered"].ToString() == "") ? "2031" : dw[i].Row["IsGathered"].ToString()); if (dw[i].Row["IsNag"].ToString() == "True") { //在此处理导航的升级操作,如果以前版本中存在导航规则,则只是一层导航 cNavigRule nRule = new cNavigRule(); nRule.Url = dw[i].Row["Url"].ToString(); nRule.Level = 1; nRule.NavigRule = dw[i].Row["NagRule"].ToString(); w.NavigRules.Add(nRule); } else { } t.WebpageLink.Add(w); w = null; } } dw = null; dw = new DataView(); dw = Old_Task.GetData("descendant::GatherRule"); Task.cWebpageCutFlag c; if (dw != null) { for (i = 0; i < dw.Count; i++) { c = new Task.cWebpageCutFlag(); c.Title = dw[i].Row["Title"].ToString(); c.DataType = int.Parse((dw[i].Row["DataType"].ToString() == null || dw[i].Row["DataType"].ToString() == "") ? "0" : dw[i].Row["DataType"].ToString()); c.StartPos = dw[i].Row["StartFlag"].ToString(); c.EndPos = dw[i].Row["EndFlag"].ToString(); c.LimitSign = int.Parse((dw[i].Row["LimitSign"].ToString() == null || dw[i].Row["LimitSign"].ToString() == "") ? "0" : dw[i].Row["LimitSign"].ToString()); //处理版本不同时造成的错误,捕获不处理 try { c.RegionExpression = dw[i].Row["RegionExpression"].ToString(); c.ExportLimit = int.Parse((dw[i].Row["ExportLimit"].ToString() == null || dw[i].Row["ExportLimit"].ToString() == "") ? "0" : dw[i].Row["ExportLimit"].ToString()); c.ExportExpression = dw[i].Row["ExportExpression"].ToString(); } catch (System.Exception) { } t.WebpageCutFlag.Add(c); c = null; } } dw = null; Old_Task = null; //获取此文件的目录传入 string FilePath = Path.GetDirectoryName(FileName); if (IsSystemTask == true) { t.DeleTask(FilePath, t.TaskName); t.Save(FilePath + "\\"); } else { t.SaveTaskFile(FilePath); } t = null; }
//��ȡһ��ִ�еļƻ� public cPlan GetSinglePlan(Int64 PlanID) { //�жϼƻ��ļ��Ƿ���ڣ�������������½� if (!IsExist()) NewIndexFile(); //�жϼƻ��Ƿ������������������Ҫ���������� cXmlIO xmlConfig = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\plan.xml"); DataView d= xmlConfig.GetData("Plans", "ID", PlanID.ToString ()); DataView t = d[0].CreateChildView("Plan_Tasks")[0].CreateChildView("Tasks_Task"); cPlan p = new cPlan(); p.PlanID = Int64.Parse(d[0].Row["ID"].ToString()); p.PlanName = d[0].Row["PlanName"].ToString(); p.PlanRemark = d[0].Row["PlanRemark"].ToString(); p.PlanState = int.Parse(d[0].Row["PlanState"].ToString()); p.IsOverRun = d[0].Row["IsOverRun"].ToString() == "True" ? true : false; p.IsDisabled = d[0].Row["IsDisabled"].ToString() == "True" ? true : false; p.DisabledType = int.Parse(d[0].Row["DisabledType"].ToString()); p.DisabledTime = int.Parse(d[0].Row["DisabledTime"].ToString()); p.DisabledDateTime = DateTime.Parse(d[0].Row["DisabledDateTime"].ToString()); p.RunTaskPlanType = int.Parse(d[0].Row["RunTaskPlanType"].ToString()); p.EnabledDateTime = d[0].Row["EnabledDateTime"].ToString(); p.RunOnesTime =d[0].Row["RunOnesTime"].ToString(); p.RunDayTime = d[0].Row["RunDayTime"].ToString(); p.RunAMTime = d[0].Row["RunAMTime"].ToString(); p.RunPMTime = d[0].Row["RunPMTime"].ToString(); p.RunWeeklyTime = d[0].Row["RunWeeklyTime"].ToString(); p.RunWeekly = d[0].Row["RunWeekly"].ToString(); p.RunTimeCount = d[0].Row["RunTimeCount"].ToString(); p.FirstRunTime = d[0].Row["FirstRunTime"].ToString(); p.RunInterval = d[0].Row["RunInterval"].ToString(); cTaskPlan tp; for (int i = 0; i < t.Count; i++) { tp = new cTaskPlan(); tp.RunTaskType =int.Parse ( t[i].Row["RunTaskType"].ToString()); tp.RunTaskName = t[i].Row["RunTaskName"].ToString(); tp.RunTaskPara = t[i].Row["RunTaskPara"].ToString(); p.RunTasks.Add(tp); } xmlConfig = null; return p; }
//���ؼƻ�,���ؼƻ���ʱ����Ҫ�Լƻ���״̬����ά�� private void IniCheckPlan() { try { cXmlIO xmlConfig = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\plan.xml"); DataView d = xmlConfig.GetData("descendant::Plans"); if (d == null) { return; } cPlan p; for (int i = 0; i < d.Count; i++) { p = new cPlan(); if (int.Parse(d[i].Row["PlanState"].ToString()) == (int)cGlobalParas.PlanState.Enabled) { p.PlanID = Int64.Parse(d[i].Row["ID"].ToString()); p.PlanName = d[i].Row["PlanName"].ToString(); p.PlanState = int.Parse(d[i].Row["PlanState"].ToString()); p.IsOverRun = d[i].Row["IsOverRun"].ToString() == "True" ? true : false; p.IsDisabled = d[i].Row["IsDisabled"].ToString() == "True" ? true : false; p.DisabledType = int.Parse(d[i].Row["DisabledType"].ToString()); p.DisabledTime = int.Parse(d[i].Row["DisabledTime"].ToString()); p.DisabledDateTime = DateTime.Parse(d[i].Row["DisabledDateTime"].ToString()); p.RunTaskPlanType = int.Parse(d[i].Row["RunTaskPlanType"].ToString()); p.EnabledDateTime = d[i].Row["EnabledDateTime"].ToString(); p.RunOnesTime = d[i].Row["RunOnesTime"].ToString(); p.RunDayTime = d[i].Row["RunDayTime"].ToString(); p.RunAMTime = d[i].Row["RunAMTime"].ToString(); p.RunPMTime = d[i].Row["RunPMTime"].ToString(); p.RunWeeklyTime = d[i].Row["RunWeeklyTime"].ToString(); p.RunWeekly = d[i].Row["RunWeekly"].ToString(); p.RunTimeCount = d[i].Row["RunTimeCount"].ToString(); p.FirstRunTime = d[i].Row["FirstRunTime"].ToString(); p.RunInterval = d[i].Row["RunInterval"].ToString(); cTaskPlan tp; DataView t = d[i].CreateChildView("Plan_Tasks")[0].CreateChildView("Tasks_Task"); for (int j = 0; j < t.Count; j++) { tp = new cTaskPlan(); tp.RunTaskType = int.Parse(t[j].Row["RunTaskType"].ToString()); tp.RunTaskName = t[j].Row["RunTaskName"].ToString(); tp.RunTaskPara = t[j].Row["RunTaskPara"].ToString(); p.RunTasks.Add(tp); } m_runTasks.Add(p); } } p = null; xmlConfig = null; //�Զ�ά���ƻ�״̬ AutoState(); } catch (System.Exception ex) { throw ex; } }
public void LoadLog() { if (!IsExist()) return ; cXmlIO xmlConfig = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\RunLog.xml"); m_dataLog = xmlConfig.GetData("descendant::Logs"); xmlConfig = null; }
//加载计划,加载计划的时候需要对计划的状态进行维护 private void IniCheckPlan() { try { cXmlIO xmlConfig = new cXmlIO(Program.getPrjPath() + "tasks\\plan\\plan.xml"); DataView d = xmlConfig.GetData("descendant::Plans"); if (d == null) { return; } cPlan p; for (int i = 0; i < d.Count; i++) { p = new cPlan(); if (int.Parse(d[i].Row["PlanState"].ToString()) == (int)cGlobalParas.PlanState.Enabled) { p.PlanID = Int64.Parse(d[i].Row["ID"].ToString()); p.PlanName = d[i].Row["PlanName"].ToString(); p.PlanState = int.Parse(d[i].Row["PlanState"].ToString()); p.IsOverRun = d[i].Row["IsOverRun"].ToString() == "True" ? true : false; p.IsDisabled = d[i].Row["IsDisabled"].ToString() == "True" ? true : false; p.DisabledType = int.Parse(d[i].Row["DisabledType"].ToString()); p.DisabledTime = int.Parse(d[i].Row["DisabledTime"].ToString()); p.DisabledDateTime = DateTime.Parse(d[i].Row["DisabledDateTime"].ToString()); p.RunTaskPlanType = int.Parse(d[i].Row["RunTaskPlanType"].ToString()); p.EnabledDateTime = d[i].Row["EnabledDateTime"].ToString(); p.RunOnesTime = d[i].Row["RunOnesTime"].ToString(); p.RunDayTime = d[i].Row["RunDayTime"].ToString(); p.RunAMTime = d[i].Row["RunAMTime"].ToString(); p.RunPMTime = d[i].Row["RunPMTime"].ToString(); p.RunWeeklyTime = d[i].Row["RunWeeklyTime"].ToString(); p.RunWeekly = d[i].Row["RunWeekly"].ToString(); p.RunTimeCount = d[i].Row["RunTimeCount"].ToString(); p.FirstRunTime = d[i].Row["FirstRunTime"].ToString(); p.RunInterval = d[i].Row["RunInterval"].ToString(); cTaskPlan tp; DataView t = d[i].CreateChildView("Plan_Tasks")[0].CreateChildView("Tasks_Task"); for (int j = 0; j < t.Count; j++) { tp = new cTaskPlan(); tp.RunTaskType = int.Parse(t[j].Row["RunTaskType"].ToString()); tp.RunTaskName = t[j].Row["RunTaskName"].ToString(); tp.RunTaskPara = t[j].Row["RunTaskPara"].ToString(); p.RunTasks.Add(tp); } m_runTasks.Add(p); } } p = null; xmlConfig = null; //自动维护计划状态 AutoState(); } catch (System.Exception ex) { throw ex; } }