• R/O
  • SSH
  • HTTPS

ea2ddl: コミット


コミットメタ情報

リビジョン131 (tree)
日時2011-09-14 22:15:11
作者taktos9

ログメッセージ

EaConnect関連を追加

変更サマリ

差分

--- trunk/ea2ddl.net/ea2ddl.net/EaConnect.cs (nonexistent)
+++ trunk/ea2ddl.net/ea2ddl.net/EaConnect.cs (revision 131)
@@ -0,0 +1,58 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Diagnostics;
4+using System.Linq;
5+using System.Text;
6+using EA;
7+
8+namespace Ea2ddlUI {
9+
10+ public class EaConnect {
11+ public Repository Repo {get; private set;}
12+
13+ public EaConnect() {
14+ Repo = new Repository();
15+ }
16+
17+ public bool OpenProject(String projectPath) {
18+ return Repo.OpenFile(projectPath);
19+ }
20+
21+ public Package PackageRoot(string rootName)
22+ {
23+ foreach (Package root in Repo.Models) {
24+ if (rootName.Equals(root.Name)) {
25+ return root;
26+ }
27+ }
28+ return null;
29+ }
30+
31+ public Package FindChild(Package package, Queue<string> paths) {
32+ if (package == null) {
33+ return null;
34+ }
35+ string name = paths.Dequeue();
36+ foreach (Package p in package.Packages) {
37+ if (name == p.Name) {
38+ return paths.Count == 0 ? p : FindChild(p, paths);
39+ }
40+ }
41+ return null;
42+ }
43+
44+ public Package FindPackage(string path) {
45+ string[] paths = path.Split('/');
46+ Queue<string> pathQ = new Queue<string>(paths);
47+
48+ Package root = PackageRoot(pathQ.Dequeue());
49+ return FindChild(root, pathQ);
50+ }
51+
52+ ~EaConnect() {
53+ Repo.CloseFile();
54+ Repo.Exit();
55+ Repo = null;
56+ }
57+ }
58+}
--- trunk/ea2ddl.net/ea2ddl.net.Test/EaConnectTest.cs (nonexistent)
+++ trunk/ea2ddl.net/ea2ddl.net.Test/EaConnectTest.cs (revision 131)
@@ -0,0 +1,54 @@
1+using System;
2+using System.Collections.Generic;
3+using System.Diagnostics;
4+using System.IO;
5+using System.Linq;
6+using System.Runtime.InteropServices;
7+using System.Text;
8+using NUnit.Framework;
9+using EA;
10+
11+namespace Ea2ddlUI {
12+
13+ [TestFixture]
14+ public class EaConnectTest {
15+
16+ [Test]
17+ public void TestOpenProject() {
18+ EaConnect con = new EaConnect();
19+ try
20+ {
21+ con.OpenProject("hoge");
22+ Assert.Fail();
23+ }
24+ catch (COMException e)
25+ {
26+ Console.WriteLine(e.Message);
27+ }
28+ }
29+
30+ [Test]
31+ public void TestPackageRoot() {
32+ EaConnect con = new EaConnect();
33+ con.OpenProject(System.Environment.CurrentDirectory + @"\exampledb.eap");
34+ string erPackage = "ビュー/クラスビュー/ER図/EXAMPLEDB";
35+ Package p = con.FindPackage(erPackage);
36+ Assert.NotNull(p);
37+ Assert.AreEqual("EXAMPLEDB", p.Name);
38+ }
39+
40+ [Test]
41+ public void TestDocumentGenerator() {
42+ EaConnect con = new EaConnect();
43+ con.OpenProject(System.Environment.CurrentDirectory + @"\exampledb.eap");
44+ string erPackage = "ビュー/クラスビュー/ER図/EXAMPLEDB";
45+ Package p = con.FindPackage(erPackage);
46+ Assert.NotNull(p);
47+
48+ Console.WriteLine(p.PackageGUID);
49+
50+ Project project = con.Repo.GetProjectInterface();
51+ project.RunHTMLReport(p.PackageGUID, @"C:\temp\eadoc", @"PNG", "", "html");
52+ }
53+ }
54+}
旧リポジトリブラウザで表示