Exemplo n.º 1
0
        public void Execute(int timeout, ILog log)
        {
            log.Write("Executing Template Instance '{0}'", this.SavedObjectName);

            string path = FileTools.ResolvePath(this.TemplatePath);

            ZeusTemplate template = new ZeusTemplate(path);

            ZeusInput zin = new ZeusInput();

            zin.AddItems(this.InputItems);

            this.ApplyOverrideData(zin);

            ZeusContext context = new ZeusContext(zin, /*new GuiController(),*/ new Hashtable());

            context.Log = log;

            template.Execute(context, timeout, true);

            foreach (string file in context.Output.SavedFiles)
            {
                if (!SavedFiles.Contains(file))
                {
                    SavedFiles.Add(file);
                }
            }
        }
		public void Execute(int timeout, ILog log)
		{
			log.Write("Executing Template Instance '{0}'", this.SavedObjectName);

			string path = FileTools.ResolvePath(this.TemplatePath);
			
			ZeusTemplate template = new ZeusTemplate(path);
			
			ZeusInput zin = new ZeusInput();
			zin.AddItems(this.InputItems);

            this.ApplyOverrideData(zin);

			ZeusContext context = new ZeusContext(zin, /*new GuiController(),*/ new Hashtable());
			context.Log = log;

			template.Execute(context, timeout, true);

            foreach (string file in context.Output.SavedFiles)
            {
                if (!SavedFiles.Contains(file)) SavedFiles.Add(file);
            }
        }
Exemplo n.º 3
0
		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;
		}