新增java代理-定时执行
原理:使用视图SelectionFormula属性修改视图筛选条件。已达到动态修改视图筛选条件的问题。
运用场景:比如公告模块的过滤过期的公告,可以使用这个属性每天修改视图条件,避免视图中直接出现动态的时间进行筛选。
主要视图如果出现动态的时间筛选 对性能影响较大,应该避免。
SELECT form = "bulletin" & eday>=@Today 高耗能,动态时间,每次执行都会更新索引,执行会很慢
SELECT form = "bulletin" & eday>= [2019-07-08] 低耗能。每天定时代理修改视图条件为静态的时间,
代码范例如下:
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
info("toUpViewFormula---beg");
// (Your code goes here)
Database db = agentContext.getCurrentDatabase();
View view = null;
view = db.getView("(byNumtz)");
view.setSelectionFormula(
"@Now < @Adjust(@modified; 0; 0; 6; 0; 0; 0)");
info("toUpViewFormula---end");
} catch(Exception e) {
info("toUpViewFormula---执行异常");
e.printStackTrace();
}
}
public void info(Object obj)
{
System.out.println(obj);
}
}