internal static void Request(MarketerDataRequest marketerDataRequest) { var cachedType = CachedRequests.FirstOrDefault(x => x.RawMarketType.id == marketerDataRequest.Id.ToString() && x.Region == marketerDataRequest.Region && x.SolarSystem == marketerDataRequest.SolarSystem); if (cachedType != null) { if (cachedType != null) { var difference = marketerDataRequest.Timestamp - cachedType.Timestamp; if (difference.TotalMinutes > 30) { CachedRequests.Remove(cachedType); } else { return; } } } var pendingRequest = PendingRequests.FirstOrDefault(x => x.Id == marketerDataRequest.Id && x.Region == marketerDataRequest.Region && x.SolarSystem == marketerDataRequest.SolarSystem); if (pendingRequest != null) { return; } PendingRequests.Add(marketerDataRequest); if (PendingRequests.Count(x => x.Region == marketerDataRequest.Region && x.SolarSystem == marketerDataRequest.SolarSystem) >= 200) { Request(marketerDataRequest.Region, marketerDataRequest.SolarSystem); } }
internal static void RequestAll() { var cachedRequests = CachedRequests.ToList(); foreach (var cachedType in cachedRequests) { MarketerDataRequest request = null; if (cachedType != null) { if (cachedType != null) { var difference = DateTime.Now - cachedType.Timestamp; if (difference.TotalMinutes > 30) { request = new MarketerDataRequest(cachedType.Id, cachedType.Region, cachedType.SolarSystem); CachedRequests.Remove(cachedType); } else { return; } } } var pendingRequest = PendingRequests.FirstOrDefault(x => x.Id == request.Id && x.Region == request.Region && x.SolarSystem == request.SolarSystem); if (pendingRequest != null) { return; } PendingRequests.Add(request); if (PendingRequests.Count(x => x.Region == request.Region && x.SolarSystem == request.SolarSystem) >= 200) { Request(request.Region, request.SolarSystem); } } ProcessPendingRequests(); }