public ProgramBlock SaveMacro(string options) { RecordingDisable(); // var program = new ProgramBlock(); program.Name = "New Macro"; program.Address = masterControlProgram.GeneratePid(); program.Type = "Wizard"; WizardEngine.WizardScript wizardScript = ((WizardEngine)program.Engine).Script; foreach (var migCommand in macroCommands) { var command = new Engines.WizardScript.ScriptCommand(); command.Domain = migCommand.Domain; command.Target = migCommand.Address; command.CommandString = migCommand.Command; command.CommandArguments = ""; if (!string.IsNullOrEmpty(migCommand.GetOption(0)) && migCommand.GetOption(0) != "null") { //TODO: should we pass entire command option string? migCmd.OptionsString command.CommandArguments = migCommand.GetOption(0) + (options != "" && options != "null" ? "/" + options : ""); } wizardScript.Commands.Add(command); } masterControlProgram.ProgramAdd(program); // return(program); }
private static string GetWizardScript(ProgramBlock program) { if (program.Type.ToLower() != "wizard" || (program.Conditions.Count <= 0 && program.Commands.Count <= 0)) { return(null); } WizardEngine.WizardScript script = new WizardEngine.WizardScript(null) { Commands = program.Commands.ToList <ScriptCommand>(), Conditions = program.Conditions.ToList <ScriptCondition>(), ConditionType = program.ConditionType }; return(JsonConvert.SerializeObject(script)); }