{= # # # run_schedule_exec.cfv (is called from run_schedule_start.cfv) # # include "templates.util.base_util"; include "templates.util.rbac.rbac_util"; include "templates.util.alert.save_alert_message"; debug_message("\n\n#### run_schedule_exec.cfv START \n"); string session_id = volatile.session_id; bool is_root_admin = get_is_root_admin(); string page_token = volatile.page_token; # # Check RBAC permissions # if ((is_root_admin or get_admin_feature_permission(session_id, "scheduler", "view")) and get_is_valid_page_token(session_id, "scheduler", page_token)) then ( string run_id = volatile.run_id; node session_schedule_run = "sessions_cache." . session_id . ".scheduler_run_now." . run_id; node the_schedule = session_schedule_run{"schedule"}; debug_message("#### the_schedule:\n" . node_as_string(the_schedule) . "\n"); # # # Run the schedule (Run is complete if run_task() returns!) # # node run_info = run_task(the_schedule); debug_message("#### run_schedule_exec.cfv - run_info:\n" . node_as_string(run_info) . "\n"); # # # Check for errors # # bool is_error = false; string alert_id; string error_message; node tasks = subnode_by_number(run_info, 0); node item; foreach item tasks ( if (item?{"error_message"}) then ( is_error = true; error_message .= @item{"error_message"} . "\n\n"; ); ); if (is_error) then ( # Save the error message to file alert_id = save_alert_message(error_message, ""); ); # # # Set node values in session_schedule_run so that run_schedule_progress.cfv # knows that run_task() completed. # # session_schedule_run . ".is_error" = is_error; session_schedule_run . ".alert_id" = alert_id; session_schedule_run . ".is_complete" = true; save_node(session_schedule_run); ) else ( # No permission to access this resource (URL) display_no_permission_html(); ); debug_message("\n\n#### run_schedule_exec.cfv END \n"); =}