AutoScript
start_agent_info
AgentName = "AU_BOTTLEDASH_EXPERT"
AgentDescr = "Bottleneck Dashboard"
AgentLanguage = ""
__timer_interval = 0 {....define (in seconds) the timer interval for the wake up}
__delete_on_termination = 0 {....1=the agent frees itself when terminates its task}
end_agent_info
start_action
function = __params[1]
{........................................SUMMARY..................................}
if (function = "SUMMARY") then
window_caption = GetMessage("Processes Bottlenecks Dashboard")
{....................................get the list of all procedures}
start_sql "*" "KOSMOS"
SELECT AU_PROCEDURE.AU_PROCEDURE, AU_PROCEDURE.ATITLE, Count(AU_PROCESS.AU_PROCESS) AS CNT
FROM AU_PROCEDURE INNER JOIN AU_PROCESS ON AU_PROCEDURE.ANAME = AU_PROCESS.AGENT_NAME
GROUP BY AU_PROCEDURE.AU_PROCEDURE, AU_PROCEDURE.ATITLE, AU_PROCESS.FINISHED
HAVING (AU_PROCESS.FINISHED=0)
ORDER BY Count(AU_PROCESS.AU_PROCESS) DESC
end_sql
q = QueryByName()
call TExecute(q)
count = TRecordCount(q)
call TFirst(q)
for id = 1 to count
lab_caption[id] = TGetFld(q,"ATITLE")
val_caption[id] = TGetFld(q,"CNT")
val_unit[id] = "#"
expand_collapse[id] = True
expanded[id] = False
expand_height[id] = 0
agent_function[id] = "GET_ACCUMULATION"
agent_function_param1[id] = TGetFld(q,"AU_PROCEDURE")
expand_to_window[id]= True
call TNext(q)
next
call FreeEmbSQL(q)
lab_count = count
return
endif
{.......................................GET_ACCUMULATION..........................}
if (function = "GET_ACCUMULATION") then
proc_id = __params[2]
hbar_series = True
title = GetMessage("Activities Accumulation")
draw_type = "CHART"
y_count = 1
show_legend = False
start_sql "*" "KOSMOS"
SELECT AU_STEP.UNAME, AU_STEP.RNAME, AU_STEP.STEP_DESCR, Count(AU_STEP.AU_STEP) AS CNT
FROM (AU_PROCEDURE INNER JOIN AU_PROCESS ON AU_PROCEDURE.ANAME = AU_PROCESS.AGENT_NAME)
INNER JOIN AU_STEP ON AU_PROCESS.AU_PROCESS = AU_STEP.AU_PROCESS
WHERE (((AU_PROCEDURE.AU_PROCEDURE)=:PR) AND ((AU_PROCESS.FINISHED)=0))
GROUP BY AU_STEP.UNAME, AU_STEP.RNAME, AU_STEP.STEP_DESCR
ORDER BY Count(AU_STEP.AU_STEP) DESC
end_sql
q = QueryByName()
call TSetParam(q,"PR",proc_id)
call TExecute(q)
msg = error_message(q)
count = TRecordCount(q)
call TLast(q)
for i = 1 to count
user = TGetFld(q,"UNAME")
role = TGetFld(q,"RNAME")
x[i] = TGetFld(q,"STEP_DESCR")
if (user <> "") then
x[i] = strcat(x[i]," / ",user)
endif
if (role <> "") then
x[i] = strcat(x[i]," / ",role)
endif
y1[i] = TGetFld(q,"CNT")
call TPrior(q)
next
call FreeEmbSQL(q)
return
endif
end_action