예제 #1
0
        private void OnDoubleClick(object sender, EventArgs e)
        {
            try
            {
                TaskNode tn = this.SelectedNode as TaskNode;
                if (tn != null)
                {
                    TaskEventArgs te = new TaskEventArgs();
                    te.Task = tn.Task;
                    OnOpenTaskEditor(te);
                    return;
                }

                OperationNode on = this.SelectedNode as OperationNode;
                if (on != null)
                {
                    AccountEventArgs te = new AccountEventArgs();
                    tn         = on.Parent as TaskNode;
                    te.Group   = tn.Task.GroupName;
                    te.Account = on.Operation.Account;
                    OnOpenAccount(te);
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.ShowMessageBox(TaskConstants.EXCEPTION_MODULE, ex);
            }
        }
예제 #2
0
        public void RefreshTaskNode(string taskid, string taskname)
        {
            foreach (TaskNode tasknode in base.Nodes[0].Nodes)
            {
                if (tasknode.Task.TaskId == taskid && tasknode.Task.TaskName == taskname)
                {
                    TaskEventArgs te = new TaskEventArgs();
                    te.Operations = new Collection <OperationInfo>();
                    TaskInfo task = ConfigCtrl.GetTask(tasknode.Task.TaskId, tasknode.Task.TaskName, false);
                    if (task == null)
                    {
                        MessageBox.Show("读取任务配置文件失败!", Constants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    tasknode.Task = task;
                    te.Task       = task;
                    tasknode.Nodes.Clear();
                    foreach (AccountInfo account in task.Accounts)
                    {
                        OperationInfo op = ConfigCtrl.GetOperation(task.GroupName, account);
                        OperationNode on = new OperationNode(op);
                        tasknode.Nodes.Add(on);
                        te.Operations.Add(op);
                    }
                    OnTaskNodeSelected(te);

                    break;
                }
            }
        }
예제 #3
0
        public void InitialNodes()
        {
            //set images
            imageListIcon.ColorDepth = ColorDepth.Depth32Bit;//不然图片会失真,周围会有黑线
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_TASKS));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_TASK));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_ADDTASK));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_START));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_PAUSE));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_STOP));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_DELETE));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_OPERATION));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_TASKSTART));
            imageListIcon.Images.Add(ImageCtrl.GetIconFromResx(TaskConstants.IMAGE_REFRESH));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_USER));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_XML));

            this.ImageList = imageListIcon;

            //set nodes
            base.Nodes.Clear();

            //build Root node
            BaseNode Root = new BaseNode("所有任务");

            base.Nodes.Add(Root);

            //build Task node
            Collection <TaskInfo> tasks = ConfigCtrl.GetTasks();

            foreach (TaskInfo task in tasks)
            {
                if (task != null)
                {
                    TaskNode tn = new TaskNode(task);
                    Root.Nodes.Add(tn);
                    foreach (AccountInfo account in task.Accounts)
                    {
                        OperationInfo operation = ConfigCtrl.GetOperation(task.GroupName, account);
                        OperationNode on        = new OperationNode(operation);
                        tn.Nodes.Add(on);
                    }
                    //如果正在执行,保持箭头图标
                    if (_executingTaskIdList.Contains(task.TaskId))
                    {
                        tn.ImageIndex         = DataConvert.GetInt32(IconType.TaskStart);
                        tn.SelectedImageIndex = DataConvert.GetInt32(IconType.TaskStart);
                    }
                }
            }

            if (Root.Nodes.Count > 0)
            {
                Root.Expand();
            }
        }
예제 #4
0
 private void OnRefreshOperationsClick(object sender, EventArgs e)
 {
     try
     {
         TaskNode tn = this.SelectedNode as TaskNode;
         if (tn != null)
         {
             tn.Nodes.Clear();
             TaskInfo task = ConfigCtrl.GetTask(tn.Task.TaskId, tn.Task.TaskName, false);
             foreach (AccountInfo account in task.Accounts)
             {
                 OperationInfo operation = ConfigCtrl.GetOperation(task.GroupName, account);
                 OperationNode an        = new OperationNode(operation);
                 tn.Nodes.Add(an);
             }
         }
     }
     catch (Exception ex)
     {
         ErrorHandler.ShowMessageBox(TaskConstants.EXCEPTION_MODULE, ex);
     }
 }
예제 #5
0
        private void TaskTree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            try
            {
                if (e.Node is TaskNode)
                {
                    TaskNode      tn = e.Node as TaskNode;
                    TaskEventArgs te = new TaskEventArgs();
                    if (tn != null)
                    {
                        te.Task = ConfigCtrl.GetTask(tn.Task.TaskId, tn.Task.TaskName, false);

                        te.Operations = new Collection <OperationInfo>();
                        foreach (AccountInfo account in te.Task.Accounts)
                        {
                            te.Operations.Add(ConfigCtrl.GetOperation(te.Task.GroupName, account));
                        }

                        //te.Task = tn.Task;
                        //te.Operations = new Collection<OperationInfo>();
                        //foreach (OperationNode on in tn.Nodes)
                        //{
                        //    te.Operations.Add(on.Operation);
                        //}
                    }
                    else
                    {
                        te.Task = null;
                    }
                    OnTaskNodeSelected(te);
                }
                else if (this.SelectedNode is TaskNode)
                {
                    TaskNode      tn = this.SelectedNode as TaskNode;
                    TaskEventArgs te = new TaskEventArgs();
                    if (tn != null)
                    {
                        te.Task       = tn.Task;
                        te.Operations = new Collection <OperationInfo>();
                        foreach (OperationNode on in tn.Nodes)
                        {
                            te.Operations.Add(on.Operation);
                        }
                    }
                    else
                    {
                        te.Task = null;
                    }
                    OnTaskNodeSelected(te);
                }
                else if (this.SelectedNode is OperationNode)
                {
                    OperationNode      on = this.SelectedNode as OperationNode;
                    OperationEventArgs oe = new OperationEventArgs();
                    if (on != null)
                    {
                        oe.Operation = on.Operation;
                    }
                    else
                    {
                        oe.Operation = null;
                    }
                    OnOperationNodeSelected(oe);
                }
                else if (this.SelectedNode is BaseNode)
                {
                    BaseNode bn = this.SelectedNode as BaseNode;
                    if (bn != null)
                    {
                        RootNodeEventArgs re = new RootNodeEventArgs();
                        re.Tasks = new Collection <TaskInfo>();
                        foreach (TaskNode tasknode in bn.Nodes)
                        {
                            re.Tasks.Add(tasknode.Task);
                        }
                        OnRootNodeSelected(re);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.ShowMessageBox(TaskConstants.EXCEPTION_MODULE, ex);
            }
        }
예제 #6
0
 private void OnRefreshOperationsClick(object sender, EventArgs e)
 {
     try
     {
         TaskNode tn = this.SelectedNode as TaskNode;
         if (tn != null)
         {
             tn.Nodes.Clear();
             TaskInfo task = ConfigCtrl.GetTask(tn.Task.TaskId, tn.Task.TaskName, false);
             foreach (AccountInfo account in task.Accounts)
             {
                 OperationInfo operation = ConfigCtrl.GetOperation(task.GroupName, account);
                 OperationNode an = new OperationNode(operation);
                 tn.Nodes.Add(an);
             }
         }
     }
     catch (Exception ex)
     {
         ErrorHandler.ShowMessageBox(TaskConstants.EXCEPTION_MODULE, ex);
     }
 }
예제 #7
0
        public void RefreshTaskNode(string taskid, string taskname)
        {
            foreach (TaskNode tasknode in base.Nodes[0].Nodes)
            {
                if (tasknode.Task.TaskId == taskid && tasknode.Task.TaskName == taskname)
                {
                    TaskEventArgs te = new TaskEventArgs();
                    te.Operations = new Collection<OperationInfo>();
                    TaskInfo task = ConfigCtrl.GetTask(tasknode.Task.TaskId, tasknode.Task.TaskName, false);
                    if (task == null)
                    {
                        MessageBox.Show("读取任务配置文件失败!", Constants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    tasknode.Task = task;
                    te.Task = task;
                    tasknode.Nodes.Clear();
                    foreach (AccountInfo account in task.Accounts)
                    {
                        OperationInfo op = ConfigCtrl.GetOperation(task.GroupName, account);
                        OperationNode on = new OperationNode(op);
                        tasknode.Nodes.Add(on);
                        te.Operations.Add(op);
                    }
                    OnTaskNodeSelected(te);

                    break;
                }
            }
        }
예제 #8
0
        public void InitialNodes()
        {
            //set images
            imageListIcon.ColorDepth = ColorDepth.Depth32Bit;//不然图片会失真,周围会有黑线
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_TASKS));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_TASK));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_ADDTASK));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_START));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_PAUSE));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_STOP));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_DELETE));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_OPERATION));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_TASKSTART));
            imageListIcon.Images.Add(ImageCtrl.GetIconFromResx(TaskConstants.IMAGE_REFRESH));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_USER));
            imageListIcon.Images.Add(IconCtrl.GetIconFromResx(TaskConstants.ICON_XML));

            this.ImageList = imageListIcon;  

            //set nodes
            base.Nodes.Clear();

            //build Root node
            BaseNode Root = new BaseNode("所有任务");
            base.Nodes.Add(Root);

            //build Task node
            Collection<TaskInfo> tasks = ConfigCtrl.GetTasks();
            foreach (TaskInfo task in tasks)
            {
                if (task != null)
                {
                    TaskNode tn = new TaskNode(task);
                    Root.Nodes.Add(tn);
                    foreach (AccountInfo account in task.Accounts)
                    {
                        OperationInfo operation = ConfigCtrl.GetOperation(task.GroupName, account);
                        OperationNode on = new OperationNode(operation);
                        tn.Nodes.Add(on);
                    }
                    //如果正在执行,保持箭头图标
                    if (_executingTaskIdList.Contains(task.TaskId))
                    {
                        tn.ImageIndex = DataConvert.GetInt32(IconType.TaskStart);
                        tn.SelectedImageIndex = DataConvert.GetInt32(IconType.TaskStart);
                    }                    
                }
            }

            if (Root.Nodes.Count > 0)
            {
                Root.Expand();
            }            
        }