Copy BootSector


Node Information
Copies BootSector from the specified location to the other specified location, usually a flash drive.Do not select the boot path directly, instead select its parent folder, the destination must be a root path of a drive.
General Information
• This node doesn't have other available options.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Execute IN RUN MULTIPLE FALSE FALSE
From IN String MULTIPLE FALSE FALSE
To IN String MULTIPLE FALSE FALSE
Finished OUT RUN MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.Win32.Boot
{
    [IsNode("Copy BootSector")]
    public class CopyBootSect : Node
    {
        Port run = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "Execute");
        Port from = new Port(PortType.IN, typeof(string), AcceptsLinks.MULTIPLE, "From");
        Port to = new Port(PortType.IN, typeof(string), AcceptsLinks.MULTIPLE, "To");
        Port runout = new Port(PortType.OUT, typeof(RUN), AcceptsLinks.MULTIPLE, "Finished");
        public BootSectType Type
        {
            set { Settings[0] = value.ToString(); }
            get
            {
                if (string.IsNullOrWhiteSpace(Settings[0]))
                {
                    return BootSectType.NT60;
                }
                else
                {
                    return (BootSectType)Enum.Parse(typeof(BootSectType), Settings[0]);
                }
            }
        }
        public CopyBootSect()
        {
            this.Dependency = DependencyLibraries.COMMANDLINE;
            this.NodeType = KGraph.NodeType.Method;
            this.Name = "Copy BootSector";
            AddPort(run);
            AddPort(from);
            AddPort(to);
            AddPort(runout);
            Information = "Copies BootSector from the specified location to the other specified location, usually a flash drive." +
                "Do not select the boot path directly, instead select its parent folder, the destination must be a root path of a drive.";
        }
        public override string Code()
        {
            string code = string.Empty;
            code = "CMDExecute cmd = new CMDExecute();" + Environment.NewLine +
                "string frm = " + "(" + GetValue(from) + ").ToString();" + Environment.NewLine +
                "string t0 = " + "(" + GetValue(to) + ").ToString();" + Environment.NewLine +
                "if(new System.IO.DirectoryInfo(frm).Parent == null){frm = frm.Replace(@" + q + @"\" + q + ", string.Empty);}" + Environment.NewLine +
                "if(new System.IO.DirectoryInfo(t0).Parent == null){t0 = t0.Replace(@" + q + @"\" + q + ", string.Empty);}" + Environment.NewLine +
            "string[] commands = {frm," + " @" + q + @"CD \BOOT" + q + ", @" + q + "BOOTSECT.EXE /" + this.Type.ToString() + " " + q + " + t0 };" + Environment.NewLine +
            "cmd.Execute(commands, 0, true, true);" + Environment.NewLine +
            "cmd.CommandExecuted += delegate(object sender, int e)\r\n{" + Environment.NewLine +
            GetValue(runout) + "};";
            return code;
        }
    }
}