public void GarbageCollector() { try { var removeCollection = new List <EveJimaUniverse.System>(); foreach (var visitedSolarSystem in Systems) { var totalHours = (DateTime.UtcNow - visitedSolarSystem.Value.Created).TotalHours; if (totalHours > Tools.SolarSystemTTL()) { removeCollection.Add(visitedSolarSystem.Value); } } foreach (var visitedSolarSystem in removeCollection) { DeletedSystems.TryAdd(visitedSolarSystem.Name, visitedSolarSystem); EveJimaUniverse.System element; Systems.TryRemove(visitedSolarSystem.Name, out element); } } catch (Exception ex) { _log.ErrorFormat("[Map.GarbageCollector] Critical error {0}", ex); } }
public void DeleteSolarSystem(string system) { try { foreach (var solarSystem in Systems) { if (solarSystem.Value.ConnectedSolarSystems.Contains(system)) { solarSystem.Value.ConnectedSolarSystems.Remove(system); solarSystem.Value.LastUpdate = DateTime.UtcNow; } } var deletedSolarSystem = GetSystem(system); deletedSolarSystem.LastUpdate = DateTime.UtcNow; DeletedSystems.TryAdd(deletedSolarSystem.Name, deletedSolarSystem); EveJimaUniverse.System element; Systems.TryRemove(deletedSolarSystem.Name, out element); Save(); } catch (Exception ex) { var a = ex.Message; } }