Example #1
0
 void taskTree_OpenTaskConfigFileEvent(object sender, TaskEventArgs e)
 {
     try
     {
         //get the top form
         MainForm mainform = this.TopLevelControl as MainForm;
         if (mainform != null)
             mainform.OpenTaskConfigFile(e.Task);
     }
     catch (Exception ex)
     {
         Program.ShowMessageBox("FrmTaskManager", ex);
     }
 }
Example #2
0
 private void taskTree_TaskNameChangedEvent(object sender, Johnny.CodeGenerator.Controls.TaskTree.TaskEventArgs e)
 {
     try
     {
         //get the top form
         MainForm mainform = this.TopLevelControl as MainForm;
         if (mainform != null)
         {
             mainform.ChangeTaskEditTabName(e.Task);
         }
     }
     catch (Exception ex)
     {
         Program.ShowMessageBox("FrmTaskManager", ex);
     }
 }
Example #3
0
        private void taskTree_StartTaskEvent(object sender, Johnny.CodeGenerator.Controls.TaskTree.TaskEventArgs e)
        {
            try
            {
                string taskid   = e.Task.TaskId;
                string taskname = e.Task.TaskName;

                Thread startThread;
                //if the thread is existing.
                if (_threadList.TryGetValue(taskid, out startThread))
                {
                    _threadList.Remove(taskid);
                }
                TaskManager task;
                if (_taskManagerList.TryGetValue(taskid, out task))
                {
                    _taskManagerList.Remove(taskid);
                }

                startThread = new System.Threading.Thread(new System.Threading.ThreadStart(delegate
                {
                    task = new TaskManager(taskid, taskname);
                    task.MessageChanged += delegate(string caption, string key, string message)
                    {
                        if (MessageChanged != null)
                        {
                            MessageChanged(caption, key, message);
                        }
                    };
                    task.ExecutionFinished += delegate(string stoppedtaskid, string stoppedtaskname)
                    {
                        taskTree.SetStoppedIcon(stoppedtaskid, stoppedtaskname);
                    };
                    _taskManagerList.Add(taskid, task);
                    task.TaskStart();
                }));

                startThread.IsBackground = true;
                startThread.Start();
                _threadList.Add(taskid, startThread);
            }
            catch (Exception ex)
            {
                Program.ShowMessageBox("FrmTaskManager", ex);
            }
        }
Example #4
0
 private void taskTree_StopTaskEvent(object sender, Johnny.CodeGenerator.Controls.TaskTree.TaskEventArgs e)
 {
     try
     {
         if (TaskStopped != null)
         {
             TaskStopped(e.Task.TaskId, e.Task.TaskName);
         }
         Thread currentThread;
         if (_threadList.TryGetValue(e.Task.TaskId, out currentThread))
         {
             _taskManagerList.Remove(e.Task.TaskId);
             currentThread.Abort();
             currentThread.Interrupt();
         }
     }
     catch (Exception ex)
     {
         Program.ShowMessageBox("FrmTaskManager", ex);
     }
 }
        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);

                        /*
                         * 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(CGConstants.MODULE_TASKTREE, ex);
            }
        }