FileNet P8 Content Engine, Versão 4.0.+              

Manipulador de Evento de Log

Esse manipulador registra eventos em um arquivo de log quando documentos são criados.

Manipulador de Evento de Log
Versão Content Engine 3.5.x VBScript
 Public
Sub OnEvent (EventObject, Subscription) 
Dim doc, message) 
Set doc = EventObject.SourceObject) 
WriteToLogFile (doc.Name & " was created on: " & Date)) 
End Sub 

Public Sub WriteToLogFile (message)) 
Dim fso, ts, logFile) 
Set fso = CreateObject("Scripting.FileSystemObject")) 
Set logFile = fso.CreateTextFile("C:\log.txt")) 
logFile = nothing) 
Set ts = fso.OpenTextFile("C:\log.txt", 8, True)) 
ts.Write (message)) 
ts.WriteBlankLines (2)) 
ts.Close) 
Set fso = Nothing) 
Set ts = Nothing) 
End Sub 
Versão Content Engine 4.x Java
 import
java.io.File; 
import java.io.FileWriter; 
import java.io.IOException; 

import com.filenet.api.core.Document; 
import com.filenet.api.engine.EventActionHandler; 
import com.filenet.api.events.ObjectChangeEvent; 
import com.filenet.api.exception.EngineRuntimeException; 
import com.filenet.api.exception.ErrorRecord; 
import com.filenet.api.exception.ExceptionCode; 
import com.filenet.api.util.Id; 

public class LogEventAction implements EventActionHandler 
{ 
public void onEvent(ObjectChangeEvent event, Id subscriptionId)
throws 
EngineRuntimeException 
{ 
try 
{ 
Document doc = (Document)event.get_SourceObject(); 
WriteToLogFile(doc.get_Name() 
+ " was created on: " + new java.util.Date() + "\r\n"); 
} 
catch (Exception e) { 
ErrorRecord er[] = {new ErrorRecord (e)}; 
throw new EngineRuntimeException(e,
ExceptionCode.EVENT_HANDLER_THREW, er);  
} 
}  
public void writeToLogFile(String message) 
{ 
try 
{ 
File outputFile = new File("C:\\log.txt"); 
FileWriter out = new FileWriter(outputFile, true); 
out.write(message); 
out.close(); 
} 
catch (IOException e) { 
ErrorRecord er[] = {new ErrorRecord (e)}; 
throw new EngineRuntimeException(e,
ExceptionCode.EVENT_HANDLER_THREW,er); 
} 
} 
} 


Feedback

Última atualização: novembro de 2010


© Copyright IBM Corporation 2010.
Este centro de informações foi desenvolvido com a tecnologia Eclipse. (http://www.eclipse.org)