Esempio n. 1
0
        /// <summary>
        /// Gets the Repository object from the currently running instance of EA.
        /// If multiple instances are running it returns the first one opened.
        /// </summary>
        /// <returns>Repository object for the running instance of EA</returns>
        private static EA.Repository getOpenedModel()
        {
            try
            {
                EA.App ap = (EA.App)Marshal.GetActiveObject("EA.App");

                return(ap.Repository);
            }
            catch (COMException)
            {
                DialogResult result = MessageBox.Show("Nie włączono aplikacji EA.\nWłącz EA i uruchom ponownie"
                                                      , "EA wyłączone", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
                if (result == DialogResult.Retry)
                {
                    //  eaRepository = new EA.Repository();
                    // eaRepository.OpenFile(@"D:\_Projekty\PR-NNN.eap");
                    //return eaRepository;
                    return(getOpenedModel());
                }
                else
                {
                    return(null);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Create a model on the first running EA instance
        /// </summary>
        public Model()
        {
            object obj = Marshal.GetActiveObject("EA.App");

            EaApp = obj as EA.App;
            Initialize(EaApp.Repository);
        }
Esempio n. 3
0
        private void AttachEA()
        {
            EA.App eaapp = null;

            try {
                eaapp = (EA.App)Microsoft.VisualBasic.Interaction.GetObject(null, "EA.App");
            } catch (Exception e) {
                toolStripStatusLabel1.Text = "EAが起動していなかったため、EAへの反映機能は使えません : " + e.Message;
                // MessageBox.Show( e.Message );
                return;
            } finally {
            }

            if (ProjectSetting.getVO() != null)
            {
                if (eaapp != null)
                {
                    EA.Repository repo = eaapp.Repository;
//					eaapp.Visible = true;
                    ProjectSetting.getVO().eaRepo = repo;
                    toolStripStatusLabel1.Text = "EAへのアタッチ成功 EA接続先=" + repo.ConnectionString;
                }
                else
                {
                    toolStripStatusLabel1.Text = "EAにアタッチできなかったため、EAへの反映機能は使えません";
                }
            }
        }
        private void AttachEA()
        {
            EA.App eaapp = null;

            if (ProjectSetting.getVO() == null)
            {
                toolStripStatusLabel1.Text = "[ファイル]メニューの[開く]を選択しプロジェクトをオープンしてください";
                return;
            }

            try {
                eaapp = (EA.App)Microsoft.VisualBasic.Interaction.GetObject(null, "EA.App");

                if (eaapp != null)
                {
                    EA.Repository repo = eaapp.Repository;
//					eaapp.Visible = true;
                    ProjectSetting.getVO().eaRepo = repo;
                    string connStr = repo.ConnectionString;
                    if (connStr.Length > 50)
                    {
                        connStr = connStr.Substring(0, 50);
                    }
                    toolStripStatusLabel1.Text = "EAへのアタッチ成功 EA接続先=" + connStr;
                }
                else
                {
                    toolStripStatusLabel1.Text = "EAにアタッチできなかったため、EAへの反映機能は使えません";
                }
            } catch (Exception ex) {
                toolStripStatusLabel1.Text = "EAが起動していなかったため、EAへの反映機能は使えません : " + ex.Message;
                return;
            }
        }
        /// <summary>
        /// Return all EA Instances from the ROT (Running Object Table) of COM.
        /// </summary>
        /// <returns></returns>
        public static List <EAAppInstance> GetEAInstances()
        {
            List <EAAppInstance> result = new List <EAAppInstance>();

            Hashtable runningObjects = GetRunningObjectTable();

            IDictionaryEnumerator rotEnumerator = runningObjects.GetEnumerator();

            while (rotEnumerator.MoveNext())
            {
                string candidateName = (string)rotEnumerator.Key;

                if (!candidateName.ToUpper().Contains("EA"))
                {
                    continue;
                }

                EA.App eaApplication = rotEnumerator.Value as EA.App;

                if (eaApplication == null)
                {
                    continue;
                }

                // Remember the process Id so we can Show that window to the user
                int processId = int.Parse(candidateName.Split(':')[1]);

                result.Add(new EAAppInstance(eaApplication, processId));
            }

            return(result);
        }
        /// <summary>
        /// Test Main: Get all EA Instances and get the connection string from the repository.
        /// </summary>
        public static void Main()
        {
            List <EAAppInstance> l = GetEAInstances();

            foreach (EAAppInstance el in l)
            {
                EA.App        eaApp = el.EaApp;
                EA.Repository rep   = eaApp.Repository;
                string        name  = rep.ConnectionString;
            }
        }
Esempio n. 7
0
 private EA.Repository GetRepository()
 {
     try
     {
         //get the EA model
         object obj   = Marshal.GetActiveObject("EA.App");
         EA.App eaApp = obj as EA.App;
         return(eaApp.Repository);
     }
     catch (Exception)
     {
         //do nothing
         return(null);
     }
 }
        private static string GetNameProperty(EABrowsableObjectsCollection <T> coll, int idx)
        {
            int    displayIndex    = idx + 1;
            string name            = "#" + displayIndex.ToString();
            T      browsableObject = coll[idx];

            EA.App        app        = System.Runtime.InteropServices.Marshal.GetActiveObject("EA.App") as EA.App;
            EA.Repository repository = app.Repository;

            EADualInterface <T> dualInterface = new EADualInterface <T>(browsableObject);
            string objectName = dualInterface.GetPropertyValue("Name");

            if (!string.IsNullOrEmpty(objectName))
            {
                name = name + "(" + objectName + ")";
            }

            return(name);
        }
 /// <summary>
 /// Create a model on the first running EA instance
 /// </summary>
 public Model()
 {
     object obj = Marshal.GetActiveObject("EA.App");
     EaApp = obj as EA.App;
     Initialize(EaApp.Repository);
 }
Esempio n. 10
0
 static RepositoryUnderTest()
 {
     App = new EA.App();
     App.Repository.CreateModel(EA.CreateModelType.cmEAPFromBase, RepositoryPath, 0);
     App.Repository.OpenFile(RepositoryPath);
 }
Esempio n. 11
0
 public EAAppInstance(EA.App eaApp, int processId)
 {
     EaApp     = eaApp;
     ProcessId = processId;
 }