예제 #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 ExecuteLoadedInput() 
		{
			try 
			{
                DefaultSettings settings = DefaultSettings.Instance;
				ZeusSimpleLog log = new ZeusSimpleLog();

				OpenFileDialog openFileDialog = new OpenFileDialog();
				openFileDialog.Filter = "Zues Input Files (*.zinp)|*.zinp";
				openFileDialog.FilterIndex = 0;
				openFileDialog.RestoreDirectory = true;
				openFileDialog.Multiselect = true;
				if(openFileDialog.ShowDialog() == DialogResult.OK)
				{
					Cursor.Current = Cursors.WaitCursor;

					foreach (string filename in openFileDialog.FileNames) 
					{
						ZeusSavedInput savedInput = new ZeusSavedInput(filename);
						if (savedInput.Load()) 
						{
							ZeusContext context = new ZeusContext();
							context.Input.AddItems(savedInput.InputData.InputItems);
							context.Log = log;

							ZeusTemplate template = new ZeusTemplate(savedInput.InputData.TemplatePath);
							template.Execute(context, settings.ScriptTimeout, true);

							if (log.HasExceptions) 
							{
								throw log.Exceptions[0];
							}
						}
					}

					Cursor.Current = Cursors.Default;
					MessageBox.Show(this, "Selected files have been executed.");
				}
			}
			catch (Exception ex)
			{
                mdi.ErrorsOccurred(ex);
                //ZeusDisplayError formError = new ZeusDisplayError(ex);
				//formError.SetControlsFromException();			
				//formError.ShowDialog(this);
			}

			Cursor.Current = Cursors.Default;
		}
		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 ExecuteLoadedInput()
        {
            bool overridden = false;
            
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "Zues Input Files (*.zinp)|*.zinp";
            openFileDialog.FilterIndex = 0;
            openFileDialog.RestoreDirectory = true;
            openFileDialog.Multiselect = true;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                ZeusSavedInput savedInput = null;
                ZeusTemplate template = null;
                if (ExecuteTemplateOverride != null)
                {
                    try
                    {
                        foreach (string filename in openFileDialog.FileNames)
                        {
                            savedInput = new ZeusSavedInput(filename);
                            if (savedInput.Load())
                            {
                                template = new ZeusTemplate(savedInput.InputData.TemplatePath);

                                overridden = ExecuteTemplateOverride(TemplateOperations.ExecuteLoadedInput, template, savedInput, _guiHandler);
                                if (!overridden) break;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        OnErrorsOccurred(ex);
                    }
                }
                

                if (!overridden)
                {
                    try
                    {
                        ZeusSimpleLog log = new ZeusSimpleLog();
                        DefaultSettings settings = DefaultSettings.Instance;

                        Cursor.Current = Cursors.WaitCursor;

                        foreach (string filename in openFileDialog.FileNames)
                        {
                            savedInput = new ZeusSavedInput(filename);
                            if (savedInput.Load())
                            {
                                ZeusContext context = new ZeusContext();
                                context.Input.AddItems(savedInput.InputData.InputItems);
                                context.Log = log;

                                template = new ZeusTemplate(savedInput.InputData.TemplatePath);
                                template.Execute(context, settings.ScriptTimeout, true);

                                foreach (string filePath in context.Output.SavedFiles)
                                {
                                    this.OnGeneratedFileSaved(filePath);
                                }

                                if (log.HasExceptions)
                                {
                                    throw log.Exceptions[0];
                                }
                            }
                        }

                        Cursor.Current = Cursors.Default;
                        MessageBox.Show(this, "Selected files have been executed.");

                    }
                    catch (Exception ex)
                    {
                        OnErrorsOccurred(ex);
                    }

                    Cursor.Current = Cursors.Default;
                }
            }
        }
예제 #5
0
        public void ExecuteTemplate(IZeusContext context, string templatePath, string inputFilePath)
        {
            ZeusTemplate template = new ZeusTemplate(templatePath);
            ZeusSavedInput savedInput = null;
            DefaultSettings settings = DefaultSettings.Instance;

            if (!string.IsNullOrEmpty(inputFilePath))
            {
                savedInput = new ZeusSavedInput(inputFilePath);
            }

            context.Log.Write("Executing: " + template.Title);
            if (savedInput != null)
            {
                context.Input.AddItems(savedInput.InputData.InputItems);
                template.Execute(context, settings.ScriptTimeout, true);
            }
            else
            {
                settings.PopulateZeusContext(context);
                template.Execute(context, settings.ScriptTimeout, false);
            }
        }
예제 #6
0
        /// <summary>
        /// Depricated! Use: Execute(string path, bool copyContext)
        /// </summary>
        /// <param name="path"></param>
        public void ExecuteTemplate(string path)
        {
            ZeusTemplate template = new ZeusTemplate(FileTools.MakeAbsolute(path, this.ExecutingTemplate.FilePath));

            template.Execute(this, 0, true);
        }
예제 #7
0
		public void Execute(string path, bool copyContext) 
		{
			ZeusTemplate template = new ZeusTemplate( FileTools.MakeAbsolute(path, this.ExecutingTemplate.FilePath) );
			if (copyContext) 
			{
				template.Execute(this.Copy(), 0, true);
			}
			else 
			{
				template.Execute(this, 0, true);
			}
		}
예제 #8
0
		/// <summary>
		/// Depricated! Use: Execute(string path, bool copyContext) 
		/// </summary>
		/// <param name="path"></param>
		public void ExecuteTemplate(string path) 
		{
			ZeusTemplate template = new ZeusTemplate( FileTools.MakeAbsolute(path, this.ExecutingTemplate.FilePath) );
			template.Execute(this, 0, true);
		}