db = LotusSession.getDatabase(initconfig.LotusServer, initconfig.LotusDataBase);
view = db.getView(initconfig.LotusView) ;
Document doc = view.getFirstDocument();
Item uitem = null;
while (doc != null)
{
AmsFields = "" ;
AmsFieldValues = "" ;
C_YWID = connectDB.getCreateGUID() ;
ExpRecCount += 1 ;
YWIndex = 0 ;
RecID = (connectDB.getMaxID(initconfig.DBTable) + 1) +"" ;
System.out.println("导出记录数: "+ExpRecCount+"-----------DB记录ID: "+RecID+"---------") ;
String IdeaFileName = "意见列表.html" ;
IdeaGUIDFileName = getGUIDFileName(IdeaFileName) ;
Vector AllItems = doc.getItems(); //获得域名
for (int i =0 ; i < AllItems.size(); i++)
{
uitem = (Item)AllItems.get(i) ;
ProcesItems(doc, uitem) ;
}
AmsFields = AmsFields + "原文数量,C_YWID" ;
AmsFieldValues = AmsFieldValues + YWIndex +",'"+C_YWID+"'" ;
connectDB.SaveInfo("\""+initconfig.DBTable+"\"", AmsFields, AmsFieldValues) ;
ftpUpfile.ftpclient.ascii(); //上传完文件必须执行
doc = view.getNextDocument(doc);
}
connectDB.CloseCon() ;
ftpUpfile.logout() ;
}
catch(Exception e)
{
e.printStackTrace() ;
}
}
//连接远程主机
public Session getSession(String sip,String port, String username,String password)
{
lotus.domino.Session s;
String sior;
try
{
sior = NotesFactory.getIOR(sip+":"+port);
s = NotesFactory.createSessionWithIOR(sior, username, password);
}
catch (Exception ex)
{
s = null;
}
return s;
}
public void ProcesItems(Document doc, Item uitem)
{
RichTextItem ruitem = null;
try
{
String itemName = uitem.toString() ;
int itemType = uitem.getType() ;
String itemValue = "" ;
switch(itemType) {
case Item.TEXT: //1280
{
int itemIndex = initconfig.LotusFields.indexOf(itemName) ; //判断是否是要导的域
if (itemIndex > -1)
{
if (doc.getItemValue(itemName).size() > 0)
itemValue = ObjToStr(doc.getItemValue(itemName).get(0)) ;
String uAmsField = ObjToStr(initconfig.FieldAttrs.get(itemName)) ;
AmsFields += uAmsField+"," ;
AmsFieldValues += "'"+itemValue+"',";
}
break;
}
case Item.RICHTEXT: //1
{
ProcesRichTextItem(doc, uitem) ;
break;
}
default:
{
break;
}
}
}
catch(Exception e)
{
e.printStackTrace() ;
}
}
public void ProcesRichTextItem(Document doc, Item uitem)
{
try
{
EmbeddedObject eo = null;
java.io.InputStream is = null;
RichTextItem ruitem = (RichTextItem)uitem ;
if (uitem.toString().equals("RCover"))
{
RichTextNavigator rtnav = ruitem.createNavigator() ;
if (rtnav.getFirstElement(RichTextItem.RTELEM_TYPE_DOCLINK) != null)
{
do
{
Document uDoc = getLinkDocument(rtnav) ;
Item uUitem = null;
Vector uAllItems = uDoc.getItems(); //获得域名
for (int i =0 ; i < uAllItems.size(); i++)
{
uUitem = (Item)uAllItems.get(i) ;
ProcesChildItems(uDoc, uUitem) ;
}
String uFormName = uDoc.getItemValueString("Form") ;
String uDocID = uDoc.getUniversalID() ;
String uDate = "to_date('"+connectDB.getCurrentDate()+"','yyyy-MM-dd HH24:mi:ss')" ;
String uValues = "'"+C_YWID+"', '"+uFormName+"', '"+uDocID+"', "+uDate ;
connectDB.SaveInfo("OA_IMPDOCIDS", "YWID,FORMNAME,DOCID,IMPDATETIME", uValues) ;
}
while(rtnav.findNextElement()) ;
}
else
System.out.println("没有doclink 在 RCover") ;
}
}
catch(Exception e)
{
e.printStackTrace() ;
}
}
/*
*
*/
public void ProcesChildItems(Document doc, Item uitem)
{
try
{
String itemName = uitem.toString() ;
int itemType = uitem.getType() ;
String itemValue = "" ;
switch(itemType) {
case Item.TEXT: //1280
{
if (doc.getItemValue(itemName) != null && doc.getItemValue(itemName).size() > 0)
{
itemValue = ObjToStr(doc.getItemValue(itemName).get(0)) ;
//判断是否是流程跟踪
int itemIndex = initconfig.LotusFlowTrackFields.indexOf(itemName) ;
if (itemIndex > -1)
{
if (!itemValue.trim().equals(""))
{
SaveFlowTrack(itemValue) ;
}
}
else if (!itemName.equals("TDispInnerUsers") && !itemName.equals("sManuTemplateFields")) //判断不写入的域
{
String uValues = "'"+C_YWID+"', '"+itemName+"', '"+itemValue+"', 1" ;
connectDB.SaveInfo("OA_IMPDOCCONTENTS", "YWID, FIELDNAME, FIELDVALUE, IORDER", uValues) ;
}
}
break;
}
case Item.RICHTEXT: //1
{
ProcesChildRichTextItem(doc, uitem) ;
break;
}
default:
{
break;
}
}
}
catch(Exception e)
{
e.printStackTrace() ;
}
}