Author Topic: Schedule a script to run in Sparx  (Read 15120 times)

OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
Schedule a script to run in Sparx
« on: January 31, 2015, 01:42:15 am »
Hi,

Is it possible to schedule a script to run in Sparx. I want run a script on a nightly basis to QA specific diagrams. I have the VB script written (in Sparx). Just need it to run each night.

Alternatively is it possible to start Sparx with a command line that runs a script automatically. I can then schedule this in Windows...

Uffe

  • EA Practitioner
  • ***
  • Posts: 1859
  • Karma: +133/-14
  • Flutes: 1; Clarinets: 1; Saxes: 5 and counting
    • View Profile
Re: Schedule a script to run in Sparx
« Reply #1 on: January 31, 2015, 01:53:53 am »
Hello,

No, and no.
You'll have to run the script outside of EA and start it off with a call to Repository.OpenFile().

/Uffe
My theories are always correct, just apply them to the right reality.

Dermot

  • EA Administrator
  • EA User
  • *****
  • Posts: 591
  • Karma: +7/-0
    • View Profile

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13083
  • Karma: +544/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Schedule a script to run in Sparx
« Reply #3 on: February 04, 2015, 05:22:16 pm »
The main problem with these kind of batch processes is that EA needs a "real" user to be logged in into the system to be able to work properly.

Usually these batch processes use some kind of system account which doesn't work with EA.

Geert

OpenIT Solutions

  • EA User
  • **
  • Posts: 555
  • Karma: +9/-1
    • View Profile
Re: Schedule a script to run in Sparx
« Reply #4 on: February 04, 2015, 08:42:17 pm »
Dont I know it ! Something Sparx really needs to think about here - we need a supported way to run Sparx as a) unattended service b) from a system account so that it can for example be run from IIS.

I've looked at Geerts excellent paper in the past - but it doesn't quite work for us - I suspect it's down to security restrictions/windows build at the bank I'm working at .... a supported approach from Sparx seems like the best way forward....


Slightly off topic - but I remember a thread regarding running Sparx (VB etc) scripts from outside Sparx - this would be the solution for me. I could of course rewrite the scripts in c# .... but then I'd have to maintain two code bases....I can't find the thread ... can anyone point me in the right direction ?

Regards,


Jon.



Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13083
  • Karma: +544/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Schedule a script to run in Sparx
« Reply #5 on: February 04, 2015, 10:58:21 pm »
Jon,

You don't need to rewrite them, just call them from your C# program.
I've done the same with EA-Matic.
From within C# add-in I execute the scripts stored in the database.

See https://github.com/GeertBellekens/Enterprise-Architect-Add-in-Framework/blob/master/EAAddinFramework/EASpecific/Script.cs

Geert

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1328
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Schedule a script to run in Sparx
« Reply #6 on: March 22, 2019, 11:21:53 pm »
Hi,

I'm reopening this thread to check if there's any news on a way round having to leave a user logged to run a script via a scheduled task.
I have a simple backup vbscript that is triggered with Windows Task Scheduler. It only works if the user session is running on the server.

I looked at the Community article here: https://community.sparxsystems.com/tutorials/603-75ea-as-an-unattended-windows-service-on-windows-server-2008r2-and-higher, but implementing a Windows Service doesn't seem to solve this task scheduler issue, does it?

Thanks
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


peterc

  • Guest
Re: Schedule a script to run in Sparx
« Reply #7 on: March 23, 2019, 12:04:42 am »
I'm not sure if this suggestion is feasible or will work (not tried it myself!)...
In the Automation user guide https://sparxsystems.com/resources/user-guides/14.0/index.html#automation, page 357, there is a FileOpen event that an Add-in can make use of.
My thought goes along these lines:
  • Write an add-in that responds to this event, which does whatever task you want in the model when opened (I don't know if that can extend to running your script)
  • Make your task scheduler open the model (this should be easy if it's an EAP file as the task will just run the EAP file, which will result in EA opening and loading the project). Might be more tricky if you have a database backed model
  • When the model opens it should action the FileOpen event which runs your required task
  • Make your task close EA (again I've no idea if you can automate that!)

As you'll notice there are a number of things in there that I don't know if they work, so, feel free to shoot down any or all of that as I've just given a suggestion based on what I spotted in the automation documentation with zero knowledge of whether it will work in practice.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13083
  • Karma: +544/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Schedule a script to run in Sparx
« Reply #8 on: March 23, 2019, 12:50:14 am »
Hi Peterc,

All of that is valuable info, but it all requires an active user session.
Guillaume is looking for a way to run automated tasks (such as backups etc) without an active user session.

Geert

hnmdijkema

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: Schedule a script to run in Sparx
« Reply #9 on: August 17, 2022, 05:15:19 pm »
Hi Peterc,

All of that is valuable info, but it all requires an active user session.
Guillaume is looking for a way to run automated tasks (such as backups etc) without an active user session.

Geert

There's software on the market that creates a service that can run your own batch files or powershell scripts with desktop and that works with EA is my experience, e.g. FireDaemonPro.