如何在其它编程语言中访问DOMINO数据库,并对其操作?

shangerhe 2004-08-19 09:05:05
如何在其它编程语言中访问DOMINO数据库,并对其实现增、删、修等操作?例如在PB、VB、VC++等下开发,使用什么协议?如果哪位有例程请给一份。

我是新手,请多多关照,如果分不够可以再加。谢谢

shangerhe@vip.sina.com
...全文
514 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
yyh319 2004-08-31
  • 打赏
  • 举报
回复
给你个vb的解决办法
客户端注册NOTES COM控件。(regsvr32 c:\lotus\notes\DOMOBJ.TLB)regsvr32 c:\lotus\notes\nlsxbe.d
<SCRIPT LANGUAGE="VBScript">
Sub Button1_OnClick
dim s, dir, db, doc, eo, no, word, worddoc
Set s = CreateObject("Lotus.NotesSession")
Call s.Initialize
这样就获得了NotesSession对象,想做什么都可以了
binzh 2004-08-31
  • 打赏
  • 举报
回复
上面這麼多例子還不夠啊?????????
shangerhe 2004-08-31
  • 打赏
  • 举报
回复
谁能给我一个例子啊.发到我的信箱中啊
gjd111686 2004-08-19
  • 打赏
  • 举报
回复
Lotus Domino/Notes是美国莲花公司出的企业通讯和群件服务平台。但由于其本身提供的开发工具的限制,在Notes中实现系统级功能十分困难。比如在Notes中,不能通过公式或脚本来得到一个数据库的未读文档的数量和其内容。但这个未读文档数的小功能在做有些方面是十分有用的,例如我们可以根据这个未读文档数来做个提醒功能,提醒用户该进行某类工作如文件签发等。Notes系统本身有个Minder的程序,它是在有新邮件来到的时候,提醒用户,并可提供一些基本的信息:来信人,标题等。我们也可以这样做(当然利用未读文档数来做不是完美,如果你有兴趣,你可以试试做个数据库钩子程序来实现,但总的来说,利用未读文档数来做较为简单。)。

  本文就是讨论如何利用Notes提供的C API来实现读取一个Notes数据库的未读文档数和其信息。因为利用的是C API,所以我们的开发语言是C。开发工具我们选用的是VC++ 6.0。我们需要借助的是Notes本身提供的C API函数。Notes的大部分API都封装在nNotes.dll文件中。其中包括有ACL,Database,User,Document,Item等各个方面的API函数。它不光能实现几乎所有在Notes中实现的功能,它还提供了其他在Notes中难以想象的功能(换句话说,你可以自己写自己特有的Notes桌面程序而不再使用Notes.exe。当然它的功能还远不止这点)。利用Notes API包,我们可以做以下的程序:

  1、独立应用程序。

  2、DOMINO 服务器的扩展插入服务(add-in tasks)。

  3、NOTES 客户机的菜单扩展插入(menu add-ins)。

  4、NOTES 客户机可动态加载的函数库。

  5、数据库的钩子驱动程序(HOOK Drivers)。

  6、扩展管理程序的钩子函数库。

  7、非NOTES数据库的驱动程序。

  下面简单介绍一下我们后面会涉及的主要的Notes API函数:

  NotesInitExtended:初始化Notes环境,应在所有Notes API函数调用前初始化系统。

  NSFDbOpen:打开指定的Notes数据库。

  NSFDbClose:关闭指定的Notes数据库。

  NSFDbGetUnreadNoteTable:取得指定数据库内的未读文档列表。

  NSFDbUpdateUnread:更新数据库的未读文档列表。

  NIFFindView:取得数据库内的指定视图或文件夹。

  NIFOpenCollection:取得指定视图或文件夹的所有文档。

  NIFUpdateCollection:更新指定视图或文件夹的所有文档。

  NIFCloseCollection:关闭文档集。

  NIFReadEntries:读取文档集的指定文档。

  NSFNoteOpen:打开指定文档。

  NSFItemGetText:取得文档的指定字段值。

  程序流程:

  数据库中有张类型为IDTable的未读文档列表,其中包含了该数据库的带有未读标志的文档号。这张表存储在数据库中和客户机的Desktop.dsk文件中。当然,在数据库和文件中的这张表是一样的。当他们不一致时,则在你打开数据库时,它们会自动同步,使他们保持一样。

  我们就是要取得这张未读文档表,再统计一下这张表中有多少项,就知道了数据库中多少文档带有未读标志。我们还可以在此基础上取得该文档的一些具体信息。但这张表是整个数据库的未读文档列表,我们怎么得到某个视图或文件夹的未读文档数和信息呢?实际上,这才是我们真正关心的。我们可以再找到某个视图和文件夹的文档列表,再与上面的未读文档列表进行一一比较,相同的则是该视图或文件夹的未读文档列表。





主要程序如下:

//////////////////////////////////////////////////////
// InitNotes:初始化Notes环境,打开数据库
// szServerName:服务器名
// szDBName:数据库名
// szDirectory:Notes系统目录
// 返回值:1 - 成功
// 0 - 失败

int CNotes::InitNotes(char *szServerName,char *szDBName,char *szDirectory)

{

STATUS status;

char szPathName[MAX_PATH];

char szpInitPara[1][260];



// 数据库路径名=服务器名+“!!”+数据库名

if (strlen(szServerName)==0)

strcpy(szPathName,szDBName);

else {

strcpy(szPathName,szServerName);

strcat(szPathName,"!!");

strcat(szPathName,szDBName);

}

strcpy(szpInitPara[0],szDirectory);

if (!m_bOpened)

NotesInitExtended(1,(char**)szpInitPara); // 初始化Notes环境

status=NSFDbOpen(szPathName,&hDb); // 打开数据库

if (status!=NOERROR) {

m_bOpened=false;

return 0;

}

m_bOpened=true;

return 1;

}



///////////////////////////////////////////////////
// GetUnread:取得指定视图或文件夹中的未读文档数
// szViewName:视图或文件夹名
// 返回值:-1 - 失败
// 其他 - 未读文档数

int CNotes::GetUnread(char *szViewName)

{

STATUS status;

char szUserName[MAX_PATH];



status=SECKFMGetUserName(szUserName); // 得到当前用户名

if (status!=NOERROR) {

m_bGetUnread=false;

return -1;

}

status=NSFDbGetUnreadNoteTable(hDb,szUserName,_
strlen(szUserName),true,&hTable);
// 取得数据库的未读文档列表

if (status!=NOERROR) {

m_bGetUnread=false;

return -1;

}

if (hTable==NULL) {

m_bGetUnread=false;

return -1;

}



status=NSFDbUpdateUnread(hDb,hTable); // 更新未读文档列表

if (status!=NOERROR) {

OSMemFree(hTable);

m_bGetUnread=false;

return -1;

}



status = NIFFindView(hDb, szViewName, &ViewID); file://得到数据库的某视图或文件夹

if (status!=NOERROR) {

OSMemFree(hTable);

m_bGetUnread=false;

return -1;

}



status=NIFOpenCollection(hDb,hDb,ViewID,0,hTable,_
&hCollection,NULL,NULL,NULL,NULL);

if (status!=NOERROR) {

OSMemFree(hTable);

m_bGetUnread=false;

return -1;

}



status =NIFUpdateCollection(hCollection);

if (status!=NOERROR) {

NIFCloseCollection(hCollection);

OSMemFree(hTable);

m_bGetUnread=false;

return -1;

}



COLLECTIONPOSITION CollPosition;

CollPosition.Level = 0;

CollPosition.Tumbler[0] = 0;

HANDLE hBuffer;

DWORD NotesFound;

WORD SignalFlags;

Status=NIFReadEntries(hCollection,&CollPosition,_
NAVIGATE_NEXT,1L,NAVIGATE_NEXT,0xFFFF,READ_MASK_NOTEID,_
&hBuffer,NULL,NULL,¬esFound,&SignalFlags);

if (status!=NOERROR) {

NIFCloseCollection(hCollection);

OSMemFree(hTable);

m_bGetUnread=false;

return -1;

}

int iViewUnread=0;

NOTEID NoteID;

BOOL fFirst=TRUE;

unsigned int i;

NOTEID* IdList;

if (hBuffer != NULLHANDLE)

{

IdList = (NOTEID far *)OSLockObject(hBuffer);



while(IDScan(hTable, fFirst, ¬eID)) // 依次取得hTable表中的文档号

{

fFirst = FALSE;

for (i=0; i

if (NoteID==IdList[i]) {

iViewUnread++;

break;

}

}

OSUnlockObject(hBuffer);

OSMemFree(hBuffer);

}



NIFCloseCollection(hCollection);

OSMemFree(hTable);

m_bGetUnread=true;

return iViewUnread;

}



//////////////////////////////////////////
// CloseNotes:关闭Notes数据库

void CNotes::CloseNotes()

{

if (m_bOpened)

NSFDbClose(hDb);

m_bOpened=false;

m_bGetUnread=false;

}

经验:

  1、在用NSFDbGetUnreadNoteTable函数取得未读文档列表时,发现在读取本地数据库时,未读文档列表是正确的,而当读取服务器上数据库时(即使你在本地做个复本,再读本地复本的未读文档列表也是一样),总是返回总文档数,即使在用NSFDbUpdateUnread函数更新了未读文档列表后仍是如此,只有在用文档集函数NIFUpdateCollection更新后才能得到真正的未读文档数。

  2、在上面得到的未读文档数是整个数据库的全部未读文档,应和视图文档进行对比后才真正得到某视图或文件夹的未读文档。

  3、Notes在处理中文时,要求每个中文前都必须有0x13字符才行。所以在处理中文数据库方面,自己还要自行处理中文名问题。

  4、要进一步得到文档的字段内容,可以用将以下函数段加入上述函数中。

BOOL fFirst = TRUE;

int j=0;

NOTEHANDLE noteHandle;

while(IDScan(hTable, fFirst, ¬eID))

{

fFirst = FALSE;



for (i=0; i

if (NoteID==IdList[i]) {

if (NSFNoteOpen(hDb, NoteID,0, ?eHandle)==NOERROR) {

NSFItemGetText(noteHandle,szItemName,Buffer[j],MAX_PATH);

}

j++;

break;

}

}



  5、本文是实现该功能的主要函数,你可以将其写成一个DLL程序,那么就可以在你的Notes Script脚本程序中来使用它。你也可以利用它写成一个独立的应用程序,你就可以在Notes外部运行它了。

  本程序在Windows2000 Server,Visual C++ 6.0下调试通过。如果本文有任何问题,请与作者联系。

参考文献:

Lotus C API 5.0.7 User Guide

Lotus C API 5.0.7 Reference
gjd111686 2004-08-19
  • 打赏
  • 举报
回复
Lotus C++ API Toolkit Documentation Release 2.4 English
http://www14.software.ibm.com/webapp/download/preconfig.jsp?id=2003-03-06+04%3A05%3A52.553792R&S_TACT=TrialsAndBetas&S_CMP=&s=

Lotus C++ API Toolkit Release 2.4 for Win32 English
http://www14.software.ibm.com/webapp/download/preconfig.jsp?id=2003-03-06+04%3A05%3A52.786750R&S_TACT=TrialsAndBetas&S_CMP=&s=
nc_uu 2004-08-19
  • 打赏
  • 举报
回复
学习中,帮你顶一下
Zerotm 2004-08-19
  • 打赏
  • 举报
回复
The back-end Domino Objects have a Component Object Model (COM) interface. The COM interface is the same as the LotusScript interface with some exceptions. These exceptions are noted below in "General exceptions to LotusScript specifications" and "Specific exceptions to LotusScript specifications," and in the LotusScript classes A-Z reference.
COM provides both early-binding (custom) and late-binding (dispatch) interfaces. Early binding makes the Domino classes available as typed variables with compile-time checking. Late binding can be used where the language (for example, VBScript) precludes early binding.
Notes
This feature is new with Release 5.0.2b.
This feature is not supported under OS/2, under UNIX, and on the Macintosh.
Requirements
The COM interface is available on a computer containing any of the following:
Domino Designer Release 5.0.2b or later
Domino Server Release 5.0.2b or later
Notes Client Release 5.0.2b or later
The Domino or Notes software must be installed but need not be running.
Installation of the Domino or Notes software makes a type library available and registers the following classes:
Lotus.NotesSession
Lotus.NotesSession.1
Do not confuse these with the OLE automation objects Notes.NotesSession and Notes.NotesUIWorkspace.
The Domino COM objects must be able to locate a valid NOTES.INI file, looking first in the Domino or Notes program directory and then at the PATH system variable. The KeyFileName setting in the NOTES.INI file specifies the user ID that COM uses.
Creating a session object
To access the Domino Objects, create an object based on the registered Lotus.NotesSession class.
Visual Basic
Include the Domino object library in the Visual Basic project:
Choose Project - References.
Check "Lotus Domino Objects."
The location will show the path to DOMOBJ.TLB in the Domino or Notes program directory.
Alternatively, you can select the Browse button and specify DOMOBJ.TLB in the Domino or Notes program directory.
The Domino Objects then become available to the project. You can see them in the Object Browser and they appear as prompts when you start typing an object name.
The classes appear in the left-hand pane of the browser; the properties and methods appear in the right-hand pane for the selected class. Constants appear in the left-hand pane as Enum data structures; the members appear in the right-hand pane. For example, the Enum structure named ACLLEVEL contains the members ACLLEVEL_AUTHOR, ACLLEVEL_DEPOSITOR, and so on. The error constants appear in the right-hand pane when NOTES_ERRORS is selected in the left-hand pane.
To access the Domino Objects, create a NotesSession object with either:
Dim session As New NotesSession
Or:
Dim session As NotesSession
Set session = CreateObject("Lotus.NotesSession")
注释 If you declare the session variable as Variant or Object, COM uses late binding.
VBScript
In VBScript, create a NotesSession object with:
Dim session
Set session = CreateObject("Lotus.NotesSession")
VBScript treats all variables as Variant so COM uses late binding.
The Domino constants are not defined. You must specify the actual values (or define the constants yourself). See the discussion of constant values below in "Constants."
Initializing a session
You must explicitly initialize a COM session with one of the following NotesSession methods. These methods do not apply to LotusScript applications.
Call session.Initialize("passwordOptional")
Call session.InitializeUsingNotesUserName("name", "passwordOptional")
The parameters are all strings. The name parameter can be an empty string. The password parameter is optional.
Initialization occurs as follows:
Initialize: this method can be used on a computer with a Notes client or Domino server and bases the session on the current user ID. If a password is specified, it must match the user ID password. If a password is not specified, the user is prompted for a password as required and as the software permits. If the software does not support prompting (for example, VBScript under ASP/IIS), you must supply the password or the user ID must not have one.
InitializeUsingNotesUserName: this method can be used only on a computer with a Domino server. If a name is specified, the InitializeUsingNotesUserName method looks it up in the local Domino Directory and permits access to the local server depending on the "Server Access" and "COM Restrictions" settings. The password must match the Internet password associated with the name. If no name is specified, access is granted if the server permits Anonymous access.
These methods assume that you trust the local Domino or Notes installation.
Access to the Domino Objects is as a client if you use the Initialize method and the user ID is not specified as a server in the local Domino or Notes directory. Otherwise, access is as a server. As a client, you can access any server that accepts your user ID. As a server, you can access only the local server.
shangerhe 2004-08-19
  • 打赏
  • 举报
回复
谁有例子能给一个吗?pb或delphi
zengxianfeng 2004-08-19
  • 打赏
  • 举报
回复
关注
虎头是我 2004-08-19
  • 打赏
  • 举报
回复
JAVA:

//访问当前DOMINO数据库
Session session = NotesFactory.createSession();
//String p = session.getPlatform();
//System.out.println("Platform = " + p);
//System.out.println(s.getCommonUserName());

String ServerName = null; //测试数据
String DBName = "HQITOverTime.nsf"; //测试数据

Database db = session.getDatabase(ServerName,DBName);
虎头是我 2004-08-19
  • 打赏
  • 举报
回复
VB:

1、引用“Lotus Domino Objects”
2、输入代码:
Dim ss as New NotesSession
ss .initialize
Dim db as NotesDatabase
set db = ss.getDatabase("";"names.nsf")
3、说明:
除NotesSession对象外,其他对象不支持NEW方法,需要从NotesSession引伸
钟伟海 2004-08-19
  • 打赏
  • 举报
回复
pb下不行,网上有一篇很老得文章,担我试过,一直没成功
DELPHI不台清楚
最好联的是JAVA。用CORBA来连接,不然你就要在客户装NOTES客户端。

536

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 Exchange Server
社区管理员
  • 消息协作社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧