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("当前无匹配结果,不能上传文件"); } }
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(); } }