1

我想以编程方式将表格从一个 NSF 复制到另一个 NSF。我知道 NotesDocument 类具有 CopyToDatabase 方法,而 NotesDatabase 类具有 CreateView 方法。

但是,我还没有找到任何可以让我向 NSF 添加表单的内容。

我正在使用 Lotus Notes 8.5.2、COM 和 C#。

我可以毫无问题地检索有关表单的信息或删除它们,并且我有以下代码片段:

        //NotesConnectionDatabase and nd2 are objects of type NotesDatabase and are 
        //members of the same session.

        //Write the name of each form to the console.
        //Delete each form from the database.
        for (int i = 0; i <= (((object[])NotesConnectionDatabase.Forms)).Length - 1; i++)
        {
            Console.WriteLine(((NotesForm)((object[])NotesConnectionDatabase.Forms)[i]).Name);
            ((NotesForm)((object[])NotesConnectionDatabase.Forms)[i]).Remove();
        }

        //For each form in nd2, copy the form to NotesConnectionDatabase.
        for (int j = 0; j <= (((object[])nd2.Forms)).Length - 1; j++)
        {
            //I am aware that there is no such method as NotesForm.CopyToDatabase
            ((NotesForm)((object[])nd2.Forms)[j]).CopyToDatabase(NotesConnectionDatabase);              
        }
4

2 回答 2

2

使用NotesNoteCollection该类,您可以获得表单的集合。该SelectForms属性应设置为TRUE,其余应设置为FALSE

构建完成后NotesNoteCollection,它将包含一组可以像这样访问的表单(文档):

nid = nc.GetFirstNoteId
  For i = 1 To nc.Count
    Set doc = db.GetDocumentByID(nid)
    nid = nc.GetNextNoteId(nid)id
  Next

可以用CopyToDatabase方法复制文件

于 2011-07-16T08:55:39.743 回答
0

对于 C# 用户...

        //NotesConnectionDatabase is of type NotesDatabase.

        //A NotesNoteCollection represents a collection of Domino design 
        //and data elements in a database.
        NotesNoteCollection nnc;
        nnc = NotesConnectionDatabase.CreateNoteCollection(false);
        //All the different types of elements default to false.
        //Set SelectForms = true to add forms to the collection.
        nnc.SelectForms = true;
        nnc.BuildCollection();

        //...

        string nid = nnc.GetFirstNoteId();
        for (int i = 1; i <= nnc.Count; i++)
        {
              NotesDocument doc = NotesConnectionDatabase.GetDocumentByID(nid);
              doc.CopyToDatabase(ndDestination);
              Console.WriteLine(nid + " copied");
              swCopyForms.WriteLine(nid + " copied");
              nid = nnc.GetNextNoteId(nid);
        }
于 2011-07-18T23:44:18.233 回答