private async Task saveEODdata(string data) // convert to json { try { EndOfDayData eodData = EndOfDayData.Deserialize(data); bool idExists = _stockScreenerService.EODIdExists(eodData.Id); if (idExists) { await _stockScreenerService.UpdateEODdata(eodData.Id, eodData); } _stockScreenerService.Create(eodData); } catch (Exception ex) { if (ex is System.ArgumentNullException || ex is System.TimeoutException) { Console.WriteLine("Exception " + ex); } Console.WriteLine("Exception " + ex); } await Task.Delay(100); // Indicate lock stream await _stockHandler.Clients.All.lockStream(serviceWorker.API_REQUESTS, true); }
public static EndOfDayData Deserialize(string query) { // Case Insensitive (Does not exclude capitals and numbers) EndOfDayData data = JsonSerializer. Deserialize <EndOfDayData>(query, new JsonSerializerOptions { PropertyNameCaseInsensitive = true }); //Console.WriteLine("data " + data.Id + " stockcode " + data.StockCode); return(data); }