{= # # # # get_task_state.cfv (is called from client progress.js) # # # include "templates.util.base_util"; include "templates.util.database"; include "templates.util.encoding"; debug_message("\n\n\n#### get_task_state.cfv START \n"); string session_id = volatile.session_id; string page_token = v.fp.page_token; if (get_is_valid_page_token(session_id, "progress", page_token)) then ( string progress_type = v.fp.progress_type; string profile_name = internal.profile_name; string task_id; bool is_active_task = false; node task_info = new_node(); node task_item; # ToDo, should we check for errors get_task_info by checking the task node? # # # This checks if a snapon task or database task is active and returns the task_id to the client # # if (progress_type eq "database") then ( # # # We check if the database is still active (building or updating) # # node db_info = get_database_info(profile_name, false); debug_message("\n\n" . node_as_string(db_info) . "\n\n"); if (db_info?{"writing_task_id"}) then ( task_id = @db_info{"writing_task_id"}; ); debug_message("#### writing_task_id of database_info: " . task_id . "\n"); if (task_id ne "") then ( task_info = get_task_info(); debug_message("\n\n" . node_as_string(task_info) . "\n\n"); # # Check if the task exists and if it is active # if (task_info?{task_id}) then ( task_item = task_info{task_id}; is_active_task = (task_item?{"active"} and @task_item{"active"}); ); ); # Clean up delete_node(db_info); ) else ( # # Check for active snapon task # task_info = get_task_info(); debug_message("\n\n" . node_as_string(task_info) . "\n\n"); foreach task_item task_info ( if (task_item?{"profile"} and (@task_item{"profile"} eq profile_name) and task_item?{"active"} and @task_item{"active"} and task_item?{"action"} and ((@task_item{"action"} eq "attaching_snapon") or (@task_item{"action"} eq "detaching_snapon"))) then ( task_id = node_name(task_item); is_active_task = true; debug_message("#### Found active snapon task: " . task_id . "\n"); last; ); ); ); debug_message("\n#### is_active_task: " . is_active_task . "\n"); # Clean up delete_node(task_info); string dat = "{"; dat .= add_json("taskId",task_id, "string"); dat .= add_json("isActiveTask", is_active_task, "bool"); dat = close_json(dat); "progress.getTaskStateResponse(" . dat . ")\n"; ) else ( display_no_permission_html(); ); =}