Index: vhLib/LogOpkuiser.cls.xml =================================================================== diff -u -r3570 -r3804 --- vhLib/LogOpkuiser.cls.xml (.../LogOpkuiser.cls.xml) (revision 3570) +++ vhLib/LogOpkuiser.cls.xml (.../LogOpkuiser.cls.xml) (revision 3804) @@ -107,18 +107,43 @@ } Do ResultSet.Close() - Do ..Logger.%New("vhLib.Logger").Info("VerwijderLogRecords", "'" _ LoggingIdsToDelete.Count() _ "' te wissen voor datum '" _ Datum _ "', Niveau '" _ Niveau _ "'.") - - #Dim AantalGewist As %Integer = 0 + Do ..Logger.Info("VerwijderLogRecords", "'" _ LoggingIdsToDelete.Count() _ "' te wissen voor datum '" _ Datum _ "', Niveau '" _ Niveau _ "'.") + + Set ExceptionList = ##class(TECH.ExceptionList).%New() + #dim MaxAantalExceptiesPerRonde As %Integer = 5 ; Na x errors wordt de while loop afgebroken + #dim ContinueLoopToDelete As %Boolean = $$$True + + #dim AantalGewist As %Integer = 0 + #dim EersteIdGewist As %String = "" + #dim LaatsteIdGewist As %String = "" Set IdsToDeleteIterator = ##class(TECH.ListIterator).%New( LoggingIdsToDelete ) - While IdsToDeleteIterator.HasNext() { - Set IdToDelete = IdsToDeleteIterator.Next() - Do ##class(vhLib.Logging).DeleteLogging(IdToDelete) - Set AantalGewist = AantalGewist + 1 + While (IdsToDeleteIterator.HasNext()) && (ContinueLoopToDelete) { + #dim IdToDelete As %String = IdsToDeleteIterator.Next() + Try { + #dim sc As %Status = ##class(vhLib.Logging).DeleteLogging(IdToDelete) + Do ##class(TECH.Exceptions.StatusException).ThrowIndienNietOK(sc) + + Set AantalGewist = AantalGewist + 1 + Set:(EersteIdGewist="") EersteIdGewist = IdToDelete + Set LaatsteIdGewist = IdToDelete + } + Catch { + #dim Exception As TECH.Exceptions.Exception = ##class(TECH.ExceptionHandler).Catch() + Do Exception.VoegToeExtraInfo("Record to delete ID='"_IdToDelete_"'") + Do ExceptionList.Insert(Exception) + Set ContinueLoopToDelete = (ExceptionList.Count() < MaxAantalExceptiesPerRonde) + } } - - Do:(LoggingIdsToDelete.Count() > 0) ..Logger.Info("VerwijderLogRecords", "'" _ AantalGewist _ "' gewist voor datum '" _ Datum _ "', Niveau '" _ Niveau _ "'.") + Do:(LoggingIdsToDelete.Count() > 0) ..Logger.Info("VerwijderLogRecords", "'" _ AantalGewist _ "' items gewist voor datum '" _ Datum _ "', Niveau '" _ Niveau _ "'; Eerste ID='"_EersteIdGewist_"' LaatsteID='"_LaatsteIdGewist_"'.") + + If ExceptionList.Count() > 0 { + Set OmvattendeException = ##class(TECH.Exceptions.GeneralErrorException).%New("Error bij VerwijderLogRecords. Aantal fouten: "_ExceptionList.Count() _$$$If(ContinueLoopToDelete, "", " (While-loop afgebroken, want max aantal fouten bereikt).") ) + Do OmvattendeException.ZetInnerExcepties(ExceptionList) + Do OmvattendeException.VoegToeExtraInfo("'" _ AantalGewist _ "' items reeds gewist voor datum '" _ Datum _ "', Niveau '" _ Niveau _ "'; Eerste ID='"_EersteIdGewist_"' LaatsteID='"_LaatsteIdGewist_"'.") + Do ..Logger.ErrorMail("VerwijderLogRecords", OmvattendeException.ToStream()) + } + Quit AantalGewist ]]>