P
pokerkmx
Хочу удалить ненужные записи из карточек пользователя. После выполнения проверяю - свойство count полей MajVer, MinVer, QMRVer, QMUVer, HotVer, FixPVer, FlagsVer, ClntDgst остаётся прежним. В чём может быть причина? Спасибо.
Java:
import java.util.Date;
import java.util.Vector;
import lotus.domino.*;
public class JavaAgent extends AgentBase{
private String[] fields={"ClntBld","ClntDate","ClntDgst","ClntMachine","ClntPltfrm","FixPVer","FlagsVer","HotVer","MajVer","MinVer","QMRVer","QMUVer"};
public void NotesMain(){
try
{
Session session = getSession();
Database db=session.getDatabase("nameserver", "names.nsf");
DocumentCollection dc=db.search("Type=\"Person\" & LocalAdmin=\""+session.getUserName()+"\"");
Document tmpdoc;
Document doc = dc.getFirstDocument();
while (doc != null)
{
if (doc.getItemValue("ClntMachine").size()>1) WorkWithDocument(doc);
tmpdoc = dc.getNextDocument();
doc.recycle();
doc = tmpdoc;
}
session.recycle();
}
catch(Exception e){e.printStackTrace();}
}
private void WorkWithDocument(Document doc) throws NotesException
{
Vector times = doc.getItemValueDateTimeArray("ClntDate");
Date max = getJavaDate(times.elementAt(0));
int max_ind=0;
for (int j=1; j<times.size(); j++)
{
Date time=getJavaDate(times.elementAt(j));
if (time.compareTo(max)>0) {max=time;max_ind=j;}
}
for (int i=0;i<fields.length;i++)
doc.replaceItemValue(fields[i], doc.getItemValue(fields[i]).elementAt(max_ind));
doc.save();
}
private Date getJavaDate(Object o) throws NotesException{return ((DateTime)o).toJavaDate();}
}