Exemplo n.º 1
0
        private void RenameNodes(WccNodeTag tag, string newName)
        {
            string[] path    = tag.NodeName.Split('.');
            string   oldName = tag.NodeName;

            path[path.Length - 1] = newName;
            if (tag.Type == WccNodeTag.WccNodeType.Project)
            {
                if (tag.Project != null)
                {
                    tag.Project.ProjectAlias = newName;
                }
            }
            string NodeName = "";

            for (int i = 0; i < path.Length; i++)
            {
                NodeName += path[i];
                if (i != path.Length - 1)
                {
                    NodeName += ".";
                }
            }
            tag.NodeName = NodeName;
            WccProject project = projectCollection[oldName];

            projectCollection.Remove(oldName);
            projectCollection.Add(NodeName, project);
            projectCollection.Serialize();
            //appDataBase.UpdateNode(tag, oldName);
        }
Exemplo n.º 2
0
 public MainForm()
 {
     InitializeComponent();
     debugViewer.Path = Application.StartupPath;
     debugViewer.StartWatch();
     InitializeDataGrid();
     selectedWccProject = null;
     InitializeTreeView();
 }
Exemplo n.º 3
0
        private void treeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            treeView.SelectedNode = e.Node;
            TreeNode   selectedNode = treeView.SelectedNode;
            WccNodeTag nodeTag      = null;

            if (selectedNode == null)
            {
                return;
            }
            nodeTag = (WccNodeTag)selectedNode.Tag;
            if (e.Button == System.Windows.Forms.MouseButtons.Right
                /*&& (nodeTag.Type == WccNodeTag.WccNodeType.CommonNode || nodeTag.Type == WccNodeTag.WccNodeType.Root)*/)
            {
                treeView.SelectedNode = e.Node;
                //CreatePvssProjectForm.CreatePvssProjectForm form = new CreatePvssProjectForm();
                //form.Show();
                Point p = new Point(e.X, e.Y);

                // Get the node that the user has clicked.
                TreeNode node = treeView.GetNodeAt(p);
                if (node != null)
                {
                    treeView.SelectedNode = node;

                    // Find the appropriate ContextMenu depending on the selected node.
                    WccNodeTag tag = (WccNodeTag)node.Tag;
                    switch (tag.Type)
                    {
                    case WccNodeTag.WccNodeType.Root:
                        rootContextMenu.Show(treeView, p);
                        break;

                    case WccNodeTag.WccNodeType.CommonNode:
                        treeContextMenu.Show(treeView, p);
                        break;

                    case WccNodeTag.WccNodeType.Project:
                        projectNodeContextMenu.Show(treeView, p);
                        break;
                    }
                }
            }
            else if (e.Button == System.Windows.Forms.MouseButtons.Left /*&& nodeTag.Type == WccNodeTag.WccNodeType.Project*/)
            {
                this.btnStartManager.Enabled = false;
                this.btnStopManager.Enabled  = false;
                this.btnKillManager.Enabled  = false;
                this.btnStartProject.Enabled = false;
                this.btnStopProject.Enabled  = false;
                this.btnLogViewer.Enabled    = false;
                SelectedProject = nodeTag.Project;
            }
        }
Exemplo n.º 4
0
 private void ChangeProjectNodeState(TreeNodeCollection nodes, WccProject project)
 {
     foreach (TreeNode node in nodes)
     {
         WccNodeTag tag = (WccNodeTag)node.Tag;
         if (tag.Type == WccNodeTag.WccNodeType.Root || tag.Type == WccNodeTag.WccNodeType.CommonNode)
         {
             ChangeProjectNodeState(node.Nodes, project);
         }
         else
         {
             if (tag.Project == project && tag.Project != null)
             {
                 int state = (int)project.ConnectionState;
                 OnProjectNodeStateChanged(node, state);
             }
         }
     }
 }
Exemplo n.º 5
0
        private void LoadTreeNodes(TreeNode parentNode, WccProjectCollection projectCollection)
        {
            foreach (var project in projectCollection)
            {
                string nodeName = project.Key;
                WccNodeTag.WccNodeType nodeType = WccNodeTag.WccNodeType.Project;
                string[] nodes = nodeName.Split('.');
                if (nodes.Length > 1)
                {
                    if (nodes[nodes.Length - 2].Equals(parentNode.Name))
                    {
                        TreeNode node = new TreeNode(nodes[nodes.Length - 1]);
                        node.Name = nodes[nodes.Length - 1];
                        WccNodeTag _tag = new WccNodeTag();
                        _tag.Type     = nodeType;
                        _tag.NodeName = nodeName;
                        if (nodeType == WccNodeTag.WccNodeType.Project)
                        {
                            WccProject proj = project.Value;
                            //project.ProjectAlias = Convert.ToString(map["projectalias"]);
                            //project.MachineName = Convert.ToString(map["machinename"]);
                            //project.PmonPort = Convert.ToInt32(map["pmonport"]);

                            //project.Credential.Login = Convert.ToString(map["login"]);
                            //project.Credential.Password = Convert.ToString(map["password"]);
                            //project.Credential.DefaultAutorization = Convert.ToBoolean(map["defaultAutorization"]);
                            //project.Path = Convert.ToString(map["path"]);
                            proj.ProjectStateChanged += OnProjectStateChanged;
                            _tag.Project              = proj;
                        }
                        else
                        {
                            LoadTreeNodes(node, projectCollection);
                        }
                        node.Tag = _tag;
                        parentNode.Nodes.Add(node);
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void deleteNode()
        {
            TreeNode   selectedNode = treeView.SelectedNode;
            WccNodeTag nodeTag      = (WccNodeTag)selectedNode.Tag;

            if (nodeTag.Type == WccNodeTag.WccNodeType.Project)
            {
                if (ReferenceEquals(SelectedProject, nodeTag.Project))
                {
                    SelectedProject.StopObserve();
                    SelectedProject.ProjectStateChanged -= OnProjectStateChanged;
                    SelectedProject = null;
                }
            }
            else
            {
                deleteChildProjectNodes(selectedNode.Nodes);
            }
            treeView.Nodes.Remove(selectedNode);
            projectCollection.Remove(nodeTag.NodeName);
            projectCollection.Serialize();
            //appDataBase.RemoveNode(nodeTag);
        }
Exemplo n.º 7
0
        private void OnProjectStateChanged(WccProject project)
        {
            if (ReferenceEquals(project, SelectedProject))
            {
                if (dataGridView.InvokeRequired)
                {
                    WccProjectStateEventHandler d = new WccProjectStateEventHandler(OnProjectStateChanged);
                    dataGridView.Invoke(d, new object[] { project });
                }
                else
                {
                    //dataSource.Clear();
                    if (dataSource.Count > SelectedProject.Managers.Count ||
                        SelectedProject.ConnectionState == WccProject.WccConnectionState.Disconnected)
                    {
                        dataSource.Clear();
                    }

                    foreach (var manager in SelectedProject.Managers.Values)
                    {
                        //dataSource.Add(manager);
                        if (dataSource.Count > manager.PmonNumber)
                        {
                            ((WccManager)dataSource[manager.PmonNumber]).Replace(manager);
                        }
                        else
                        {
                            dataSource.Add(manager);
                        }

                        SelectedProject.Managers[manager.PmonNumber].ManagerStateChanged -= OnManagerStateChanged;
                        manager.ManagerStateChanged += new ManagerEventHandler(OnManagerStateChanged);
                    }

                    dataGridView.Update();

                    for (int i = 0; i < dataGridView.RowCount; i++)
                    {
                        dataGridView["St", i].Style.BackColor
                            = Color.White;
                        if (dataGridView["St", i].FormattedValue.ToString().Contains("2"))
                        {
                            dataGridView["St", i].Style.BackColor = Color.FromArgb(0, 255, 0);
                        }
                        else if (dataGridView["St", i].FormattedValue.ToString().Contains("3"))
                        {
                            dataGridView["St", i].Style.BackColor = Color.Pink;
                        }
                        else if (dataGridView["St", i].FormattedValue.ToString().Contains("1"))
                        {
                            dataGridView["St", i].Style.BackColor = Color.Yellow;
                        }
                        else if (dataGridView["St", i].FormattedValue.ToString().Contains("0") &&
                                 dataGridView["ИД процесса", i].FormattedValue.ToString().Contains("-2"))
                        {
                            dataGridView["St", i].Style.BackColor = Color.Blue;
                        }
                        else if (dataGridView["St", i].FormattedValue.ToString().Contains("0") &&
                                 (((WccManager)dataSource[i]).Mode == WccManager.ManagerMode.alwayes ||
                                  ((WccManager)dataSource[i]).Mode == WccManager.ManagerMode.once))
                        {
                            dataGridView["St", i].Style.BackColor = Color.Red;
                        }
                    }

                    txtProjectName.Text = SelectedProject.ProjectName;

                    if (project.IsObserved)
                    {
                        btnStartObserve.ImageIndex = 0;
                    }
                    else
                    {
                        btnStartObserve.ImageIndex = 1;
                    }

                    if (project.ConnectionState != WccProject.WccConnectionState.Processing)
                    {
                        gbProjectControl.Enabled = true;
                    }

                    if (project.IsObserved)
                    {
                        if (project.IsStarted && project.IsObserved)
                        {
                            this.btnStartProject.Enabled = false;
                            this.btnStopProject.Enabled  = true;
                        }
                        else if (!project.IsStarted && project.IsObserved)
                        {
                            this.btnStartProject.Enabled = true;
                            this.btnStopProject.Enabled  = false;
                        }
                        this.btnLogViewer.Enabled = true;
                    }
                    else
                    {
                        this.btnStartProject.Enabled = false;
                        this.btnStopProject.Enabled  = false;
                        this.btnLogViewer.Enabled    = false;
                    }

                    if (dataGridView.RowCount > 0)
                    {
                        ManagerControlPanelStateChange((WccManager)dataSource[dataGridView.CurrentRow.Index]);
                    }
                }
            }
            else if (SelectedProject == null)
            {
                if (txtProjectName.InvokeRequired)
                {
                    WccProjectStateEventHandler d = new WccProjectStateEventHandler(OnProjectStateChanged);
                    txtProjectName.Invoke(d, new object[] { project });
                }
                else
                {
                    txtProjectName.Text = "";
                }
            }
            ChangeProjectNodeState(treeView.Nodes, project);
        }
Exemplo n.º 8
0
 public Item()
 {
     path        = "";
     projectInfo = null;
 }