/// ======================================================================================================= public static bool Run(string auto_alias, string binary_name, string number = null, bool new_form = false) { int commandnumber = Convert.ToInt32(number); int batchnumber = 0; // Default AutoReport autoreport = new AutoReport(auto_alias); // Always something to report autoreport.Enabled = (bool)FormAccess(FormDelegates.ReportEnabled, null, auto_alias); List <Control> interactivecontrols = new List <Control>(); if (!Running) // Not allowed to run while running { string autovars = (string)FormAccess(FormDelegates.GetAutoVars, null, auto_alias); if (!autovars.Contains(COMMAND_MODE_DIRTY_RUN)) { CleanRun(auto_alias); } AutoTasks = new List <Task>(); BatchTasks = new List <Task>(); CommandTasks = new List <Task>(); Running = true; RunMode = RunType.Command; string binary_path = DISK.AutoAddBaseDirectory(auto_alias + @"\" + binary_name); DataGridView batchdata = Data.BlankDgv((int)CAT.BatchFields.NumberOfColumns); DataGridView autodata = Data.BlankDgv((int)CAT.AutoFields.NumberOfColumns); if (File.Exists(binary_path)) { if (Regex.IsMatch(binary_path, "auto.bin")) { Data.LoadDataGrid(binary_path, ref autodata); RunMode = number == null ? RunType.Auto : RunType.Batch; if (RunMode == RunType.Batch) { Data.LoadDataGrid(new FileInfo(binary_path).Directory.FullName + @"\batch" + number + ".bin", ref batchdata); } } else if (Regex.IsMatch(binary_path, @"batch\d*.bin")) { Data.LoadDataGrid(new FileInfo(binary_path).Directory.FullName + @"\auto.bin", ref autodata); RunMode = number == null ? RunType.Batch : RunType.Command; Data.LoadDataGrid(binary_path, ref batchdata); string subvalue = Regex.Match(binary_path, @"batch\d*.bin").Value; string newvalue = Regex.Match(subvalue, @"[0-9]+").Value; batchnumber = Convert.ToInt32(newvalue); } else { Running = false; throw new Exception("Binary " + binary_path + " is invalid - thus did not start automation"); } } else { Running = false; throw new Exception("Binary " + binary_path + " does not exist - thus did not start automation"); } switch (RunMode) { case RunType.Command: if (Regex.IsMatch(Data.GetCell(batchdata, (int)CAT.BatchFields.Mode, commandnumber), "-nr")) { autoreport.Enabled = false; } autoreport.AddBatch(new BatchReport(batchnumber, Data.GetCell(autodata, (int)CAT.AutoFields.Name, batchnumber))); RunCommand(autoreport, new Map(auto_alias, batchnumber, commandnumber), batchdata, out interactivecontrols, GetAutoVars(autodata, batchnumber, auto_alias)); autoreport.WaitForBatch(batchnumber); Running = false; break; case RunType.Batch: if (Regex.IsMatch(Data.GetCell(autodata, (int)CAT.AutoFields.Mode, batchnumber), "-nr")) { autoreport.Enabled = false; } RunBatch(autoreport, auto_alias, batchnumber, autodata, batchdata, out interactivecontrols); Running = false; break; case RunType.Auto: RunAuto(autoreport, auto_alias, binary_name, out interactivecontrols); Running = false; break; } autoreport.WaitForAuto(); if (autoreport.Enabled) { ShowReport(autoreport); } if (interactivecontrols != null && interactivecontrols.Count > 0) { InteractiveShowControls(interactivecontrols); } return(true); } else { autoreport.AddOverlay("Busy running automation - thus did not start new automation - please wait (or click abort then retry run)...", Status.BUSY); return(false); } }