FileNet P8 Content Engine, 버전 4.0.+              

로그 이벤트 핸들러

이 핸들러는 문서가 작성되면 로그 파일에 이벤트를 기록합니다.

이벤트 로깅 핸들러
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 
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); 
} 
} 
} 


피드백

마지막 업데이트 날짜: 2010년 11월


© Copyright IBM Corp. 2010.
이 Information Center는 Eclipse 기술로 구현됩니다. (http://www.eclipse.org)