Lotus notes 获取并排序数据库中的所有视图

Lotus notes 获取并排序数据库中的所有视图,lotus-notes,lotusscript,Lotus Notes,Lotusscript,我有一些代码可以获取数据库中所有视图和文件夹的列表。问题是一切都组织得很糟糕。视图列表显示为几乎随机的,尽管我假设有一些顺序 是否有方法获取对话框提示上显示的所有视图的列表,然后按字母顺序对列表进行排序 Sub Initialize Dim s As New NotesSession Dim w As New NotesUIWorkspace Dim dbSource As NotesDatabase, dbDest As NotesDatabase Dim source As NotesVie

我有一些代码可以获取数据库中所有视图和文件夹的列表。问题是一切都组织得很糟糕。视图列表显示为几乎随机的,尽管我假设有一些顺序

是否有方法获取对话框提示上显示的所有视图的列表,然后按字母顺序对列表进行排序

Sub Initialize
Dim s As New NotesSession
Dim w As New NotesUIWorkspace
Dim dbSource As NotesDatabase, dbDest As NotesDatabase
Dim source As NotesView, dest As NotesView
Dim vc As NotesViewEntryCollection
Dim docDest As NotesDocument
Dim ve As NotesViewEntry
Dim folders() As String
Dim i As Integer
Dim ret, rez

Set dbSource = s.CurrentDatabase

ForAll v In dbSource.Views
    If v.IsFolder Then
        i = i + 1
        ReDim Preserve folders( i - 1 ) As String
        folders( i - 1 ) = v.Name
    End If
End ForAll

ret = w.Prompt( PROMPT_OKCANCELLISTMULT, "Folder selection", "Select one or more folders to move.", folders(0), folders )
If IsEmpty( ret ) Then
    MessageBox "User canceled", , "Folder not selected"
    Exit Sub
Else


      rez = w.Prompt( 13, "Database selection", "Choose the database to move the folder to" )


      ForAll f In ret  


        Set source = dbSource.GetView( f )
        Set vc = source.AllEntries





          Set dbDest = s.GetDatabase( rez(0), rez(1), False )
          Call dbDest.EnableFolder( f )

          Set ve = vc.GetFirstEntry
          Do Until ve Is Nothing
              Set docDest = ve.Document.CopyToDatabase( dbDest )
              Call docDest.PutInFolder( f )
              Set ve = vc.GetNextEntry( ve )
        Loop

        Call vc.RemoveAllFromFolder( f )
             Call source.Remove
         End ForAll
End If

End Sub

在将
文件夹
数组包含在提示方法中之前,可以添加此子例程对其进行排序

只需使用w.Prompt()在行前面调用
ShellSort(folders)

子外壳排序(ar()作为字符串)
变暗为整数
将上限设置为整数
Dim botMax作为整数
作为整数的Dim i
将k变为整数
作为整数的Dim h
将v作为字符串
较低%=磅(ar$())
上限%=Ubound(应收账款$())
h%=1
做
h%=(3*h%)+1
循环直到h%>上限%-下限%+1
做
h%=h%\3
botMax%=较低的%+h%-1
对于i%=botMax%+1至上限%
v$=ar$(i%)
k%=i%
而ar$(k%-h%)>v$
ar$(k%)=ar$(k%-h%)
k%=k%-h%

如果(k%,您可以在求值调用中使用
@Sort
,对文件夹名称进行排序

Dim folders作为字符串列出
变暗文件夹作为变量
...
对于dbSource.Views中的所有v
如果v.IsFolder那么
foldersList=foldersList++:“|+替换(替换(v.Name,| \ |,| \ |,| \ |),|“,| \”+|”|
如果结束
端孔
如果文件夹列表为“”,则
文件夹=求值(|@Sort(|+StrRight(foldersList,“:”)+|)
...
上面的代码是这样工作的:

首先,将字符串中的所有文件夹名称收集为公式列表,如

"xyz":"abc":"mno":"def"
确保文件夹名称中的引号替换为
\”
,子文件夹的反斜杠替换为
\

其次,使用
@Sort(“xyz”:“abc”:“mno”:“def”)
计算公式

结果是一个排序变量字符串数组,您可以像前面一样在
w.Prompt(…,…,folders(0),folders)
中使用


此解决方案的优点是代码非常短,而且速度也很快。

如果使用列表而不是数组,则值将自动按排序顺序排列。例如

Dim folders List As Boolean
ForAll v In dbSource.Views
  If (v.IsFolder) Then folders(v.Name) = True 
End ForAll

非常好。谢谢你的帮助!谢谢你的回答。我可以试着比较一下这个和“纯”的性能“ls-way。性能可能不是重点,因为您可能不会有数百或数千个文件夹。我添加了更多这种方法,因为它是使用Lotus Notes中现有排序功能的一种简单方法。列表项不会自动排序,而是按创建顺序存储的…”。。。
Dim folders List As Boolean
ForAll v In dbSource.Views
  If (v.IsFolder) Then folders(v.Name) = True 
End ForAll