70
« on: May 19, 2006, 01:30:32 am »
Hi Peter,
steps 1+2 - I do not know whether.......
This is my script to export the root-packages to XMI. I run it with VB2005 Express edition. If you don't have it, get it for free from Microsoft. You must create a window with a Listbox named "List1" to run it.
Sorry, I haven'd had the time to translate my comments and names into english and to clean up my companies stuff and my private stuff. Just ask me if you encounter any problems.
It picks up parameters from the environment to open the given Oracle database, but you'll find commented areas as well, where you can fill in the parameters of your local EAP-file. The script creates one or more XML-files named like <toplevel-package-name><date><time>.XML.
I hope someone can add information to the other steps.
Stefan
Option Strict Off
Option Explicit On
Friend Class XML_Export
Inherits System.Windows.Forms.Form
Dim m_Repository As EA.Repository
Dim package As EA.Package
Dim m_project As EA.Project
Dim pw, pfad, filePath, dateiName, user, datei As String
Dim j As Short
Sub main_Renamed()
'Datenbank-Repository öffnen, XML-Dateinamen festlegen aus Umgebungsvariablen
filePath = Environ("BLWDB_filePath")
user = Environ("BLWDB_user")
pw = Environ("BLWDB_pw")
dateiName = Environ("BLWDB_dateiName")
pfad = Environ("BLWDB_pfad")
If filePath = "" Or user = "" Or dateiName = "" Or pfad = "" Then
ListAdd("Repository --- Umgebungsvariable nicht gefunden")
ListAdd("BLWDB_filePath = " & filePath)
ListAdd("BLWDB_user = " & user)
ListAdd("BLWDB_pw = " & pw)
ListAdd("BLWDB_dateiName = " & dateiName)
ListAdd("BLWDB_pfad = " & pfad)
GoTo fehler
End If
' 'MasterModel-Repository öffnen, XML-Dateinamen festlegen
' filePath$ = "MasterModel --- DBType=3;Connect=Provider=OraOLEDB.Oracle.1;Password=xxx;Persist Security Info=True;User ID=xxx;Data Source=xxx.xxx.de"
' user$ = "your name"
' pw$ = "your secret PW"
' dateiName$ = "MasterModel"
' pfad$ = "C:\xxx"
'lokales Repository öffnen
' filePath$ = "C:\xxx\xxx_lokal.EAP"
' user$ = ""
' pw$ = ""
' dateiName$ = "xxx_lokal"
' pfad$ = "C:\xxx\"
ListAdd(("***** XML_Exportieren (Version 1.02 ******"))
' ListAdd ("Optionen: " + Command$)
ListAdd(("Öffne Repository: " & filePath) & " am " & Format(Now(), "short Date") & " " & TimeString)
m_Repository = New EA.Repository
If user = "" Then
If Not m_Repository.OpenFile(filePath) Then
ListAdd("Repository Open failed")
GoTo fehler
End If
Else
If Not m_Repository.OpenFile2(filePath, user, pw) Then
ListAdd("Repository Open failed")
GoTo fehler
End If
End If
For j = 0 To m_Repository.Models.Count - 1
'datei = CStr(CDbl(pfad & dateiName & "_" & jjmmtt_hhmmss() & "_") + m_Repository.Models.GetAt(j).Name + CDbl(".xml"))
datei = pfad & dateiName & "_" & jjmmtt_hhmmss() & "_" + m_Repository.Models.GetAt(j).Name + ".xml"
ListAdd("XML-Export läuft für: " & " " + m_Repository.Models.GetAt(j).Name)
'ListAdd(" Zeit: " & Str(Today.ToOADate) & " " & Str(TimeOfDay.ToOADate))
ListAdd(" Zeit: " & Format(Now(), "short Date") & " " & TimeString)
ListAdd(" Datei: " & datei)
' bei Mastermodell: 0 = Spielwiese
' 1 = BLW Konzeptionelles Modell
m_Repository.GetProjectInterface.ExportPackageXMI(m_Repository.Models.GetAt(j).PackageGUID, EA.EnumXMIType.xmiEA11, 1, 0, 1, 1, datei)
Next j
m_Repository.CloseFile()
ListAdd("Fertig!" & Format(Now(), "short Date") & " " & TimeString)
Me.Close()
GoTo ende
fehler:
ListAdd("FEHLER! " & Format(Now(), "short Date") & " " & TimeString)
ende:
End Sub
Sub ListAdd(ByRef sString As String)
' Text1.Text = Text1.Text + " / " + sString$
List1.Items.Add((sString))
End Sub
Private Sub XML_Export_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
Me.Show()
main_Renamed()
End Sub
Private Function jjmmtt_hhmmss() As String
jjmmtt_hhmmss = Mid(Format(Now(), "short Date"), 7, 4) & Mid(Format(Now(), "short Date"), 4, 2) & Mid(Format(Now(), "short Date"), 1, 2) & "_" & Mid(TimeString, 1, 2) & Mid(TimeString, 4, 2) & Mid(TimeString, 7, 2)
End Function
End Class