是否有可能确定Lotus Notes代理上次从C#运行多长时间?

时间:2014-08-01 07:35:35

标签: c# lotus-notes lotus-domino

我成功地使用托管Lotus Nodes包装器与C#中的Lotus Notes C API一起使用,以获取有关所有数据库中所有代理的调度信息。

我现在想要的是获取有关这些代理的运行时间的信息。我认为它必须在某个地方的API中,但我看过这里http://www-12.lotus.com/ldd/doc/domino_notes/8.5.3/api853ref.nsf并找不到任何东西。

另一种方法是查看任何日志文件中是否有任何指示开始/停止时间的内容,但我真的不知道在哪里查看。 log.nsf中似乎没有任何内容。

3 个答案:

答案 0 :(得分:2)

如果您查看代理日志,那么您将看到如下内容:

  

于08/01/2014 03:55:51 PM开始运行座席'YourAgentName'   Ran LotusScript代码
  在08/01/2014 03:56:23 PM

完成正在运行的代理'YourAgentName'

因此,如果您可以获得这两次,那么您可以确定莲花注释代理上次运行的时间。从最后一行日志开始,您只需从NotesAgent.LastRun属性获取。从第一行日志开始的时间只能通过解析日志本身来获得。您可以使用$AssistRunInfo代理注释项来获取代理日志。可以使用C API访问此项的值 您可以从«IBM C and C++ API Toolkits for Notes® and Domino®»获取C API样本。如果您查看«samples \ dbdesign \ agents \ ragents.c»文件,那么您可以找到GetAgentRunInfo函数。
这是它的代码:

/************************************************************************

    FUNCTION:   GetAgentRunInfo (DBHANDLE hDb, char *szAgentName)

    PURPOSE:    Read the agent run data ($AssistRunInfo item) of an 
                executed agent note.

                This routine sequentially reads the CD records associated
                with the run data objects created by Domino and Notes and 
                attached to the $AssistRunInfo item.  

                First, the number of object entries are determined by 
                reading the ODS_ASSISTRUNOBJECTHEADER record.  Next, the size
                of each object entry is determined by reading the sequence
                of ODS_ASSISTRUNOBJECTENTRY records, and used to determine
                which object has data.  Finally, if the ODS_ASSISTRUNINFO 
                record (entry 1) and the execution log entry (entry 3) have
                data, they read and/or displayed as appropriate.  

                Note that any other object entries are reserved by Domino 
                and Notes and not read.

    INPUTS:     DBHANDLE    hDb             - handle to the open database
                char        *szAgentName    - agent name ($TITLE)

*************************************************************************/
STATUS  LNPUBLIC  GetAgentRunInfo( DBHANDLE hDb, char *szAgentName )
{
    STATUS          error = NOERROR;
    NOTEID                      AgentId;        
    NOTEHANDLE      hAgentNote;

/* $AssistRunInfo run data object variables */
    OBJECT_DESCRIPTOR           objRunInfo;
    BLOCKID                     bidRunInfo;
    WORD                        wDataType;
    DWORD                       dwItemSize;
    char                       *pObject;
    DWORD                       dwObjectSize;
    WORD                        wClass;
    WORD                        wPrivs;
    WORD                        wCounter;
    DHANDLE                       hBuffer;
    DWORD                       dwOffset;
    ODS_ASSISTRUNOBJECTHEADER   RunHeader;
    ODS_ASSISTRUNOBJECTENTRY    RunEntry[5];
    ODS_ASSISTRUNINFO           RunInfo;
    char                        RunTime[MAXALPHATIMEDATE+1];
    WORD                        wLength;

/* Given the handle of the database and the Agent name,
 * find the Note ID for the Agent.
 */
    if (error = NIFFindDesignNote (hDb, szAgentName,
                                   NOTE_CLASS_FILTER, &AgentId))
    {
        if (error = NIFFindPrivateDesignNote (hDb, szAgentName, NOTE_CLASS_FILTER, &AgentId))
            goto Exit0; 
    }

/* Now report the results of the agent execution stored in the 
   $AssistRunInfo object item of the Agent note */ 
    if (error = NSFNoteOpen (hDb, AgentId, (WORD) 0, &hAgentNote))
        goto Exit0;

    if (error = NSFItemInfo(hAgentNote, ASSIST_RUNINFO_ITEM, 
                        (WORD) strlen (ASSIST_RUNINFO_ITEM),
                        NULL, &wDataType, &bidRunInfo, &dwItemSize))
        goto Exit1;

/* assign pointer to item, and skip over TYPE_OBJECT word */
    pObject = OSLockBlock(char, bidRunInfo);
    pObject += ODSLength(_WORD);

/* Read in the OBJECT_DESCRIPTOR ODS record and ensure that there are 
data objects */
    ODSReadMemory( &pObject, _OBJECT_DESCRIPTOR, &objRunInfo, 1 );
    OSUnlockBlock(bidRunInfo);
    if (error = NSFDbGetObjectSize (hDb, objRunInfo.RRV, objRunInfo.ObjectType,
                                        &dwObjectSize, &wClass, &wPrivs ))
        goto Exit1;

    if (dwObjectSize == 0)
    {
        fprintf(pAgentsLog, "Invalid run data object item\n\n");
        goto Exit1;
    }

/* 
 * Sequentially read in the header, entries, and related run information objects
 * that are created during an agent execution.
 */
    dwOffset = 0;

/* 
 * ODS_ASSISTRUNOBJECTHEADER - contains the number of run data object entries. 
 * By default, there are at least 5 objects reserved for run data.  Of 
 * importance, the first of these always contains the RunInfo data.   The 
 * third of these always contains an agent execution log.  
 */
    if (error = NSFDbReadObject(hDb, objRunInfo.RRV, dwOffset, 
                        ODSLength(_ODS_ASSISTRUNOBJECTHEADER), &hBuffer))
        goto Exit1;
    pObject = OSLock (char, hBuffer);
    ODSReadMemory( &pObject, _ODS_ASSISTRUNOBJECTHEADER, &RunHeader, 1 );
    OSUnlock(hBuffer);
    OSMemFree(hBuffer);
    if (RunHeader.wEntries == 0)
    {
        fprintf(pAgentsLog, "No run data entries to report; Agent never executed\n\n");
        goto Exit1;
    }
    dwOffset += ODSLength(_ODS_ASSISTRUNOBJECTHEADER);

/* 
 * ODS_ASSISTRUNOBJECTENTRY - determines which entry has run data.
 * If the entry length of both the run info data and log objects are greater 
 * than zero, than the agent has been executed at least once and run data 
 * exists.  */

    if (error = NSFDbReadObject(hDb,objRunInfo.RRV, dwOffset, 
                    ODSLength(_ODS_ASSISTRUNOBJECTENTRY)*RunHeader.wEntries, &hBuffer))
        goto Exit1;
    pObject = OSLock (char, hBuffer);

/* read the first entry and make sure that a RunInfo data object exists. */
    ODSReadMemory( &pObject, _ODS_ASSISTRUNOBJECTENTRY, &RunEntry[0], 1 );
    if (RunEntry[0].dwLength == 0)
    {
        fprintf(pAgentsLog, "No run information data to report; Agent never executed\n\n");
        goto Exit1;
    }
    fprintf(pAgentsLog, "Agent Run Information:\n");

/* read the third entry and make sure that an execution log object exists.
 * Note - we check this only because the Notes UI creates an empty RunInfo 
 * data object when an agent is executed, but only creates the log object 
 * if executed. 
 */
    ODSReadMemory( &pObject, _ODS_ASSISTRUNOBJECTENTRY, &RunEntry[1], 1 );
    ODSReadMemory( &pObject, _ODS_ASSISTRUNOBJECTENTRY, &RunEntry[2], 1 );
    if (RunEntry[2].dwLength == 0)
    {
        fprintf(pAgentsLog, "Agent log does not exist; Never executed\n\n");
        goto Exit1;
    }

/* and skip over the remaining reserved run data objects */
    for (wCounter = 3; wCounter < RunHeader.wEntries; wCounter++)
        ODSReadMemory( &pObject, _ODS_ASSISTRUNOBJECTENTRY, &RunEntry[wCounter], 1 );

    dwOffset += ODSLength(_ODS_ASSISTRUNOBJECTENTRY)*RunHeader.wEntries;
    OSUnlockObject(hBuffer);
    OSMemFree(hBuffer);

/* 
 * ODS_ASSISTRUNINFO - contain the Run Information.
 * It is always the first run data object. 
 */
    if (error = NSFDbReadObject(hDb, objRunInfo.RRV, dwOffset, 
                      ODSLength(_ODS_ASSISTRUNINFO), &hBuffer))
        goto Exit1;
    pObject = OSLock (char, hBuffer);
    ODSReadMemory( &pObject, _ODS_ASSISTRUNINFO, &RunInfo, 1 );
    OSUnlock(hBuffer);
    OSMemFree(hBuffer);
    (void) ConvertTIMEDATEToText (NULL, NULL, &RunInfo.LastRun, RunTime, 
                                        MAXALPHATIMEDATE, &wLength);
    RunTime[wLength] = '\0'; 
    fprintf(pAgentsLog, "TimeDate of Execution: %s\n", RunTime);
    fprintf(pAgentsLog, "Documents Processed By Formula: %ld\n", RunInfo.dwProcessed);
    fprintf(pAgentsLog, "Exit Code: %ld\n\n", RunInfo.dwExitCode);

/* skip the next one, display the execution log, and dump the rest */
    dwOffset += RunEntry[0].dwLength;
    for (wCounter = 1;wCounter < RunHeader.wEntries; wCounter++)
    {
        if (RunEntry[wCounter].dwLength != 0)
        {
            if (error = NSFDbReadObject(hDb, objRunInfo.RRV, dwOffset, 
                             RunEntry[wCounter].dwLength, &hBuffer))
                goto Exit1;
            pObject = OSLock (char, hBuffer);
            if (wCounter == 2)
            {
                pObject[RunEntry[wCounter].dwLength]='\0';
                fprintf(pAgentsLog, "Agent Log <Start>:\n%s", pObject);
                fprintf(pAgentsLog, "Agent Log <End>:\n");
            }
            dwOffset += RunEntry[wCounter].dwLength;
            OSUnlock(hBuffer);
            OSMemFree(hBuffer);
        }
    }

Exit1:
    NSFNoteClose (hAgentNote);

Exit0:
    return (error);
}

您可以将此代码迁移到c#程序中 以下是LotusScript的示例(在this的帮助下):

'Declarations
Type BLOCKID
    pool As Long
    block As Long
End Type

Type OBJECT_DESCRIPTOR
    ObjectType As Integer
    RRV As Long
End Type

Type ODS_ASSISTRUNOBJECTHEADER
    dwFlags As Long
    wEntries As Integer
    wSpare As Integer
End Type

Type ODS_ASSISTRUNOBJECTENTRY
    dwLength As Long
    dwFlags As Long
End Type

Type TIMEDATE
    Innards(0 To 1) As Long
End Type

Type ODS_ASSISTRUNINFO
    LastRun As TIMEDATE
    dwProcessed As Long
    AssistMod As TIMEDATE
    DbID As TIMEDATE
    dwExitCode As Long
    dwSpare(0 To 3) As Long
End Type

Declare Function OSPathNetConstruct Lib "nnotes.dll" (PortName As Any, Byval ServerName As String, Byval FileName As String, Byval retPathName As String) As Integer
Declare Function NSFDbOpen Lib "nnotes.dll" (Byval PathName As String, rethDB As Long) As Integer
Declare Function NSFDbClose Lib "nnotes.dll" (Byval hDB As Long) As Integer
Declare Function NIFFindDesignNote Lib "nnotes.dll" (Byval hFile As Long, Byval DesignName As String, Byval ClassKbn As Integer, retNoteID As Long) As Integer
Declare Function NIFFindPrivateDesignNote Lib "nnotes.dll" (Byval hFile As Long, Byval DesignName As String, Byval ClassKbn As Integer, retNoteID As Long) As Integer
Declare Function NSFNoteOpen Lib "nnotes.dll" (Byval db_handle As Long, Byval note_id As Long, Byval open_flags As Integer, note_handle As Long) As Integer
Declare Function NSFNoteClose Lib "nnotes.dll" (Byval note_handle As Long) As Integer
Declare Function OSTranslate Lib "nnotes.dll" (Byval TranslateMode As Integer, Byval InData As String, Byval InLength As Integer, Byval OutData As String, Byval OutLength As Integer) As Integer
Declare Function NSFItemInfo Lib "nnotes.dll" (Byval note_handle As Long, Byval item_name As String, Byval name_len As Integer, item_blockid As Any, value_datatype As Integer, value_blockid As BLOCKID, value_len As Long) As Integer
Declare Function OSLockObject Lib "nnotes.dll" (Byval Handle As Long) As Long
Declare Function OSUnlockObject Lib "nnotes.dll" ( Byval Handle As Long ) As Integer
Declare Function ODSLength Lib "nnotes.dll" (Byval ODStype As Integer) As Integer
Declare Function NSFDbReadObject Lib "nnotes.dll" (Byval hDB As Long, Byval ObjectID As Long, Byval Offset As Long, Byval Length As Long, rethBuffer As Long) As Integer
Declare Function OSMemFree Lib "nnotes.dll" (Byval Handle As Long) As Integer
Declare Function ConvertTIMEDATEToText Lib "nnotes.dll" (IntlFormat As Any, TextFormat As Any, InputTime As TIMEDATE, Byval retTextBuffer As String, Byval TextBufferLength As Integer, retTextLength As Integer) As Integer
Declare Function OSLoadString Lib "nnotes.dll" (Byval hModule As Long, Byval StringCode As Long, Byval retBuffer As String, Byval BufferLength As Integer) As Integer
Declare Function NSFDbGetObjectSize Lib "nnotes.dll" (Byval hDB As Long, Byval ObjectID As Long, Byval ObjectType As Integer, retSize As Long, retClass As Integer, retPrivileges As Integer) As Integer
Declare Function ODSReadMemory Lib "nnotes.dll" (ppSrc As Any, Byval iType As Integer, pDest As Any, Byval iterations As Integer) As Integer

Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, Byval Length As Long)
Declare Sub MoveMemoryToString Lib "kernel32" Alias "RtlMoveMemory" (Byval Destination As String, Source As Any, Byval Length As Long)

'Main procedure.
Sub ShowAgentLog

    Dim ses As New NotesSession
    Dim db As NotesDatabase
    Dim agent As NotesAgent
    Dim sLog As String

    Set db = ses.CurrentDatabase
    Set agent = db.GetAgent("YourAgentName")

    If agent Is Nothing Then
        Exit Sub
    End If

    sLog$ = GetAgentLog(agent)

    If sLog$ = "" Then
        Exit Sub
    End If

    sLog$ = Strleft(sLog$, Chr(13))
    sLog$ = Strright(sLog$, "on ")

    Dim startDateTime As Variant
    Dim endDateTime As Variant
    Dim betweenTime As Variant

    startDateTime = Cdat(sLog$)
    endDateTime =agent.LastRun  
    betweenTime = Cdat(endDateTime - startDateTime)

    Messagebox "Started: " & startDateTime & Chr(13) & Chr(10) & "Done: " & endDateTime & Chr(13) & Chr(10) & "Between: " & betweenTime

End Sub

Function GetAgentLog(agent As NotesAgent) As String

    Dim db As NotesDatabase

    Set db = agent.Parent

    Dim fullPathName As String

    Const MAXPATH = 256

    fullPathName$ = Space$(MAXPATH)
    Call OSPathNetConstruct(Byval h0&, db.Server, db.FilePath, fullPathName$)

    Dim dbHandle As Long    
    Dim errorCode As Integer

    errorCode% = NSFDbOpen(toLMBCS(fullPathName$), dbHandle&)

    If errorCode% = 0 Then
        GetAgentLog$ = GetAgentRunInfoLog(dbHandle&, toLMBCS(agent.Name))
    Else
        Msgbox getErrorMessage(errorCode%)
    End If

    If dbHandle& <> 0 Then
        Call NSFDbClose(dbHandle&)
    End If

End Function

Function GetAgentRunInfoLog(dbHandle As Long, agentName As String) As String

    Dim errorCode As Integer
    Dim agentID As Long 

'Given the handle of the database and the Agent name, find the Note ID for the Agent.   
    Const NOTE_CLASS_FILTER = &h0200

    errorCode% = NIFFindDesignNote(dbHandle&, agentName$, NOTE_CLASS_FILTER%, agentID&)

    If errorCode% <> 0 Then
        errorCode% = NIFFindPrivateDesignNote(dbHandle&, agentName$, NOTE_CLASS_FILTER%, agentID&)

        If errorCode% <> 0 Then
            Msgbox getErrorMessage(errorCode%)
            Exit Function
        End If
    End If

    Dim agentNote As Long

    errorCode% = NSFNoteOpen(dbHandle&, agentID&, 0, agentNote&)

    If errorCode% <> 0 Then
        Msgbox getErrorMessage(errorCode%)
        Exit Function
    End If

'Now report the results of the agent execution stored in the $AssistRunInfo object item of the Agent note
    GetAgentRunInfoLog$ = GetAssistRunInfoLog(dbHandle&, agentNote&)

    Call NSFNoteClose(agentNote&)

End Function

Function GetAssistRunInfoLog(dbHandle As Long, agentNote As Long) As String

    Dim errorCode As Integer
    Dim iDataType As Integer
    Dim runInfoID As BLOCKID
    Dim itemSize As Long
    Dim objectAddress As Long

    Const ASSIST_RUNINFO_ITEM = "$AssistRunInfo"
    errorCode% = NSFItemInfo(agentNote&, ASSIST_RUNINFO_ITEM$, Len(ASSIST_RUNINFO_ITEM$), Byval &h0, iDataType%, runInfoID, itemSize&)

    If errorCode%<> 0 Then
        Msgbox getErrorMessage(errorCode%)
        Exit Function
    End If

    objectAddress& = OSLockObject(runInfoID.pool&) + runInfoID.block&

    Const ODS_TYPE_WORD = 0

'assign pointer to item, and skip over TYPE_OBJECT word
    objectAddress& = objectAddress& + ODSLength(ODS_TYPE_WORD)

    Dim objRunInfo As OBJECT_DESCRIPTOR

'Read in the OBJECT_DESCRIPTOR ODS record and ensure that there are data objects
    objRunInfo.ObjectType% = ReadInteger(objectAddress&)
    objRunInfo.RRV& = ReadLong(objectAddress&)

    Call OSUnlockObject(runInfoID.pool&)

    Dim objectSize As Long
    Dim iClass As Integer
    Dim privs As Integer

    errorCode% = NSFDbGetObjectSize(dbHandle, objRunInfo.RRV&, objRunInfo.ObjectType%, objectSize&, iClass%, privs%)

    If errorCode% <> 0 Then
        Msgbox getErrorMessage(errorCode%)
        Exit Function
    End If

    If objectSize& = 0 Then
        Msgbox "Invalid run data object item"
        Exit Function
    End If

'Sequentially read in the header, entries, and related run information objects that are created during an agent execution

    Dim offset As Long
    Dim buffer As Long

%REM
ODS_ASSISTRUNOBJECTHEADER - contains the number of run data object entries. 
By default, there are at least 5 objects reserved for run data.
Of importance, the first of these always contains the RunInfo data.
The third of these always contains an agent execution log.
%END REM

    Const ODS_TYPE_ASSISTRUNOBJECTHEADER = 374
    errorCode% = NSFDbReadObject(dbHandle, objRunInfo.RRV&, offset&, ODSLength(ODS_TYPE_ASSISTRUNOBJECTHEADER), buffer&)

    If errorCode% <> 0 Then
        Msgbox getErrorMessage(errorCode%)
        Exit Function
    End If

    Dim runHeader As ODS_ASSISTRUNOBJECTHEADER

    objectAddress& = OSLockObject(buffer&)

    runHeader.dwFlags& = ReadLong(objectAddress&)
    runHeader.wEntries% = ReadInteger(objectAddress&)
    runHeader.wSpare% = ReadInteger(objectAddress&)

    Call OSUnlockObject(buffer&)
    Call OSMemFree(buffer&)

    If runHeader.wEntries = 0 Then
        Msgbox "No run data entries to report; Agent never executed"
        Exit Function
    End If

    offset& = offset& + ODSLength(ODS_TYPE_ASSISTRUNOBJECTHEADER)

%REM
ODS_ASSISTRUNOBJECTENTRY - determines which entry has run data.
If the entry length of both the run info data and log objects are greater than zero, than the agent has been executed at least once and run data exists.
%END REM

    Const ODS_TYPE_ASSISTRUNOBJECTENTRY = 375
    errorCode% = NSFDbReadObject(dbHandle&, objRunInfo.RRV&, offset&, ODSLength(ODS_TYPE_ASSISTRUNOBJECTENTRY) * RunHeader.wEntries%, buffer&)

    If errorCode% <> 0 Then
        Msgbox getErrorMessage(errorCode%)
        Exit Function
    End If

    objectAddress& = OSLockObject(buffer&)

    Dim runEntry() As ODS_ASSISTRUNOBJECTENTRY
    Redim runEntry(runHeader.wEntries - 1) As ODS_ASSISTRUNOBJECTENTRY

'read the first entry and make sure that a RunInfo data object exists.
    Call ReadEntry(runEntry(0), objectAddress&)
    If runEntry(0).dwLength& = 0 Then
        Msgbox "No run information data to report; Agent never executed"
        Exit Function
    End If

    Call ReadEntry(runEntry(1), objectAddress&)
    Call ReadEntry(runEntry(2), objectAddress&)
    If runEntry(2).dwLength& = 0 Then
        Msgbox "Agent log does not exist; Never executed"
        Exit Function
    End If

'and skip over the remaining reserved run data objects
    For counter% = 3 To runHeader.wEntries% - 1
        Call ReadEntry(runEntry(counter%), objectAddress&)
    Next

    offset& = offset& + ODSLength(ODS_TYPE_ASSISTRUNOBJECTENTRY) * runHeader.wEntries%
    Call OSUnlockObject(buffer&)
    Call OSMemFree(buffer&)

%REM 
ODS_ASSISTRUNINFO - contain the Run Information.
It is always the first run data object.
%END REM

    Dim runInfo As ODS_ASSISTRUNINFO

    Const ODS_TYPE_ASSISTRUNINFO = 326
    errorCode% = NSFDbReadObject(dbHandle&, objRunInfo.RRV&, offset&, ODSLength(ODS_TYPE_ASSISTRUNINFO), buffer&)
    If errorCode% <> 0 Then
        Msgbox getErrorMessage(errorCode%)
        Exit Function
    End If
    objectAddress& = OSLockObject(buffer&)

    Call ReadTIMEDATE(runInfo.LastRun, objectAddress&)
    runInfo.dwProcessed& = ReadLong(objectAddress&)
    Call ReadTIMEDATE(runInfo.AssistMod, objectAddress&)
    Call ReadTIMEDATE(runInfo.DbID, objectAddress&)
    runInfo.dwExitCode& = ReadLong(objectAddress&)

    For counter% = 0 To 3
        runInfo.dwSpare&(counter%) = ReadLong(objectAddress&)
    Next    

    Call OSUnlockObject(buffer&)
    Call OSMemFree(buffer&)

    Dim runTime As String
    Dim length As Integer
    Const MAXALPHATIMEDATE = 80

    runTime$ = String$(MAXALPHATIMEDATE + 1, Chr$(0))
    Call ConvertTIMEDATEToText(Byval &h0, Byval &h0, runInfo.LastRun, runTime$, MAXALPHATIMEDATE, length%)

    runTime$ = Left$(runTime$, Instr(runTime$, Chr$(0)) - 1)

    offset& = offset& + runEntry(0).dwLength
    For counter% = 1 To runHeader.wEntries - 1
        If runEntry(counter%).dwLength <> 0 Then
            errorCode% = NSFDbReadObject(dbHandle, objRunInfo.RRV, offset&, runEntry(counter%).dwLength, buffer&)

            If errorCode% <> 0 Then
                Msgbox getErrorMessage(errorCode%)
                Exit Function
            End If

            objectAddress& = OSLockObject(buffer&)

            If (counter% = 2) Then
                Dim sLog As String
                sLog$ = String$(runEntry(counter%).dwLength + 1, Chr$(0))
                Call MoveMemoryToString(sLog$, Byval objectAddress&, runEntry(counter%).dwLength)
                sLog$ = Left$(sLog$, Instr(sLog$, Chr$(0)) - 1)

                GetAssistRunInfoLog$ = toNATIVE(sLog$)
            End If

            offset& = offset& + runEntry(counter%).dwLength
            OSUnlockObject(buffer&)
            OSMemFree(hBuffer&)
        End If
    Next

End Function

Function toLMBCS(p_sInBuffer As String) As String

    Dim sOutBuffer As String

    sOutBuffer = Space$(Lenbp(p_sInBuffer) * 3 + 1)
    Const OS_TRANSLATE_NATIVE_TO_LMBCS = 0
    Call OSTranslate(OS_TRANSLATE_NATIVE_TO_LMBCS, p_sInBuffer, Lenbp(p_sInBuffer), sOutBuffer, Lenbp(sOutBuffer))

    toLMBCS = Left$(sOutBuffer, Instr(sOutBuffer, Chr$(0)) -1)

End Function

Function toNATIVE(p_sInBuffer As String) As String

    Dim sOutBuffer As String

    sOutBuffer = Space$(Lenbp(p_sInBuffer) + 1)
    Const OS_TRANSLATE_LMBCS_TO_NATIVE = 1
    Call OSTranslate(OS_TRANSLATE_LMBCS_TO_NATIVE, p_sInBuffer, Lenbp(p_sInBuffer), sOutBuffer, Lenbp(sOutBuffer))

    toNATIVE = Left$(sOutBuffer, Instr(sOutBuffer, Chr$(0)) - 1)

End Function

Function getErrorMessage(p_iErrorCode As Integer) As String

    Dim iErrorCode As Integer
    Dim sErrorMessageIn As String
    Dim sErrorMessageOut As String

    sErrorMessageIn = Space$(255)
    sErrorMessageOut = Space$(255)

    iErrorCode = p_iErrorCode And &h3fff
    Call OSLoadString(0, iErrorCode, sErrorMessageIn, Len(sErrorMessageIn) - 1)

    Const OS_TRANSLATE_LMBCS_TO_NATIVE = 1
    Call OSTranslate(OS_TRANSLATE_LMBCS_TO_NATIVE, sErrorMessageIn, Len(sErrorMessageIn) - 1, sErrorMessageOut, Len(sErrorMessageOut) - 1)

    sErrorMessageOut = Left$(sErrorMessageOut, Instr(sErrorMessageOut, Chr$(0)) - 1)

    getErrorMessage = sErrorMessageOut

End Function

Function ReadInteger(objectAddress As Long) As Integer
    Call MoveMemory(ReadInteger%, Byval objectAddress&, 2)
    objectAddress& = objectAddress& + 2
End Function

Function ReadLong(objectAddress As Long) As Long
    Call MoveMemory(ReadLong&, Byval objectAddress&, 4)
    objectAddress& = objectAddress& + 4
End Function

Sub ReadEntry(entry As ODS_ASSISTRUNOBJECTENTRY, objectAddress As Long)
    entry.  dwLength& = ReadLong(objectAddress&)
    entry.dwFlags& = ReadLong(objectAddress&)
End Sub

Sub ReadTIMEDATE(timeDate As TIMEDATE, objectAddress As Long)
    timeDate.Innards(0) = ReadLong(objectAddress&)
    timeDate.Innards(1) = ReadLong(objectAddress&)
End Sub

上面的代码将显示如下消息:

  

开始时间:08/01/2014 03:55:51 PM
  完成:08/01/2014 03:56:23 PM
  介于:00:00:32之间

答案 1 :(得分:1)

代理具有自己的日志,其中包含有关运行时的一些信息。您可以通过右键单击并通过&#34;查看日志&#34;来获取它。对于这些信息,必须有一个api电话,但我找不到它。一种可能性是获取Note定义代理并将其导出为DXL。在生成的XML中,您将找到<runlog>标记,该标记准确显示此代理上次运行的时间和时长。

另一种可能性是设置LOG_AGENTMANAGER = 1

这将使每个代理在服务器日志中将其起始端打印为执行结束。

您可以使用eventhandler(在events4.nsf中配置)对这些事件做出反应,并从那里提取运行时信息。

答案 2 :(得分:0)

计划代理确实出现在log.nsf中。 还有一个名为LastRun的NotesAgent类的属性,但它只提供运行时的日期/时间,而不是多长时间。 我写了一个简单的代理记录器来完成你所要求的,所以我有一个很好的数据库,我可以看到我的关键预定代理上次运行时,以及多长时间。 您可以在此处找到它:http://blog.texasswede.com/agent-logging-budget-style/