public IZeusSavedInput ExecuteTemplateAndCollectInput(IZeusContext context, string templatePath)
        {
            var template       = new ZeusTemplate(templatePath);
            var collectedInput = new ZeusSavedInput();

            DefaultSettings.Instance.PopulateZeusContext(context);
            template.ExecuteAndCollect(context, DefaultSettings.Instance.ScriptTimeout, collectedInput.InputData.InputItems);
            collectedInput.Save();

            return(collectedInput);
        }
Beispiel #2
0
        public IZeusSavedInput CollectTemplateInput(IZeusContext context, string templatePath)
        {
            ZeusTemplate    template       = new ZeusTemplate(templatePath);
            ZeusSavedInput  collectedInput = new ZeusSavedInput();
            DefaultSettings settings       = DefaultSettings.Instance;

            settings.PopulateZeusContext(context);
            template.Collect(context, settings.ScriptTimeout, collectedInput.InputData.InputItems);
            collectedInput.Save();

            return(collectedInput);
        }
        public IZeusSavedInput ExecuteTemplateAndCollectInput(IZeusContext context, string templatePath)
        {
            ZeusTemplate template = new ZeusTemplate(templatePath);
            ZeusSavedInput collectedInput = new ZeusSavedInput();
            DefaultSettings settings = DefaultSettings.Instance;

            settings.PopulateZeusContext(context);
            template.ExecuteAndCollect(context, settings.ScriptTimeout, collectedInput.InputData.InputItems);
            collectedInput.Save();

            return collectedInput;
        }
		public void SaveInput(ZeusTemplate template) 
		{
			try 
			{
                DefaultSettings settings = DefaultSettings.Instance;

				ZeusSimpleLog log = new ZeusSimpleLog();
				ZeusContext context = new ZeusContext();
				context.Log = log;

				ZeusSavedInput collectedInput = new ZeusSavedInput();
				collectedInput.InputData.TemplateUniqueID = template.UniqueID;
				collectedInput.InputData.TemplatePath = template.FilePath + template.FileName;

				settings.PopulateZeusContext(context);
				template.Collect(context, settings.ScriptTimeout, collectedInput.InputData.InputItems);
					
				if (log.HasExceptions) 
				{
					throw log.Exceptions[0];
				}
				else 
				{
					SaveFileDialog saveFileDialog = new SaveFileDialog();
					saveFileDialog.Filter = "Zues Input Files (*.zinp)|*.zinp";
					saveFileDialog.FilterIndex = 0;
					saveFileDialog.RestoreDirectory = true;
					if(saveFileDialog.ShowDialog() == DialogResult.OK)
					{
						Cursor.Current = Cursors.WaitCursor;

						collectedInput.FilePath = saveFileDialog.FileName;
						collectedInput.Save();
					}
				}

				MessageBox.Show(this, "Input collected and saved to file: \r\n" + collectedInput.FilePath);
			}
			catch (Exception ex)
			{
                mdi.ErrorsOccurred(ex);
                //ZeusDisplayError formError = new ZeusDisplayError(ex);
				//formError.SetControlsFromException();			
				//formError.ShowDialog(this);
			}

			Cursor.Current = Cursors.Default;
		}
        private void _SaveTemplateInput()
        {
            try
            {
                Directory.SetCurrentDirectory(Application.StartupPath);
                this.RefreshTemplateFromControl();

                DefaultSettings settings = DefaultSettings.Instance;

                ZeusSimpleLog log = new ZeusSimpleLog();
                log.LogEntryAdded += new EventHandler(Log_EntryAdded);
                ZeusContext context = new ZeusContext();
                context.Log = log;

                ZeusSavedInput collectedInput = new ZeusSavedInput();
                collectedInput.InputData.TemplateUniqueID = _template.UniqueID;
                collectedInput.InputData.TemplatePath = _template.FilePath + _template.FileName;

                settings.PopulateZeusContext(context);

                _template.Collect(context, settings.ScriptTimeout, collectedInput.InputData.InputItems);

                if (log.HasExceptions)
                {
                    throw log.Exceptions[0];
                }
                else
                {
                    SaveFileDialog saveFileDialog = new SaveFileDialog();
                    saveFileDialog.Filter = "Zues Input Files (*.zinp)|*.zinp";
                    saveFileDialog.FilterIndex = 0;
                    saveFileDialog.RestoreDirectory = true;
                    if (saveFileDialog.ShowDialog() == DialogResult.OK)
                    {
                        Cursor.Current = Cursors.WaitCursor;

                        collectedInput.FilePath = saveFileDialog.FileName;
                        collectedInput.Save();
                    }
                }

                MessageBox.Show(this, "Input collected and saved to file:" + "\r\n" + collectedInput.FilePath);
            }
            catch (Exception ex)
            {
                HandleExecuteException(ex);
            }

            Cursor.Current = Cursors.Default;
        }
        public void SaveInput(ZeusTemplate template)
        {
            bool overridden = false;
            if (ExecuteTemplateOverride != null)
            {
                overridden = ExecuteTemplateOverride(TemplateOperations.SaveInput, template, null, _guiHandler);
            }

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

                    ZeusSimpleLog log = new ZeusSimpleLog();
                    ZeusContext context = new ZeusContext();
                    context.Log = log;

                    ZeusSavedInput collectedInput = new ZeusSavedInput();
                    collectedInput.InputData.TemplateUniqueID = template.UniqueID;
                    collectedInput.InputData.TemplatePath = template.FilePath + template.FileName;

                    settings.PopulateZeusContext(context);
                    template.Collect(context, settings.ScriptTimeout, collectedInput.InputData.InputItems);

                    if (log.HasExceptions)
                    {
                        throw log.Exceptions[0];
                    }
                    else
                    {
                        SaveFileDialog saveFileDialog = new SaveFileDialog();
                        saveFileDialog.Filter = "Zues Input Files (*.zinp)|*.zinp";
                        saveFileDialog.FilterIndex = 0;
                        saveFileDialog.RestoreDirectory = true;
                        if (saveFileDialog.ShowDialog() == DialogResult.OK)
                        {
                            Cursor.Current = Cursors.WaitCursor;

                            collectedInput.FilePath = saveFileDialog.FileName;
                            collectedInput.Save();
                        }
                    }

                    MessageBox.Show(this, "Input collected and saved to file: \r\n" + collectedInput.FilePath);
                }
                catch (Exception ex)
                {
                    OnErrorsOccurred(ex);
                }

                Cursor.Current = Cursors.Default;
            }
        }
Beispiel #7
0
        private void _ProcessTemplate()
        {
            ZeusTemplate   template       = this._argmgr.Template;
            ZeusSavedInput savedInput     = this._argmgr.SavedInput;
            ZeusSavedInput collectedInput = this._argmgr.InputToSave;
            ZeusContext    context        = new ZeusContext();

            context.Log = _log;
            DefaultSettings settings;

            this._log.Write("Executing: " + template.Title);
            try
            {
                if (savedInput != null)
                {
                    context.Input.AddItems(savedInput.InputData.InputItems);
                    template.Execute(context, this._argmgr.Timeout, true);
                }
                else if (collectedInput != null)
                {
                    settings = DefaultSettings.Instance;
                    settings.PopulateZeusContext(context);
                    template.ExecuteAndCollect(context, this._argmgr.Timeout, collectedInput.InputData.InputItems);
                    collectedInput.Save();
                }
                else
                {
                    settings = DefaultSettings.Instance;
                    settings.PopulateZeusContext(context);
                    template.Execute(context, this._argmgr.Timeout, false);
                }

                if (this._argmgr.PathOutput != null)
                {
                    StreamWriter writer = File.CreateText(this._argmgr.PathOutput);
                    writer.Write(context.Output.text);
                    writer.Flush();
                    writer.Close();
                }
                else
                {
                    if (!_argmgr.IsSilent)
                    {
                        Console.WriteLine(context.Output.text);
                    }
                }
            }
            catch (Exception ex)
            {
                this._log.Write(ex);
                this._log.Write("Template execution failed.");
            }

            if (context != null && this._argmgr.InternalUseOnly)
            {
                foreach (string file in context.Output.SavedFiles)
                {
                    this._log.Write("[GENERATED_FILE]" + file);
                }
            }
        }