Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Andreas Morgenstern

Pages: 1 [2]
16
General Board / Deleting of Notes not possible
« on: June 14, 2016, 08:22:20 pm »
Hello all,

I've got some strange artifacts (Notes) in my EA model which I'm not able to delete.
These are notes that had originally been generated during the import of Use Cases (Extension Point:read an alert).
Any idea how I can remove them ?


Andreas

17
Automation Interface, Add-Ins and Tools / Re: Run Script by AddIn
« on: July 07, 2015, 06:19:23 pm »
Hi,

last year I had exactly the same problem. You can use MSScript Control. You can search the forum for the problem.
I also included some sample code I used for that purpose.

Andreas


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MSScriptControl;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using System.Xml.Linq;
using MSScriptControl;
namespace AddInScriptInterop
{
    class ScriptInterop
    {
        public string[] ScriptNames { get; private set; }
        public string[] ScriptLanguage { get; private set; }
        private EA.Repository Repository;
        public void startControl(EA.Repository rep)
        {
            this.Repository = rep;
        }
        /// <summary>
        /// Extracts the Script names from the Repository
        /// </summary>
        /// <returns></returns>
        public string[] getScriptNames()
        {
            String xmlString = (Repository.SQLQuery("SELECT Notes from t_script WHERE Notes LIKE '*Script Name*'"));
            return
                ((from sc in
                 (
                     // we take notes and have to parse the value to get the script node!
                     from notes in (XDocument.Parse(xmlString).Descendants("Notes"))
                     select (XDocument.Parse(notes.Value))
                 )
             select (sc.Element("Script").Attribute("Name").Value)).ToArray<string>());
            
        }
        public string[] getScriptLanguages() {
            String xmlString = (Repository.SQLQuery("SELECT Notes from t_script WHERE Notes LIKE '*Script Name*'"));
        return
                (from sc in
                     (
                         // we take notes and have to parse the value to get the script node!
                        from notes in (XDocument.Parse(xmlString).Descendants("Notes"))
                        select (XDocument.Parse(notes.Value))
                    )
                 select (sc.Element("Script").Attribute("Language").Value)).ToArray<string>();
        }

        /// <summary>
        /// Execute a script. Data Exchange can either be done by passing parameters or by handing over global objects
        /// </summary>
        /// <param name="script">script to be executed</param>
        /// <param name="scriptlanguage">script language</param>
        /// <param name="runobject">paremters passed to the script</param>
        /// <param name="addObject">global objects added to the script control engine</param>
        /// <returns></returns>
        private int ExecuteScript(string script, string scriptlanguage, Object[] runobject, Object[] addObject)
        {
            MSScriptControl.ScriptControlClass control = new ScriptControlClass();
            control.Language = scriptlanguage;
            control.AllowUI = true;
            // Pass global objects
            control.AddObject("Repository", Repository);
            for (int i = 0; i < addObject.Length; i++)
            {
                string name = "AddObject" + i;
                control.AddObject(name, addObject);
            }
            int ret = -1;
            try
            {
                control.AddCode(script);
                ret = (int)control.Run("main", runobject);
            }
            catch
            {
                MessageBox.Show(control.Error.Description + " (line " + control.Error.Line + ")");
            }
            return ret;

        }

    }
}

18
Ok,

thanks. I feared that that would be the answer.

Andreas

19
Hi,

that works. But I found no way to automatically add
it to the profile/MDG. Any idea ?
I already tried to create a project template. But it seems that the setting of the project template package is lost when I export it  :(

Andreas

20
Hi,

I've created a RTF-Template for an "Architecture Scenario Template" and added it to our UML-profile. Moreover, I created a Stereotype "Architecture Scenario" that extends artifact.

However, ideally, I'd like to have that whenever a new "Architecture Scenario" Element is created, a linked document filled with "Architecture Scenario Template" should be automatically added.
Is there a way to achieve that without addins ?

Thanks a lot,

Andreas
  


21
Ok,

thanks for your answer. I was expecting that after reading the API docu, but wanted to make sure.

Andreas

22
Hi,

Is there a way to synchronize the EA Database and the "Objects" provided by the API.
Assume I retrieved the root model with
Code: [Select]
root=Repository.Models.getAt(0)in an Addin
Clearly, I can change the name with
Code: [Select]
root.Name="Test" Updating the database can now be done with
Code: [Select]
root.Update()
But I don't know how to do accomplish this the opposite way. Is there a build-in method that reloads the content of the database?
I mean I can retrieve the root again from the database, but is there an automatic way to do it?

Thanks,

Andreas


23
Automation Interface, Add-Ins and Tools / Re: Run script from API
« on: July 15, 2014, 06:08:58 pm »
Hi,

thanks for your help. Now it is running. May I add another question?
Have you ever tried to Exchange data between the addin and the script (in both directions)?

Andreas

24
Automation Interface, Add-Ins and Tools / Re: Run script from API
« on: July 11, 2014, 10:27:08 pm »
Hi,

I've just started working with EA and find this discussion really interesting, since this is exactly what I was looking for. But I'm a Little bit confused. Is the code from :
Quote
Dear Nizam,

thanks for your script.

The above montioned code works great, except the sc.RUN-command needs additional objects.

For completeness:

Code: [Select]
               SC.AddCode(Repo.SQLquery(""));
                Object[] runobject = { };
                    result = SC.Run("FuncName", runobject);
                }

Best regards

Stefan

used in your addin, i.e. is it a VBA addin ?
If yes, I'm trying to achieve the same in an addin implemented in C#. Does this also work?

Andreas
 

25
Automation Interface, Add-Ins and Tools / Event on run script
« on: July 16, 2014, 10:01:07 pm »
Hi,

I'd like to react in a (C#) Addin when a user runs a script.
Is this somehow possible ?

Andreas

Pages: 1 [2]