Lotus Notes 学习笔记

这是一个学习关于如何使用Lotus Notes的Agent功能来实现自动化办公的学习笔记。

 

 

一. 介绍


  Lotus Notes/Domino 是一个世界领先的企业级通讯、协同工作及Internet/Intranet平台;具有完善的工作流控制、数据库复制技术和完善可靠的安全机制;尤其适合于处理各种非结构化与半结构化的文档数据、建立工作流应用、建立各类基于Web的应用。它全面实现了对非结构化信息的管理和共享,内含强大的电子邮件功能及工作流软件开发环境,是实现群组协同工作、办公自动化的最佳开发环境。

 

Notes的主要设计元素:

数据库:在notes中存储文档的单元,文档是用来保存数据的,数据库里保存了若干个文档。
表单:是用来定义文档的格式和布局,每个表单包含域、静态文本、图形和按钮。
视图:是帮助用户很容易的找到你想要的文档。视图可以为数据库内容提供概述报告
文件夹:类似于视图,但可以将视图中的文档拖到文件夹,反之则不行。
代理:是在数据库中执行特定任务的单机程序:如修改域值,发送邮件
XPages: XPages是Domino 8.5引进的基于JSF的设计元素。大大丰富了Domino的Web开发功能。

二. Lotus Notes 安装和配置


 

2.1 Lotus 产品说明

  IBM公司提供的这一软件产品的全称是IBM Lotus Notes & Domino. Notes是客户端,Domino是服务器。

  Lotus Notes是指Notes客户端,它安装在用户个人电脑上,用于访问电子邮件和Notes应用。

  Domino则是Notes/Domino组合的服务器部分,它可以运行在各种操作系统中。当用户通过Notes客户端连接服务器备份邮件数据时,用来从用户邮件数据库中提取内容的正是Domino服务器。Domino服务器还负责控制邮件和应用数据库的登录和安全等。Domino服务器拥有强大的安全模式,可以控制访问单个Notes文档级别的安全性。主要通过基于用户Notes ID登录系统,以及数据库和网络通信加密技术等来实现。

2.2 安装

2.2.1 环境:
  服务器:DOMI_SRV_9.0_WIN_64_EN_TRIAL.exe

  客户端:NotDesg_9.0_WIN_SC_deve.exe/lotus_notes853_win_SC.exe

  这里建议客户端选择Notes design。因为需要使用Domino Administrator来对Domino服务器进行配置,一般的Lotus Notes客户端不附带该组件。

  

2.2.2 Server安装和配置:

 服务器安装步骤,安装默认设置安装服务器domino,服务器在初次启动的时候,将要求配置该服务器。

详细的配置方法可以参考后面的参考资料进行配置,这里只说明一些需要注意的地方:

  1. 服务器名称应与计算机名称相同,否则在配置过程中可能会出现错误,导致服务器运行不正常或无法配置。计算机名称的修改如下:右击桌面的“我的电脑”,单击“属性”,选择“计算机名”标签,再单击“更改”。

    

 

  2. 自定义服务器管理员的用户名和密码,用户只需要在“Last name”项中填入名称即可。下面的“Also save a local copy of the ID file”要勾选,它会创建一个“admin.id”的文件,用户加载到Note Administrator客户端用于管理Domino服务器。

    

 

2.2.3 Client端的安装和配置

1. 按照默认安装完Notes后(如果不了解,可以参考后面的参考资料),连接上服务器。

如果想配置服务器的话,你需要安装包含Administrator 的客户端版本,这里安装的是NotDesg_9.0_WIN_SC_deve.exe。

2. 配置邮件服务器

参考《IBM Lotus Domino 邮件服务器配置攻略》

三. Lotus Script语法介绍


 

  LotusScript是一种和Basic相兼容的面向对象的Scripting环境,它具有强大的能够从事面向对象应用软件开发的语言范围,能够提供循环和分支的能力、数组以及访问Notes对象的能力。 
  判断Notes中什么时候使用LotusScript或公式语言 

  1. 任何时候当执行该任务的函数或命令存在时,使用公式。 
  2. 对于复杂的程序控制或循环,使用LotusScript。 
  3. 存取或操作储存的文档数据要使用LotusScript,特别对于跨文档、跨数据库的存取。 
  4. 若公式语言不能办到,则使用LotusScript 

具体内容请参考 《LotusScript语言的基本知识》

四. Lotus Notes 的Agent编程


 

 在参考《在 Lotus Notes 中设置邮件定时发送的方法及代理功能介绍》中具体介绍了Agent的概念和如何使用。

 这里只就Lotus Script的编程进行一些使用上的说明:

  1. Declerations 用来定义一些函数或者全局变量,比如下面的 createPath 在Declerations中定义并实现后,将变成下面这样

    

 

  2. 程序的入口使用Initialize,Terminate入口一般不使用,如果程序实现在Terminate中,一些Lotus Script接口将无法被调用。

 

五. 具体实例


  这里有一个Notes 的邮件附件处理Agent,具体的需求是根据邮件的时间和标题来创建文件夹,并将附件存储在标题文件夹中。

 

  1 Sub createPath(path As String)
  2     
  3     Set objFSO = CreateObject("Scripting.FileSystemObject")
  4     
  5     If objFSO.FolderExists(path) Then
  6         'Messagebox ("Directory does exist")
  7     Else
  8         'Messagebox("Directory does not exist")
  9         Mkdir (path)    
 10     End If 
 11 End Sub
 12 
 13 
 14 
 15 
 16 
 17 Sub Initialize
 18     
 19     Dim DirResult As String 
 20     Dim dirPath As String 
 21     dirPath = "d:\loans"
 22     
 23     Dim names As String
 24     Dim compname As String
 25     Dim zhihangList(32) As String
 26     zhihangList(0) = "scarlettduan"
 27     zhihangList(1) = "jack"
 28     zhihangList(2) = "god"
 29     zhihangList(3) = "lu"
 30     
 31     Dim session As New NotesSession
 32     Dim db As NotesDatabase
 33     Dim dc As NotesDocumentCollection
 34     Dim doc As NotesDocument
 35     Dim item As NotesItem
 36     Dim body As NotesRichTextItem
 37     Dim rtnav As NotesRichTextNavigator
 38     Dim rtrange As NotesRichTextRange
 39     
 40     Set db = session.CurrentDatabase
 41     Set dc = db.UnprocessedDocuments
 42     Set doc = dc.GetFirstDocument
 43     Set body = doc.GetFirstItem("Body")
 44     
 45     Set rtnav = body.CreateNavigator
 46     
 47     REM 过滤发件人
 48     Set item = doc.GetFirstItem("From")
 49     If (item Is Nothing) Then
 50         Msgbox "收件人不存在,这个程序不能运行 ",16,"退出"
 51         Exit Sub '退出程序 1
 52     Else
 53         Dim nameArr
 54         
 55         nameArr = Split(Cstr(item.Text),"/", -1, 1)
 56         
 57             'For i = 0 To Ubound(nameArr)
 58             '    Messagebox nameArr(i)
 59             'Next i
 60         
 61         '取倒数第三个作为发件人
 62         'names = Mid(nameArr( Ubound(nameArr) - 2), 4)
 63         names = Mid(nameArr(0), 4)
 64         
 65         For i = 0 To Ubound(zhihangList)
 66             If(zhihangList(i) = names) Then
 67                 'Messagebox ("find the zhihang from the list")
 68                 Goto Step1
 69             End If
 70         Next i
 71         
 72         Msgbox "发件人不正确,可能不是你想要加工的邮件 ",16,"退出"
 73         Exit Sub '退出程序 2
 74     End If
 75     
 76     
 77 Step1:
 78     
 79     REM 过滤附件信息
 80     If rtnav.FindFirstElement(RTELEM_TYPE_FILEATTACHMENT) Then 
 81         
 82         Dim filetype As String    
 83         Do
 84             Set att = rtnav.GetElement()
 85             filetype = Strright(att.Source,".")
 86             'Messagebox filetype
 87             If filetype = "xls" Or filetype = "xlsx" Then
 88                 Msgbox "该邮件中存在EXCEL 附件,可能不是你想要加工的邮件 ",16,"退出"
 89                 Exit Sub '退出程序 3
 90             End If
 91             
 92         Loop While rtnav.FindNextElement()
 93     Else
 94         Msgbox "该邮件中不存在附件,可能不是你想要加工的邮件 ",16,"退出"
 95         Exit Sub '退出程序 5    
 96     End If
 97     
 98     
 99     REM 获得时间,创建文件夹
100     Dim timeArr
101     Dim myMouth As String
102     Dim myDay As String
103     Dim dateTime As New NotesDateTime( "" )
104     Set item = doc.GetFirstItem( "DateComposed" )
105     
106     dateTime.LSLocalTime = doc.Created
107     
108     createPath(dirPath)
109     
110     myMouth = Format(Cstr(dateTime.LSLocalTime), "yyyymm")
111     dirPath = dirPath & "\" & myMouth
112     
113     'Messagebox "dirPath " & dirPath
114     createPath(dirPath)
115     
116     myDay = Format(Cstr(dateTime.LSLocalTime), "yyyymmdd")
117     dirPath = dirPath & "\" & myDay 
118     
119     'Messagebox "dirPath " & dirPath
120     createPath(dirPath)
121     
122     
123     REM 这里需要根据实际情况修改
124      REM 获得邮件标题,创建文件夹
125     Set item = doc.GetFirstItem( "Subject" )
126     
127     
128     If ( item.Text = "" ) Then '如果该邮件没有标题,根据需要创建文件名
129         
130         'Messagebox( "There is no Subject item on the document.you need to create file by youself" )
131         compname = Cstr(Inputbox$("There is no Subject item on the document. " + Chr(13) + "the document name should be?"))
132         
133         If(compname = "") Then
134             Msgbox "你必须输入一个公司名称 ",16,"退出"
135             Exit Sub  '退出程序 4
136         End If
137         
138         compname = dirpath & "\" & names & compname
139         createPath(compname)
140         
141     Else ' 在邮件有标题的情况下
142         
143         'Messagebox(  "The Subject item on the document has the value: " + item.Text )
144         Dim subArr 
145         Dim haveComp As Boolean
146         'Dim names As String
147         
148         haveComp = False
149         subArr = Split(Cstr(item.Text),"", -1, 1)
150         
151         'Messagebox subArr(0) & " " & Cstr(item.Text)
152         '一般情况下,格式为xxx申请:xxx公司,这里表示没有使用“:”作为分隔符的情况下,提示手动输入
153         If subArr(0) = item.Text Then '如果非上面格式的情况,使用“:”分割的邮件名
154             
155             'Messagebox ("have not 公司 1")
156             compname = Cstr(Inputbox$("There is no Subject item on the document. " + Chr(13) + "the document name should be?"))
157             
158             If(compname = "") Then
159                 Msgbox "你必须输入一个公司名称 ",16,"退出"
160                 Exit Sub  '退出程序 4
161             End If
162             
163             compname = dirpath & "\" & names  & compname
164             createPath(compname)
165             
166         Else
167             For i = 0 To Ubound(subArr)
168                 
169                 '这里是创建文件夹的关键位置,公司名需要是带有申请两字的后面
170                 If Instr(subArr(i), "申请") = 0 Then '''''''(1)
171                     '如果整个标题中都没有上面的关键字,该处理将在后面进行,对于下面的have not 公司 2
172                 Else
173                     'Messagebox ("hava  公司 2")
174                     haveComp = True
175                     compname = subArr(i + 1)
176                     compname = dirpath & "\"& names & compname
177                     createPath(compname)
178                 End If    
179             Next i
180             
181             '一般情况下,下面的路径不会运行到
182             If haveComp = False Then 'have not 公司 2.对于上面的(1)
183                 
184                 'Messagebox ("have not 公司 2")
185                 compname = Cstr(Inputbox$("There is no Subject item on the document. " + Chr(13) + "the document name should be?"))
186                 
187                 If(compname = "") Then
188                     Msgbox "你必须输入一个公司名称 ",16,"退出"
189                     Exit Sub  '退出程序 4
190                 End If
191                 
192                 compname = dirpath & "\" & names  & compname
193                 createPath(compname)
194             End If
195         End If    
196         
197     End If
198     
199     
200     REM Get attachments
201     If rtnav.FindFirstElement(RTELEM_TYPE_FILEATTACHMENT) Then
202         
203         Do
204             Set att = rtnav.GetElement()
205             filepath$ = compname + "\" & att.Source
206             
207             'Messagebox(filepath$)
208             Call att.ExtractFile(filepath$)
209                 'Print filepath$ & " extracted"
210         Loop While rtnav.FindNextElement()
211         
212     End If
213 End Sub

 

参考资料:

IBM Lotus Domino Server首次配置详解 http://net.zol.com.cn/103/1032259.html

IBM Lotus Domino 邮件服务器配置攻略 http://net.zol.com.cn/105/1052918.html

LotusScript基本语法及举例分析 http://news.ccidnet.com/art/32855/20100709/2110929_1.html

LotusScript语言的基本知识 http://wnight88.blog.51cto.com/512204/140459

在 Lotus Notes 中设置邮件定时发送的方法及代理功能介绍 http://www.ibm.com/developerworks/cn/lotus/notes-timing/

 

附件

转载于:https://www.cnblogs.com/xw022/p/3392923.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值