public void ScriptGenerate_Click(object sender, System.EventArgs e) { ZeusParser parser = new ZeusParser(); ZeusOutput zout = null; ZeusTemplate template; try { template = parser.LoadTemplate(this.ScriptStream.BaseStream, this.ScriptFilePath); System.Console.WriteLine(template.ScriptBody); ExecuteZeusTemplate ex = new ExecuteZeusTemplate(); ex.ShowGUI += new ShowGUIEventHandler(DynamicGUI_Display); zout = ex.Execute(template); } catch (Exception x) { ZeusDisplayError formError = new ZeusDisplayError(x); formError.ShowDialog(this); } if (zout != null) { SimpleOutputForm frm = new SimpleOutputForm(); frm.OutText = zout.text; frm.ShowDialog(this); } }
public _DotNetScriptTemplate(ZeusTemplateContext context) { this.input = context.Input; this.objects = context.Objects; this.output = context.Output; }
public bool Execute(ZeusInput input, ZeusOutput output, string code) { return false; }
public bool Execute(ZeusInput input, ZeusOutput output, string code) { return(false); }
public void ExecuteTemplate(ZeusTemplate template) { this.Cursor = Cursors.WaitCursor; DefaultSettings settings = new DefaultSettings(); ZeusInput zin = new ZeusInput(); ZeusOutput zout = new ZeusOutput(); Hashtable objects = new Hashtable(); ZeusGuiContext guicontext; ZeusTemplateContext bodycontext = null; dbRoot myMeta = new dbRoot(); // Set the global variables for the default template/output paths zin["defaultTemplatePath"] = settings.DefaultTemplateDirectory; zin["defaultOutputPath"] = settings.DefaultOutputDirectory; string driver, connectionString; //if there is a connection string set, it in the input section here. if (settings.DbDriver != string.Empty) { driver = settings.DbDriver; connectionString = settings.ConnectionString; zin["dbDriver"] = driver; zin["dbConnectionString"] = connectionString; try { // Try to connect to the DB with MyMeta (using default connection info) myMeta.Connect(settings.DbDriver, settings.ConnectionString); // Set DB global variables and also input variables if (settings.DbTarget != string.Empty) { myMeta.DbTarget = settings.DbTarget; } if (settings.DbTargetMappingFile != string.Empty) { myMeta.DbTargetMappingFileName = settings.DbTargetMappingFile; } if (settings.LanguageMappingFile != string.Empty) { myMeta.LanguageMappingFileName = settings.LanguageMappingFile; } if (settings.DbTarget != string.Empty) { myMeta.DbTarget = settings.DbTarget; } if (settings.Language != string.Empty) { myMeta.Language = settings.Language; } if (settings.UserMetaDataFileName != string.Empty) { myMeta.UserMetaDataFileName = settings.UserMetaDataFileName; } } catch { // Give them an empty MyMeta myMeta = new dbRoot(); } } bool exceptionOccurred = false; bool result = false; try { // Add any objects here that need to be embedded in the script. objects.Add("MyMeta", myMeta); guicontext = new ZeusGuiContext(zin, new GuiController(), objects); template.GuiSegment.ZeusScriptingEngine.Executioner.ScriptTimeout = settings.ScriptTimeout; template.GuiSegment.ZeusScriptingEngine.Executioner.SetShowGuiHandler(new ShowGUIEventHandler(DynamicGUI_Display)); result = template.GuiSegment.Execute(guicontext); if (result) { bodycontext = new ZeusTemplateContext(guicontext); result = template.BodySegment.Execute(bodycontext); } } catch (Exception ex) { ZeusDisplayError formError = new ZeusDisplayError(ex); formError.SetControlsFromException(); formError.ShowDialog(this); exceptionOccurred = true; } if (!exceptionOccurred && result) { MessageBox.Show("Successfully rendered template: " + template.Title); } this.Cursor = Cursors.Default; }