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; } }
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; }