public decimal SelectByXPath(Provider Provider) { string html = Resource.ResourceManager.GetString(Provider.Name); IFfeWebParser webParser = null; switch (WebParser) { case Parser.Auto: throw new Exception("No parse method available."); case Parser.HAP: webParser = new FfeWebHap(html); break; case Parser.AngleSharp: webParser = new FfeWebAngleSharp(html); break; case Parser.HttpClient: throw new Exception("No parse method available."); case Parser.WebClient: throw new Exception("No parse method available."); default: break; } string value = webParser.SelectByXPath(Provider.XPath); decimal price = decimal.Parse(value); return(price); }
private static (object Value, CbqInfo CbqInfo, IFfeWebParser WebParser) QueryConsorsbank(string isin_wkn, string exchange, string info) { object value = ExcelError.ExcelErrorNA; CbqInfo cbqInfo = CbqInfo.price; // Default IFfeWebParser webParser = null; try { if (!String.IsNullOrEmpty(info)) { info = info.ToLower(); cbqInfo = (CbqInfo)Enum.Parse(typeof(CbqInfo), info); if (!(Enum.IsDefined(typeof(CbqInfo), cbqInfo))) { throw new NotSupportedException("Not supported Info parameter value"); } } // Price if (cbqInfo == CbqInfo.price) { string url = CbqSetting.Default.QCB_URL; url = url.Replace("{ISIN_WKN}", isin_wkn); if (!String.IsNullOrEmpty(exchange)) { url += "?exchange={EXCHANGE}"; url = url.Replace("{EXCHANGE}", exchange); } log.Debug("Querying the stock info {@Info} for {@IsinWkn} from {@Provider}", cbqInfo.ToString(), isin_wkn, "consorsbank.de"); webParser = new FfeWebAngleSharp(new Uri(url)); string xPath = CbqSetting.Default.QCB_Price_XPath_Price; string quote = webParser.SelectByXPath(xPath); decimal price = decimal.Parse(quote, new CultureInfo("de-DE")); value = price; } } catch (FormatException fex) { log.Error(fex.Message); log.Debug("Could not parse {@QuoteValue} to decimal type", value); return(Value : ExcelError.ExcelErrorGettingData, CbqInfo : cbqInfo, WebParser : null); } catch (Exception ex) { log.Error(ex.Message); return(Value : ExcelError.ExcelErrorGettingData, CbqInfo : cbqInfo, WebParser : null); } return(value, cbqInfo, webParser); }