Public Function CheckNewVersion_Continue() As Boolean
On Error GoTo ErrH
CheckNewVersion_Continue = True
Const CURVER = "CUR_VERSION"
Const NEWVER = "NEW_VERSION"
Const VIEW_RELEASES = "Releases"
Dim ns As New NotesSession
Dim sStartTime As String, dUpTime As NotesDateTime
sStartTime = ns.GetEnvironmentString("NotesStartTime", False)
If IsDate(sStartTime) Then
Set dUpTime = New NotesDateTime(sStartTime)
Else
Set dUpTime = New NotesDateTime(Now)
Dim nUpTimeSeconds As Long
nUpTimeSeconds = getUptimeSeconds()
Dim nMinutes As Long
Dim nHours As Long
Dim nDays As Long
nMinutes = Fix(nUpTimeSeconds / 60) Mod 60
Call dUpTime.AdjustMinute(-nMinutes)
nHours = Fix(nUpTimeSeconds / 3600) Mod 24
Call dUpTime.AdjustHour(-nHours)
nDays = Fix(nUpTimeSeconds / 86400) Mod 30
Call dUpTime.AdjustDay(-nDays)
If DEBUG_MODE = 1 Then Print "[CheckNewVersion_Continue] UpTime: ", CStr(nUpTimeSeconds)
End If
If DEBUG_MODE = 1 Then Print "[CheckNewVersion_Continue] Start time: ", dUpTime.LocalTime
Dim dCurVerTime As NotesDateTime
Set dCurVerTime = dtCommonGet(ns.GetEnvironmentString(CURVER, False))
If dCurVerTime Is Nothing Then
Set dCurVerTime = dUpTime
If DEBUG_MODE = 1 Then Print "[CheckNewVersion_Continue] CURVER flag NOT found. Use client's uptime"
End If
Dim ndbConf As NotesDatabase
Dim nvSett As NotesView
Set nvSett = ndbConf.GetView(VIEW_RELEASES)
Call nvSett.Refresh()
Dim oNVE As NotesViewEntry
Set oNVE = nvSett.GetEntryByKey(ns.CurrentDatabase.FileName, False)
If Not oNVE Is Nothing Then
Dim dLastRelease As NotesDateTime
Set dLastRelease = dtCommonGet(CStr(oNVE.ColumnValues(2)))
Dim bNewVerPresent As Boolean
Dim dNewVerTime As NotesDateTime
Set dNewVerTime = dtCommonGet(ns.GetEnvironmentString(NEWVER, False))
bNewVerPresent = (Not dNewVerTime Is Nothing)
If bNewVerPresent Then
If DEBUG_MODE = 1 Then Print "[CheckNewVersion_Continue] NEWVER flag found"
End If
If dUpTime.TimeDifference(dLastRelease) > 0 Then
If Not bNewVerPresent Then
If dCurVerTime.TimeDifference(dLastRelease) <> 0 Then
Call dtCommonSetVar(CURVER, dLastRelease)
End If
Else
Call dtCommonSetVar(CURVER, dNewVerTime)
Call setEnvironmentVar(NEWVER, "", False)
If DEBUG_MODE = 1 Then Print "[CheckNewVersion_Continue] NEWVER is present AND client was rebooted - update local flags"
End If
Else
If dLastRelease.TimeDifference(dCurVerTime) > 0 Then
If DEBUG_MODE = 1 Then Print "[CheckNewVersion_Continue] Update available (" + dLastRelease.Dateonly + " " + dLastRelease.Timeonly + ")"
Dim ndSett As NotesDocument
Set ndSett = oNVE.Document
If DEBUG_MODE = 1 Then Print "[CheckNewVersion_Continue] Updated DBs: ", Join(ndSett.vDBsList, ", ")
If DEBUG_MODE = 1 Then Print "[CheckNewVersion_Continue] " + ns.CurrentDatabase.FilePath + " database was updated"
If Not bNewVerPresent And ndSett.whatsNewPresent(0) = "1" Then
If DEBUG_MODE = 1 Then Print "[CheckNewVersion_Continue] Show what's new dialog"
ndSett.subject = "Обновление в ЭДБ от " + dLastRelease.DateOnly + " " + StrLeftBack(dLastRelease.TimeOnly, ":")
Dim wrk As New NotesUIWorkspace
Call wrk.Dialogbox("Release", True, True, True, True, True, True, "Новое обновление ЭДБ", ndSett, True, False, False)
End If
If ndSett.getItemValue("bNeedClientReboot")(0) = "1" Then
Call dtCommonSetVar(NEWVER, dLastRelease)
CheckNewVersion_Continue = False
If DEBUG_MODE = 1 Then Print "[CheckNewVersion_Continue] NEED to REBOOT"
MsgBox "Обнаружено обновление СЭД." + Chr(13) + Chr(13) + "Для корректной работы в Lotus Вам необходимо ЗАКРЫТЬ ВСЕ ВКЛАДКИ и перезагрузить его.", 48, "Проверка обновлений..."
Else
Call dtCommonSetVar(CURVER, dLastRelease)
Call setEnvironmentVar(NEWVER, "", False)
If DEBUG_MODE = 1 Then Print "[CheckNewVersion_Continue] Update local flags"
End If
End If
End If
End If
Quit:
Exit Function
ErrH:
Dim sErrText As String
sErrText = GetThreadInfo(1) & " (" & Erl & ") -> " & Error$ + " {" & Err & "}"
Print "ОШИБКА при проверке обновлений: " + sErrText
Resume Quit
End Function