} // end of WriteSlowSingleRowToRepository function /// <summary>Saves single row & fast changing metric</summary> private void WriteFastSingleRowToRepository(int targetId, MetricGroup metricGroup, ProbeResultingData data) { // generate SQL statement string dataSqlStmt = GenerateSqlSingleRowFast(targetId, metricGroup, data); _logger.Trace(dataSqlStmt); SqlServerProbe.ExecuteSql(dataSqlStmt, targetId, metricGroup); // update in-memory data object[] newValues = new object[data.NumberOfColumns]; for (int i = 0; i < data.NumberOfColumns; i++) { newValues[i] = data.values[0, i]; } // create in-memory cache table if it doesn't exist string cacheKey = InMemoryCache.GetCacheKey(-1, metricGroup); if (!InMemoryCache.ContainsKey(cacheKey)) { // Do no create new cache table if target has been deleted if (!Configuration.targets.ContainsKey(targetId)) { return; } InMemoryCache.CreateCacheTableSingleRow(metricGroup, CacheType.Data); } Configuration.inMemoryCache[cacheKey].AddOrUpdateRowValues(-1, new object[] { targetId }, newValues); } // end of WriteFastSingleRowToRepository function
} // end of GenerateSqlSlowDict method #endregion private static methods declarations #region private methods declarations /// <summary>Saves single row & slow changing metric</summary> private void WriteSlowSingleRowToRepository(int targetId, MetricGroup metricGroup, ProbeResultingData data) { int dataMatches; string dataSqlStmt; object[] newValues; // compare with in-memory data dataMatches = this.CompareSlowSingleRowWithInMemoryData(targetId, metricGroup, data, this.reposConn); // generate SQL statement dataSqlStmt = GenerateSqlSingleRowSlow(targetId, metricGroup, dataMatches, data); _logger.Trace(dataSqlStmt); SqlServerProbe.ExecuteSql(dataSqlStmt, targetId, metricGroup); // update in-memory data newValues = new object[data.NumberOfColumns]; for (int i = 0; i < data.NumberOfColumns; i++) { newValues[i] = data.values[0, i]; } if (dataMatches == -1) { InMemoryCache.Add(InMemoryCache.GetCacheKey(targetId, metricGroup), -1, new object[] { targetId }, newValues); } else { Configuration.inMemoryCache[InMemoryCache.GetCacheKey(targetId, metricGroup)].UpdateRowValues(new object[] { targetId }, newValues); } } // end of WriteSlowSingleRowToRepository function