Декодировать Assistinfo агента

Тема в разделе "Lotus - Программирование", создана пользователем Omh, 9 окт 2007.

  1. Omh

    Omh Lotus team
    Lotus team

    Регистрация:
    4 июл 2007
    Сообщения:
    2.210
    Симпатии:
    0
    Добрый день!

    При считываении данных агента через API имеет место быть тип
    Код (Text):
    Type ODS_ASSISTSTRUCT
    wVersion As Integer '/* Structure version */
    wTriggerType As Integer '/* Type of trigger */
    wSearchType As Integer '/* Type of search */
    wIntervalType As Integer '/* Type of interval */
    wInterval As Integer '/* Interval */
    dwTime11 As Integer '/* depends on interval type */
    dwTime12 As Integer '/* depends on interval type */
    dwTime21 As Integer '/* depends on interval type */
    dwTime22 As Integer '/* depends on interval type */
    StartTime(1) As Long '/* Agent does not run before this time */
    EndTime(1) As Long '/* Agent does not run after this time */
    dwFlags As Long
    dwSpare(15) As Long
    End Type
    Меня интересует алгоритм декодинга след. параметров:
    Код (Text):
    dwTime11 As Integer '/* depends on interval type */
    dwTime12 As Integer '/* depends on interval type */
    dwTime21 As Integer '/* depends on interval type */
    dwTime22 As Integer '/* depends on interval type */
    В них закодировано время Between Times.

    Нету ли у кого этого алгоритма?
    Спасибо!
     
  2. Kee_Keekkenen

    Kee_Keekkenen Well-Known Member

    Регистрация:
    5 сен 2006
    Сообщения:
    616
    Симпатии:
    4
    на абиэмовском форуме частенько это попадалось..

    ...
    вот демо код, который по заверениям автора работает
    оригинал
    Код (Text):
    Const wAPIModule = "NNOTES" ' Windows/32

    Const NOTE_CLASS_FILTER = &H0200



    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 Click(Source As Button)

    a$ = Inputbox$("Name of agent:", "Agent Info", "")

    If a$ = "" Then Exit Sub



    Dim session As New NotesSession

    Dim info As AssistInfo

    GetAssistInfo session.CurrentDatabase, a$, info



    Messagebox "Version: " & Cstr(info.Version) _

    & Chr$(10) & "TriggerType: " & Cstr(info.TriggerType) _

    & Chr$(10) & "SearchType: " & Cstr(info.SearchType) _

    & Chr$(10) & "IntervalType: " & Cstr(info.IntervalType) _

    & Chr$(10) & "Interval: " & Cstr(info.Interval) _

    & Chr$(10) & "Time1: " & Cstr(info.Time1) _

    & Chr$(10) & "Time2: " & Cstr(info.Time2) _

    & Chr$(10) & "StartTime: " & Cstr(info.StartTime) _

    & Chr$(10) & "EndTime: " & Cstr(info.EndTime) _

    & Chr$(10) & "Flags: " & Cstr(info.Flags)

    End Sub





    Sub GetAssistInfo(db As NotesDatabase, agent As String, info As AssistInfo)

    np$ = Space(1024)

    OSPathNetConstruct 0, db.Server, db.FilePath, np$



    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





    Sub SetAssistInfo(db As NotesDatabase, agent As String, info As AssistInfo)

    np$ = Space(1024)

    OSPathNetConstruct 0, db.Server, db.FilePath, np$



    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

    Poke p& + 2, info.Version, 2

    Poke p& + 4, info.TriggerType, 2

    Poke p& + 6, info.SearchType, 2

    Poke p& + 8, info.IntervalType, 2

    Poke p& + 10, info.Interval, 2

    If Isdate(info.Time1) Then Poke p& + 12, Clng(Cdbl(info.Time1) * 24 * 60 * 60 * 100), 4 _

    Else Poke p& + 12, Clng(info.Time1), 4

    If Isdate(info.Time2) Then Poke p& + 16, Clng(Cdbl(info.Time2) * 24 * 60 * 60 * 100), 4 _

    Else Poke p& + 16, Clng(info.Time2), 4

    Dim hM As Long

    OSMemAlloc 0, 81, hM

    b& = OSLockObject(hM)

    If Isdate(info.StartTime) Then

    t$ = Cstr(info.StartTime) & Chr$(0)

    PokeString b&, t$, Len(t$)

    ConvertTextToTIMEDATE 0, 0, b&, 81, p& + 20

    Else

    Poke p& + 20, 0&, 4

    Poke p& + 24, 0&, 4

    End If

    If Isdate(info.EndTime) Then

    t$ = Cstr(info.EndTime) & Chr$(0)

    PokeString b&, t$, Len(t$)

    ConvertTextToTIMEDATE 0, 0, b&, 81, p& + 28

    Else

    Poke p& + 28, 0&, 4

    Poke p& + 32, 0&, 4

    End If

    Poke p& + 36, info.Flags, 4

    OSUnlockObject hM

    OSMemFree hM

    OSUnlockObject vB.hPool

    End If



    NSFNoteUpdate hNT, 0

    NSFNoteClose hNT

    NSFDbClose hDB

    End Sub
     
  3. Omh

    Omh Lotus team
    Lotus team

    Регистрация:
    4 июл 2007
    Сообщения:
    2.210
    Симпатии:
    0
    Я уже почти разобрался.
    Как я понимаю, этот код для R4, т.е. позже появились ещё пара членов.
    Сделаю решение - выложу.
     
  4. Omh

    Omh Lotus team
    Lotus team

    Регистрация:
    4 июл 2007
    Сообщения:
    2.210
    Симпатии:
    0
    Вот 2 процедурки что кодяд время в integer'ы и обратно:
    Код (Text):
    Sub TimeToInt(hrs As Long, mins As Long, int1 As Integer, int2 As Integer)
    Dim longtime As Long
    longtime = (hrs * 60 + mins) * 60 * 100
    Dim tmp As Long
    tmp = longtime Mod 65536
    If tmp > 32767 Then int1 = tmp - 65536 Else int1 = tmp
    int2 = longtime \ 65536
    End Sub

    Sub IntToTime(int1 As Integer, int2 As Integer, hrs As Long, mins As Long)
    Dim longtime As Long
    Dim tmp As Long
    If int1 < 0 Then tmp = 65536 + int1
    longtime = int2 * 65536 + tmp
    mins = ((longtime) / 6000) Mod 60
    hrs = ((longtime) / 6000) \ 60
    End Sub
    Оставим потомкам :)
     
Загрузка...
Похожие Темы - Декодировать Assistinfo агента
  1. DarkJoker
    Ответов:
    0
    Просмотров:
    1.173

Поделиться этой страницей