public ESResultModel ByTaxId(string taxId) { if (taxId.Length != 8) { return(null); } Guid correlationId = Guid.NewGuid(); Stopwatch watch = Stopwatch.StartNew(); logger.Debug($"{correlationId} - Search ES Request by taxId:{taxId} started"); CompanyESProvider provider = new CompanyESProvider(correlationId); ESResultModel result; try { result = provider.GetCompanyByTaxId(taxId); } catch (Exception e) { logger.Error($"{correlationId} - Error appeared: {e}"); result = new ESResultModel(); result.Errors.Add("Request failed"); return(result); } logger.Debug($"{correlationId} - Search ES Request by taxId:{taxId} finished. Time:{watch.Elapsed}"); result.TimeTaken = watch.Elapsed; return(result); }
public ESResultModel By(string name = "", string city = "", string taxId = "") { Guid correlationId = Guid.NewGuid(); Stopwatch watch = Stopwatch.StartNew(); logger.Debug($"{correlationId} - Search ES Data Request for {{taxId:{taxId}, name:{name}, city:{city}}} started"); CompanyESProvider provider = new CompanyESProvider(correlationId); ESResultModel result; try { result = provider.Search(taxId, name, city); } catch (Exception e) { logger.Error($"{correlationId} - Error appeared: {e}"); result = new ESResultModel(); result.Errors.Add("Request failed"); return(result); } logger.Debug($"{correlationId} - Search ES Request ended. Time:{watch.Elapsed}"); result.TimeTaken = watch.Elapsed; return(result); }
public ESResultModel Search(string taxId = "", string name = "", string city = "") { Logger.Debug($"{CorrelationId} - Request with query:{{taxId:{taxId}, name: {name}, city: {city}}} started"); Stopwatch timer = Stopwatch.StartNew(); string url = PrepareUrl(new Dictionary <string, string> { { "ico", taxId }, { "obch_jm", name }, { "obec", city } }); Logger.Debug($"{CorrelationId} - Generated Url for ES request: {url}"); Ares_odpovedi aresResponse = WebRequestHelper.XmlWebRequestSequence <Ares_odpovedi>( url); Logger.Debug($"{CorrelationId} - Got response from ARES. Time:{timer.Elapsed}"); timer.Restart(); ESResultModel result = BaseMapper.MapESData(aresResponse); Logger.Debug($"{CorrelationId} - Ares response mapped. Time:{timer.Elapsed}"); return(result); }
public ESResultModel GetCompanyByTaxId(string taxId) { Logger.Debug($"{CorrelationId} - Request for taxId:{taxId} started"); Stopwatch timer = Stopwatch.StartNew(); Ares_odpovedi ares = taxId.Length != 8 ? null : WebRequestHelper.XmlWebRequestSequence <Ares_odpovedi>(BaseUrl + "?ico=" + taxId); ESResultModel result; if (ares != null && ares.Odpoved.Help == null) { result = new ESResultModel { ItemsFound = Convert.ToInt16(ares.Odpoved.Pocet_zaznamu), Items = ares.Odpoved.V.S.Select(x => new ESCompanyModel { Address = x.Jmn, Name = x.Ojm, TaxId = x.Ico }).ToList() }; } else if (ares?.Odpoved.Help != null) { Logger.Debug($"{CorrelationId} - ARES response contains Help node. taxId:{taxId}. HelpMsg:{ares.Odpoved.Help.R}"); result = new ESResultModel { ItemsFound = 0, Items = null, Errors = ares.Odpoved.Help.R }; } else { return(null); } Logger.Debug($"{CorrelationId} - Request finished, Time: {timer.Elapsed}"); return(result); }