Exemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (m_TaskInfo == null)
            {
                return;
            }

            U50TaskInfo taskInfo = new U50TaskInfo();

            taskInfo.Guid    = m_TaskInfo.Guid;
            taskInfo.Name    = m_TaskInfo.Name;
            taskInfo.General = m_TaskBControl.GetTaskGeneral();
            taskInfo.Request = m_TaskCControl.GetTaskRequest();
            taskInfo.Policy  = m_TaskDControl.GetTaskPolicy();
            taskInfo.Result  = m_TaskEControl.GetTaskResult();

            U50GlobalSetting.ScanTaskThread(taskInfo);

            this.button3.Enabled = false;
            this.Timer1.Enabled  = true;

            //TaskPolicy taskPolicy = GetTaskPolicy();

            ////ReportInfo reportInfo = ScanTask( taskPolicy );
            //ReportInfo reportInfo = new ReportInfo();

            //for ( int i = 0; i < reportInfo.ReportArray.Length; i++ )
            //{
            //    Report report = reportInfo.ReportArray[i];
            //}
        }
        private void ButtonOK_Click(object sender, EventArgs e)
        {
            foreach (var item in m_DeleteTreeNode)
            {
                UserControl outConfigControl = null;
                if (this.m_AllConfigControlInfo.TryGetValue(item.Nodes[0], out outConfigControl) == true)
                {
                    if (outConfigControl == m_CurrentConfigControl)
                    {
                        this.TreeView.SelectedNode = m_MainTreeNodeSub;
                    }

                    this.Panel.Controls.Remove(outConfigControl);
                }

                if (this.m_AllConfigControlInfo.TryGetValue(item.Nodes[1], out outConfigControl) == true)
                {
                    if (outConfigControl == m_CurrentConfigControl)
                    {
                        this.TreeView.SelectedNode = m_MainTreeNodeSub;
                    }

                    this.Panel.Controls.Remove(outConfigControl);
                }

                if (this.m_AllConfigControlInfo.TryGetValue(item.Nodes[2], out outConfigControl) == true)
                {
                    if (outConfigControl == m_CurrentConfigControl)
                    {
                        this.TreeView.SelectedNode = m_MainTreeNodeSub;
                    }

                    this.Panel.Controls.Remove(outConfigControl);
                }

                if (this.m_AllConfigControlInfo.TryGetValue(item.Nodes[3], out outConfigControl) == true)
                {
                    if (outConfigControl == m_CurrentConfigControl)
                    {
                        this.TreeView.SelectedNode = m_MainTreeNodeSub;
                    }

                    this.Panel.Controls.Remove(outConfigControl);
                }

                this.m_AllConfigControlInfo.Remove(item.Nodes[0]);
                this.m_AllConfigControlInfo.Remove(item.Nodes[1]);
                this.m_AllConfigControlInfo.Remove(item.Nodes[2]);
                this.m_AllConfigControlInfo.Remove(item.Nodes[3]);
                this.m_AllConfigControlInfo.Remove(item);

                U50TaskInfo outTaskInfo = null;
                if (this.m_TreeNodeTaskInfo.TryGetValue(item, out outTaskInfo) == true)
                {
                    this.m_TreeNodeTaskInfo.Remove(item);
                    TaskManager.Instance.RemoveTaskInfoByGuid(outTaskInfo.Guid);
                }
            }

            foreach (var item in m_TreeNodeTaskInfo)
            {
                UserControl outTaskControl = null;
                if (m_AllConfigControlInfo.TryGetValue(item.Key.Nodes[0], out outTaskControl) == false)
                {
                    continue;
                }

                TaskBControl taskBControl = outTaskControl as TaskBControl;
                if (taskBControl == null)
                {
                    continue;
                }

                item.Value.General = taskBControl.GetTaskGeneral();

                if (m_AllConfigControlInfo.TryGetValue(item.Key.Nodes[1], out outTaskControl) == false)
                {
                    continue;
                }

                TaskCControl taskCControl = outTaskControl as TaskCControl;
                if (taskCControl == null)
                {
                    continue;
                }

                item.Value.Request = taskCControl.GetTaskRequest();

                if (m_AllConfigControlInfo.TryGetValue(item.Key.Nodes[2], out outTaskControl) == false)
                {
                    continue;
                }

                TaskDControl taskDControl = outTaskControl as TaskDControl;
                if (taskDControl == null)
                {
                    continue;
                }

                item.Value.Policy = taskDControl.GetTaskPolicy();

                if (m_AllConfigControlInfo.TryGetValue(item.Key.Nodes[3], out outTaskControl) == false)
                {
                    continue;
                }

                TaskEControl taskEControl = outTaskControl as TaskEControl;
                if (taskDControl == null)
                {
                    continue;
                }

                item.Value.Result = taskEControl.GetTaskResult();

                if (m_NewTreeNode.Contains(item.Key) == true)
                {
                    TaskManager.Instance.AddTaskInfo(item.Value);
                }
            }

            U50GlobalSetting.SaveTaskSetting(U50GlobalSetting.TaskFilePath, TaskManager.Instance.ToArray());
            U50GlobalSetting.SaveGlobalRegistry();

            m_NewTreeNode.Clear();
            m_DeleteTreeNode.Clear();
        }
        public void NewTask()
        {
            if (m_IsInitializing == false)
            {
                TaskForm_Load(this, EventArgs.Empty);
            }

            U50TaskInfo taskInfo = new U50TaskInfo();

            taskInfo.Guid = Guid.NewGuid().ToString();

            do
            {
                taskInfo.Name = string.Format("U50任务{0}", m_TaskCount++);

                if (m_TaskName.Contains(taskInfo.Name) == false)
                {
                    break;
                }
            } while (true);

            // U50策略01
            TreeNode newTreeNodeTask     = new TreeNode(taskInfo.Name);
            TreeNode newTreeNodeTaskSub  = new TreeNode("常规");
            TreeNode newTreeNodeTaskSub1 = new TreeNode("需求");
            TreeNode newTreeNodeTaskSub2 = new TreeNode("策略");
            TreeNode newTreeNodeTaskSub3 = new TreeNode("扫描结果");

            newTreeNodeTask.Nodes.Add(newTreeNodeTaskSub);
            newTreeNodeTask.Nodes.Add(newTreeNodeTaskSub1);
            newTreeNodeTask.Nodes.Add(newTreeNodeTaskSub2);
            newTreeNodeTask.Nodes.Add(newTreeNodeTaskSub3);

            TaskBControl taskBControl = new TaskBControl();

            taskBControl.Dock    = DockStyle.Fill;
            taskBControl.Visible = false;
            taskInfo.General     = taskBControl.GetTaskGeneral();

            this.m_AllConfigControlInfo.Add(newTreeNodeTask, taskBControl);
            this.m_AllConfigControlInfo.Add(newTreeNodeTaskSub, taskBControl);

            this.Panel.Controls.Add(taskBControl);

            TaskCControl taskCControl = new TaskCControl();

            taskCControl.Dock    = DockStyle.Fill;
            taskCControl.Visible = false;
            taskInfo.Request     = taskCControl.GetTaskRequest();

            this.m_AllConfigControlInfo.Add(newTreeNodeTaskSub1, taskCControl);

            this.Panel.Controls.Add(taskCControl);

            TaskDControl taskDControl = new TaskDControl();

            taskDControl.Dock    = DockStyle.Fill;
            taskDControl.Visible = false;
            taskInfo.Policy      = taskDControl.GetTaskPolicy();

            this.m_AllConfigControlInfo.Add(newTreeNodeTaskSub2, taskDControl);

            this.Panel.Controls.Add(taskDControl);

            TaskEControl taskEControl = new TaskEControl();

            taskEControl.Dock    = DockStyle.Fill;
            taskEControl.Visible = false;
            taskInfo.Result      = taskEControl.GetTaskResult();

            this.m_AllConfigControlInfo.Add(newTreeNodeTaskSub3, taskEControl);

            this.Panel.Controls.Add(taskEControl);

            //
            taskDControl.m_TaskInfo     = taskInfo;
            taskDControl.m_TaskBControl = taskBControl;
            taskDControl.m_TaskCControl = taskCControl;
            taskDControl.m_TaskDControl = taskDControl;
            taskDControl.m_TaskEControl = taskEControl;

            this.TreeView.Nodes.Add(newTreeNodeTask);

            this.TreeView.SelectedNode = newTreeNodeTask;

            m_NewTreeNode.Add(newTreeNodeTask);

            m_TreeNodeTaskInfo.Add(newTreeNodeTask, taskInfo);
        }