Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - George..Brennan

Pages: [1]
1
Automation Interface, Add-Ins and Tools / Re: Saving/backup vbscripts
« on: October 04, 2018, 11:40:35 pm »
Thanks, Geert,

Just seen this, that's  an impressive and extensive body of code, I'll need time to review it before I can make real use of it - and learn some lessons  ;)

Meanwhile I've been diving in and taking a much less generic view with XML to handle the SQL, works for the moment.

FYI


option explicit

!INC Local Scripts.EAConstants-VBScript
!INC ESFA-ScriptLib.VBS-Utils
'
' Script Name: EA-Utils
' Author:  George Brennan (xxxxxxxxxxxx)
' Purpose: Export VBS scripts from the repository for versioning
' Assumes path of  of "{user}\Documents\VBS-Sparx\"
'
const basePath = "Documents\VBS-Sparx\" '-- root for output files
const dataNodes = "//EADATA//Dataset_0//Data//Row" '-- EA XML Elements
'
const K_GROUP2FOLDER = 0
const K_SCRIPT_FILE = 1
const K_SCRIPT_TEXT = 2
'
const K_DEBUG = true

main
sub main

   '-- prep for outputs
   dim wsh       : Set wsh = CreateObject("WScript.Shell")
    dim fso        : Set fso = CreateObject("Scripting.FileSystemObject")   
   dim userProfile : userProfile = wsh.ExpandEnvironmentStrings( "%userprofile%" )
   dim path       : path = userProfile & "\" & basePath
   dim filePathName
   
    '-- Make an EA repository SQL Call and parse the return set as a DOM tree
    dim SQL
    SQL =    "SELECT g.Script as ScriptGroup, " & _
         "       cast(s.Notes as xml).value('(Script/@Name)[1]', 'varchar(max)') as ScriptName, " & _
         "       s.[Script] " & _
         "  from t_script s " & _
         " inner join t_script g on s.ScriptAuthor = g.ScriptName " & _
         " where cast(s.Notes as xml).value('(Script/@Language)[1]', 'varchar(max)') = 'VBScript' "& _
         " order by g.Script " '-- by target folder
    dim doc : set doc = CreateObject("MSXML2.DOMDocument")
    doc.validateOnParse = False
    doc.async = False
    doc.loadXML(SQLQuery(SQL))

   '-- Traverse the DOMDocument and output each script as a file
    dim rowSet : Set rowSet = doc.selectNodes(dataNodes)
   For Each row In rowSet   
           
      '-- check group folder exists
      If not fso.FolderExists( path & row.childNodes(K_GROUP2FOLDER).text ) Then
         fso.CreateFolder( path & row.childNodes(K_GROUP2FOLDER).text )
      end if
      
      '-- build path/name and write file
      filePathName = path & row.childNodes(K_GROUP2FOLDER).text & "\" & row.childNodes(K_SCRIPT_FILE).text & ".vbs"
      dim oFile : Set oFile = fso.CreateTextFile( filePathName, True)            
      oFile.Write ( "'" & vbNewLine & "'-- exported : " & FormatDateTime(Now, vbGeneralDate) & vbNewLine & "'" & vbNewLine )
      oFile.Write (row.childNodes(K_SCRIPT_TEXT).text)
      oFile.Close    

      if K_DEBUG then Session.output(">> wrote: " & filePathName) end if

    Next 

end sub
'--


George

I wrote a script to do that.

https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Tools/Script%20Management/SaveAllScripts.vbs

This way I can manage my scripts in a version control system.

Geert

2
Automation Interface, Add-Ins and Tools / Saving/backup vbscripts
« on: October 04, 2018, 08:52:09 pm »
Currently looking at export/backup user VBS-Scripts from the repository to the file system.
Has anyone tried this?

G.

3
Automation Interface, Add-Ins and Tools / Re: Linked to Element Feature
« on: November 27, 2017, 08:43:54 pm »
Hi Guillaume,

Many thanks, working fine now.

George

4
Automation Interface, Add-Ins and Tools / Linked to Element Feature
« on: November 25, 2017, 12:54:17 am »
VBScripting ( ugh )

Well It looks like I can add a connector between Elements but when I try to use StyleEx to add an atttribute level link such..

   newStyleEx = "LFEP=" & oAttributeSource.AttributeGUID & "L;LFSP=" & oAttributeTarget.AttributeGUID & "R;"               
   'Session.Output("+:" & newStyleEx )
   set oConnector = oSource.Connectors.AddNew ("","Association")
   oConnector.StyleEx = newStyleEx
   oConnector.SupplierID = oTarget.ElementID
   oConnector.update()


everthing looks fine in the database tables but it's not rendering the attribute linkage ends only the relation ship to the element.

Can anyone please tell me what am I missing ?

G.

Pages: [1]