public static async Task <FmgQuoteOnlyPrice> RetrieveFmgQuoteOnlyPrice(string symbol) { string url = FmgBaseUrl + FmgQuoteOnlyPriceUrl + symbol; var responseTask = RetrieveFromUrl(url); string response = await responseTask; if (response == "{ }" || string.IsNullOrEmpty(response)) { throw new ArgumentException("FmgQuoteOnlyPrice null. " + symbol); } FmgQuoteOnlyPrice result = ParseStringToFmgQuoteOnlyPrice(response); return(result); }
public static async Task <UIComapnyRow> GetUICompanyRowTaskBySymbol(string symbol) //ex FormatException { //ex: ArgumentException, SystemException, FormatException try { DateTime start = DateTime.Now; FmgQuoteOnlyPrice fmgQuoteOnlyPrice = await RetrieveJsonDataHelper.RetrieveFmgQuoteOnlyPrice(symbol); //ex: ArgumentException FmgSingleQuote singleQuote = await RetrieveJsonDataHelper.RetrieveFmgSingleQuote(symbol); //ex: ArgumentException DateTime end = DateTime.Now; TimeSpan timeSpan = new TimeSpan(); timeSpan = end - start; Console.Out.WriteLine($"Time: {timeSpan.TotalMilliseconds} mills for {symbol}"); Company company = DatabaseHelper.GetCompanyFromDb(symbol); //ex: SystemException return(new UIComapnyRow(company, fmgQuoteOnlyPrice, singleQuote)); //ex: FormatException } catch (SystemException ex) { throw new SystemException(ex.Message); } }
private static async Task <UIComapnyRow> GetWatchUIComanyRowTask(int userId, Company company) { try { Stopwatch sw = Stopwatch.StartNew(); FmgQuoteOnlyPrice fmgQuoteOnlyPrice = await RetrieveJsonDataHelper.RetrieveFmgQuoteOnlyPrice(company.Symbol); FmgSingleQuote singleQuote = await RetrieveJsonDataHelper.RetrieveFmgSingleQuote(company.Symbol); UIComapnyRow companyRow = new UIComapnyRow(company, fmgQuoteOnlyPrice, singleQuote); //ex: FormatException sw.Stop(); Console.Out.WriteLine( $"\n---- Add one companyRow to result in GetWatchUICompanyRowList: {company.Symbol}, time: {sw.Elapsed.TotalMilliseconds} mills"); return(companyRow); } catch (SystemException ex) { throw new SystemException(ex.Message); } }