diff --git a/Service.EDMIService/Scheduler/DatatableJob.vb b/Service.EDMIService/Scheduler/DatatableJob.vb index 1c9f0246..dc05a2fd 100644 --- a/Service.EDMIService/Scheduler/DatatableJob.vb +++ b/Service.EDMIService/Scheduler/DatatableJob.vb @@ -20,6 +20,7 @@ Public Class DatatableJob Dim oCronJobTitle As String = oJobData.Item("CronJobTitle") Dim oLogger As Logger = oLogConfig.GetLogger() + Dim oStopWatch As New Stopwatch() Dim oResult As New JobResult() oLogger.Info("Running Datatable Job [{0}]/[{1}]", context.JobDetail.Key, oCronJobTitle) @@ -43,12 +44,18 @@ Public Class DatatableJob oLogger.Debug("Datatable Name: {0}", oDatatableName) oLogger.Debug("Connection Id: {0}", oConnectionId) + oStopWatch.Start() + Dim oConnectionString = oMSSQL.Get_ConnectionStringforID(oConnectionId) Dim oDecryptedConnectionString = MSSQLServer.DecryptConnectionString(oConnectionString) Dim oTable = oMSSQL.GetDatatableWithConnection(oSQL, oDecryptedConnectionString, COMMAND_SQL_TIMEOUT) oTable.TableName = oDatatableName + oStopWatch.Stop() + oLogger.Debug("[Time] Getting Data From DB: {0}ms", oStopWatch.ElapsedMilliseconds) + oStopWatch.Restart() + Dim oView As DataView = Nothing ' This creates an Index for the columns specified in INDEX_COLUMNS to speed up calls to 'Table.Select'! @@ -59,6 +66,10 @@ Public Class DatatableJob } End If + oStopWatch.Stop() + oLogger.Debug("[Time] Creating Indexes: {0}ms", oStopWatch.ElapsedMilliseconds) + oStopWatch.Restart() + oLogger.Debug("Result Datatable [{0}] contains [{1}] rows", oTable.TableName, oTable.Rows.Count) Dim oResultTable = New JobResult.ResultTable() With { @@ -81,6 +92,9 @@ Public Class DatatableJob oResultTable.TableRelationColumn = oParentColumn End If + oStopWatch.Stop() + oLogger.Debug("[Time] Adding Relations: {0}ms", oStopWatch.ElapsedMilliseconds) + oLogger.Info("Fetched Datatable [{0}]", oDatatableName) oResult.Tables.Add(oResultTable) Catch ex As Exception diff --git a/Service.EDMIService/Scheduler/JobListener.vb b/Service.EDMIService/Scheduler/JobListener.vb index 9fabc4bf..995c2d55 100644 --- a/Service.EDMIService/Scheduler/JobListener.vb +++ b/Service.EDMIService/Scheduler/JobListener.vb @@ -164,13 +164,14 @@ Public Class JobListener Dim oName As String = Result.DetailRow.Item("DT_NAME") Dim oDetailId As Integer = Result.DetailRow.Item("GUID") - Dim oDatatableNameTemp As String = oName & "-TEMP" ' Used for debugging relations and constraints '_Logger.Debug("Dataset BEFORE saving datatables") 'ListTables(Dataset) If Dataset.Tables.Contains(oName) Then + _Logger.Debug("Datatable [{0}] already exists, replacing.", oName) + ' Replace existing table If Result.ChildTable IsNot Nothing Then ReplaceExistingTable(oName, oTable, Dataset, Result.ChildTable) @@ -179,6 +180,8 @@ Public Class JobListener ReplaceExistingTable(oName, oTable, Dataset) End If Else + _Logger.Debug("Datatable [{0}] does not exist yet, adding.", oName) + AddNewTable(oName, oTable, Dataset) If Result.ChildTable IsNot Nothing Then @@ -192,6 +195,11 @@ Public Class JobListener '_Logger.Debug("Dataset AFTER saving datatables") 'ListTables(Dataset) + Dim oMemoryUsage = GC.GetTotalMemory(True) + Dim oUsageString = Utils.BytesToString(oMemoryUsage) + + _Logger.Debug("Estimated memory usage after Job is [{0}]", oUsageString) + _MSSQL.ExecuteNonQuery($"INSERT INTO TBAPPSERV_CRON_DETAIL_HISTORY (DETAIL_ID) VALUES ({oDetailId})") Catch ex As Exception _Logger.Warn("Unexpected error in JobListener: {0}", ex.Message)