/// <summary> /// Return a list of all the queries cached by dapper /// </summary> /// <param name="ignoreHitCountAbove"></param> /// <returns></returns> public static IEnumerable <Tuple <string, string, int> > GetCachedSQL(int ignoreHitCountAbove = int.MaxValue) { var data = _queryCache.Select(pair => Tuple.Create(pair.Key.connectionString, pair.Key.sql, pair.Value.GetHitCount())); if (ignoreHitCountAbove < int.MaxValue) { data = data.Where(tuple => tuple.Item3 <= ignoreHitCountAbove); } return(data); }
private async Task <IEnumerable <string> > GetPartitionKeys() { System.Collections.Concurrent.ConcurrentDictionary <string, byte> partitionKeys = new System.Collections.Concurrent.ConcurrentDictionary <string, byte>(); await _tableStorage.ExecuteAsync(new TableQuery <CheckResultEntity>(), entity => { foreach (var et in entity.Select(m => m.PartitionKey)) { partitionKeys.TryAdd(et, 0); } }); return(partitionKeys.Select(m => m.Key)); }
public async Task SynchronizeConfiguration(bool firstLoad) { var result = await GetConfiguration(); if (result == null) { return; } var isDirty = false; var servicesToDelete = _list.Select(i => i.Key) .Except(result.Select(i => i.ServiceName)) .ToList(); var servicesToAdd = result.Select(i => i.ServiceName) .Except(_list.Select(i => i.Key)) .ToList(); // Existing foreach (var existing in _list) { var remote = result.SingleOrDefault(i => i.ServiceName == existing.Key); if (remote == null) { continue; } existing.Value.AdminServiceUrl = remote.AdminServiceUrl; existing.Value.ServiceName = remote.ServiceName; existing.Value.AlwaysStarted = remote.AlwaysStarted; existing.Value.MainAssembly = remote.MainAssembly; existing.Value.PalaceApiKey = remote.PalaceApiKey; existing.Value.SSLCertificate = remote.SSLCertificate; existing.Value.Arguments = remote.Arguments; existing.Value.InstallationFolder = remote.InstallationFolder; existing.Value.PackageFileName = remote.PackageFileName; } foreach (var serviceName in servicesToAdd) { var serviceToAdd = result.SingleOrDefault(i => i.ServiceName == serviceName); if (serviceToAdd != null) { _list.TryAdd(serviceName, serviceToAdd); if (!firstLoad) { serviceToAdd.MarkHasNew = true; } isDirty = true; } } foreach (var delete in servicesToDelete) { var existing = _list.SingleOrDefault(i => i.Key == delete); if (existing.Key != null) { existing.Value.MarkToDelete = true; } } if (isDirty) { Logger.LogInformation("Configuration changed detected"); } }