public bool Collect(ZeusTemplate template, IZeusContext context, int timeout, InputItemCollection collectedinput, ShowGUIEventHandler eventhandler) { IZeusExecutionHelper execHelper = null; bool exceptionOccurred = false; bool result = false; try { //Initialize Context for collection collectedinput.CopyTo(context.Gui.Defaults); context.Gui.ForceDisplay = true; collectedinput.Clear(); execHelper = template.GuiSegment.ZeusScriptingEngine.ExecutionHelper; execHelper.Timeout = timeout; if (eventhandler == null) { execHelper.SetShowGuiHandler(new ShowGUIEventHandler(DynamicGUI_Display)); } else { execHelper.SetShowGuiHandler(new ShowGUIEventHandler(eventhandler)); } result = template.GuiSegment.Execute(context); execHelper.Cleanup(); if (collectedinput != null) { collectedinput.Add(context.Input); } } catch (Exception ex) { context.Log.Write(ex); exceptionOccurred = true; } if (!exceptionOccurred && result) { context.Log.Write("Successfully collected input for Template: " + template.Title); } else { context.Log.Write("Canceled Template execution: " + template.Title); } return(result); }
public IZeusContext Execute(ZeusTemplate template, IZeusContext context, int timeout, InputItemCollection collectedinput, ShowGUIEventHandler eventhandler, bool skipGui) { IZeusExecutionHelper execHelper = null; bool exceptionOccurred = false; bool result = false; try { if (skipGui) { PopulateContextObjects(context); foreach (IZeusContextProcessor processor in ZeusFactory.Preprocessors) { processor.Process(context); } result = true; } else { execHelper = template.GuiSegment.ZeusScriptingEngine.ExecutionHelper; execHelper.Timeout = timeout; if (eventhandler == null) { execHelper.SetShowGuiHandler(new ShowGUIEventHandler(DynamicGUI_Display)); } else { execHelper.SetShowGuiHandler(new ShowGUIEventHandler(eventhandler)); } result = template.GuiSegment.Execute(context); execHelper.Cleanup(); if (collectedinput != null) { collectedinput.Add(context.Input); } } if (result) { execHelper = template.BodySegment.ZeusScriptingEngine.ExecutionHelper; execHelper.Timeout = timeout; result = template.BodySegment.Execute(context); } } catch (Exception ex) { context.Log.Write(ex); exceptionOccurred = true; } if (!exceptionOccurred && result) { context.Log.Write("Successfully rendered Template: " + template.Title); } else { context.Log.Write("Canceled Template execution: " + template.Title); } return(context); }