My next idea to help run My Book It is for the admin site (and potentially to build into the site itself if it is successful) is the ability for the site to be able to schedule and run complicated processes automatically. Sounds simple right, I want the system to be flexible enough to cover what I want it to do now and that I don’t need to touch any code to update procedures and workflows AND it needs to be able to handle possible future requirements what ever they may be.

My current requirements are

  • To be able to schedule a process to run on a date and time
  • For a process to be kicked off if a field in the database matches a particular criteria (i.e. TRUE, y, or any value that I can dream up)
  • For it to be able to execute a SQL command
  • For it to be able to update a database item. (Really similar to above, will see if this is required)
  • For it to be able to queue an email to be sent
  • For it to be able to provide information into an email that will allow it to continue to run a process (i.e. asking a customer if they want to continue with a site after a trial)

Now I realise that it would be completely impossible to comprehend all possible future requirements, this aside adding new scopes (that’s what I will call it for now) should be as easy as adding a new permission to the site. (i.e. a single update in under 10 lines of code)

I have been thinking about this for a day or so now and think I have a basic design in my head which I will start to put down here as I go about the building process. This is going to get real complicated, real quick but I will do my best to keep it flowing.

The process will need to be broken up into a few sections which can then be drawn together to form a workflow or procedure.

  • First up I will need to be able to create and edit SQL scripts and Email Templates. Both need to be able to be updated via the website and be able to contain variables that can be substituted from information that is drawn into the workflow.
  • Second I will need to be able to relate variables, mostly from the database into variables which can be used in templates.
  • Third I will need to be able to create a workflow or process based on the items in the first point. I will need to be able to order and remove them as I need all via the web interface. Multiple of these will need to be able to be created
  • Forth, I will need to be able to trigger the workflow or process off an item. The first part will need to choose what triggers the process such as a date, or something in the database.
  • Lastly I will need a cron job that runs really regularly (every minute?) that effectively wakes up and checks the workflows to ensure that nothing needs to be run. If nothing then just exit (after logging?). If there is a process that matches its criteria, run through its process and then exit.

Logging would be fantastic for troubleshooting and to be able to check the history.

Now that that is all out of my head. I will start on the process from start to finish. As I work through the steps I will post how I did it on here. I may skip some of the more mundane parts such as the template and SQL setup)