Workflow: reset e rigenerazione

' Il seguente snippet può essere usato per resettare il workflow e rigenerarlo

Dim QWSess As QWSession = DB.QWSession
Dim ok as boolean
Dim ss as string, msg as string
Dim TIPO, TIPO_CONT, NUMERO as string
Dim IND_REV as integer

unpackcode("DW",CODDOC,TIPO,TIPO_CONT,NUMERO,IND_REV)

'DOC_REVE
ss = "delete from DOC_REVE where TIPO = '" + TIPO + "' and TIPO_CONT = '" + TIPO_CONT + "' and NUMERO = '" + NUMERO + "' and IND_REV = " + cstr(IND_REV) 
ok = DB.ExecuteSQL(ss)

if not ok then
     msg = "Questa Query ha restituito un errore : " + vbnewline
     WriteLog("ERRORE " + vbnewline + msg + ss)
end if

'WF
msg = ""
msg = QWWorkFlowEngine.RemoveWorkFlow(QWSess, "DW", CODDOC)

if msg <> "" then
     WriteLog("ERRORE " + vbnewline + msg)
end if

dim qwdr as QWTable = new QWTable
qwdr.database = DB
qwdr.sql = "SELECT * "
qwdr.sql += "FROM DOCUMENT "
qwdr.allowallrecords = false
qwdr.requestlive = true
qwdr.active = true

if qwdr.rowset.findkey(TIPO, TIPO_CONT, NUMERO, IND_REV) then
     msg = ""
     ok = QWFD_SetWorkflow(QWSess, qwdr, msg)

     if not ok then
          WriteLog("ERRORE " + vbnewline + msg)          
     end if
end if

qwdr.active = false
qwdr.dispose()