代码之家  ›  专栏  ›  技术社区  ›  vikramjb

使用Notes.jar获取给定日期的所有日历项

  •  2
  • vikramjb  · 技术社区  · 16 年前

    我正在编写一个简单的Java代码来提取给定日期的所有日历条目。我知道可以使用Domingo,但我只想使用Notes.jar。我可以基于给定的凭据创建会话并获取日历对象。我希望提取当前运行的Notes会话,并使用该会话对象打开邮件文件中的日历视图并开始使用它。但我无法让它工作。有人对此有任何想法或链接吗?

    4 回复  |  直到 13 年前
        1
  •  3
  •   vikramjb    16 年前

    我已经使用了默认的notes API,下面是代码。

    NotesAPITest nat = new NotesAPITest();
            NotesThread.sinitThread();
    
            Session sess1 = NotesFactory.createSession();
            System.out.println(sess1.getUserName());
            Database database = sess1.getDatabase("", "mailfile");
            View calendarView = database.getView("($Calendar)");
            DateTime dt = sess1.createDateTime("today");
            ViewEntryCollection vec = calendarView.getAllEntriesByKey(dt, true);
    
            ViewEntry entry = vec.getFirstEntry();
             while (entry != null) 
             {
    
               Document caldoc = entry.getDocument();
    
               System.out.println("Subject: " + caldoc.getItemValueString("Subject"));
               System.out.println("Chair Person: " + caldoc.getItemValueString("Chair"));
               System.out.println("Start Time: " + nat.getStartEndTimes(caldoc, "StartDateTime") );
               System.out.println("Start Time: " + nat.getStartEndTimes(caldoc, "EndDateTime") );
               System.out.println("Required: " + caldoc.getItemValueString("RequiredAttendees"));
               entry = vec.getNextEntry(); 
             }  
    

    我看到的唯一缺点是,每当提取会话时,notes都会弹出一个密码对话框。到目前为止,在我的搜索中,我还没有找到解决这个问题的方法。很明显,我想是LN的保安安排。

        2
  •  2
  •   Andrey Adamovich    16 年前

    this article . 他们在那里为Notes创建了一个Eclispe插件。还有获取员工brithdays的示例代码(我想日历的工作方式与此类似):

        s = NotesFactory.createSession();
    
        // Get the local address book
        Database nab = s.getDatabase("",s.getAddressBooks().elementAt(0).toString());
        if (nab.isOpen() == false) nab.open();  
    
        // Get the Birthdays & Anniversaries view           
        View baview = nab.getView("BA");
        ViewEntryCollection eba = baview.getAllEntries();
        ViewEntry entry = eba.getFirstEntry();
    
        list = new String[eba.getCount()];
        int count = 0;
    
        while (entry != null) {
    
            Vector vals = entry.getColumnValues();                           
            list[count]= vals.elementAt(1).toString() + " " + vals.elementAt(2).toString();                         
            entry = eba.getNextEntry();
            count++;
        }
    

    编辑 :另请看 this link 有关Notes.jar的一些文档。

        3
  •  2
  •   Ed Schembor    16 年前

    您可以使用NotesFactory.createSession()方法获取当前会话的句柄。Notes将自动共享当前客户端会话。如果此方法失败,则基本配置可能有问题。确保:

    • 您已在运行Java应用程序的计算机上完全安装了Notes客户端,并确保存在有效的Notes ID文件。(例如,确保可以在此计算机上成功打开Notes客户端)。
    • 此外,请确保可以在您的计算机路径上访问nnotes.dll文件(与Java类路径不同)。
    • 并且,确认Notes.ini文件也在机器的路径上。
        4
  •  1
  •   subdigit    16 年前

    @vikramjb,尝试执行NotesFactory.createSession((字符串)null,(字符串)null,密码);防止每次对会话执行需要安全性的操作时,notes密码弹出窗口提示您。

    从这里了解到: http://lekkimworld.com/2006/07/10/java_in_notes_domino_explained_domino_session_tester.html