private void OnLoadFiles(TreeNode node)
        {
            if (node == null)
            {
                if (_srTreeView.Nodes.Count == 0)
                {
                    MessageBox.Show("没有指定的目标机!");
                    return;
                }
                //指向“应用集合”节点
                node = _srTreeView.Nodes[0].Nodes[1];
            }
            TargetNode tNode = TargetNodes[node.Parent.Index];//treeNode对应的目标节点

            if (AppMatchTopoNode != null)
            {
                //显示加载执行文件的窗体
                var upLoadFileForm = new ExeFileForm(AppMatchTopoNode, tNode.ExeFile);
                upLoadFileForm.ShowDialog();
                if (upLoadFileForm.DialogResult == DialogResult.Yes)
                {
                    tNode.ExeFile = upLoadFileForm.GetFilesHt();
                }
                upLoadFileForm.Dispose();
            }
            else
            {
                MessageBox.Show("当前无匹配结果,不能上传文件");
            }
        }
        //_srcTreeView的目标节点下面的信息有改变
        private void ChildrenNodeInfoChange(int index, TargetNode tNode)
        {
            var nodes = _srTreeView.Nodes[index].Nodes;

            foreach (TreeNode node in nodes)
            {
                try
                {
                    NodeInfo info = node.Tag as NodeInfo;
                    if (info._formFlag) //  有对应窗体显示,才触发该事件
                    {
                        info.TriggerNodeInfoChanged(tNode);
                        //若当前视图为应用视图那么记录匹配的节点
                        if (info._formType == Princeple.FormType.APP)
                        {
                            var topo = (DynamicTopo)(info._form.showViewPanel1.ShowView);
                            AppMatchTopoNode = topo.GetMatchedNodes();
                            if (topo._reconfigFlag && AppMatchTopoNode != null)
                            {
                                ReconfigProcess(node);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    MainForm.SetOutPutText(e.Message + "\n" + e.StackTrace);
                }
            }
        }
        private void OnMatchApp(TreeNode node)
        {
            if (node == null)
            {
                if (_srTreeView.Nodes.Count == 0)
                {
                    MessageBox.Show("没有指定的目标机!");
                    return;
                }
                //指向“应用集合”节点
                node = _srTreeView.Nodes[0].Nodes[1];
            }
            TargetNode targetNode = TargetNodes[node.Parent.Index];//treeNode对应的目标节点
            NodeInfo   info       = node.Tag as NodeInfo;

            try
            {
                var     topo             = (DynamicTopo)(info._form.showViewPanel1.ShowView);
                Boolean autoReconfigFlag = targetNode.AutoReconfigFlag;
                if (topo.ChooseStrategy(ref autoReconfigFlag))
                {
                    topo.TriggerRedrawRequst();
                    AppMatchTopoNode            = topo.GetMatchedNodes();
                    targetNode.AutoReconfigFlag = autoReconfigFlag;
                }
            }
            catch (NullReferenceException)
            {
                MessageBox.Show("请添加/显示对应应用");
            }
            catch (Exception ex)
            {
                MessageBox.Show("_srcCMS_MatchApp_Click:" + ex.Message);
            }
        }
Exemple #4
0
 public void TriggerNodeInfoChanged(TargetNode tNode)
 {
     if (NodeInfoChanged != null)
     {
         NodeInfoChanged(tNode);
     }
 }
        public void OnNodeInfoChanged(TargetNode tNode)
        {
            Dictionary <int, SlotInfo> infos = new Dictionary <int, SlotInfo>();   //当前的健康信息数据集合

            //处理数据
            ProcessNodeInfo(tNode.MultiPacket.SysInfo, infos);
            _statusInfo = infos;
            base.TriggerRedrawRequst();
        }
        /*显示被选中的元件节点*/
        private void SelectLibNodeToShow(TreeNode node)
        {
            ShowViewForm viewForm = null;
            NodeInfo     info     = (NodeInfo)node.Tag;

            CloseExistForm(node);

            try
            {
                if (info._formType == Princeple.FormType.APP || info._formType == Princeple.FormType.STATUS)
                {
                    TargetNode   target   = GetTargetNode(node);
                    ShowViewForm destForm = (info._formType == Princeple.FormType.APP ? target.DynamicTopoForm : target.StatusForm);
                    if (destForm != null)
                    {
                        viewForm = destForm;
                    }
                    else
                    {
                        viewForm = new ShowViewForm(node);
                        if (info._formType == Princeple.FormType.APP)
                        {
                            target.DynamicTopoForm = viewForm;
                        }
                        else
                        {
                            target.StatusForm = viewForm;
                        }
                    }
                }
                else
                {
                    viewForm = new ShowViewForm(node);
                }

                //1.显示窗体
                viewForm.Text = node.Text;
                WeifenLuo.WinFormsUI.Docking.DockPanel panel = MainForm.GetPanel();
                viewForm.Show(panel);

                //2.通过view来初始化propertyGrid
                PropertyForm.Show(viewForm.showViewPanel1.ShowView.GetModelInstance());

                //3.配置树节点的NodeInfo
                info._form     = viewForm;
                info._formFlag = true;
            }
            catch (Exception e)
            {
                MainForm.SetOutPutText(e.StackTrace);
            }
        }
        //添加一个目标节点
        private void AddTargetNode(TcpManager.TargetTcpClient targetClient)
        {
            TargetNode tNode = new TargetNode(targetClient);

            TargetNodes.Add(tNode);
            if (targetClient == null)
            {
                AddSrcTreeNode("示例:X.X.X.X");
            }
            else
            {
                AddSrcTreeNode(targetClient.IpAddr.ToString());
            }
        }
        public void OnNodeInfoChanged(TargetNode tNode)
        {
            Boolean nodeDropFlag = false;   //是否有点接掉线

            _reconfigFlag = false;

            //处理信息,信息只表示是一个机箱
            var cnt0Flags = _onLineFlags[0];

            for (int i = 0; i < cnt0Flags.Count; i++)
            {
                Boolean newFlag = IsBoardOnLine(i, tNode.MultiPacket.SysInfo);
                if (!newFlag && cnt0Flags[i])    //判断有无新节点掉线
                {
                    MainForm.SetOutPutText(string.Format("槽位{0}板卡节点掉线", i + 1));
                    nodeDropFlag = true;
                }
                cnt0Flags[i] = newFlag;//更新各槽位的在线情况
                var dNodes = _topoNet.NodeArray.Where(dNode => dNode.SNode.FrameId == 0 && dNode.SNode.SlotId == i);
                foreach (var dNode in dNodes)
                {
                    if (newFlag)
                    {
                        if (dNode.Status == NodeStatus.OffLine)//新上线
                        {
                            dNode.Status = NodeStatus.OnLine;
                        }
                    }
                    else
                    {
                        dNode.Status = NodeStatus.OffLine;
                    }
                }
            }

            if (nodeDropFlag)
            {
                Boolean autoReconfigFlag = tNode.AutoReconfigFlag;
                ProcessNodeDrop(ref autoReconfigFlag);
                tNode.AutoReconfigFlag = autoReconfigFlag;
                base.TriggerRedrawRequst();
            }
        }
        private void On_pTimer_Tick(object sender, EventArgs e)
        {
            var        targetNode = _srTreeView.SelectedNode;             //选中的treeNode
            TargetNode tNode      = TargetNodes[targetNode.Parent.Index]; //treeNode对应的目标节点
            var        ip         = targetNode.Parent.Text;

            //统算时间,判断是否超时
            var      nowTicks = DateTime.Now.Ticks;
            TimeSpan ts       = new TimeSpan(nowTicks - _timeTicks);

            if (ts.TotalMilliseconds > 20000)//500ms之内需应用停止成功
            {
                _pTimer.Stop();
                MainForm.SetOutPutText("应用停止失败!用时超过500ms");
                return;
            }
            MainForm.SetOutPutText(string.Format("OnTick!时间{0}ms", ts.TotalMilliseconds));
            //获取回复命令
            var recvTcpCmd = TcpManager.Instance.RecvOneCmd(ip, CmdCode.StopApp);

            if (recvTcpCmd != null)
            {
                _pTimer.Stop();
                MainForm.SetOutPutText(string.Format("应用停止成功!时间{0}ms", ts.TotalMilliseconds));

                var upLoadFileForm = new ExeFileForm(AppMatchTopoNode, tNode.ExeFile);
                if (tNode.AutoReconfigFlag)//自动匹配
                {
                    upLoadFileForm.DeployFiles();
                }
                else
                {
                    //进入部署界面
                    upLoadFileForm.ShowDialog();
                    if (upLoadFileForm.DialogResult == DialogResult.Yes)
                    {
                        tNode.ExeFile = upLoadFileForm.GetFilesHt();
                    }
                }
                upLoadFileForm.Dispose();
            }
        }
        private void OnClearSource(TreeNode node)
        {
            if (node == null)
            {
                if (_srTreeView.Nodes.Count == 0)
                {
                    MessageBox.Show("没有指定的目标机!");
                    return;
                }
                node = _srTreeView.Nodes[0];
            }
            var nodeSysName  = node.Nodes[0].Text;  //系统的名字
            var cntFrontName = nodeSysName.Substring(0, nodeSysName.IndexOf(':') + 1);

            //清除系统名,应用名
            node.Nodes[0].Text = cntFrontName;
            node.Nodes[1].Nodes.Clear();

            //清除对应目标机的相关信息
            TargetNode target = GetTargetNode(node);

            target.StatusForm      = null;
            target.DynamicTopoForm = null;
        }