-1

嗨,我是 Lotus Script 的新手

我想运行一个访问数据库的 Java 代理来读取表单存储的视图。

我更新了代码

下面是我的代码:

public class JavaAgent extends AgentBase {

    public void NotesMain() {

      try {
          Session session = getSession();
          AgentContext agentContext = session.getAgentContext();
          // (Your code goes here) 
          Database db = agentContext.getCurrentDatabase();
          View view = db.getView("PetView");
          view.setAutoUpdate(false);
          view.setAutoUpdate(false);
          ViewEntryCollection vec = view.getAllEntries();
          System.out.println("Parent is " + 
            vec.getParent().getName());
          System.out.println("Number of entries = " + 
            vec.getCount());
          ViewEntry tmpentry;
          ViewEntry entry = vec.getFirstEntry();
          while (entry != null) {
            System.out.println("Entry is at position " + 
            entry.getPosition('.'));
            tmpentry = vec.getNextEntry();
            entry.recycle();
            entry = tmpentry;
          }
      } catch(Exception e) {
          e.printStackTrace();
       }
   }
}

我的调试控制台 O/P 是:

    Parent is PetView
Number of entries = 8
Entry is at position 1
Entry is at position 2
Entry is at position 3
Entry is at position 4
Entry is at position 5
Entry is at position 6
Entry is at position 7
Entry is at position 8

如我错了请纠正我

谢谢 。

4

2 回答 2

0

您的代码甚至没有尝试访问视图。您正在访问包含所有文档的集合。

要访问视图,您只需要以下内容:

View v = tempDb.getView("theViewNameOrAliasGoesHere");
于 2015-01-23T07:48:07.977 回答
0

要获取本地数据库,只需使用不带服务器名的 getdatabase。

设置 db = notessession.getdatabase("", "path\dbname.nsf")

于 2015-01-23T06:24:49.297 回答