Schedules can be executed from within a script. This can be used to check results of a dataset query and execute a specific schedule based on those results.
Sample script with comments attached below. The dataset in this example returns a field called “RESULT”. If that result has a specific error message, the schedule ID 3 is executed.

using System;
using System.Diagnostics;
using System.Data;
using System.Collections.Generic;
using LogixEco;
using LogixEco.Controllers;
using System.Web.Mvc;
using Nathean.DataWrangling;

namespace Nathean
   public class SchedulerCustom
       public void TriggerSchedulerRefresh(DataTable dt)
              // initialise solution subsystem
		   ScriptHelper sh = new ScriptHelper();
		   sh.InitialiseSolution("OCAC02"); //This is your unique system code. It can be found in Eco - Help - About
           ScheduleController sc = new ScheduleController() ;

           string newResult = "EmailSent";
           string errorString = "Error Found in Query"; //This is the error that will cause schedule to run
           int ScheduleId = 3; //This is hardcoded in this example. You could set it to a Schedule ID returned from query if desired.

          foreach (DataRow dr in dt.Rows)

                 if (dr["RESULT"].ToString() == errorString)

                   //ScheduleId = dr["SCHEDULE_ID"] //You can run multiple schedules. To do so, return the SCHEDULE_ID on separate rows.

                    sc.runScheduleNow(ScheduleId); //Schedule ID to run if error
                  //sc.UpdateSchedule(ScheduleId); //This is the command to update a schedule rather than run it.



The “Script Details” should be set as follows:

Classname: Nathean.SchedulerCustom
MemberName: TriggerSchedulerRefresh
ScriptNotes: Any notes, can not be blank.

Revision: 5
Last modified: Nov 11, 2019


Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.

Post your comment on this topic.

Post Comment