/// ======================================================================================================= public static void InteractiveShowReport(Func <Return> returndatafunction, double y_scale) { CAT.FormAccess(CAT.FormDelegates.FormClose, null, "Report"); AutoReport autoreport = new AutoReport(CAT.InteractiveControlsFormName); Map map = new Map(CAT.InteractiveControlsFormName, 0, 0); try { DateTime start = DateTime.Now; bool complete = false; InteractiveAddNamedOverlay("InteractiveProgress", "Started", Status.BUSY); new Thread(() => { while (!complete) { InteractiveUpdateNamedOverlay("InteractiveProgress", "Processing " + (DateTime.Now - start).TotalMilliseconds + "ms", Status.BUSY); Thread.Sleep(10); } InteractiveUpdateNamedOverlay("InteractiveProgress", "Complete " + (DateTime.Now - start).TotalMilliseconds + "ms", Status.PASS); }).Start(); autoreport.AddBatch(new BatchReport(0, "Batch")); autoreport.AddCommand(new CommandReport(map, "Command")); Return returndata = returndatafunction(); if (returndata.Charts != null) { autoreport.AddChartList(map, returndata.Charts); } if (returndata.Messages != null) { foreach (CATMessage msg in returndata.Messages) { autoreport.AddOverlayedMessage(map, msg.Text, msg.Status); } } autoreport.CommandComplete(map, CAT.Status.PASS); autoreport.BatchComplete(0); autoreport.AutoComplete(); CAT.ShowReport(autoreport, y_scale); complete = true; } catch (Exception ex) { InteractiveUpdateNamedOverlay("InteractiveProgress", "Failed control", Status.PASS); autoreport.AddOverlayedMessage(map, CAT.ErrorMsg(ex), CAT.Status.FAIL); try { CAT.ShowReport(autoreport, y_scale); } catch { } } }
/// ======================================================================================================= private static void RunBatch(AutoReport auto_report, string auto_alias, int batch_number, DataGridView auto_data, DataGridView batch_data, out List <Control> interactive_controls, int?command_number = null) { List <Control> interactivecontrols = new List <Control>(); int rep = 1; if (Regex.IsMatch(Data.GetCell(auto_data, (int)CAT.AutoFields.Mode, batch_number), COMMAND_MODE_REPEAT)) { rep = Convert.ToInt16(Regex.Match(Data.GetCell(auto_data, (int)CAT.AutoFields.Mode, batch_number), COMMAND_MODE_REPEAT).Value.Substring(1)); } for (int i = 0; i < rep; i++) { Action runbatch = new Action(() => { FormAccess(FormDelegates.SelectAutoRow, new object[] { batch_number }, auto_alias); FormAccess(FormDelegates.LoadBatchData, new object[] { batch_number }, auto_alias); FormAccess(FormDelegates.ClearBatchStatuses, new object[] { }, auto_alias); auto_report.AddBatch(new BatchReport(batch_number, Data.GetCell(auto_data, (int)CAT.AutoFields.Name, batch_number))); Status?status = null; if (Data.IsBatchEnabled(auto_data, batch_number) || command_number != null) { CAT.FormAccess(CAT.FormDelegates.SetBatchStatus, new object[] { Status.BUSY, batch_number }, auto_alias); foreach (DataGridViewRow commandrow in batch_data.Rows) { if (!AbortAll && ((command_number != null && command_number == commandrow.Index) || command_number == null) && commandrow.Index < batch_data.RowCount - 1) { FormAccess(FormDelegates.SelectBatchRow, new object[] { commandrow.Index }, auto_alias); List <Control> ctrls; RunCommand(auto_report, new Map(auto_alias, batch_number, commandrow.Index), batch_data, out ctrls, GetAutoVars(auto_data, batch_number, auto_alias)); if (ctrls != null) { foreach (Control ctrl in ctrls) { interactivecontrols.Add(ctrl); } } } } status = auto_report.CalculatedBatchResult(batch_number); } else { status = Status.SKIP; } CAT.FormAccess(CAT.FormDelegates.SetBatchStatus, new object[] { status, batch_number }, auto_alias); auto_report.BatchComplete(batch_number, status); }); if (Regex.IsMatch(Data.GetCell(auto_data, (int)CAT.AutoFields.Mode, batch_number), "-t")) { Task t = new Task(() => { runbatch(); }); BatchTasks.Add(t); t.Start(); } else { runbatch(); CAT.FormAccess(CAT.FormDelegates.SaveSelectedBatch, new object[] { }, auto_alias); } } interactive_controls = interactivecontrols; }