コード例 #1
0
		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;
		}
コード例 #2
0
		private void SaveInput() 
		{
			try 
			{
				ZeusTemplate template = new ZeusTemplate(this.SelectedTemplate.Tag.ToString());
                DefaultSettings settings = DefaultSettings.Instance;

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

				SavedObject.TemplateUniqueID = template.UniqueID;
				SavedObject.TemplatePath = template.FilePath + template.FileName;

				settings.PopulateZeusContext(context);
				if (_module != null) 
				{
					_module.PopulateZeusContext(context);
				}

				if (template.Collect(context, settings.ScriptTimeout, SavedObject.InputItems)) 
				{
					this._lastRecordedSelectedNode = this.SelectedTemplate;
				}
					
				if (log.HasExceptions) 
				{
					throw log.Exceptions[0];
				}
			}
			catch (Exception ex)
			{
				ZeusDisplayError formError = new ZeusDisplayError(ex);
				formError.SetControlsFromException();			
				formError.ShowDialog(this);
			}

			Cursor.Current = Cursors.Default;
		}
コード例 #3
0
		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;
		}
コード例 #4
0
        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;
        }
コード例 #5
0
        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;
                }
            }
        }
コード例 #6
0
        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;
            }
        }
コード例 #7
0
		private void SaveInput() 
		{
			try 
			{
                if (_collectInChildProcess)
                {
                    this.buttonCollectInput.Enabled = false;
                    this.Cursor = Cursors.WaitCursor;
                    ZeusProcessManager.RecordProjectItem(this._module.RootProject.FilePath, _module.ProjectPath + "/" + SavedObject.SavedObjectName, this.SelectedTemplate.Tag.ToString(), _executionCallback);
                }
                else
                {
                    //RecordProjectItem
                    ZeusTemplate template = new ZeusTemplate(this.SelectedTemplate.Tag.ToString());
                    DefaultSettings settings = DefaultSettings.Instance;

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

                    SavedObject.TemplateUniqueID = template.UniqueID;
                    SavedObject.TemplatePath = template.FilePath + template.FileName;

                    settings.PopulateZeusContext(context);
                    if (_module != null)
                    {
                        _module.PopulateZeusContext(context);
                        _module.OverrideSavedData(SavedObject.InputItems);
                    }

                    if (template.Collect(context, settings.ScriptTimeout, SavedObject.InputItems))
                    {
                        this._lastRecordedSelectedNode = this.SelectedTemplate;
                    }

                    if (log.HasExceptions)
                    {
                        throw log.Exceptions[0];
                    }
                }
            }
			catch (Exception ex)
			{
                mdi.ErrorsOccurred(ex);
                //ZeusDisplayError formError = new ZeusDisplayError(ex);
				//formError.SetControlsFromException();			
				//formError.ShowDialog(this);
			}

			Cursor.Current = Cursors.Default;
        }