FileNet P8 Content Engine, 版本 4.0.+              

“将文档存档”处理程序

此处理程序将文档存档到指定的文件夹(此文件夹由该文档上触发的事件确定)。

“将文档存档”处理程序
Content Engine V3.5.x JScript 版本
function OnEvent (Event, Subscription) 
{ 
var doc = Event.SourceObject; 
if (Event.IsOfClass("CreationEvent")) 
{ 
FileDocInFolder("/Docs", doc); 
} 
else if (Event.IsOfClass("ChangeClassEvent")) 
{ 
FileDocInFolder("/Archives", doc); 
} 
} 
function FileDocInFolder(otherFolderName, doc) 
{ 
var os = doc.ObjectStore; 
var rootFld = os.RootFolder; 
var fldSet = new Enumerator(rootFld.SubFolders); 
var subFld; 
for (; !fldSet.atEnd(); fldSet.moveNext()) 
{ 
subFld = fldSet.item(); if (subFld.Name == otherFolderName) 
{ subFld.File(doc, 0, doc.DocumentTitle);
 }
 }
 } 
Content Engine V4.x Java 版本
import com.filenet.api.constants.*; 
import com.filenet.api.constants.DefineSecurityParentage; 
import com.filenet.api.core.*; 
import com.filenet.api.engine.EventActionHandler; 
import com.filenet.api.events.ObjectChangeEvent; 
import com.filenet.api.exception.EngineRuntimeException; 
import com.filenet.api.exception.ExceptionCode; 
import com.filenet.api.util.Id; public class FileDocumentAction implements 
EventActionHandler { 

public void onEvent(ObjectChangeEvent event, Id subscriptionId) throws 
EngineRuntimeException 
{ 
Document doc = (Document)event.get_SourceObject(); 
try 
{ 
if (event.getClassName().equalsIgnoreCase("CreationEvent")) 
FileDocInFolder("/docs", doc); 
else if (event.getClassName().equalsIgnoreCase("ChangeClassEvent")) 
FileDocInFolder("/Archives", doc); 
} 
catch (Exception e) 
{ 
throw new EngineRuntimeException(ExceptionCode.E_FAILED); 
} 
}  
public void fileDocInFolder(String folderName, Document doc) 
{ 
try 
{ 
Folder folder = (Folder)doc.getObjectStore().getObject("Folder", folderName); 
ReferentialContainmentRelationship rel = folder.file (doc, 
AutoUniqueName.AUTO_UNIQUE, doc.get_Name(), 
DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE); 
rel.save(RefreshMode.NO_REFRESH); 
} 
catch (Exception e) 
{ 
e.printStackTrace(); 
} 
} 
} 


反馈

最近一次更新时间: 2010 年 11 月


© Copyright IBM Corporation 2010.
本信息中心基于 Eclipse 技术。(http://www.eclipse.org)