在c#中确定notes代理'

本文关键字:代理 notes | 更新日期: 2023-09-27 18:15:18

我想从c#程序中获得所有代理及其时间表的列表。

到目前为止,我已经列举了我要寻找的代理。不幸的是,COM对象似乎并没有暴露我所追求的:

var Session = new NotesSession();
Session.Initialize();
var Servers = new[] { "westerham01/Aqualisa", "westerham02/Aqualisa" };
foreach (var Server in Servers)
{
    var DbDirectory = Session.GetDbDirectory(Server);
    foreach (var Database in GetFromFirstNext<NotesDatabase>(() => { return DbDirectory.GetFirstDatabase(Domino.DB_TYPES.NOTES_DATABASE); },
                                                            DbDirectory.GetNextDatabase))
    {
        Database.Open();
        if (Database.Agents != null)
        {
            foreach (NotesAgent agent in Database.Agents)
            {
                if (agent.IsEnabled && agent.Trigger == AG_TRIGGER.TRIGGER_SCHEDULED)
                {
                    //?????
                }
            }
        }
    }
}

我已经设法在笔记中做到这一点,尽管我发现代码所以不太理解它是如何工作的:

Type AssistInfo
    Version As Integer
    TriggerType As Integer  ' 0 none, 1 schedule, 2 new mail, 3 paste, 4 manual, 5 update, 6 router
    SearchType As Integer  ' 0 none, 1 all, 2 new, 3 new/mod, 4 selected, 5 view, 6 unread, 7 prompt, 8 UI
    IntervalType As Integer  ' 0 none, 1 minutes, 2 days, 3 weeks, 4 months
    Interval As Integer
    Time1 As Variant  ' Start time (ms since midnight)
    Time2 As Variant  ' Long (weekday or day of month) or end time (ms since midnight)
    StartTime As Variant  ' Time/Date
    EndTime As Variant  ' Time/Date
    Flags As Long  ' 1 hidden, 2 no weekends, 4 store highlights, 8 mail/paste, 16 choose server
    Spare(15) As Long
End Type
Type BlockID
    hPool As Long
    Block As Integer
End Type
Declare Function ConvertTIMEDATEToText Lib wAPIModule Alias "ConvertTIMEDATEToText" _
(  Byval zI As Long, Byval zT As Long, Byval T As Long, Byval S As String, Byval nS As Integer, nT As Integer) As Integer
Declare Function ConvertTextToTIMEDATE Lib wAPIModule Alias "ConvertTextToTIMEDATE" _
(  Byval zI As Long, Byval zT As Long, pS As Long, Byval nS As Integer, Byval T As Long) As Integer
Declare Private Function NIFFindDesignNote Lib wAPIModule Alias "NIFFindDesignNote" _
(  Byval hDB As Long, Byval S As String, Byval C As Integer, N As Long) As Integer
Declare Private Function NSFDbOpen Lib wAPIModule Alias "NSFDbOpen" _
(  Byval PathName As String, DbHandle As Long) As Integer
Declare Private Function NSFDbClose Lib wAPIModule Alias "NSFDbClose" _
(  Byval DbHandle As Long) As Integer
Declare Private Function NSFNoteOpen Lib wAPIModule Alias "NSFNoteOpen" _
(  Byval hDB As Long, Byval NoteID As Long, Byval F As Integer, hNT As Long) As Integer
Declare Private Function NSFNoteClose Lib wAPIModule Alias "NSFNoteClose" _
(  Byval hNT As Long) As Integer
Declare Function NSFItemInfo Lib wAPIModule Alias "NSFItemInfo" _
(  Byval hNT As Long, Byval N As String, Byval nN As Integer _
,  iB As BlockID, D As Integer, vB As BlockID, nV As Long) As Integer
Declare Private Function NSFNoteUpdate Lib wAPIModule Alias "NSFNoteUpdate" _
(  Byval hNT As Long, Byval F As Integer) As Integer
Declare Function NSFItemDelete Lib wAPIModule Alias "NSFItemDelete" _
(  Byval hNT As Long, Byval N As String, Byval nN As Integer) As Integer
Declare Private Function OSMemAlloc Lib wAPIModule Alias "OSMemAlloc" _
(  Byval T As Integer, Byval N As Long, hM As Long) As Long
Declare Private Function OSMemFree Lib wAPIModule Alias "OSMemFree" _
(  Byval hM As Long) As Long
Declare Private Function OSLockObject Lib wAPIModule Alias "OSLockObject" _
(  Byval H As Long) As Long
Declare Private Sub OSUnlockObject Lib wAPIModule Alias "OSUnlockObject" _
(  Byval H As Long)
Declare Private Function OSPathNetConstruct Lib wAPIModule Alias "OSPathNetConstruct" _
(  Byval NullPort As Long, Byval Server As String, Byval FIle As String, Byval PathNet As String) As Integer
Declare Private Sub Peek Lib "MSVCRT" Alias "memcpy" _
(  D As Any, Byval P As Long, Byval N As Long)
Declare Private Sub Poke Lib "MSVCRT" Alias "memcpy" _
(  Byval D As Long, D As Any, Byval N As Long)
Declare Private Sub PokeString Lib "MSVCRT" Alias "memcpy" _
(  Byval D As Long, Byval S As String, Byval N As Long)
Sub GetAssistInfo(db As NotesDatabase, agent As String, info As AssistInfo)
    Dim np$
    Dim nt%
    Dim t$
    Dim pt&
    Dim p&
    Dim nv&
    Dim ti$
    Dim dt%
    Dim v&
    np$ = Space(1024)
    OSPathNetConstruct 0, db.Server, db.FilePath, np$
'   Dim nc As NotesNoteCollection
'   Set nc = db.CreateNoteCollection(False)
'   nc.SelectAgents = True
'   Call nc.BuildCollection()
'   Dim nid As String
'   nid = nc.GetFirstNoteId()
'   For i = 1 To Count
'       
'   Next
    Dim hDB As Long
    NSFDbOpen np$, hDB
    If hDB = 0 Then
        Messagebox "Can't open database", 16
        Exit Sub
    End If
    pt& = Instr(agent, "|")
    If pt& = 0 Then ti$ = Trim$(agent) Else ti$ = Trim$(Left$(agent, pt& - 1))
    Dim nID As Long
    NIFFindDesignNote hDB, ti$, NOTE_CLASS_FILTER, nID
    If nID = 0 Then
        'Messagebox "Can't find agent " & ti$, 16
        Exit Sub
    End If
    If Instr(db.GetDocumentByID(Hex$(nID)).~$Flags(0), "f") = 0 Then
        Messagebox ti$ & " is not an agent", 16
        Exit Sub
    End If
    Dim hNT As Long
    NSFNoteOpen hDB, nID, 0, hNT
    Dim iB As BlockID, vB As BlockID
    NSFItemInfo hNT&, "$AssistInfo", 11, iB, dt%, vB, nv&
    If Not vB.hPool = 0 Then
        p& = OSLockObject(vB.hPool) + vB.Block
        Peek info.Version, p& + 2, 2
        Peek info.TriggerType, p& + 4, 2
        Peek info.SearchType, p& + 6, 2
        Peek info.IntervalType, p& + 8, 2
        Peek info.Interval, p& + 10, 2
        Peek v&, p& + 12, 4
        If v& <= 31 Then info.Time1 = v& Else info.Time1 = Cdat(v&/100/60/60/24)
        Peek v&, p& + 16, 4
        If v& <= 31 Then info.Time2 = v& Else info.Time2 = Cdat(v&/100/60/60/24)
        t$ = Space(81)
        ConvertTIMEDATEToText 0, 0, p& + 20, t$, 80, nt%
        If Not nt% = 0 Then info.StartTime = Cdat(Left$(t$, nt%))
        t$ = Space(81)
        ConvertTIMEDATEToText 0, 0, p& + 28, t$, 80, nt%
        If Not nt% = 0 Then info.EndTime = Cdat(Left$(t$, nt%))
        Peek info.Flags, p& + 36, 4
        OSUnlockObject vB.hPool
    End If
    NSFNoteClose hNT
    NSFDbClose hDB
End Sub

下面的代码可以翻译成c#吗?有没有其他方法可以查看探员的日程安排?

在c#中确定notes代理'

您正在查看的LotusScript代码正在调用Notes C API。c#绝对可以调用C例程,所以代码是可以翻译的。实际上,这里有一篇文章的链接,该文章展示了如何从c#调用Notes C API。