Beispiel #1
0
 private XmlExporter(XDocument document, XmlNamespaceManager namespaceManager, EA.Project projectInterface, ModelEntityRepository repo)
 {
     Document         = document;
     NamespaceManager = namespaceManager;
     ProjectInterface = projectInterface;
     Repo             = repo;
 }
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            string exePath    = "\"" + Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string tempFolder = "temp/";
            string fileName   = tempFolder + "result.json";

            if (!Directory.Exists(tempFolder))
            {
                Directory.CreateDirectory(tempFolder);
            }

            using (FileStream fs = File.Create(fileName))
            {
                Byte[] info = new UTF8Encoding(true).GetBytes(jsonText);
                fs.Write(info, 0, info.Length);
            }
            backgroundWorker.ReportProgress(20, new string[] { "JSON read and saved!" });

            //Domain Model Discovery
            string jsonPath      = exePath + "/" + fileName + "\"";
            string ecorePath     = tempFolder + "result.ecore";
            string ecoreFullPath = exePath + "/" + ecorePath + "\"";

            ExecuteCommand(exePath + "/jars/JsonDiscovererCaller.jar\" " + jsonPath + " " + ecoreFullPath);
            backgroundWorker.ReportProgress(40, new string[] { "Domain Model Discovery complete!" });

            //Ecore2UML Transformation
            string primitiveTypesPath = "libs/UMLPrimitiveTypes.library.uml";
            string xisMobilePath      = "libs/xis.profile.uml";
            string emfUmlPath         = tempFolder + "result.uml";

            ExecuteCommand(exePath + "/jars/Ecore2Uml.jar\" " + ecorePath + " " + primitiveTypesPath + " " + xisMobilePath
                           + " " + emfUmlPath + " " + exePath + "\"");
            backgroundWorker.ReportProgress(60, new string[] { "Model Transformation complete!" });

            //EMF2EA Conversion
            string eaUmlPath = tempFolder + "result.xmi";

            ExecuteCommand(exePath + "/jars/Emf2EaXMIAdapter.jar\" " + emfUmlPath + " " + eaUmlPath);
            backgroundWorker.ReportProgress(80, new string[] { "UML Conversion complete!" });

            //Import XMI
            string eaUmlFullPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "/" + eaUmlPath;

            EA.Project project = repository.GetProjectInterface();
            EA.Package package = (EA.Package)repository.Models.GetAt(0);
            project.ImportPackageXMI(package.PackageGUID, eaUmlFullPath, 1, 1);
            Directory.Delete(tempFolder, true);
            backgroundWorker.ReportProgress(100, new string[] { "Model Import complete!" });

            MessageBox.Show("JSON Domain Model successfully discovered!",
                            "JSON Domain Model Discovery",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Information,
                            MessageBoxDefaultButton.Button1);
        }
Beispiel #3
0
        private string SetupTempBaseline()
        {
            EA.Project iProject       = m_Repository.GetProjectInterface();
            string     strPackageGUID = ((EA.Package)m_Packages["UseCaseRepository"]).PackageGUID;

            // first check if baseline alread exists:
            string       strBaseLines  = iProject.GetBaselines(strPackageGUID, "");
            StringReader strXMLSource  = new StringReader(strBaseLines);
            XDocument    xBaselines    = XDocument.Load(strXMLSource);
            string       sBaselineGUID = "";

            try
            {
                sBaselineGUID = xBaselines.XPathSelectElement("EA.BaseLines/Baseline[@version='Import1A']").Attribute("guid").Value;
            }
            catch (Exception ex)
            {
                LogMsg(LogMsgType.MiscExceptions, "Exception caught checking for baseline. " + ex.Message);
            }

            if (sBaselineGUID != "")
            {
                // seems to already exist
                LogError(LogErrorLevel.A, "Could not create temporary project baseline. Baseline 'Import 1A' already exsts. Please delete this baseline and make sure to check other baselines.");

                ////temp for test:
                //string strMergeInstructions = "<Merge><MergeItem guid=\"RestoreAll\" changed=\"true\" baselineOnly=\"true\" modelOnly=\"true\" moved=\"true\" fullRestore=\"false\" /></Merge>";
                //string sRes = iProject.DoBaselineMerge(strPackageGUID, sBaselineGUID, strMergeInstructions, "");
                //iProject.DeleteBaseline(sBaselineGUID);

                return("");
            }
            //else
            //{
            //    // temp for test: restore to base empty structure:

            //    sBaselineGUID = xBaselines.XPathSelectElement("EA.BaseLines/Baseline[@version='BASE']").Attribute("guid").Value;
            //    string strMergeInstructions = "<Merge><MergeItem guid=\"RestoreAll\" changed=\"true\" baselineOnly=\"true\" modelOnly=\"true\" moved=\"true\" fullRestore=\"false\" /></Merge>";
            //    string sRes = iProject.DoBaselineMerge(strPackageGUID, sBaselineGUID, strMergeInstructions, "");
            //}

            bool bRes = iProject.CreateBaseline(strPackageGUID, "Import1A", "");

            if (bRes == false)
            {
                LogError(LogErrorLevel.A, "Could not create project baseline");
                return("");
            }

            strBaseLines  = iProject.GetBaselines(strPackageGUID, "");
            strXMLSource  = new StringReader(strBaseLines);
            xBaselines    = XDocument.Load(strXMLSource);
            sBaselineGUID = xBaselines.XPathSelectElement("EA.BaseLines/Baseline[@version='Import1A']").Attribute("guid").Value;

            return(sBaselineGUID);
        }
        //This is used for extra commands such as doing the preview.
        public ActionResult OSLC_BigPreview()
        {
            //Get the URL that was posted.
            var    fullURL = this.Url.Action();
            string url     = fullURL.ToString();

            //parse the URL
            var VallueArray = url.Split('/');

            //Clean emptycells
            string[] CleanURL = VallueArray.Where(x => !string.IsNullOrEmpty(x)).ToArray();

            //store the current working repository
            EA.Repository m_Repository = new EA.Repository();

            //I don't know what this is about but it can cause trouble if not caught
            if (CleanURL.Count() > 2)
            {
                if (CleanURL[1] == "__browserLink")
                {
                    return(View());
                }
            }



            string ThingOfInterest  = CleanURL[CleanURL.Count() - 2];
            string ActionOfInterest = CleanURL[CleanURL.Count() - 1];

            m_Repository = getEA_Repos(CleanURL[1]);

            string[] UrlArray = ThingOfInterest.Split('|');

            string TOI_Name = UrlArray[0];
            string TOI_Type = UrlArray[1];
            string TOI_GUID = UrlArray[2];



            string path = AppDomain.CurrentDomain.BaseDirectory + "images";

            //If the path does exist then create it.
            if (System.IO.Directory.Exists(path) == false)
            {
                System.IO.Directory.CreateDirectory(path);
            }

            EA.Project eaProject = m_Repository.GetProjectInterface();
            eaProject.PutDiagramImageToFile(TOI_GUID, path + "\\" + TOI_Name + ".jpg", 1);

            return(base.File(path + "\\" + TOI_Name + ".jpg", "image/jpeg"));
        }
Beispiel #5
0
        private void CleanupTempBaseline(string sBaselineGUID, int iErrorCount)
        {
            string strPackageGUID = ((EA.Package)m_Packages["UseCaseRepository"]).PackageGUID;

            EA.Project iProject = m_Repository.GetProjectInterface();

            if (iErrorCount != 0)
            {
                string strMergeInstructions = "<Merge><MergeItem guid=\"RestoreAll\" changed=\"true\" baselineOnly=\"true\" modelOnly=\"true\" moved=\"true\" fullRestore=\"false\" /></Merge>";
                string sRes = iProject.DoBaselineMerge(strPackageGUID, sBaselineGUID, strMergeInstructions, "");
            }

            iProject.DeleteBaseline(sBaselineGUID);
        }
        public bool GetNewest()
        {
            // check nested packages
            foreach (EA.Package nestedPkg in _pkg.Packages)
            {
                var mks = new Mks(_rep, nestedPkg);
                mks.GetNewest();
            }
            if (_pkg.IsControlled)
            {
                //
                _rep.ShowInProjectView(_pkg);
                try
                {
                    // preference head revision
                    var mks = new Mks(_rep, _pkg);
                    mks.Checkout();

                    // load package
                    _rep.CreateOutputTab("Debug");
                    _rep.EnsureOutputVisible("Debug");
                    _rep.WriteOutput("Debug", _pkg.Name + " " + _pkg.Notes, 0);

                    //MessageBox.Show(_pkg.Name + " " + _pkg.Packages.Count.ToString() + " " + _pkg.PackageGUID, "CountBefore");
                    EA.Project prj = _rep.GetProjectInterface();
                    prj.LoadControlledPackage(_pkg.PackageGUID);


                    _rep.WriteOutput("Debug", _pkg.Name + " " + _pkg.Notes, 0);
                    //MessageBox.Show(_pkg.Name + " " + _pkg.Packages.Count.ToString() + " " + _pkg.PackageGUID, "CountAfter");
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString(), @"Error");
                }
            }



            return(true);
        }
Beispiel #7
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();
            }
        }
Beispiel #8
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();
            }
        }
Beispiel #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);
            }
        }
Beispiel #10
0
 public EaRepository(string connection)
 {
     repo.OpenFile(connection);
     project = repo.GetProjectInterface();
 }
Beispiel #11
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);
            }
        }