• Познакомьтесь с пентестом веб-приложений на практике в нашем новом бесплатном курсе

    «Анализ защищенности веб-приложений»

    🔥 Записаться бесплатно!

  • CTF с учебными материалами Codeby Games

    Обучение кибербезопасности в игровой форме. Более 200 заданий по Active Directory, OSINT, PWN, Веб, Стеганографии, Реверс-инжинирингу, Форензике и Криптографии. Школа CTF с бесплатными курсами по всем категориям.

Как поймать кодом время последней репликации?

E

Elena Nefedova

Здравствуйте!

Нужно получать в программе дату-время последней репликации (мы ведь можем ее видеть в окошке свойств базы, значит, она где-то хранится)

Среди документированных возможностей в ReplicationInfo базы данных и во всех ее Entries ничего не нашла, чтоб узнать, когда же произошла последняя репликация с таким-то сервером.

Может, кто-то недокументированные возможности знает доступа к этой дате-времени?
 
O

oshmianski

Для: Elena Nefedova
Код:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim rep As NotesReplication
Set db = session.CurrentDatabase
Set rep = db.ReplicationInfo
...
далее смотри NotesReplication class
 
E

Elena Nefedova

Для: oshmianski
Вот я и говорю: в какое место NotesReplication я должна посмотреть?
Что-то в глаза никакие даты не бросаются :(
 
F

Fossil Code

И действительно, методов и свойств хватает, даже для очистки Replication History, а вот для непосредственного программного доступа туда -- нет, не видать. Вероятно, остаются толко косвенные методы -- через лог и т.п.

Method Description
Replication history Records each successful replication session for a database. Useful for determining at a glance if a replication is occurring.

Replication Events view of the log file (LOG.NSF) Shows details about replication events between servers. Useful for determining the cause of replication failure and for verifying that the expected number of replication updates occurred.

Replication monitor Notifies you when replication of a database hasn't occurred within a specified time period. A server administrator creates replication monitors as a part of configuring the Event Monitor task.

Database analysis tool Lets you collect replication history and replication events from the log file, and other database-specific information into a results database that you can analyze.
 
O

oshmianski

Для: Elena Nefedova
Для: Fossil Code
согласен, что прямых путей нету :( или я не вижу
 
30.05.2006
1 345
12
BIT
0
Для: Elena Nefedova
Для: Fossil Code
согласен, что прямых путей нету :( или я не вижу
Через C API доступна история репликации:
Код:
'ReplicationHistory: 

Option Declare
Use "CAPI_Common"




' Notes API constants
Public Const DIRECTION_NEVER=0
Public Const DIRECTION_SEND=1
Public Const DIRECTION_RECEIVE=2
Const MAXPATH=256
Public Const ERR_SPECIAL_ID=578

' custom type for storing individual replication history entries
Public Type HIST_ENTRY
RepTime As Variant
Server As Variant
FilePath As String
Direction As Integer
End Type

' Notes API types (based on C structs)
Type REPLHIST_SUMMARY
ReplicationTime As TIMEDATE
AccessLevel As Integer
AccessFlags As Integer
Direction As Integer
ServerNameOffset As Long
ServerNameLength As Integer
FileNameLength As Integer
Spare1 As Long
Spare2 As Long
End Type

' Notes API declares
Declare Function W32NSFDbGetReplHistorySummary Lib "nnotes" Alias "NSFDbGetReplHistorySummary" (Byval hDb&, Byval Flags&, rethSummary&, retNumEntries&) As Integer
Declare Function Os2NSFDbGetReplHistorySummary Lib "inotes" Alias "NSFDbGetReplHistorySummary" (Byval hDb&, Byval Flags&, rethSummary&, retNumEntries&) As Integer
Declare Function LnxNSFDbGetReplHistorySummary Lib "libnotes.so" Alias "NSFDbGetReplHistorySummary" (Byval hDb&, Byval Flags&, rethSummary&, retNumEntries&) As Integer
'Declare Function OSMemFree% Lib "nnotes" (Byval Handle&)
'Declare Function OSLockObject& Lib "nnotes" (Byval nHandle&)
'Declare Function OSUnlockObject% Lib "nnotes" (Byval nHandle&)

' Win32 API declares
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As REPLHIST_SUMMARY, Byval pSource&, Byval dwLength&)
Declare Sub CopyMemoryStr Lib "kernel32" Alias "RtlMoveMemory" (Byval pDest$, Byval pSource&, Byval dwLength&)

Public Function GetReplHistory(db As NotesDatabase, entry() As HIST_ENTRY) As Integer
Dim hDb&, hLock&, hSummary&, lEntries&
Dim nLoop%, cbReturn%, nPos%, nRetCode%
Dim sPath$, sHold$, sRepTime$, sTemp$, sServer$, sFileName$
Dim summary As REPLHIST_SUMMARY

On Error Goto ErrH

' what to return if no errors are found
GetReplHistory=0

' prepare a string for API call
sPath$=Space(MAXPATH)

'create an API-friendly path to the db and open it
OSPathNetConstruct "", db.Server, db.FilePath, sPath$
nRetCode%=NSFDbOpen(sPath$, hDb&)

If nRetCode% <> 0 Then
GetReplHistory = nRetCode%
Else
' get handle to replication history summary (sorted by server name)
nRetCode% = NSFDbGetReplHistorySummary(hDb&, 0, hSummary&, lEntries&)

If nRetCode% <> 0 Then
GetReplHistory = nRetCode%
Else

' process only if there are entries in the history summary
If lEntries& > 0 Then
Redim entry(lEntries& - 1)
sRepTime$=Space(MAXALPHATIMEDATE + 1)

' lock down the handle to the history summary so we can get at the data
hLock&=OSLockObject(hSummary&)

For nLoop%=0 To lEntries&-1
' extract replication history by looping over the array of REPLHIST_SUMMARY structs
CopyMemory summary, hLock&, Lenb(summary)

ConvertTIMEDATEToText 0, 0, summary.ReplicationTime, sRepTime$, MAXALPHATIMEDATE, cbReturn%
Set entry(nLoop%).RepTime = New NotesDateTime(Left$(sRepTime$, cbReturn%))

' get replication direction
Select Case summary.Direction
Case DIRECTION_NEVER
entry(nLoop%).Direction=DIRECTION_NEVER

Case DIRECTION_SEND
entry(nLoop%).Direction=DIRECTION_SEND

Case DIRECTION_RECEIVE
entry(nLoop%).Direction=DIRECTION_RECEIVE

End Select

'advance offset to next REPLHIST_SUMMARY struct
hLock&=hLock&+Lenb(summary)
Next

' as server/filenames are not part of the REPLHIST_SUMMARY struct, but rather at the end of the
' array of these structs, we'll need to grab this info one char at a time (for each entry we find) in the
' format: CN=ServerA/O=OrgA!!myfile.nsf/0CN=ServerB/O=OrgAA!!myfile.nsf/0, etc.
sHold$=""
sTemp$=String$(1, 0)
nLoop%=0
Do While nLoop% < lEntries&
CopyMemoryStr sTemp$, hLock&, 1
If sTemp$ = Chr$(0) Then
'parse out server and filename
nPos%=Instr(1, sHold$, "!!")
Set entry(nLoop%).Server = New NotesName(Left$(sHold$, nPos%-1))
entry(nLoop%).FilePath=Right$(sHold$, Len(sHold$)-nPos%-1)
sHold$=""
nLoop%=nLoop% + 1
Else
'build the string one char at a time
sHold$=sHold$ & sTemp$
End If

'advance the offset
hLock& = hLock& + 1
Loop

'release the lock on the history summary handle once we're done with it
OSUnlockObject(hSummary&)
End If
End If

'free any open handles to the history summary and/or the db
If hSummary& <> 0 Then OSMemFree hSummary&
If hDb& <> 0 Then NSFDbClose hDb&
End If
Eos:	Exit Function
ErrH:
On Error Goto 0
Error Err,"ReplicationHistory.GetReplHistory("& Erl &"): "& Error$
Resume Eos
End Function
Public Function IsReplicatedAfter(TimeMark As Variant, Mode As Integer) As Integer
'	Mode = 1 - Send
'		 2 - Receive	or 1+2
Dim session As NotesSession
Dim conf As NotesDocument
Dim rList() As HIST_ENTRY
Dim rc As Integer

On Error Goto ErrH
Set session = New NotesSession

rc = GetReplHistory(session.CurrentDataBase, rList)
If rc=ERR_SPECIAL_ID Then IsReplicatedAfter = False
If rc=0 Then
Forall rEntry In rList
If (rEntry.RepTime.LSLocalTime>=TimeMark) And (rEntry.Direction And Mode) Then
IsReplicatedAfter = True
Exit Function
End If
End Forall
IsReplicatedAfter = False
Else
'ничего не ясно, но...
IsReplicatedAfter = True
End If
Eos:	Exit Function
ErrH:
On Error Goto 0
Error Err,"ReplicationHistory.IsReplicatedAfter("& Erl &"): "& Error$
Resume Eos
End Function
Function NSFDbGetReplHistorySummary(Byval hDb&, Byval Flags&, rethSummary&, retNumEntries&) As Integer
Dim session As New NotesSession
Select Case session.Platform
Case "Windows/32"
NSFDbGetReplHistorySummary = W32NSFDbGetReplHistorySummary(hDb&, Flags&, rethSummary&, retNumEntries&)
Case Else
Error 9999,"Неподдерживаемая платформа. Ф-ции прямых манипуляций с памятью"
End Select
End Function
 
O

oshmianski

Для: Constantin A Chervonenko
пасибки. только бы вот еще библиотечку CAPI_Common посмотреть :( а то куча функций не определо
 
E

Elena Nefedova

Для: Constantin A Chervonenko
Большое спасибо за код.
А в юникс-подобных средах эти библиотеки (nnotes, inotes и libnotes.so) доступны?
 
30.05.2006
1 345
12
BIT
0
Для: Constantin A Chervonenko
пасибки. только бы вот еще библиотечку CAPI_Common посмотреть ;) а то куча функций не определо
А.. Эт самописная, забыл..
Код:
'CAPI_Common: 

Option Declare
Option Compare Nocase
Use "CAPI_TIMEDATE"

Dim session As NotesSession
Dim Platform As Integer

' --- Notes C API declares and constants (translated from the header files)
Public Type OID
FileDBID As TIMEDATE
Note As TIMEDATE
Sequence As Long
SequenceTime As TIMEDATE
End Type

' --- note classifications
Public Const NOTE_CLASS_DOCUMENT = &H0001
Public Const NOTE_CLASS_INFO = &H0002
Public Const NOTE_CLASS_FORM = &H0004
Public Const NOTE_CLASS_VIEW = &H0008
Public Const NOTE_CLASS_ICON = &H0010
Public Const NOTE_CLASS_DESIGN = &H0020
Public Const NOTE_CLASS_ACL = &H0040
Public Const NOTE_CLASS_HELP_INDEX = &H0080
Public Const NOTE_CLASS_HELP = &H0100
Public Const NOTE_CLASS_FILTER = &H0200
Public Const NOTE_CLASS_FIELD = &H0400
Public Const NOTE_CLASS_REPLFORMULA = &H0800
Public Const NOTE_CLASS_PRIVATE = &H1000
Public Const NOTE_CLASS_ALL = &H7fff

Public Const UPDATE_NOSTUB = &H0200	'Ключик для NSFNoteDelete

Declare Sub W32OSPathNetConstruct Lib "nnotes" Alias "OSPathNetConstruct" ( _
Byval portName As Lmbcs String, Byval ServerName As Lmbcs String, Byval FileName As String, _
Byval retPathName As String)
Declare Sub Os2OSPathNetConstruct Lib "inotes" Alias "OSPathNetConstruct" ( _
Byval portName As Lmbcs String, Byval ServerName As Lmbcs String, Byval FileName As String, _
Byval retPathName As String)
Declare Sub LnxOSPathNetConstruct Lib "libnotes.so" Alias "OSPathNetConstruct" ( _
Byval portName As Lmbcs String, Byval ServerName As Lmbcs String, Byval FileName As String, _
Byval retPathName As String)

Declare Function W32NSFDbOpen Lib "nnotes" Alias "NSFDbOpen" (Byval PathName As Lmbcs String, rethDb As Long) As Integer
Declare Function Os2NSFDbOpen Lib "inotes" Alias "NSFDbOpen" (Byval PathName As Lmbcs String, rethDb As Long) As Integer
Declare Function LnxNSFDbOpen Lib "libnotes.so" Alias "NSFDbOpen" (Byval PathName As Lmbcs String, rethDb As Long) As Integer

Declare Function W32NSFDbClose Lib "nnotes" Alias "NSFDbClose" (Byval hDb As Long) As Integer
Declare Function Os2NSFDbClose Lib "inotes" Alias "NSFDbClose" (Byval hDb As Long) As Integer
Declare Function LnxNSFDbClose Lib "libnotes.so" Alias "NSFDbClose" (Byval hDb As Long) As Integer

Declare Function W32OSLoadString Lib "nnotes" Alias "OSLoadString" (Byval hModule As Long, _
Byval StringCode As Integer, _
Byval retBuffer As Lmbcs String, _
Byval BufferLength As Integer _
) As Integer
Declare Function Os2OSLoadString Lib "inotes" Alias "OSLoadString" (Byval hModule As Long, _
Byval StringCode As Integer, _
Byval retBuffer As Lmbcs String, _
Byval BufferLength As Integer _
) As Integer
Declare Function LnxOSLoadString Lib "libnotes.so" Alias "OSLoadString" (Byval hModule As Long, _
Byval StringCode As Integer, _
Byval retBuffer As Lmbcs String, _
Byval BufferLength As Integer _
) As Integer

Declare Function W32NSFDbGetNoteInfo Lib "nnotes" Alias "NSFDbGetNoteInfo"(Byval hDb As Long, Byval NoteID As Long, _
retNoteOID As OID, retModified As TIMEDATE, retNoteClass As Integer) As Integer
Declare Function Os2NSFDbGetNoteInfo Lib "inotes" Alias "NSFDbGetNoteInfo"(Byval hDb As Long, Byval NoteID As Long, _
retNoteOID As OID, retModified As TIMEDATE, retNoteClass As Integer) As Integer
Declare Function LnxNSFDbGetNoteInfo Lib "libnotes.so" Alias "NSFDbGetNoteInfo"(Byval hDb As Long, Byval NoteID As Long, _
retNoteOID As OID, retModified As TIMEDATE, retNoteClass As Integer) As Integer

Declare Function W32NSFNoteDelete Lib "nnotes" Alias "NSFNoteDelete" _
( Byval hDb As Long, Byval NoteID As Long, Byval UpdateFlags As Integer) As Integer
Declare Function Os2NSFNoteDelete Lib "inotes" Alias "NSFNoteDelete" _
( Byval hDb As Long, Byval NoteID As Long, Byval UpdateFlags As Integer ) As Integer
Declare Function LnxNSFNoteDelete Lib "libnotes.so" Alias "NSFNoteDelete" _
( Byval hDb As Long, Byval NoteID As Long, Byval UpdateFlags As Integer ) As Integer

Declare Function W32OSMemFree Lib "nnotes" Alias "OSMemFree" (Byval Handle&) As Integer
Declare Function Os2OSMemFree Lib "inotes" Alias "OSMemFree" (Byval Handle&) As Integer
Declare Function LnxOSMemFree Lib "libnotes.so" Alias "OSMemFree" (Byval Handle&) As Integer

Declare Function W32OSLockObject Lib "nnotes" Alias "OSLockObject" (Byval nHandle&) As Long
Declare Function Os2OSLockObject Lib "inotes" Alias "OSLockObject" (Byval nHandle&) As Long
Declare Function LnxOSLockObject Lib "libnotes.so" Alias "OSLockObject" (Byval nHandle&) As Long

Declare Function W32OSUnlockObject Lib "nnotes" Alias "OSUnlockObject" (Byval nHandle&) As Integer
Declare Function Os2OSUnlockObject Lib "inotes" Alias "OSUnlockObject" (Byval nHandle&) As Integer
Declare Function LnxOSUnlockObject Lib "libnotes.so" Alias "OSUnlockObject" (Byval nHandle&) As Integer


Sub Initialize
Set session = New NotesSession
Select Case session.Platform
Case "Windows/32"
Platform = 1
Case "OS/2v2"
Platform = 2
Case "Windows/16"
Platform = 3
Case "Linux"
Platform = 4
End Select
End Sub
Public Sub OSPathNetConstruct(Byval portName As String, Byval ServerName As String, Byval FileName As String, _
retPathName As String)
If session.IsOnServer Then
If session.CurrentDataBase.Server=ServerName Then ServerName=""
End If
Select Case Platform
Case 1
Call W32OSPathNetConstruct(PortName, ServerName, FileName, retPathName)
Case 2
Call Os2OSPathNetConstruct(PortName, ServerName, FileName, retPathName)
Case 4
Call LnxOSPathNetConstruct(PortName, ServerName, FileName, retPathName)
End Select
End Sub
Public Function NSFDbOpen(Byval PathName As String, rethDb As Long) As Integer
Select Case Platform
Case 1
NSFDbOpen = W32NSFDbOpen(PathName, rethDb)
Case 2
NSFDbOpen = Os2NSFDbOpen(PathName, rethDb)
Case 4
NSFDbOpen = LnxNSFDbOpen(PathName, rethDb)
End Select
End Function
Public Function NSFDbClose(Byval hDb As Long) As Integer
Select Case Platform
Case 1
NSFDbClose = W32NSFDbClose(hDb)
Case 2
NSFDbClose = Os2NSFDbClose(hDb)
Case 4
NSFDbClose = LnxNSFDbClose(hDb)
End Select
hDb = 0
End Function
Public Function OSLoadString(Byval hModule As Long, Byval StringCode As Integer, _
retBuffer As String, Byval BufferLength As Integer) As Integer
Select Case Platform
Case 1
OSLoadString = W32OSLoadString(hModule, StringCode, retBuffer, BufferLength)
Case 2
OSLoadString = Os2OSLoadString(hModule, StringCode, retBuffer, BufferLength)
Case 4
OSLoadString = LnxOSLoadString(hModule, StringCode, retBuffer, BufferLength)
End Select
End Function

Public Function GetNoteClass(iNoteClass As Integer) As String
' GetNoteClass - This function takes a note type and returns a text string representing the note class type to the caller.
Dim sNoteType As String
Select Case iNoteClass
Case NOTE_CLASS_DOCUMENT
sNoteType = "Document"
Case NOTE_CLASS_INFO
sNoteType = "Help-about"
Case NOTE_CLASS_FORM
sNoteType = "Form"
Case NOTE_CLASS_VIEW
sNoteType = "View"
Case NOTE_CLASS_ICON
sNoteType = "Icon"
Case NOTE_CLASS_DESIGN
sNoteType = "Design collection"
Case NOTE_CLASS_ACL
sNoteType = "ACL"
Case NOTE_CLASS_HELP_INDEX
sNoteType = "Help index"
Case NOTE_CLASS_HELP
sNoteType = "Help-using"
Case NOTE_CLASS_FILTER
sNoteType = "Filter"
Case NOTE_CLASS_FIELD
sNoteType = "Field"
Case NOTE_CLASS_REPLFORMULA
sNoteType = "Replication formula"
Case NOTE_CLASS_PRIVATE
sNoteType = "Private design"
Case Else
sNoteType = "Unknown"
End Select
GetNoteClass = sNoteType
End Function
Public Function GetCAPIErrorMsg(iStatus As Integer) As String
%REM
GetCAPIErrorMsg - This function takes a status code returned from a C API call, retrieves the corresponding
error message from Notes' internal string tables, and returns the string to the caller.
%END REM
Const NULLHANDLE = 0&
Dim iLen As Integer
Dim sBuffer As String
sBuffer = String$(256, 0)
' --- get the API error message from the internal Notes/Domino string tables
iLen = OSLoadString(NULLHANDLE, iStatus, sBuffer, Len(sBuffer) - 1)
If iLen > 0 Then
GetCAPIErrorMsg = Left$(sBuffer, Instr(1, sBuffer, Chr$(0)) - 1)
Else
GetCAPIErrorMsg = "Unknown error"
End If
End Function
Public Function NSFNoteDelete(Byval hDb As Long, Byval NoteID As Long, Byval UpdateFlags As Integer) As Integer
Select Case Platform
Case 1
NSFNoteDelete = W32NSFNoteDelete(hDb, NoteID, UpdateFlags)
Case 2
NSFNoteDelete = Os2NSFNoteDelete(hDb, NoteID, UpdateFlags)
Case 4
NSFNoteDelete = LnxNSFNoteDelete(hDb, NoteID, UpdateFlags)
End Select
End Function
Public Function NSFDbGetNoteInfo(Byval hDb As Long, Byval NoteID As Long, _
retNoteOID As OID, retModified As TIMEDATE, retNoteClass As Integer) As Integer
Select Case Platform
Case 1
NSFDbGetNoteInfo = W32NSFDbGetNoteInfo(hDb, NoteID, retNoteOID, retModified, retNoteClass)
Case 2
NSFDbGetNoteInfo = Os2NSFDbGetNoteInfo(hDb, NoteID, retNoteOID, retModified, retNoteClass)
Case 4
NSFDbGetNoteInfo = LnxNSFDbGetNoteInfo(hDb, NoteID, retNoteOID, retModified, retNoteClass)
End Select
End Function
Public Function OSMemFree(Byval Handle As Long) As Integer
Select Case Platform
Case 1
OSMemFree = W32OSMemFree(Handle)
Case 2
OSMemFree = Os2OSMemFree(Handle)
Case 4
OSMemFree = LnxOSMemFree(Handle)
End Select
End Function
Public Function OSLockObject(Byval Handle As Long) As Long
Select Case Platform
Case 1
OSLockObject = W32OSLockObject(Handle)
Case 2
OSLockObject = Os2OSLockObject(Handle)
Case 4
OSLockObject = LnxOSLockObject(Handle)
End Select
End Function
Public Function OSUnlockObject(Byval Handle As Long) As Integer
Select Case Platform
Case 1
OSUnLockObject = W32OSUnLockObject(Handle)
Case 2
OSUnLockObject = Os2OSUnLockObject(Handle)
Case 4
OSUnLockObject = LnxOSUnLockObject(Handle)
End Select
End Function


Для: Constantin A Chervonenko
Большое спасибо за код.
А в юникс-подобных средах эти библиотеки (nnotes, inotes и libnotes.so) доступны?
Библиотека xNOTES есть на всех платформах, и точки входа идентичны. Префикс - специфичен (N- Виндовз, I- OS/2 и т.д.)
 
O

oshmianski

Для: Constantin A Chervonenko
Границ моей благодарности не будет в пределах разумного ;)
 
A

allex

Господа... давай те пополнять Codebase...
а то как то все в форум да в форкм.
 
30.05.2006
1 345
12
BIT
0
Ну, не все же в один пост грузить
Код:
'CAPI_TIMEDATE: 
Option Declare
Use "CommonDeclare"

' --- Notes C API declares and constants (translated from the header files)
Public Type TIMEDATE
Innards(1) As Long
End Type

Public Const TIMEDATE_MINIMUM = 0
Public Const TIMEDATE_MAXIMUM = 1
Public Const TIMEDATE_WILDCARD = 2
Public Const MAXALPHATIMEDATE = 80

Dim session As NotesSession
Dim Platform As Integer

Declare Sub W32TimeConstant Lib "nnotes"	 Alias "TimeConstant"(Byval TimeConstantType As Integer, td As TIMEDATE)
Declare Sub Os2TimeConstant Lib "inotes"	 Alias "TimeConstant"(Byval TimeConstantType As Integer, td As TIMEDATE)
Declare Sub LnxTimeConstant Lib "libnotes.so" Alias "TimeConstant"(Byval TimeConstantType As Integer, td As TIMEDATE)

Declare Sub W32OSCurrentTIMEDATE Lib "nnotes"	 Alias "OSCurrentTIMEDATE"(retTimeDate As TIMEDATE)
Declare Sub Os2OSCurrentTIMEDATE Lib "inotes"	 Alias "OSCurrentTIMEDATE"(retTimeDate As TIMEDATE)
Declare Sub LnxOSCurrentTIMEDATE Lib "libnotes.so" Alias "OSCurrentTIMEDATE"(retTimeDate As TIMEDATE)

Declare Function W32ConvertTIMEDATEToText Lib "nnotes"	 Alias "ConvertTIMEDATEToText"(Byval intFormat&, Byval TextFormat&, InputTime As TIMEDATE, Byval retTextBuffer$, Byval TextBufferLength%, retTextLength%) As Integer
Declare Function Os2ConvertTIMEDATEToText Lib "inotes"	 Alias "ConvertTIMEDATEToText"(Byval intFormat&, Byval TextFormat&, InputTime As TIMEDATE, Byval retTextBuffer$, Byval TextBufferLength%, retTextLength%) As Integer
Declare Function LnxConvertTIMEDATEToText Lib "libnotes.so" Alias "ConvertTIMEDATEToText"(Byval intFormat&, Byval TextFormat&, InputTime As TIMEDATE, Byval retTextBuffer$, Byval TextBufferLength%, retTextLength%) As Integer

Declare Function W32TimeDateDifference Lib "nnotes"	 Alias "TimeDateDifference"(t1 As TIMEDATE, t2 As TIMEDATE) As Long
Declare Function Os2TimeDateDifference Lib "inotes"	 Alias "TimeDateDifference"(t1 As TIMEDATE, t2 As TIMEDATE) As Long
Declare Function LnxTimeDateDifference Lib "libnotes.so" Alias "TimeDateDifference"(t1 As TIMEDATE, t2 As TIMEDATE) As Long

%REM
Declare Function W32NSFItemGetTime Lib "nnotes" Alias "NSFItemGetTime"(Byval handle As Long, Byval ItemName As String, td As TIMEDATE) As Integer
Declare Function Os2NSFItemGetTime Lib "inotes" Alias "NSFItemGetTime"(Byval handle As Long, Byval ItemName As String, td As TIMEDATE) As Integer
Declare Function LnxNSFItemGetTime Lib "libnotes.so" Alias "NSFItemGetTime"(Byval handle As Long, Byval ItemName As String, td As TIMEDATE) As Integer
%END REM

Declare Function W32TimeDateAdjust Lib "nnotes" Alias "TimeDateAdjust"(Tim As TIMEDATE, _
Byval secs As Integer, Byval mins As Integer, Byval hours As Integer,_
Byval days As Integer, Byval months As Integer, Byval years As Integer) As Integer
Declare Function Os2TimeDateAdjust Lib "inotes" Alias "TimeDateAdjust"(Tim As TIMEDATE, _
Byval secs As Integer, Byval mins As Integer, Byval hours As Integer,_
Byval days As Integer, Byval months As Integer, Byval years As Integer) As Integer
Declare Function LnxTimeDateAdjust Lib "libnotes.so" Alias "TimeDateAdjust"(Tim As TIMEDATE, _
Byval secs As Integer, Byval mins As Integer, Byval hours As Integer,_
Byval days As Integer, Byval months As Integer, Byval years As Integer) As Integer

Sub Initialize
Set session = New NotesSession
Select Case session.Platform
Case "Windows/32"
Platform = 1
Case "OS/2v2"
Platform = 2
Case "Windows/16"
Platform = 3
Case "Linux"
Platform = 4
End Select
End Sub

Public Sub TimeConstant(Byval TimeConstantType As Integer, td As TIMEDATE)
Select Case Platform
Case 1
Call W32TimeConstant(TimeConstantType, td)
Case 2
Call Os2TimeConstant(TimeConstantType, td)
Case 4
Call LnxTimeConstant(TimeConstantType, td)
End Select
End Sub


Public Sub OSCurrentTIMEDATE(retTimeDate As TIMEDATE)
Select Case Platform
Case 1
Call W32OSCurrentTIMEDATE(retTimeDate)
Case 2
Call Os2OSCurrentTIMEDATE(retTimeDate)
Case 4
Call LnxOSCurrentTIMEDATE(retTimeDate)
End Select
End Sub

Public Sub ConvTIMEDATEtoDateTime(td As TIMEDATE, nt As Variant)
Dim buf As String
Dim rc As Integer, rlen As Integer

On Error Goto ErrH
buf = Space$(32)
rc = ConvertTIMEDATEToText(0&,0&, td, buf, Len(buf)-1, rlen)
If rc<>0 Then Error 7000,"ConvTIMEDATEtoDateTime: ConvertTIMEDATEToText rc="& Cstr(rc)
Select Case Datatype(nt)
Case V_PRODOBJ
Set nt = New NotesDateTime(Trim$(buf))
Case Else
nt = Cdat(Trim$(buf))
End Select
Eos:	Exit Sub
ErrH:
On Error Goto 0
Error Err, "ConvTIMEDATEtoDateTime("& Cstr(Erl) &"): "& Error$
Resume Eos
End Sub

Public Sub ConvDateTimeToTIMEDATE(nt As Variant, td As TIMEDATE)
Dim nTime As NotesDateTime
Dim Intr As NotesInternational
Dim bits As String

On Error Goto ErrH

Select Case Datatype(nt)
Case V_DATE
Set nTime = session.CreateDateTime(Cstr(nt))
Case V_PRODOBJ
Set nTime = nt
End Select
Set Intr = session.International

td.Innards(0) = ((Hour(nTime.LSGMTTime)*60+Minute(nTime.LSGMTTime))*60+Second(nTime.LSGMTTime))*100
bits = "&B"
If Intr.IsDST Then
bits = bits &"1"
Else
bits = bits &"0"
End If
If Intr.TimeZone<0 Then	'East?
bits = bits &"1"
Else
bits = bits &"0"
End If

bits = bits & Right$("0"& Bin$(Cint(Abs(Intr.TimeZone)\100)\15), 2) & Right$("000"& Bin$(Abs(Intr.TimeZone) Mod 100), 4)
bits = bits & Right$(String(23,"0") & Bin$(Clng(Cdbl(nTime.LSLocalTime))+2415018), 24)	'дни от сотворения Мира
td.Innards(1)= Val(bits &"&")
Eos:	Exit Sub
ErrH:
On Error Goto 0
Error Err, "ConvDateTimeToTIMEDATE("& Cstr(Erl) &"): "& Error$
Resume Eos
End Sub
Sub GetNow(nt As Variant, dt As TIMEDATE)
'Возвращает кореллированные времена текущего сервера
Dim tdoc As NotesDocument
Dim db As NotesDatabase

On Error Goto ErrH
Set db = session.CurrentDatabase

Set tdoc = New NotesDocument(db)
Dim t1 As New NotesDateTime(Cstr(tdoc.Created))
dt.Innards(1) = Val("&H"& Mid$(tdoc.UniversalID,17,8) &"&")
dt.Innards(0) = Val("&H"& Mid$(tdoc.UniversalID,25,8) &"&")

If Isempty(nt) Or Datatype(nt)=V_DATE Then
nt = t1.LSLocalTime
Elseif Datatype(nt)=V_PRODOBJ Then
On Error Goto 0
If nt Isa "NotesDateTime" Then Set nt = t1 Else Error 7000, "Invalid parameter type"
Else
On Error Goto 0
Error 7000, "Invalid parameter type"
End If
Eos:	Exit Sub
ErrH:
On Error Goto 0
Error Err, "GetNow("& Cstr(Erl) &"): "& Error$
Resume Eos
End Sub
Public Function TimeDateDifference(t1 As TIMEDATE, t2 As TIMEDATE) As Long
Select Case Platform
Case 1
TimeDateDifference = W32TimeDateDifference(t1, t2)
Case 2
TimeDateDifference = Os2TimeDateDifference(t1, t2)
Case 4
TimeDateDifference = LnxTimeDateDifference(t1, t2)
End Select
End Function

Public Function TimeDateAdjust(Tim As TIMEDATE,_
Byval secs As Integer, Byval mins As Integer, Byval hours As Integer,_
Byval days As Integer, Byval months As Integer, Byval years As Integer) As Integer
Select Case Platform
Case 1
TimeDateAdjust = W32TimeDateAdjust(Tim, secs, mins, hours, days, months, years)
Case 2
TimeDateAdjust = Os2TimeDateAdjust(Tim, secs, mins, hours, days, months, years)
Case 4
TimeDateAdjust = LnxTimeDateAdjust(Tim, secs, mins, hours, days, months, years)
End Select
End Function

Public Function ConvertTIMEDATEToText(Byval intFormat&, Byval TextFormat&, InputTime As TIMEDATE, retTextBuffer$, Byval TextBufferLength%, retTextLength%) As Integer
Select Case Platform
Case 1
ConvertTIMEDATEToText = W32ConvertTIMEDATEToText(intFormat, TextFormat, InputTime, retTextBuffer, TextBufferLength, retTextLength)
Case 2
ConvertTIMEDATEToText = Os2ConvertTIMEDATEToText(intFormat, TextFormat, InputTime, retTextBuffer, TextBufferLength, retTextLength)
Case 4
ConvertTIMEDATEToText = LnxConvertTIMEDATEToText(intFormat, TextFormat, InputTime, retTextBuffer, TextBufferLength, retTextLength)
End Select
End Function
Код:
'CommonDeclare: 

Option Declare

%INCLUDE "lsconst"
 
M

morpheus

Для: Constantin A Chervonenko
ого.... а слабо в link removed залепить.. буду благодарен безмерно ;)
 
E

Elena Nefedova

Для: Constantin A Chervonenko
Спасибо, что заставили всех нас пошевелить мозгами :)
Вот теперь можно тестировать
 
30.05.2006
1 345
12
BIT
0
Для: Constantin A Chervonenko
ого.... а слабо в link removed залепить.. буду благодарен безмерно ;)
Там сопли кругом. Выставлять их на витрину :) ? В Replication history надо от виндового АПИ отвязаться... Руки не доходят.
Подарил as is
 
D

deeeman

Привет!

Задача выпала - как название топика. Отследить дату последней репликации базы с одного сервера на другой.
взял все либы которые дал Constantin A Chervonenko и внес их в базу (приложил базу)

пыжился что то передать в них, но не научился, кто нибудь их настроил для себя? они работают?

Подскажите как их юзать?



Может есть способ проще получить требуемое?
 

Вложения

  • Replicat.rar
    35,6 КБ · Просмотры: 219
D

deeeman

ясно, тогда что передавать это супер библе в параметрах?

есть метод "GetReplHistory" в библе ReplicationHistory
там параметры для входа: (db As NotesDatabase, entry() As HIST_ENTRY)

первый понятно, а второй откудава взять?
 
Мы в соцсетях:

Обучение наступательной кибербезопасности в игровой форме. Начать игру!