延續昨天的介紹今天我們來看看可以列出所有Notes資料庫名稱的程式是怎撰寫達到的.
小小的範例如主題.
Step01:執行該範例程式
Step02:輸出結果
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Domino;
using System.Diagnostics; // Debug
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ListDBTitle();
}
public static string[] ListDBTitle()
{
NotesSession session = new NotesSession();
session.Initialize("");
Domino.NotesDatabase database;
database = session.GetDatabase("hub/wwcorp", "catalog.nsf", false);
string SearchFormula = string.Concat("Form = \"Notefile\""
, " & Server = \"CN=hub/O=wwcorp\"");
NotesDocumentCollection collection = database.Search(SearchFormula, null, 0);
NotesDocument document = collection.GetFirstDocument();
string[] ticketList = new string[collection.Count];
for (int i = 0; i < collection.Count; ++i)
{
ticketList[i] = ((object[])(document.GetItemValue("Title")))[0].ToString();
document = collection.GetNextDocument(document);
Debug.WriteLine(ticketList[i]);
}
document = null;
collection = null;
database = null;
session = null;
return ticketList;
}
}
}