CSDN博客

img chenyg2000

A sample code stub written in Java agent to transfer attachment to BLOB

发表于2004/10/27 10:31:00  775人阅读

分类: Lotus Others

import lotus.domino.*;
import java.util.Vector;
import java.util.Enumeration;

public class JavaAgent extends AgentBase {

public void NotesMain() {

try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
DBHandler lobs = new DBHandler(); // Instantiate root frame
DateTime date = session.createDateTime("11/11/01");
DocumentCollection dc = agentContext.unprocessedSearch("AttachedFile=1",date,0);
if (dc.getCount() != 0) {
Integer intObj = new Integer(0);
Document doc = dc.getFirstDocument();
if (doc != null) {
lobs.dbConnection();
if (lobs.m_connection != null) {
while (doc != null) {
Item it = doc.getFirstItem("UNID");
RichTextItem rtitem = (RichTextItem)doc.getFirstItem("attachfile");
Vector v = rtitem.getEmbeddedObjects();
Enumeration e = v.elements();
while (e.hasMoreElements()) {
EmbeddedObject eo = (EmbeddedObject)e.nextElement();
lobs.insertBLOB(it.getValueString(), eo);
}
doc.replaceItemValue("AttachedFile", intObj);
doc.save(true);
doc = dc.getNextDocument(doc);
} //End while (doc != null)
lobs.closeSession();
} //End if (lobs.m_connection != null)
} //End if (doc != null)
}
log.close();
} catch(Exception e) {
e.printStackTrace();
}
}

}
阅读全文
0 0

相关文章推荐

img
取 消
img