Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Adam P on January 20, 2015, 10:22:58 am
-
I am trying to get a "LastModified" time for connectors in my model. I have turned on Auditing and can see the modification dates in the Audit Log, but I would like to output that data programmatically.
How do I go about getting Audit data out of the repository and / or database? I see a mention in Thomas's book about the t_snapshot table -- is the best route to do a SQLQuery() to find the GUID and modification dates in that table?
-
The API only supports Clear and Save for the audit. So SQLQuery is the way to go here.
q.
-
Thanks. Is the t_snapshot table the right table to query for audits logs? I don't see any timestamp in that table, unless it is hidden in the binary blobs.
Here's an example of the XML I am getting back from t_snapshot:
http://codebin.org/view/b5ebdbf2
-
Good grief :( My brain doesn't seem to be what it used to be. Actually there is no time stamp inside. I'd have made an oath that there is :-[
Now, there's always a way around. Once you found the modification entry for a connector just find the previous and next one for a normal element which have not been changed successively and inspect their modification date. A rather awkward deviation. ::)
Can you tell us the intention for finding the modification date of connectors?
q.
-
Back to business :)
The record actually contains the time stamp:User="Adam" DateTime="2015-01-19 10:13:51"
Just decode Bincontent1 using base64 (you can do that with Notepad++) and unzip the result. Inside is a str.dat file which contains the information in XML format.
q.
-
Wow, I certainly would have never found that. Thanks a million.
The reason behind all this is that I have created a rather complex data mapping model which is providing field-level mapping from multiple source databases, through an enterprise services bus (ESB), to a central database. This creates thousands of attribute-to-attribute connectors that need to be communicated with various parts of the team (e.g. - the engineers that are implementing the ESB code, data modelers, etc.) which is currently being done through a script that creates a CSV of all the data mappings.
The team needs a "last modified" timestamp to see what has been updated since the last version of the data mapping document.
As a follow-on question: I'm implementing this as a JScript under EA so that it is more maintainable and easier for people after me to run it without installing an external development environment. I'm now going to need to load an unzip library to get at the contents of BinContent1. Is there any way to load a JavaScript library such as zip.js from within a EA JScript? e.g. - http://gildas-lormeau.github.io/zip.js/fs-api.html
-
If they are just javascript then you can copy them into jscript scripts and use !INC to include them.
Geert
-
Unzipping binContent to get at the XML content is turning out to be a total nightmare. Anyone have any tricks or tips about how to do this from JScript?
-
You'd better be served on StackOverflow with that kind of question. I guess there is some lib for base64 decode as well as unzip.
q.
P.S.: http://techslides.com/extract-zip-and-rar-files-with-html5
-
The team needs a "last modified" timestamp to see what has been updated since the last version of the data mapping document.
How about teaching them to read the audit log from within EA?
q.
-
Back to business :)
The record actually contains the time stamp:User="Adam" DateTime="2015-01-19 10:13:51"
Just decode Bincontent1 using base64 (you can do that with Notepad++) and unzip the result. Inside is a str.dat file which contains the information in XML format.
q.
I got the code working last night to base64 decode, unzip and inflate the BinContent section. Thanks again for the help -- is there someplace I can share this code for the benefit of others?
q: As I'm looking at the Notes section of the audits, it's not entirely clear what all the different fields are supposed to mean in different circumstances. Do you have any thoughts / documentation about the Audit Notes field?
-
Regarding sharing: have a look at http://community.sparxsystems.com. That's probably a good place.
Regarding the notes: I don't have a general insight. If you have a specific field feel free to ask. We all will see what it could be.
q.
-
I got the code working last night to base64 decode, unzip and inflate the BinContent section. Thanks again for the help -- is there someplace I can share this code for the benefit of others?
Hello Adam
Have you shared this code somewhere ?
I am very interested
Thanks
Michel
-
@Adam P - did you ever post the code to do the decoding somewhere?
I really need to access this Audit data (and all the other base64 stuff which is in the data model thee days), and whilst I understand the principle form bits of other posts, nobody has - so far- posted a complete solution:
- get column from EA (in base64)
- return some content (probably XML) which can be processed.
I somehow get lost in the byte array, memorystreams and encoding.
Sounds like you have a solution.
-
I am interested too. I'd like to be able to identify who is making the change, when they made it, and what elements or connectors they changed.
-
I have done something like this in vbscript:
- Script that calls the function decodeBase64zippedXML(): https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Tools/Script%20Management/ExportAllShapeScripts.vbs (https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Tools/Script%20Management/ExportAllShapeScripts.vbs)
- Script that defines the function decodeBase64zippedXML() https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Utils/XML.vbs (https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/blob/master/Framework/Utils/XML.vbs)
- BinaryFile and FileSystemFolder scripts are found here: https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/tree/master/Framework/Utils (https://github.com/GeertBellekens/Enterprise-Architect-VBScript-Library/tree/master/Framework/Utils)
What I do is read the contents and write that in a binary file with extension .zip. Then I unzip that zipt file and then read the unzipped file as a text file.
The contents of that textfile is then base64 decoded and voila, there is the plain text content.
Geert