示例#1
0
        public void ExecuteTemplate(ZeusTemplate template)
        {
            Cursor.Current = Cursors.WaitCursor;

            DefaultSettings settings = DefaultSettings.Instance;

            IZeusContext    context       = new ZeusContext();
            IZeusGuiControl guiController = context.Gui;
            IZeusOutput     zout          = context.Output;

            settings.PopulateZeusContext(context);

            bool exceptionOccurred = false;
            bool result            = false;

            try
            {
                template.GuiSegment.ZeusScriptingEngine.ExecutionHelper.Timeout = settings.ScriptTimeout;
                template.GuiSegment.ZeusScriptingEngine.ExecutionHelper.SetShowGuiHandler(new ShowGUIEventHandler(DynamicGUI_Display));
                result = template.GuiSegment.Execute(context);
                template.GuiSegment.ZeusScriptingEngine.ExecutionHelper.Cleanup();

                if (result)
                {
                    template.BodySegment.ZeusScriptingEngine.ExecutionHelper.Timeout = settings.ScriptTimeout;
                    result = template.BodySegment.Execute(context);
                    template.BodySegment.ZeusScriptingEngine.ExecutionHelper.Cleanup();
                }
            }
            catch (Exception ex)
            {
                mdi.ErrorsOccurred(ex);
                //ZeusDisplayError formError = new ZeusDisplayError(ex);
                //formError.SetControlsFromException();
                //formError.ShowDialog(this);

                exceptionOccurred = true;
            }

            Cursor.Current = Cursors.Default;

            if (!exceptionOccurred && result)
            {
                if (settings.EnableClipboard)
                {
                    try
                    {
                        Clipboard.SetDataObject(zout.text, true);
                    }
                    catch
                    {
                        // HACK: For some reason, Clipboard.SetDataObject throws an error on some systems. I'm cathhing it and doing nothing for now.
                    }
                }

                MessageBox.Show("Successfully rendered Template: " + template.Title);
            }
        }
示例#2
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;
        }