Exemplo n.º 1
0
        public void Analyze()
        {
            try
            {
                bool success = _repository.OpenFile(_analyzerSettings.InputFilename);
                if (success)
                {
                    _elementCount = 0;
                    for (short index = 0; index < _repository.Models.Count; index++)
                    {
                        EA.Package model = (EA.Package)_repository.Models.GetAt(index);
                        FindPackageElements(model);
                    }
                    UpdateElementProgress(true);

                    _relationCount = 0;
                    for (short index = 0; index < _repository.Models.Count; index++)
                    {
                        EA.Package model = (EA.Package)_repository.Models.GetAt(index);
                        FindPackageRelations(model);
                    }
                    UpdateRelationProgress(true);

                    _repository.CloseFile();
                }

                _repository.Exit();
            }
            catch (Exception e)
            {
                Logger.LogException($"Reading EA model failed file={_analyzerSettings.InputFilename}", e);
            }
            AnalyzerLogger.Flush();
        }
Exemplo n.º 2
0
 public void eaClose()
 {
     if (r != null)
     {
         r.CloseFile();
         r.Exit();
     }
 }
Exemplo n.º 3
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
                    {
                    }
                }
            }
        }
Exemplo n.º 4
0
        public void doExport()
        {
            if (export.Value)
            {
                EA.Repository repository = null;
                try
                {
                    Console.Out.WriteLine("DEBUG:Starting export process#");
                    if (parser.AdditionalArgumentsSettings.AdditionalArguments.Count() > 0)
                    {
                        eapFile.Values.AddRange(parser.AdditionalArgumentsSettings.AdditionalArguments);
                    }

                    foreach (String filename in eapFile.Values)
                    {
                        Console.Out.WriteLine("INFO:Start Export of '" + filename + "'#");
                        repository = new EA.Repository();
                        repository.OpenFile(filename);

                        EAPUpdater updater = new EAPUpdater(repository, false);
                        updater.updateEAPIfNecessary(false);

                        SQLRepository sqlRepository = new SQLRepository(repository, true, false);

                        Console.Out.WriteLine("DEBUG:Initialize Exporter#");
                        Export exporter = new Export(sqlRepository, true, false);

                        Console.Out.WriteLine("DEBUG:Do Export#");
                        exporter.doExport();

                        Console.Out.WriteLine("INFO:Export of '" + filename + "' was successfull#");

                        repository.Exit();
                    }
                }
                catch (Exception e)
                {
                    repository.Exit();
                    Console.Out.WriteLine("ERROR:Export failed " + "\n" + e.Message + "\n" + e.ToString() + "\n" + e.StackTrace + "#");
                }
            }
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            int packageID;

            String[] list;

            EA.DocumentGenerator doc = r.CreateDocumentGenerator();

            try
            {
                Console.WriteLine("Введите наименование файла модели");

                r.OpenFile(Environment.CurrentDirectory + "\\" + Console.ReadLine());
                EA.Project project = new EA.Project();

                Console.WriteLine("Введите наименование выходного файла");
                String path = Environment.CurrentDirectory + "\\" + Console.ReadLine();

                Console.WriteLine("Введите путь к пакету. разделительный символ - \\");
                list = Console.ReadLine().Split('\\');

                packageID = getPackageId(list);

                Console.WriteLine("Документирую!");
                ////////////////

                project.RunReport(r.GetPackageByID(packageID).PackageGUID, "sequential", path);

                Console.WriteLine("OK");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.GetBaseException());
                Console.ReadLine();
            }
            finally
            {
                r.CloseFile();
                r.Exit();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Close
        /// </summary>
        public void Close()
        {
            // close the repository and tidy up
            if (m_bCloseEAFileOnExit)
            {
                m_bCloseEAFileOnExit = false;
                m_Repository.CloseFile();
            }

            if (m_bCloseEAOnExit)
            {
                m_Repository.Exit();
                m_bCloseEAOnExit = false;
            }

            if (m_oWord != null)
            {
                m_oWord.Quit();
            }

            m_oWord = null;
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            int packageID; //ID пакета в EA.
            String[] list; //
            String template; //Наименование шаблона документации в EA.
            String path = null; //Выходной документ.
            String docTemplatePath; // Путь к документу word, в котором находятся стили для замены.
            TextWriter errWriter = Console.Error; //Вывод в stderror.
            StreamReader reader; // Чтение входного файла переданного в 7-ом параметре.
            Object missingObj = System.Reflection.Missing.Value;
            Word.Application app = new Word.Application();
            Object missing = Type.Missing;

            try
            {
                if (args.Length < 1)
                {
                    throw new ReportException(withoutArgs, 1);
                }

                if (args[0] == help || args[0] == anotherHelp)
                {
                    printHelp();
                    Environment.Exit(1);
                }

                else
                    if (args.Length >= 5)
                    {
                        EA.Repository r = new EA.Repository();
                        EA.Project project = new EA.Project();

                        if (args.Length > 6)
                        {
                            reader = new StreamReader(args[6], Encoding.Default);//File.OpenText(args[6]);
                            styles(reader);
                            reader.Close();
                        }
                        else
                            styles();

                        //Открываем файл модели
                        if (!args[0].Contains(fileDelimiter))
                            args[0] = Environment.CurrentDirectory + fileDelimiter + args[0];

                        if (File.Exists(args[0]))
                            r.OpenFile(args[0]);
                        else
                            throw new ReportException(fileNotFound, 1);

                        //Выходной файл
                        if (args[1].Substring(args[1].Length - 5) == format)
                            path = Environment.CurrentDirectory + fileDelimiter + args[1];
                        else
                            throw new ReportException(incorrect, 1);

                        //Путь к документируемому пакету
                        list = args[2].Split(delimiter);

                        if (list.Length < 2)
                            throw new ReportException(incorrectPath, 1);

                        //Наименование шаблона документации
                        template = args[3];

                        //Получаем ID пакета
                        packageID = getPackageId(list, r);

                        //Запуск документации по шаблону
                        project.RunReport(r.GetPackageByID(packageID).PackageGUID, template, path);

                        r.CloseFile();
                        r.Exit();
                    }
                    else
                        throw new ReportException(incorrectArgsCount, 1);

                if (args[4].Contains(fileDelimiter))
                    docTemplatePath = args[4];
                else
                    docTemplatePath = Environment.CurrentDirectory + fileDelimiter + args[4];

                if (File.Exists(path) && File.Exists(docTemplatePath))
                {
                    Word.Document doc = app.Documents.Open(path);

                    if (args.Length > 5)
                    {
                        if (args[5].Equals(sixthArg))
                        {
                            Word.Find find = app.Selection.Find;
                            find.Text = emptyString;
                            find.Replacement.Text = emptyString.Substring(0, 2);
                            Object wrap = Word.WdFindWrap.wdFindContinue;
                            Object replace = Word.WdReplace.wdReplaceAll;
                            find.Execute(FindText: Type.Missing, MatchCase: false, MatchWholeWord: false, MatchWildcards: false, MatchSoundsLike: missing, MatchAllWordForms: false, Forward: true, Wrap: wrap, Format: false, ReplaceWith: missing, Replace: replace);
                        }
                    }

                    Word.Document docTemplate = app.Documents.Open(docTemplatePath);

                    foreach (Word.Paragraph p in doc.Paragraphs)
                    {
                        if (styleNames.ContainsKey(p.get_Style().NameLocal))
                        {
                            foreach (Word.Style s in docTemplate.Styles)
                            {
                                if (s.NameLocal == styleNames[p.get_Style().NameLocal])
                                {
                                    p.set_Style(s);
                                    break;
                                }
                            }
                        }
                    }

                    doc.Save();
                    doc.Close();
                    docTemplate.Close();
                    app.Quit(ref missingObj, ref  missingObj, ref missingObj);
                }
                else
                    throw new ReportException(templateNotFound, 1);

            }
            catch (ReportException re)
            {
                if (re.getPrintByte() == (byte)1)
                {
                    printPackageTree(re.getRepository().GetPackageByID(1));

                }

                re.eaClose();
                re.print(errWriter);
                app.Quit(ref missingObj, ref  missingObj, ref missingObj);
                Environment.Exit(1);
            }
            catch (Exception e)
            {
                errWriter.WriteLine(e.GetBaseException());
                app.Quit(ref missingObj, ref  missingObj, ref missingObj);
                Environment.Exit(2);
            }
        }
Exemplo n.º 8
0
 public void Exit()
 {
     eaRepository.Exit();
 }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            int packageID;                          //ID пакета в EA.

            String[]     list;                      //
            String       template;                  //Наименование шаблона документации в EA.
            String       path = null;               //Выходной документ.
            String       docTemplatePath;           // Путь к документу word, в котором находятся стили для замены.
            TextWriter   errWriter = Console.Error; //Вывод в stderror.
            StreamReader reader;                    // Чтение входного файла переданного в 7-ом параметре.
            Object       missingObj = System.Reflection.Missing.Value;

            Word.Application app     = new Word.Application();
            Object           missing = Type.Missing;

            try
            {
                if (args.Length < 1)
                {
                    throw new ReportException(withoutArgs, 1);
                }

                if (args[0] == help || args[0] == anotherHelp)
                {
                    printHelp();
                    Environment.Exit(1);
                }

                else
                if (args.Length >= 5)
                {
                    EA.Repository r       = new EA.Repository();
                    EA.Project    project = new EA.Project();

                    if (args.Length > 6)
                    {
                        reader = new StreamReader(args[6], Encoding.Default);    //File.OpenText(args[6]);
                        styles(reader);
                        reader.Close();
                    }
                    else
                    {
                        styles();
                    }

                    //Открываем файл модели
                    if (!args[0].Contains(fileDelimiter))
                    {
                        args[0] = Environment.CurrentDirectory + fileDelimiter + args[0];
                    }

                    if (File.Exists(args[0]))
                    {
                        r.OpenFile(args[0]);
                    }
                    else
                    {
                        throw new ReportException(fileNotFound, 1);
                    }

                    //Выходной файл
                    if (args[1].Substring(args[1].Length - 5) == format)
                    {
                        path = Environment.CurrentDirectory + fileDelimiter + args[1];
                    }
                    else
                    {
                        throw new ReportException(incorrect, 1);
                    }

                    //Путь к документируемому пакету
                    list = args[2].Split(delimiter);

                    if (list.Length < 2)
                    {
                        throw new ReportException(incorrectPath, 1);
                    }

                    //Наименование шаблона документации
                    template = args[3];

                    //Получаем ID пакета
                    packageID = getPackageId(list, r);

                    //Запуск документации по шаблону
                    project.RunReport(r.GetPackageByID(packageID).PackageGUID, template, path);

                    r.CloseFile();
                    r.Exit();
                }
                else
                {
                    throw new ReportException(incorrectArgsCount, 1);
                }

                if (args[4].Contains(fileDelimiter))
                {
                    docTemplatePath = args[4];
                }
                else
                {
                    docTemplatePath = Environment.CurrentDirectory + fileDelimiter + args[4];
                }

                if (File.Exists(path) && File.Exists(docTemplatePath))
                {
                    Word.Document doc = app.Documents.Open(path);

                    if (args.Length > 5)
                    {
                        if (args[5].Equals(sixthArg))
                        {
                            Word.Find find = app.Selection.Find;
                            find.Text             = emptyString;
                            find.Replacement.Text = emptyString.Substring(0, 2);
                            Object wrap    = Word.WdFindWrap.wdFindContinue;
                            Object replace = Word.WdReplace.wdReplaceAll;
                            find.Execute(FindText: Type.Missing, MatchCase: false, MatchWholeWord: false, MatchWildcards: false, MatchSoundsLike: missing, MatchAllWordForms: false, Forward: true, Wrap: wrap, Format: false, ReplaceWith: missing, Replace: replace);
                        }
                    }

                    Word.Document docTemplate = app.Documents.Open(docTemplatePath);

                    foreach (Word.Paragraph p in doc.Paragraphs)
                    {
                        if (styleNames.ContainsKey(p.get_Style().NameLocal))
                        {
                            foreach (Word.Style s in docTemplate.Styles)
                            {
                                if (s.NameLocal == styleNames[p.get_Style().NameLocal])
                                {
                                    p.set_Style(s);
                                    break;
                                }
                            }
                        }
                    }

                    doc.Save();
                    doc.Close();
                    docTemplate.Close();
                    app.Quit(ref missingObj, ref missingObj, ref missingObj);
                }
                else
                {
                    throw new ReportException(templateNotFound, 1);
                }
            }
            catch (ReportException re)
            {
                if (re.getPrintByte() == (byte)1)
                {
                    printPackageTree(re.getRepository().GetPackageByID(1));
                }

                re.eaClose();
                re.print(errWriter);
                app.Quit(ref missingObj, ref missingObj, ref missingObj);
                Environment.Exit(1);
            }
            catch (Exception e)
            {
                errWriter.WriteLine(e.GetBaseException());
                app.Quit(ref missingObj, ref missingObj, ref missingObj);
                Environment.Exit(2);
            }
        }