private void LoadTask(string TClassPath, string TaskName) { //ÿ�μ�������ǰ�������뽫�������ÿ� int i = 0; m_listNaviRules = null; m_listNaviRules = new List<cNavigRules>(); Task.cTask t = new Task.cTask(); try { t.LoadTask(TClassPath + "\\" + TaskName); } catch (cSoukeyException ex) { throw ex; } //��ʼ�ж�����汾�ţ��������汾�Ų�ƥ�䣬����������Ϣ�ļ��� if (this.SupportTaskVersion !=t.TaskVersion) { t = null; MessageBox.Show(rm.GetString("Info1"), rm.GetString("MessageboxInfo"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } this.tTask.Text =t.TaskName ; this.txtTaskDemo.Text = t.TaskDemo; if (t.TaskClass == "") { this.comTaskClass.SelectedIndex = 0; } else { this.comTaskClass.SelectedItem=t.TaskClass ; } this.TaskType.SelectedItem = cGlobalParas.ConvertName(int.Parse(t.TaskType)); this.comRunType.SelectedItem = cGlobalParas.ConvertName(int.Parse(t.RunType)); if (this.comRunType.SelectedIndex == 0) { //���ڵ������� switch ((cGlobalParas.PublishType)int.Parse(t.ExportType)) { case cGlobalParas.PublishType.PublishExcel : this.raExportExcel.Checked = true; break; case cGlobalParas.PublishType.PublishTxt : this.raExportTxt.Checked = true; break; case cGlobalParas.PublishType.PublishAccess: this.raExportAccess.Checked = true; break; case cGlobalParas.PublishType.PublishMSSql : this.raExportMSSQL.Checked = true; break; case cGlobalParas.PublishType .PublishMySql : this.raExportMySql.Checked = true; break; case cGlobalParas.PublishType .PublishWeb : this.raExportWeb.Checked = true; break; default : break; } this.txtFileName.Text = t.ExportFile; this.txtDataSource.Text = t.DataSource; this.comTableName.Text = t.DataTableName; this.txtInsertSql.Text = t.InsertSql; this.txtExportUrl.Text = t.ExportUrl; if (t.ExportUrlCode == null || t.ExportUrlCode =="") this.comExportUrlCode.SelectedIndex = 0; else this.comExportUrlCode.SelectedItem = cGlobalParas.ConvertName(int.Parse(t.ExportUrlCode)); this.txtExportCookie.Text = t.ExportCookie; } else { //���ɼ����� this.groupBox4.Enabled = false; this.txtFileName.Text = ""; this.comTableName.Text = ""; } this.txtSavePath.Text = t.SavePath; this.udThread.Value = t.ThreadCount; this.txtStartPos.Text = t.StartPos; this.txtEndPos.Text = t.EndPos; this.txtWeblinkDemo.Text = t.DemoUrl; this.txtCookie.Text = t.Cookie; this.comWebCode.SelectedItem = cGlobalParas.ConvertName(int.Parse (t.WebCode)); this.IsLogin.Checked = t.IsLogin; this.txtLoginUrl.Text = t.LoginUrl; this.IsUrlEncode.Checked = t.IsUrlEncode; if (t.UrlEncode == "") { this.comUrlEncode.SelectedIndex = -1; } else { this.comUrlEncode.SelectedItem = cGlobalParas.ConvertName(int.Parse(t.UrlEncode)); } //���ظ����� this.udAgainNumber.Value = t.GatherAgainNumber; this.IsIgnore404.Checked = t.IsIgnore404; this.IsSaveErrorLog.Checked = t.IsErrorLog; this.IsDelRepRow.Checked = t.IsDelRepRow; this.IsIncludeHeader.Checked = t.IsExportHeader; this.IsStartTrigger.Checked = t.IsTrigger; if (t.TriggerType == ((int)cGlobalParas.TriggerType.GatheredRun).ToString ()) this.raGatheredRun.Checked = true; else if (t.TriggerType == ((int)cGlobalParas.TriggerType.PublishedRun).ToString ()) this.raPublishedRun.Checked = true; //������������ if (this.IsStartTrigger.Checked == true) { ListViewItem litem; for (i = 0; i <t.TriggerTask.Count ; i++) { litem = new ListViewItem(); litem.Text = cGlobalParas.ConvertName(t.TriggerTask[i].RunTaskType); if (t.TriggerTask[i].RunTaskType == (int)cGlobalParas.RunTaskType.DataTask) litem.SubItems.Add(cGlobalParas.ConvertName(int.Parse(t.TriggerTask[i].RunTaskName))); else litem.SubItems.Add(t.TriggerTask[i].RunTaskName); litem.SubItems.Add(t.TriggerTask[i].RunTaskPara); this.listTask.Items.Add(litem); } } ListViewItem item; for (i = 0; i < t.WebpageLink.Count; i++) { item=new ListViewItem (); if (t.WebpageLink[i].IsNavigation == true) { cNavigRules cns = new cNavigRules(); cns.Url = t.WebpageLink[i].Weblink.ToString(); cns.NavigRule = t.WebpageLink[i].NavigRules; //for (int m=0;m<t.WebpageLink [i].NavigRules.Count;m++) //{ // cn=new cNavigRule (); // cn.Url =t.WebpageLink[i].NavigRules[m].Url ; // cn.Level = t.WebpageLink[i].NavigRules[m].Level; // cn.IsOppUrl = t.WebpageLink[i].NavigRules[m].IsOppUrl; // cn.NavigRule = t.WebpageLink[i].NavigRules[m].NavigRule; // cns.NavigRule.Add(cn); //} m_listNaviRules.Add(cns); } item.Name =t.WebpageLink[i].id.ToString (); item.Text =t.WebpageLink[i].Weblink.ToString (); if (t.WebpageLink[i].IsNavigation == true) { item.SubItems.Add("Y"); item.SubItems.Add(t.WebpageLink[i].NavigRules.Count.ToString ()); } else { item.SubItems.Add("N"); item.SubItems.Add("0"); } item.SubItems.Add(t.WebpageLink[i].NextPageRule); item.SubItems.Add(gUrl.GetUrlCount(t.WebpageLink[i].Weblink.ToString ()).ToString ()); this.listWeblink.Items.Add (item); item=null; } for (i = 0; i < t.WebpageCutFlag.Count ; i++) { item=new ListViewItem() ; item.Name =t.WebpageCutFlag[i].id.ToString (); item.Text =t.WebpageCutFlag[i].Title.ToString (); item.SubItems.Add(cGlobalParas.ConvertName (t.WebpageCutFlag[i].DataType) ); item.SubItems.Add (t.WebpageCutFlag[i].StartPos.ToString ()); item.SubItems.Add (t.WebpageCutFlag[i].EndPos .ToString ()); item.SubItems.Add(cGlobalParas.ConvertName (t.WebpageCutFlag[i].LimitSign)); item.SubItems.Add(t.WebpageCutFlag [i].RegionExpression ); if ((int)t.WebpageCutFlag[i].ExportLimit == 0) item.SubItems.Add(""); else item.SubItems.Add(cGlobalParas.ConvertName(t.WebpageCutFlag[i].ExportLimit)); item.SubItems.Add(t.WebpageCutFlag [i].ExportExpression ); this.listWebGetFlag.Items.Add(item); item=null; } t=null ; }
public void AutoAddTask() { //��ȡ���з��࣬Ȼ����ݷ���������� cTaskClass xmlTClass = new cTaskClass(); cTaskIndex xmlTasks; //��ȡ���ж��ٸ�������� int TClassCount = xmlTClass.GetTaskClassCount(); for (int i = 0; i < TClassCount; i++) { xmlTasks = new cTaskIndex(); //��ȡ�˷����¹��й��ٸ����� xmlTasks.GetTaskDataByClass(xmlTClass.GetTaskClassName(i)); int count = xmlTasks.GetTaskClassCount(); cTask t; ListViewItem Litem; for (int j = 0; j < count; j++) { t = new cTask(); try { t.LoadTask(xmlTClass.GetTaskClassPathByName(xmlTClass.GetTaskClassName(i)) + "\\" + xmlTasks.GetTaskName(j) + ".xml"); t = null; } catch (cSoukeyException) { Litem = new ListViewItem(); Litem.ImageIndex = 0; Litem.Text = "�ȴ�����"; Litem.SubItems.Add(xmlTasks.GetTaskName(j)); Litem.SubItems.Add(t.TaskVersion.ToString()); Litem.SubItems.Add(xmlTClass.GetTaskClassName(i)); Litem.SubItems.Add(xmlTClass.GetTaskClassPathByName(xmlTClass.GetTaskClassName(i))); Litem.SubItems.Add(""); //���½�������Ϣ m_sender.BeginInvoke(m_senderDelegate, new object[] { TClassCount + count, j + i, Litem, false }); Application.DoEvents(); } catch (System.Exception ex) { } } //���½�������Ϣ m_sender.BeginInvoke(m_senderDelegate, new object[] { TClassCount, i, null, false }); } m_sender.BeginInvoke(m_senderDelegate, new object[] { TClassCount, TClassCount,null, true }); xmlTClass = null; }
private void AddUpgradeTask(string FileName) { cTask t = new cTask(); ListViewItem Litem; try { t.LoadTask(FileName); t = null; MessageBox.Show(rm.GetString("Info106"), rm.GetString("MessageboxInfo"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } catch (cSoukeyException) { Litem = new ListViewItem(); Litem.ImageIndex = 0; Litem.Text = "�ȴ�����"; Litem.SubItems.Add(t.TaskName); Litem.SubItems.Add(t.TaskVersion.ToString()); Litem.SubItems.Add(""); Litem.SubItems.Add(Path.GetDirectoryName (FileName )); Litem.SubItems.Add(""); this.listTask.Items.Add(Litem); Application.DoEvents(); } catch (System.Exception ex) { MessageBox.Show(rm.GetString("Info107") + ex.Message, rm.GetString("MessageboxInfo"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } }
private void ImportTask() { //֧��ͬʱ���������� this.openFileDialog1.Title = rm.GetString ("Info44"); openFileDialog1.InitialDirectory = Program.getPrjPath() + "tasks"; openFileDialog1.Filter = "Soukey Task Files(*.xml)|*.xml"; if (this.openFileDialog1.ShowDialog() == DialogResult.Cancel) { return; } string FileName = this.openFileDialog1.FileName; string TaskClass = ""; string NewFileName = ""; //��֤�����ʽ�Ƿ���ȷ try { Task.cTask t = new Task.cTask(); t.LoadTask(FileName); if (t.TaskName != "") { NewFileName = t.TaskName + ".xml"; } if (t.TaskClass != "") { TaskClass = t.TaskClass.ToString(); } //��������ķ��ർ��ָ����Ŀ¼ string TaskPath = Program.getPrjPath() + "tasks\\"; if (TaskClass != "") { TaskPath += TaskClass ; } if (NewFileName == "") { NewFileName = "task" + DateTime.Now.ToFileTime().ToString() + ".xml"; } if (FileName == TaskPath + NewFileName) { MessageBox.Show(rm.GetString("Info45"), rm.GetString ("MessageboxInfo"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } Task.cTaskClass cTClass = new Task.cTaskClass(); if (!cTClass.IsExist(TaskClass) && TaskClass != "") { //��ʾ��һ����������� int TaskClassID = cTClass.AddTaskClass(TaskClass, TaskPath); cTClass = null; //�������νṹ���������ڵ� TreeNode newNode = new TreeNode(); newNode.Tag = TaskPath; newNode.Name = "C" + TaskClassID; newNode.Text = TaskClass; newNode.ImageIndex = 0; newNode.SelectedImageIndex = 0; this.treeMenu.Nodes["nodTaskClass"].Nodes.Add(newNode); newNode = null; } try { System.IO.File.Copy(FileName, TaskPath + "\\" + NewFileName); } catch (System.IO.IOException) { t = null; MessageBox.Show(rm.GetString("Info46"), rm.GetString("MessageboxInfo"), MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //�������������ļ� t.InsertTaskIndex(TaskPath); t = null; MessageBox.Show(rm.GetString ("Info47") + TaskClass, rm.GetString("MessageboxInfo"), MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (cSoukeyException ) { if (MessageBox.Show(rm.GetString("Quaere17"), rm.GetString("MessageboxQuaere"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { frmUpgradeTask fu = new frmUpgradeTask(FileName); fu.ShowDialog(); fu.Dispose(); fu = null; } return; } catch (System.Exception ex) { MessageBox.Show(rm.GetString("Info48") + ex.Message, rm.GetString ("MessageboxError"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }