예제 #1
0
        private void worker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker = sender as BackgroundWorker;

            MainImport import = MainImport.getInstance(repository, worker);

            import.startImport(mocaTree, checkedMetamodelsToImport, true);
        }
예제 #2
0
        public void doImport()
        {
            if (import.Value && eapFile.Values.Count == 1)
            {
                EA.Repository repository = null;
                try
                {
                    foreach (String eapFilename in eapFile.Values)
                    {
                        Console.Out.WriteLine("DEBUG:Start import#");
                        String xmiFilename = xmiFile.Value;

                        EAEcoreAddin.Main main = new EAEcoreAddin.Main();
                        repository = new EA.Repository();
                        repository.OpenFile(eapFilename);



                        Console.Out.WriteLine("DEBUG:Initialize Importer#");
                        SQLRepository sqlRepository = new SQLRepository(repository, false);
                        MainImport    importer      = MainImport.getInstance(sqlRepository, new BackgroundWorker());


                        Console.Out.WriteLine("DEBUG:Get MocaTree Node#");
                        MocaNode    exportedTree    = new MocaNode();
                        String      readText        = File.ReadAllText(xmiFilename);
                        XmlDocument mocaXmlDocument = XmlUtil.stringToXmlDocument(readText);
                        exportedTree.deserializeFromXmlTree(mocaXmlDocument.DocumentElement.FirstChild as XmlElement);

                        Console.Out.WriteLine("DEBUG:Do Import#");
                        checkedMetamodelsToImport = new List <string>();

                        MocaNode mocaTree = new MocaNode();
                        mocaTree.appendChildNode(exportedTree);
                        importer.startImport(exportedTree, checkedMetamodelsToImport, false);
                        ////open the empty eap


                        Console.Out.WriteLine("INFO:Import was Successfull#");
                    }
                }
                catch (Exception e)
                {
                    Console.Out.Write("ERROR:Import was not successfull. Reason: " + e.Message);
                }
                finally
                {
                    try
                    {
                        repository.Exit();
                    }
                    catch
                    {
                    }
                }
            }
        }