基本的に、このデータが記述したデータ モデルにリンクされる方法は 2 つあります。データが応答ドキュメント階層を介してリンクされている場合、キー ベースのドキュメント構造とは少し異なります。
これを開発者に見せれば、開発者は文字通りコードをプラグインして、あなたが話している「出席者の移動」要件を有効にすることができるはずです。
注意すべき点がいくつかあります。
- 操作する必要があるすべてのデータが 1 つのデータベースにあると想定しています。
- 私はあなたが提供したあなたの図を文字通り取っています。
キー ベースのドキュメント構造については、出席者ドキュメントの検索に使用されるビューとキー値を確認する必要があります。具体的には、「MoveAttendeesKeyBased」サブの次の 2 行を確認してください。
Set vwAttendeesByCourseID = db.GetView("(LkupAllAttendeesByCourseID)")
dcAttendees = vwAttendeesbyCourseID.GetAllDocumentsByKey(docCourseFrom.CourseID(0), True) を設定します。
このコードは、"CourseID"、"Status" と呼ばれるフィールド、および移動する出席者のステータス値の "Wait Listed" の値を調べるように設計されています。
この関数の両方のバージョンを記述するのに約 20 分かかりました。
応答ベースのドキュメント構造の場合
Sub MoveAttendeesResponseBased(docCourseFrom As notesDocument, docCourseTo As NotesDocument)
%REM
A simple move attendees function if the relationship between courses and attendees is based on
response document hierarchies
%END REM
On Error Goto errHandle
Dim dcAttendees As notesDocumentCollection
Dim docAttendee As notesDocument
Dim iAvailablePlaces As Integer
Dim bMoved As Boolean
If Not (docCourseFrom Is Nothing Or docCourseTo Is Nothing) Then
iAvailablePlaces = docCourseTo.availablePlaces(0)
If 0 < iAvailablePlaces Then
bMoved = False
Set dcAttendees = docCourseFrom.Responses
Set docAttendee = dcAttendees.GetFirstDocument
While Not docAttendee Is Nothing And 0 < iAvailablePlaces
If Ucase(Trim(docAttendee.Status(0)))= "WAIT LISTED" Then
Call docAttendee.MakeResponse(docCourseTo)
If docAttendee.Save(True,True) Then
iAvailablePlaces = iAvailablePlaces - 1
bMoved = True
End If
End If
Set docAttendee = dcAttendees.GetNextDocument(docAttendee)
Wend
If bMoved Then
docCourseTo.availablePlaces = iAvailablePlaces
Call docCourseTo.Save(True,False)
End If
End If
End If
Exit Sub
errHandle:
Messagebox Lsi_info(2) + " - " + Str(Err) + " : " + Error(Err) + ", at line " + Str(Erl)
Exit Sub
End Sub
キーベースのドキュメント構造の場合
Sub MoveAttendeesKeyBased(docCourseFrom As notesDocument, docCourseTo As notesDocument)
%REM
A simple move attendees function if the relationship between courses and attendees uses
(non-response) key based documents
%END REM
On Error Goto errHandle
Dim session As New notesSession
Dim dcAttendees As notesDocumentCollection
Dim docAttendee As notesDocument
Dim iAvailablePlaces As Integer
Dim bMoved As Boolean
' a view that lists attendees by Course ID
Dim vwAttendeesByCourseID As notesView
Dim db As notesDatabase
If Not (docCourseFrom Is Nothing Or docCourseTo Is Nothing) Then
iAvailablePlaces = docCourseTo.availablePlaces(0)
If 0 < iAvailablePlaces Then
Set db = session.CurrentDatabase
' do a lookup of all attendees based on the CourseFrom document course id
Set vwAttendeesByCourseID = db.GetView("(LkupAllAttendeesByCourseID)")
' this is the collection of all attendees under the CourseFrom document
Set dcAttendees = vwAttendeesbyCourseID.GetAllDocumentsByKey(docCourseFrom.CourseID(0), True)
bMoved = False
Set docAttendee = dcAttendees.GetFirstDocument
' While there are attendee documents to process and there are available places to goto
While Not docAttendee Is Nothing And 0 < iAvailablePlaces
' if the attendee's status is "Wait Listed" then move them
If Ucase(Trim(docAttendee.Status(0)))= "WAIT LISTED" Then
' Update the course ID for the Attendee
docAttendee.CourseID = docCourseTo.CourseID(0)
If docAttendee.Save(True,True) Then
' decrement the available places
iAvailablePlaces = iAvailablePlaces - 1
bMoved = True
End If
End If
Set docAttendee = dcAttendees.GetNextDocument(docAttendee)
Wend
If bMoved Then
' available places may be >= 0. Just update the available places so you don't over book the course
docCourseTo.availablePlaces = iAvailablePlaces
Call docCourseTo.Save(True,False)
End If
End If
End If
Exit Sub
errHandle:
Messagebox Lsi_info(2) + " - " + Str(Err) + " : " + Error(Err) + ", at line " + Str(Erl)
Exit Sub
End Sub
キーベースのドキュメントは少し手間がかかりますが、データベース内のドキュメントを簡単に移動したり、バックアップから復元したり、コピーして貼り付けたりできるため、より良い構造だと思います. 応答文書では、バックアップの復元に問題が発生する可能性があります。これは、応答文書が親文書の UNID を使用して自分自身を関連付けるためです。また、誤って出席者を移動した場合、元のコース情報がないと、出席者をどのコースに戻すかを知ることができません。 、したがって、ドキュメントのキーベースの構造に戻ります(ただし、それは私の意見です).....