public void Execute()
        {
            this.Save();
            ZeusProject proj = this._rootNode.Project;

            Cursor.Current = Cursors.WaitCursor;

            TreeNode        node     = this.treeViewProject.SelectedNode;
            DefaultSettings settings = DefaultSettings.Instance;

            if (node is ProjectTreeNode)
            {
                OnExecutionStarted();
                ZeusProcessManager.ExecuteProject(proj.FilePath, ExecutionCallback);
            }
            else if (node is ModuleTreeNode)
            {
                ZeusModule module = node.Tag as ZeusModule;
                OnExecutionStarted();
                ZeusProcessManager.ExecuteModule(proj.FilePath, module.ProjectPath, ExecutionCallback);
                //module.Execute(settings.ScriptTimeout, log);
            }
            else if (node is SavedObjectTreeNode)
            {
                SavedTemplateInput savedinput = node.Tag as SavedTemplateInput;
                ZeusModule         module     = node.Parent.Tag as ZeusModule;
                OnExecutionStarted();
                ZeusProcessManager.ExecuteProjectItem(proj.FilePath, module.ProjectPath + "/" + savedinput.SavedObjectName, ExecutionCallback);
                //savedinput.Execute(settings.ScriptTimeout, log);
            }
        }
        public void LoadProject(string filename)
        {
            this.treeViewProject.Nodes.Clear();

            ZeusProject proj = new ZeusProject(filename);

            if (proj.Load())
            {
                this.Text    = "Project: " + proj.Name;
                this.TabText = proj.Name;

                rootNode = new ProjectTreeNode(proj);

                foreach (ZeusModule module in proj.ChildModules)
                {
                    LoadModule(rootNode, module);
                }

                foreach (SavedTemplateInput input in proj.SavedObjects)
                {
                    rootNode.AddSorted(new SavedObjectTreeNode(input));
                }
            }
            rootNode.Expand();


            this.treeViewProject.Nodes.Add(rootNode);
        }
        private void SaveAs()
        {
            Stream         myStream;
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = "Zeus Project (*.zprj)|*.zprj|All files (*.*)|*.*";
            saveFileDialog.FilterIndex      = 0;
            saveFileDialog.RestoreDirectory = true;

            ZeusProject proj = this.rootNode.Project;

            if (proj.FilePath != null)
            {
                saveFileDialog.FileName = proj.FilePath;
            }

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                myStream = saveFileDialog.OpenFile();

                if (null != myStream)
                {
                    _isDirty = false;

                    myStream.Close();
                    proj.FilePath = saveFileDialog.FileName;
                    proj.Save();
                }
            }
        }
        public void LoadProject(string filename)
        {
            this.treeViewProject.Nodes.Clear();

            ZeusProject proj = new ZeusProject(filename);

            proj.DefaultSettingsDelegate = new GetDefaultSettingsDelegate(GetDefaultSettingsDictionary);
            if (proj.Load())
            {
                OnTextChanged("Project: " + proj.Name, proj.Name, filename);

                _rootNode = new ProjectTreeNode(proj);

                foreach (ZeusModule module in proj.ChildModules)
                {
                    LoadModule(_rootNode, module);
                }

                foreach (SavedTemplateInput input in proj.SavedObjects)
                {
                    _rootNode.AddSorted(new SavedObjectTreeNode(input));
                }
            }
            _rootNode.Expand();


            this.treeViewProject.Nodes.Add(_rootNode);
        }
Exemple #5
0
        public ProjectTreeNode(ZeusProject proj)
        {
            this.Tag = proj;

            this.Text               = proj.Name;
            this.ImageIndex         = 1;
            this.SelectedImageIndex = 1;
        }
        public void CreateNewProject()
        {
            this.treeViewProject.Nodes.Clear();

            ZeusProject proj = new ZeusProject();

            proj.Name        = "New Project";
            proj.Description = "New Zeus Project file";

            rootNode = new ProjectTreeNode(proj);
            rootNode.Expand();

            this.Text    = "Project: " + proj.Name;
            this.TabText = proj.Name;

            this.treeViewProject.Nodes.Add(rootNode);
        }
Exemple #7
0
        public void LoadProject(string filename)
        {
            this.treeViewProject.Nodes.Clear();

            if (rootNode == null)
            {
                ZeusProject proj = new ZeusProject(filename);
                if (proj.Load())
                {
                    //rootNode = new ProjectTreeNode(proj);
                    LoadModule(null, proj);
                }
                rootNode.Expand();
            }

            this.treeViewProject.Nodes.Add(rootNode);
        }
        public void CreateNewProject()
        {
            this.treeViewProject.Nodes.Clear();

            ZeusProject proj = new ZeusProject();

            proj.DefaultSettingsDelegate = new GetDefaultSettingsDelegate(GetDefaultSettingsDictionary);
            proj.Name        = "New Project";
            proj.Description = "New Zeus Project file";

            _rootNode = new ProjectTreeNode(proj);
            _rootNode.Expand();

            OnTextChanged("Project: " + proj.Name, proj.Name, null);

            this.treeViewProject.Nodes.Add(_rootNode);
        }
        public void ExecuteProjectModule(IZeusContext context, string projectFilePath, params string[] modules)
        {
            var zeusProject = new ZeusProject(projectFilePath);

            if (modules.Length == 0)
            {
                context.Log.Write("Executing: " + zeusProject.Name);
                zeusProject.Execute(DefaultSettings.Instance.ScriptTimeout, context.Log);
            }
            else
            {
                foreach (var mod in modules)
                {
                    context.Log.Write("Executing: " + mod);
                    ExecuteModules(context, zeusProject, new List <string>(modules), DefaultSettings.Instance.ScriptTimeout);
                }
            }
        }
Exemple #10
0
        public void ExecuteProjectModule(IZeusContext context, string projectFilePath, params string[] modules)
        {
            ZeusProject     proj     = new ZeusProject(projectFilePath);
            DefaultSettings settings = DefaultSettings.Instance;

            if (modules.Length == 0)
            {
                context.Log.Write("Executing: " + proj.Name);
                proj.Execute(settings.ScriptTimeout, context.Log);
            }
            else
            {
                foreach (string mod in modules)
                {
                    context.Log.Write("Executing: " + mod);
                    ExecuteModules(context, proj, new List <string>(modules), settings.ScriptTimeout);
                }
            }
        }
Exemple #11
0
        private void Parse(string[] args)
        {
            int    numargs = args.Length;
            string arg;

            if (numargs == 0)
            {
                this._showHelp = true;
                return;
            }

            for (int i = 0; i < numargs; i++)
            {
                arg = args[i];

                switch (arg)
                {
                case "-internaluse":
                    this._internalUse = true;
                    break;

                case "-installvs2005":
                    this._installVS2005 = true;
                    break;

                case "-tc":
                case "-testconnection":
                    this._mode = ProcessMode.MyMeta;
                    if (numargs > (i + 2))
                    {
                        this._connType   = args[++i];
                        this._connString = args[++i];
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-aio":
                case "-addintrinsicobject":
                    if (numargs > (i + 3))
                    {
                        string assembly  = args[++i];
                        string classpath = args[++i];
                        string varname   = args[++i];

                        ZeusIntrinsicObject iobj = new ZeusIntrinsicObject(assembly, classpath, varname);
                        this._intrinsicObjects.Add(iobj);
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-rio":
                case "-removeintrinsicobject":
                    if (numargs > (i + 1))
                    {
                        string varname = args[++i];
                        foreach (ZeusIntrinsicObject zio in ZeusConfig.Current.IntrinsicObjects)
                        {
                            if (zio.VariableName == varname && !_intrinsicObjectsToRemove.Contains(zio))
                            {
                                this._intrinsicObjectsToRemove.Add(zio);
                                break;
                            }
                        }
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-r":
                case "-relative":
                    this._makeRelative = true;
                    break;

                case "-s":
                case "-silent":
                    this._silent = true;
                    break;

                case "-?":
                case "-h":
                case "-help":
                    this._showHelp = true;
                    break;

                case "-l":
                case "-logfile":
                    this._enableLog = true;
                    if (numargs > (i + 1))
                    {
                        this._pathLog = args[++i];
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-o":
                case "-outfile":
                    if (numargs > (i + 1))
                    {
                        this._pathOutput = args[++i];
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-p":
                case "-project":
                    this._mode = ProcessMode.Project;
                    if (numargs > (i + 1))
                    {
                        this._pathProject = args[++i];
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-mumd":
                case "-mergeusermetadata":
                    this._mode          = ProcessMode.MyMeta;
                    this._metaDataMerge = true;
                    if (numargs > (i + 5))
                    {
                        this._metaDataFile1      = args[++i];
                        this._metaDatabase1      = args[++i];
                        this._metaDataFile2      = args[++i];
                        this._metaDatabase2      = args[++i];
                        this._metaDataFileMerged = args[++i];
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-m":
                case "-pf":
                case "-module":
                case "-projectfolder":
                    if (numargs > (i + 1))
                    {
                        string data = args[++i];
                        if (!_moduleNames.Contains(data))
                        {
                            this._moduleNames.Add(data);
                        }
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-rti":
                case "-recordtemplateinstance":
                    if (numargs > (i + 1))
                    {
                        this._projectItemToRecord = args[++i];
                        this._mode = ProcessMode.Project;
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-ti":
                case "-templateinstance":
                    if (numargs > (i + 1))
                    {
                        string data = args[++i];
                        if (!_projectItems.Contains(data))
                        {
                            this._projectItems.Add(data);
                        }
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-i":
                case "-inputfile":
                    this._mode = ProcessMode.Template;
                    if (numargs > (i + 1))
                    {
                        this._pathXmlData = args[++i];
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-t":
                case "-template":
                    this._mode = ProcessMode.Template;
                    if (numargs > (i + 1))
                    {
                        this._pathTemplate = args[++i];
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-c":
                case "-collect":
                    this._mode = ProcessMode.Template;
                    if (numargs > (i + 1))
                    {
                        this._pathCollectXmlData = args[++i];
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                case "-e":
                case "-timeout":
                    if (numargs > (i + 1))
                    {
                        try
                        {
                            this._timeout = Int32.Parse(args[++i]);
                        }
                        catch
                        {
                            this._timeout = -1;
                        }
                    }
                    else
                    {
                        this._valid        = false;
                        this._errorMessage = "Invalid switch usage: " + arg;
                    }
                    break;

                default:
                    _valid             = false;
                    this._errorMessage = "Invalid argument: " + arg;
                    break;
                }
            }

            if (this._makeRelative)
            {
                if (this._pathCollectXmlData != null)
                {
                    this._pathCollectXmlData = Zeus.FileTools.MakeAbsolute(this._pathCollectXmlData, FileTools.ApplicationPath);
                }
                if (this._pathLog != null)
                {
                    this._pathLog = Zeus.FileTools.MakeAbsolute(this._pathLog, FileTools.ApplicationPath);
                }
                if (this._pathOutput != null)
                {
                    this._pathOutput = Zeus.FileTools.MakeAbsolute(this._pathOutput, FileTools.ApplicationPath);
                }
                if (this._pathProject != null)
                {
                    this._pathProject = Zeus.FileTools.MakeAbsolute(this._pathProject, FileTools.ApplicationPath);
                }
                if (this._pathTemplate != null)
                {
                    this._pathTemplate = Zeus.FileTools.MakeAbsolute(this._pathTemplate, FileTools.ApplicationPath);
                }
                if (this._pathXmlData != null)
                {
                    this._pathXmlData = Zeus.FileTools.MakeAbsolute(this._pathXmlData, FileTools.ApplicationPath);
                }
                if (this._metaDataFile1 != null)
                {
                    this._metaDataFile1 = Zeus.FileTools.MakeAbsolute(this._metaDataFile1, FileTools.ApplicationPath);
                }
                if (this._metaDataFile2 != null)
                {
                    this._metaDataFile2 = Zeus.FileTools.MakeAbsolute(this._metaDataFile2, FileTools.ApplicationPath);
                }
                if (this._metaDataFileMerged != null)
                {
                    this._metaDataFileMerged = Zeus.FileTools.MakeAbsolute(this._metaDataFileMerged, FileTools.ApplicationPath);
                }
            }


            // Validate required fields are filled out for the selected mode.
            if (_valid)
            {
                if (this.Mode == ProcessMode.MyMeta)
                {
                    if (this._metaDataMerge)
                    {
                        if (!System.IO.File.Exists(_metaDataFile1) || !System.IO.File.Exists(_metaDataFile2))
                        {
                            _valid             = false;
                            this._errorMessage = "The two source files must exist for the merge to work!";
                        }
                    }
                }
                else if (this._mode == ProcessMode.Project)
                {
                    if (this._pathProject == null)
                    {
                        _valid             = false;
                        this._errorMessage = "Project Path Required";
                    }
                    else
                    {
                        try
                        {
                            this._project = new ZeusProject(this._pathProject);
                            this._project.Load();
                        }
                        catch (Exception ex)
                        {
                            this._project      = null;
                            this._valid        = false;
                            this._errorMessage = ex.Message;
                        }
                    }


                    if (this._pathTemplate != null)
                    {
                        try
                        {
                            this._template = new ZeusTemplate(this._pathTemplate);
                        }
                        catch (Exception ex)
                        {
                            this._template     = null;
                            this._valid        = false;
                            this._errorMessage = ex.Message;
                        }
                    }
                }
                else if (this._mode == ProcessMode.Template)
                {
                    if ((this._pathTemplate == null) && (this._pathXmlData == null))
                    {
                        _valid             = false;
                        this._errorMessage = "Template path or XML input path required.";
                    }
                    else
                    {
                        if (this._pathTemplate != null)
                        {
                            try
                            {
                                this._template = new ZeusTemplate(this._pathTemplate);
                            }
                            catch (Exception ex)
                            {
                                this._template     = null;
                                this._valid        = false;
                                this._errorMessage = ex.Message;
                            }
                        }

                        if ((this._valid) && (this._pathXmlData != null))
                        {
                            try
                            {
                                this._savedInput = new ZeusSavedInput(this._pathXmlData);
                                this._savedInput.Load();

                                if (this._template == null)
                                {
                                    this._template = new ZeusTemplate(this._savedInput.InputData.TemplatePath);
                                }
                            }
                            catch (Exception ex)
                            {
                                this._savedInput   = null;
                                this._template     = null;
                                this._valid        = false;
                                this._errorMessage = ex.Message;
                            }
                        }

                        if ((this._valid) && (this._pathCollectXmlData != null))
                        {
                            try
                            {
                                this._inputToSave = new ZeusSavedInput(this._pathCollectXmlData);
                                this._inputToSave.InputData.TemplatePath     = this._template.FilePath + this._template.FileName;
                                this._inputToSave.InputData.TemplateUniqueID = this._template.UniqueID;
                            }
                            catch (Exception ex)
                            {
                                this._inputToSave  = null;
                                this._valid        = false;
                                this._errorMessage = ex.Message;
                            }
                        }
                    }
                }
            }
        }
Exemple #12
0
        private void _ProcessProject()
        {
            ZeusProject proj = this._argmgr.Project;

            this._log.Write("Begin Project Processing: " + proj.Name);
            if (this._argmgr.ModuleNames.Count > 0)
            {
                foreach (string mod in _argmgr.ModuleNames)
                {
                    this._log.Write("Executing: " + mod);
                    try
                    {
                        if (!ExecuteModule(proj, mod))
                        {
                            this._log.Write("Project Folder not found: {0}.", mod);
                        }
                    }
                    catch (Exception ex)
                    {
                        this._log.Write(ex);
                        this._log.Write("Project Folder execution failed for folder: {0}.", mod);
                    }
                }
            }
            else if (!string.IsNullOrEmpty(this._argmgr.ProjectItemToRecord) &&
                     !string.IsNullOrEmpty(this._argmgr.PathTemplate))
            {
                string item     = _argmgr.ProjectItemToRecord;
                string template = _argmgr.PathTemplate;
                this._log.Write("Collecting: " + item + " for template " + template);
                try
                {
                    if (!CollectProjectItem(proj, item, template))
                    {
                        this._log.Write("Project Item not found: {0}.", item);
                    }
                }
                catch (Exception ex)
                {
                    this._log.Write(ex);
                    this._log.Write("Project Item collection failed for item: {0}.", item);
                }
            }
            else if (this._argmgr.ProjectItems.Count > 0)
            {
                foreach (string item in _argmgr.ProjectItems)
                {
                    this._log.Write("Executing: " + item);
                    try
                    {
                        if (!ExecuteProjectItem(proj, item))
                        {
                            this._log.Write("Project Item not found: {0}.", item);
                        }
                    }
                    catch (Exception ex)
                    {
                        this._log.Write(ex);
                        this._log.Write("Project Item execution failed for item: {0}.", item);
                    }
                }
            }
            else
            {
                this._log.Write("Executing: " + proj.Name);
                try
                {
                    proj.Execute(this._argmgr.Timeout, this._log);

                    if (this._argmgr.InternalUseOnly)
                    {
                        foreach (string file in proj.SavedFiles)
                        {
                            this._log.Write("[GENERATED_FILE]" + file);
                        }
                    }
                }
                catch (Exception ex)
                {
                    this._log.Write(ex);
                    this._log.Write("Project execution failed.");
                }
            }
            this._log.Write("End Project Processing: " + proj.Name);
            if (_argmgr.InternalUseOnly)
            {
                this._log.Write("[PROJECT_GENERATION_COMPLETE]");
            }
        }