示例#1
0
        public override CommandResult Execute(CommandTreeViewNode node = null)
        {
			CommandResult rlt = new CommandResult();
			try
			{
				object resultValue = new CommandResult();
				if (string.Equals(CommandExecutionContext.Instance.CurrentMachine.Address, ".") || string.Equals(CommandExecutionContext.Instance.CurrentMachine.Address, "127.0.0.1"))
				{
					ProcessStartInfo info = new ProcessStartInfo();
					info.FileName = "cmd.exe";
					info.Arguments = string.Format("/c {0}", this.Command_Line);
					Process.Start(info);
				}
				else
				{
					resultValue = RemoteExecute(this.Command_Line);
				}
				rlt.ResultValue = resultValue;
			}
			catch (Exception e)
			{
				rlt.LastError = e;
			}
			return rlt;
        }
示例#2
0
 public override CommandResult Execute(CommandTreeViewNode node = null)
 {
     CommandResult result = new CommandResult();
     CommandExecutionContext.Instance.CurrentMachine.DomainUsername = Username;
     CommandExecutionContext.Instance.CurrentMachine.Password = Password;
     CommandExecutionContext.Instance.CurrentMachine.Address = Address;
     return result;
 }
示例#3
0
		public override CommandResult Execute(CommandTreeViewNode node = null)
		{
			CommandResult rlt = new CommandResult();
			times++;
			if (node != null)
			{
				if (Repeat_Times < 0 || times <= Repeat_Times)
				{
					CommandTreeViewNode prev = node;
					while (prev.PrevNode != null && !isCancelling)
					{
						prev = prev.PrevNode as CommandTreeViewNode;
					}
					if (base.AccomplishCancellation())
					{
						rlt.Next = null;
					}
					else
					{
						rlt.Next = prev;
					}
				}
			}
			//try
			//{
			//    foreach (CommandNode i in this.Children)
			//    {
			//        if (i != null)
			//        {
			//            CommandResult r = i.Execute();
			//            if (r.IsError)
			//            {
			//                rlt.LastError = r.LastError;
			//                break;
			//            }
			//        }
			//    }
			//}
			//catch (Exception e)
			//{
			//    rlt.LastError = e;
			//}
			return rlt;
		}
示例#4
0
		public override CommandResult Execute(CommandTreeViewNode node = null)
		{
			Thread.Sleep(Time_In_Second * 1000);
			return new CommandResult();
		}
示例#5
0
文件: PlanForm.cs 项目: mind0n/hive
		private void InsertTreeViewNode(CommandTreeViewNode node)
		{
			node.ActivateCallback = NodeActivateCallback;
			if (tvPlan.SelectedNode != null)
			{
				tvPlan.Nodes.Insert(tvPlan.Nodes.IndexOf(tvPlan.SelectedNode) + 1, node);
			}
			else
			{
				tvPlan.Nodes.Add(node);
			}
			tvPlan.SelectedNode = node;
		}
示例#6
0
文件: PlanForm.cs 项目: mind0n/hive
		private CommandResult ExecuteCommand(CommandTreeViewNode node, bool suppressSuccessMsg = true)
		{
			if (node != null)
			{
				obox.WriteMsg("{0}&nbsp;", false, "gray", false, node.Text);
				CommandResult result = node.Execute(node, obox);
				if (result.Next == null)
				{
					result.Next = node.NextNode as CommandTreeViewNode;
				}
				if (result != null)
				{
					this.Invoke((MethodInvoker)delegate
					{
						node.Update();
					});
					if (result.IsSuccessful && !suppressSuccessMsg && !isCancelled)
					{
						obox.WriteSuccessMsg("Successful");
					}
					else if (result.IsError)
					{
						obox.WriteErrorMsg("Failed <br />{0}", result.LastError.Message);
					}
					else if (result.IsCanceled)
					{
						obox.WriteMsg("Canceled");
					}
				}
				else
				{
					obox.WriteErrorMsg("Failed <br />Command result missing.", node.Text);
				}
				return result;
			}
			return new CommandResult();
		}
示例#7
0
        public override CommandResult Execute(CommandTreeViewNode node = null)
        {
			CommandResult rlt = new CommandResult();
			try
			{
                string targetName = null;
                ManagementObjectCollection machines = GetMgmtObjects("\\\\.\\root\\MicrosoftNLB", "Select * from MicrosoftNLB_Node");
                if (machines != null)
                {
                    foreach (ManagementObject m in machines)
                    {
                        string cname = (string)m.GetPropertyValue("ComputerName");
                        uint status = (uint)m.GetPropertyValue("StatusCode");
                        if (".".Equals(Computer_Name))
                        {
                            targetName = GetLocalName();
                        }
                        else
                        {
                            targetName = Computer_Name;
                        }
                        if (string.Equals(targetName, cname, StringComparison.OrdinalIgnoreCase))
                        {
                            string curtStatus = "Error";
                            if (status == 1008 || status == 1007)
                            {
                                curtStatus = "Normal";
                            }
                            if (status != 0 && !string.Equals(curtStatus, Correct_Status))
                            {
                                rlt.LastError = new Exception("Incorrect status detected: " + cname + "," + status);
                            }
                        }
                        else
                        {
                            Output(string.Join(",", new string[] {"Skipped",  cname, status.ToString() }));
                        }
                    }
                }
                //object resultValue = new CommandResult();
                //ProcessStartInfo info = new ProcessStartInfo();
                //info.FileName = "cscript.exe";
                //info.Arguments = Vb_Script;
                //info.StandardOutputEncoding = Encoding.ASCII;
                //info.UseShellExecute = false;
                //info.RedirectStandardOutput = true;
                //info.RedirectStandardError = true;
                //info.CreateNoWindow = true;
                //Process p = new Process();
                //p.StartInfo = info;
                //p.OutputDataReceived += new DataReceivedEventHandler(p_OutputDataReceived);
                //p.ErrorDataReceived += new DataReceivedEventHandler(p_ErrorDataReceived);
                //p.Start();
                //p.BeginOutputReadLine();
                //p.BeginErrorReadLine();
                //p.WaitForExit();
			}
			catch (Exception e)
			{
				rlt.LastError = e;
			}
			return rlt;
        }