Esempio n. 1
0
        private bool CollectProjectItem(ZeusModule parent, string projectPath, string templatePath)
        {
            bool complete    = false;
            int  moduleIndex = projectPath.LastIndexOf('/');

            if (moduleIndex >= 0)
            {
                string modulePath = projectPath.Substring(0, moduleIndex),
                       objectName = projectPath.Substring(moduleIndex + 1);

                ZeusModule m = FindModule(parent, modulePath);
                if (m != null)
                {
                    ZeusTemplate    template = new ZeusTemplate(templatePath);
                    DefaultSettings settings = DefaultSettings.Instance;

                    SavedTemplateInput savedInput = null;
                    if (m.SavedObjects.Contains(objectName))
                    {
                        savedInput = m.SavedObjects[objectName];
                    }
                    else
                    {
                        savedInput = new SavedTemplateInput();
                        savedInput.SavedObjectName = objectName;
                    }


                    ZeusContext context = new ZeusContext();
                    context.Log = this._log;

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

                    settings.PopulateZeusContext(context);
                    if (m != null)
                    {
                        m.PopulateZeusContext(context);
                        m.OverrideSavedData(savedInput.InputItems);
                    }

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


                    if (this._argmgr.InternalUseOnly)
                    {
                        this._log.Write("[BEGIN_RECORDING]");

                        this._log.Write(savedInput.XML);

                        this._log.Write("[END_RECORDING]");
                    }
                    complete = true;
                }
            }
            return(complete);
        }
Esempio n. 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;
        }