Author:水如烟
1、重构各类
目的:明确传递参数或返回值的类型。
注意:还是有些类型为System.Object的参数或返回值是无法明确的,在代码中须要自动转换成已重构的类或原Domino类。
返回值自动转换成已重构的类,参数自动转换成原Domino类
示例:
Namespace LzmTW.Lotus Public Class NotesRichTextNavigator Inherits LzmTW.Lotus.IComClassBase(Of Domino.NotesRichTextNavigator) ''' ''' Returns the element at the current position. ''' ''' NotesEmbeddedObject, NotesRichTextDocLink, NotesRichTextSection, or NotesRichTextTable. The requested element. ''' This method does not change the current position. Public Function GetElement() As Object Return Me.GetObjectValuesFromCom(Me.com.GetElement()) 'EditObject End Function End Class End Namespace Namespace LzmTW.Lotus _ Public Class NotesDocument Inherits LzmTW.Lotus.IComClassBase(Of Domino.NotesDocument) ''' ''' Creates a new item in a document and sets the item value. ''' ''' String. The name of the new item. ''' The value of the new item. The data type of the new item depends upon the data type of the value that you place in it. ''' Data type of value// Resulting NotesItem ''' String// Text item containing the value ''' Array of String// Text item containing each element of the value ''' Long, Integer, Double, Single, or Currency// Number item containing the value ''' Array of Long, Integer, Double, Single, or Currency Number// item containing each element of the value ''' Variant of type DATE or NotesDateTime// Date-time item containing the value ''' Array of Variant of type DATE or array of NotesDateTime// Date-time item containing each element of the value ''' NotesItem// Item whose data type matches the NotesItem type and whose value(s) match the NotesItem value(s) ''' Type conversion occurs as necessary. For example, floating-point numeric items are double precision so a value of type Single is converted to Double prior to storage. ''' A NotesItem. The new item. ''' Public Function AppendItemValue(ByVal pName As String, ByVal Value As Object()) As NotesItem Return New NotesItem(Me.com.AppendItemValue(pName, Me.GetComValuesFromObject(Value))) 'EditObject End Function End Class End Namespace
2、获取数据库基本信息
一般是利用NotesSession.GetDatabase(String server, String db)来获取数据库
只是,有些数据库是不能打开的(无权限),用此方法,返回的将是Nothing。
利用NotesDbDirectory遍历所有数据库,在不打开数据库的情形下,可以取到数据库的基本信息。如:
Private Sub TestOpenDataBase Dim dbDirectory As NotesDbDirectory dbDirectory = session.GetDbDirectory(session.Environment.Server) dbDirectory.ForEachDatabase(AddressOf Action) End Sub Private Sub Action(ByVal db As NotesDatabase) If db.FilePath = "reports.nsf" Then Console.WriteLine("{0,-12}{1,-7}{2,-30}{3,-20}{4}", db.FilePath, db.TryOpen, db.DesignTemplateName, db.ReplicaID, db.Title) End If End Sub
通过dbDirectory.OpenMailDatabase()可以获取当前登录用户的邮箱。
3、Domino分层索引做法分析
以帮助文档Lotus Domino Designer 7 Help为例,它的数据库为help7_designer.nsf。索引视图为IndexWeb。
视图输出有两列,第一列为索引组,第二列为关键词。
如关键词“Formula fields”,它的索引组有9个索引项:
$/$HLFormula field
$/$fields/$HLFormula
F/Fields, types of/formula fields
F/Formula fields/described
F/Formula fields/programming
F/Formulas/literalizing
H/Headlines database/described
S/Subscription documents/storing
S/Subscriptions/described
每一索引项是以“/”分隔的层次(树形)结构,在界面上,除顶项(如第一项的“$”) 不显示过,其它逐级显示,最后一项总是关键词“Formula fields”。
IndexWeb一共有5801项记录,但有些是重复的。