{= # # # check_export_complete.cfv # # This template is called from the client GUI, it checks if the given csv_file exists, # if the file exists we assume that export is complete. # # # include "templates.util.base_util"; include "templates.util.encoding"; debug_message("\n\n#### check_export_complete.cfv START \n"); string session_id = volatile.session_id; string profile_name = internal.profile_name; bool is_root_admin = get_is_root_admin(); bool is_export_permission = (is_root_admin or get_report_feature_permission(session_id, profile_name, "csv_export")); string page_token = v.fp.page_token; if (is_export_permission and get_is_valid_page_token(session_id, "statistics", page_token)) then ( debug_message("\n" . node_as_string("v.fp") . "\n"); string csv_file = v.fp.csv_file; string csv_fileref_argument = v.fp.csv_fileref_argument; string task_id = v.fp.task_id; bool is_complete = false; string csv_file_href_in_client_anchor; # # # Get task state # # bool is_active_task = false; delete_node("v.task_info"); get_task_info("v.task_info"); debug_message("#### task_id: " .task_id . "\n"); if (?("v.task_info." . task_id)) then ( debug_message("\n\n#### exporting task:\n" . node_as_string("v.task_info." . task_id) . "\n\n"); if (?("v.task_info." . task_id . ".active") and @("v.task_info." . task_id . ".active")) then ( is_active_task = true; ); ) else ( debug_message("#### TASK DOES NOT EXIST! \n"); ); debug_message("\n#### is_active_task: " . is_active_task . "\n"); # # # # TEMP, check if we get progress for export (08/Jun/2007, progress exists but progres meter stays at 0) # # KHP-RC, we may need to implement normal progress, # mostly for the log_detail report which is always accomplished with # a new query! # #* delete_node("v.progress_info"); v.progress_info = ""; get_progress_info(task_id, "v.progress_info"); node progress_node = "v.progress_info"; bool progress_exists = if (progress_node?{"exists"} and @progress_node{"exists"}) then (true) else (false); debug_message("\n#### progress_exists: " . progress_exists . "\n\n"); debug_message("\n\n#### PROGRESS DEBUG\n" . node_as_string(progress_node) . "\n\n"); *# # # # Check if file exists # # # Note, the file may already exist although it is not complete (if writing data to file), # hence we only check for file existence if the task is complete. if (!is_active_task and file_exists(csv_file)) then ( is_complete = true; csv_file_href_in_client_anchor = fileref(csv_fileref_argument); ); # # Send response data # string dat = "{"; dat .= add_json("isComplete", is_complete, "bool"); dat .= add_json("csvFileHref", csv_file_href_in_client_anchor, "string"); dat = close_json(dat); "exportTable.checkExportCompleteResponse(" . dat . ")\n"; ) else ( # No permission to view this resource (URL) display_no_permission_html(); ); =}