Book a Demo

Author Topic: Enable and disabling Auditing in a script?  (Read 5379 times)

bknoth2

  • EA User
  • **
  • Posts: 129
  • Karma: +2/-0
    • View Profile
Enable and disabling Auditing in a script?
« on: April 07, 2018, 07:30:10 am »
I'd like to disable and enable auditing through a script (as a workaround for an EA bug that prevents transferring a project through a script when auditing is enabled). Is there an interface for enabling and disabling auditing? I found the ClearAuditLogs() method in the repository class, but I can't find anything about turning auditing on and off.

Thanks
Bruce

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Enable and disabling Auditing in a script?
« Reply #1 on: April 07, 2018, 05:30:29 pm »
IIRC there is nothing offered in the API. However, in the table t_genopt you find a record with key "auditing". If you remove that entry auditing will be disabled and it can be restored later by re-entering the value. What I have not tested is whether such a manipulation has direct effect. It might be necessary to restart EA before the altered setting takes effect.

q.

bknoth2

  • EA User
  • **
  • Posts: 129
  • Karma: +2/-0
    • View Profile
Re: Enable and disabling Auditing in a script?
« Reply #2 on: April 08, 2018, 03:33:45 am »
Any thoughts on how to do that in a script? I see (based on what I think is your book) that there's an undocumented Execute() function for executing SQL. I can try that, but I'd appreciate suggestions.

Needless to say, I'll work with a copy of my model!

Thanks for your help.
Bruce

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Enable and disabling Auditing in a script?
« Reply #3 on: April 08, 2018, 08:51:00 am »
Yes, that's supposed to be the last resort.
Code: [Select]
Repository.Execute("DELETE FROM t_Genopt WHERE AppliesTo='auditing'") will do the one side. The other should be obvious.

q.

bknoth2

  • EA User
  • **
  • Posts: 129
  • Karma: +2/-0
    • View Profile
Re: Enable and disabling Auditing in a script?
« Reply #4 on: April 09, 2018, 08:13:56 am »
I looked into it a bit.

The record for auditing reads: reveng=0;xmiimport=0;xmiexport=0;auditLevel=131072;auditOptions=4;dbtimestamp=0;enabled=0;

Enabling and disabling auditing toggles the enabled (at the end of the string) field to 1 and then 0. Sadly, disabling auditing by changing that 1 to a 0 doesn't provide a work-around for my original problem (details here: http://www.sparxsystems.com/forums/smf/index.php/topic,39455.msg243549.html#msg243549

The gist of it is that ProjectTransfer fails if auditing is enabled (the fifth line below) but works if disabled.  Transferring the project manually through the UI works with auditing on, though.

   dim repository
   dim projectInterface
   set repository = GetObject(, "EA.App").Repository
   set projectInterface = repository.GetProjectInterface()
   projectInterface.ProjectTransfer eapString, TargetFilePath, LogFilePath

Maybe I'll play around a bit more, but that's it for now.

Thanks again for your help
Bruce
« Last Edit: April 09, 2018, 10:14:41 am by bknoth2 »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Enable and disabling Auditing in a script?
« Reply #5 on: April 09, 2018, 03:43:49 pm »
I'm pretty sure you need to restart EA once you made changes to that specific entry. EA will not look into that record every time it needs to record an audit. That would be too laggy. Instead it will remember the setting after start (and if changed via GUI it will know by itself).

q.

bknoth2

  • EA User
  • **
  • Posts: 129
  • Karma: +2/-0
    • View Profile
Re: Enable and disabling Auditing in a script?
« Reply #6 on: April 10, 2018, 01:30:40 am »
You are probably right, but that won't work for me. I just want to turn it off, backup, and turn it on and that's only because EA won't let me backup through a script when auditing is on. I'll go to plan B, whatever that is.

Thanks again for your help. I learned a few things.

Bruce

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Enable and disabling Auditing in a script?
« Reply #7 on: April 10, 2018, 06:49:36 am »
You can work with an external script. Start EA and remove the t_genopt record. Close EA and start it new with your backup. When done restore the record. Should preferably run at night when nobody else is logged on.

q.