1. Beatrix Willius
  2. Valentina Database ADK
  3. Mittwoch, März 30 2016, 01:45 PM
  4.  Abonnieren via E-Mail
I've got some code for doing a diagnosis. Today I got a log from a user with the text "The diagnose file is not there after all." Is this a success or a failure?

If there had been a problem with creating the file then the error message should say so. But so far every time there were problems with the database, then the diagnosis had some result.


 'check a database, if it has any problems

if theDatabase = nil then Return

dim theDiagnoseFile as FolderItem = folderItemUtils.getTempFolderitem
if theDiagnoseFile = nil or not theDiagnoseFile.Exists then
Globals.theErrorLog.LogItem "It wasn't possible to create the diagnosis file! Please check your permissions and try again."
NotificationManager.Post "DiagnoseFinished", "Failure"
Return
end if

try
if theDatabase.Diagnose(EVVerboseLevel.kVeryHigh, theDiagnoseFile) then

'database is okay
theDiagnoseFile.Delete

NotificationManager.Post "DiagnoseFinished", "Success"
else

if theDiagnoseFile = nil or not theDiagnoseFile.Exists then
Globals.theErrorLog.LogItem "The diagnose file is not there after all."
NotificationManager.Post "DiagnoseFinished", "Failure"
Return
end if
dim theDiagnoseBin as BinaryStream = BinaryStream.Open(theDiagnoseFile, false)
if theDiagnoseBin = nil then
Globals.theErrorLog.LogItem "The diagnose file is there but it can't be read."
NotificationManager.Post "DiagnoseFinished", "Failure"
Return
end if
dim DiagnoseResult as String = theDiagnoseBin.Read(theDiagnoseBin.Length)
Globals.theErrorLog.LogItem "Database Diagnosis Result:", ""
Globals.theErrorLog.LogItem DiagnoseResult, ""
Globals.theErrorLog.LogItem "************************", ""
NotificationManager.Post "DiagnoseFinished", "Failure"
end if

'when the database is really corrupt then there may be a crash instead of a normal diagnose result
catch err as VException

Globals.theErrorLog.LogItem "Database Diagnosis Result:", ""
Globals.theErrorLog.LogItem "Message: " + err.Message + ", Error Number: " + str(err.ErrorNumber) + ", Stack: " + Join(err.stack)
Globals.theErrorLog.LogItem "************************", ""
NotificationManager.Post "DiagnoseFinished", "Failure"

end try

exception exc
theException = new ErrorException(exc, currentMethodName)


Regards

Beatrix Willius
Kommentar
There are no comments made yet.
Ivan Smahin Akzeptierte Antwort
BTW, you can call diagnose without file ref at all in order to get simply "yes or no" as result of diagnose. And if diagnose fails you can notify user and let he choose the file for detailed report (doing diagnose one more time with file ref).
Kommentar
There are no comments made yet.
Beatrix Willius Akzeptierte Antwort
Hi Ivan,

this is interesting but not quite what I was asking here. There was a diagnosis done. But there was no file. Is this a success or a failure?

Regards

Beatrix Willius
Kommentar
There are no comments made yet.
Ivan Smahin Akzeptierte Antwort

if theDatabase.Diagnose(EVVerboseLevel.kVeryHigh, theDiagnoseFile) then



If result of diagnose call is true, then db is ok, and something wrong with db otherwise.
Absence of report file - no idea. Could you diagnose that db in vStudio, is it ok there?
Kommentar
There are no comments made yet.
  • Seite :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.

Categories

Announcements & News
  1. 0 subcategories
Valentina Studio
  1. 2 subcategories
Valentina Server
  1. 4 subcategories
Valentina Database ADK
  1. 0 subcategories
Valentina Reports ADK
  1. 0 subcategories
Other Discussions
  1. 2 subcategories
BETA Testing
  1. 0 subcategories
Education & Research
  1. 0 subcategories