2011-07-15 2 views
1

あるNSFから別のNSFにプログラムでフォームをコピーしたいと思います。私は、NotesDocumentクラスにはCopyToDatabaseメソッドがあり、NotesDatabaseクラスにはCreateViewメソッドがあることを認識しています。Lotus Notes - プログラムでフォームを追加する - NotesForm

しかし、NSFにフォームを追加することはできません。

私はLotus Notes 8.5.2、COM、およびC#を使用しています。

私は問題の形式についての情報を取得するか、それらを削除していない、と私は、次のコードスニペットを持っている:

NotesNoteCollectionクラスを使用して
 //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);    
     } 

答えて

2

あなたがフォームのコレクションを取得することができます。 SelectFormsプロパティはTRUEに設定し、残りはFALSEに設定する必要があります。文書はCopyToDatabaseメソッドのC#ユーザーの場合

+0

ありがとう、ジャスパー、私はあなたの技術が動作することを確認します。 –

0

でコピーすることができます

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

:それはこのようにアクセスすることができ、フォームのコレクション(文書)が含まれますNotesNoteCollectionを構築した後

。 ..

 //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); 
     } 
関連する問題