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

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

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

shangerhe@vip.sina.com
...全文
500 12 打赏 收藏 转发到动态 举报
写回复
用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客户端。
SOAOFFICE - 微软 OFFICE 间件 SOAOffice 间件是北京科翰软件为微软OFFICE量身打造的Web间件,是Web调用Office、存取Office数据的必备间件。SOAOffice间件由服务器端数据组件和客户端显示控件构成。 SOAOffice 完全抛弃了传统利用Office服务器端自动化技术存取文档数据的种种弊端和缺陷,采用独创的专利技术构建了一个功能强大、简单易用的微软Office间件平台,平台提供标准的.net和java组件接口,不但能够在线(浏览器页面)打开、编辑、保存Office文档,而且开发人员还能够以简洁的代码快速的将数据库数据动态填充到Office文档指定位置,并且也能够从Office文档提取指定位置的数据保存到数据库。 SOAOffice提供这些强大功能的同时,服务器端并不需要安装运行Office软件。通过SOAOffice,在Web世界里,难以驯服的Word/Excel就变成了普通的、熟悉的、服务器端可调用的.Net组件、Java组件、ASP组件、PHP组件,开发人员再也不用研究复杂的Word/Excel COM自动化细节、学习复杂的VBA语法调用,也不用去应对Word/Excel死进程、系统稳定运行的问题。开发人员能够节省宝贵的精力和时间,把它投放到更重要的业务逻辑和系统架构上,而控制Office的具体技术细节交给SOAOffice去做。 SOAOffice除了提供Word/Excel动态数据填充,Word/Excel数据导入导出,Word/Excel/PowerPoint等Office文档的在线打开、编辑、保存,权限控制,只读控制等功能外,还给在线办公内置了强大的支持功能:强制痕迹保留,手写批注,圈阅签字,手写签名,电子印章、数字签名、模板套红、一键套红等。 科翰软件是国内唯一的微软Office间件开发商,拥有卓越的自主研发实力和独创的专利技术,其产品SOAOffice不仅畅销国内,而且还远销欧美国际市场,其世界500强美国Dover集团、可口可乐 Coca-Cola、石油、石化等都是SOAOffice产品的忠实客户。 SOAOFFICE间件主要应用在Web系统下所有涉及编程调用Office的领域,例如: 1. 需要把数据库字段内容填充到Word/Excel指定位置的; 2. 需要把Word/Excel指定位置的内容提取出来保存到数据库字段的; 3. 需要动态生成指定格式的Word文档的; 4. 需要把html页面表格导出到excel的; 5. 需要在html页面套打票据、报表的; 6. 需要在html页面显示复杂报表,并要求精确打印预览及打印的; 7. 需要动态生成国式复杂格式报表的; 8. 需要在html页面输入复杂票据的; 9. 使用COM服务器自动化技术调用Word/Excel经常产生死进程或系统不稳定的; 10.Web系统调用Word/Excel的页面有大量并发用户访问的; 11.使用jacob、jxl、apache poi的; 12.需要在Web调用Word/Excel,并且追求系统运行稳定、可靠的; 13.最终用户可以浏览 Word/Excel/Ppt 文档内容,但需要禁止复制、粘贴、下载、另存的; 14.需要在html页面在线编辑Word公文的; 15.需要在协同办公强制保留Word修改痕迹的; 16.需要在协同办公手写批注、手写签名、加盖电子印章、模板套红的; 17.需要在新闻编辑强制保留Word修改痕迹、手写批注、圈阅的; 18.需要在远程教育实现试卷、作业在线批改的。 19.需要在html页面把Word转换为pdf的; 20.需要在html页面快速打开、显示pdf的; 21.需要在Ajax架构里调用Word/Excel的,包括服务器端和客户端Javascript都适用。 22.需要控制不同的用户在Word/Excel不同的区域编辑权限的; 23.需要在企业局域网内架设在线Office文档心、知识管理的; 24.需要在web页面导入导出Excel单元格数据的; ……… SOAOFFICE间件包括三个内置组件:SOAExcel、SOAWord、SOAPowerPoint。另外企业版还包括支持PDF文件的SOAPDF组件。 SOAOFFICE 间件采用标准HTTP传输协议,跨平台性好,支持任意Web服务器(IIS,WebLogic,WebSphere,Apache,Tomcat,Domino等),任意服务器操作系统(Win2k, Win2003,Win2008,Linux,Unix等),任意数据库(Access,SQL Server,Oracle,MySQL,DB2,Sybase等),以及任意WEB编程语言和Web架构(C#,Java,VB.Net,PHP,DOMINO,JSP,ASP,J2EE,ASP.NET,Ajax等)。SOAOFFICE同时支持C/S方式的编程和其他支持ActiveX的容器,您可以在VB,Delphi以及C++ Builder使用本间件,快速创建C/S结构的应用。 SOAOFFICE间件是一个国际化产品,支持多种界面语言:简体文、繁体文、英语、日语、法语、德语等。

535

社区成员

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

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