/// <remarks/> public void GetItemByGTINAsync(GetItemByGTIN GetItemByGTIN1, object userState) { if ((this.GetItemByGTINOperationCompleted == null)) { this.GetItemByGTINOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetItemByGTINOperationCompleted); } this.InvokeAsync("GetItemByGTIN", new object[] { GetItemByGTIN1}, this.GetItemByGTINOperationCompleted, userState); }
/// <remarks/> public System.IAsyncResult BeginGetItemByGTIN(GetItemByGTIN GetItemByGTIN1, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("GetItemByGTIN", new object[] { GetItemByGTIN1}, callback, asyncState); }
/// <remarks/> public void GetItemByGTINAsync(GetItemByGTIN GetItemByGTIN1) { this.GetItemByGTINAsync(GetItemByGTIN1, null); }
public Product GetProduct(string gtin) { var gepirProductService = WebServiceFactory.CreateProductServiceProxy(); var mappedProduct = new Product { GlobalTradeItemNumber = gtin, LastUpdated = DateTime.Now }; try { var paddedGtin = gtin.PadLeft(14, '0'); var getItemByGtin = new GetItemByGTIN { requestedGtin = paddedGtin, versionSpecified = false }; var itemByGtin = gepirProductService.GetItemByGTIN(getItemByGtin); // If request ok (return code 0) and product found if (gepirProductService.gepirResponseHeaderValue.returnCode == 0 && itemByGtin != null && itemByGtin.itemDataLine != null && itemByGtin.itemDataLine.Length > 0) { var gepirProduct = itemByGtin.itemDataLine[0]; //TODO Sometimes leads to NotSupportedException - Adding/Attaching an item that is not new //UpdateDomain(gepirProductService, gtin, gepirProduct); //mappedProduct = _productDomainService.FindProductByGtin(gtin, true); mappedProduct = _gepirProductMapper.Map(gepirProduct); } // If the product couldn't be found we can still get the GTIN owner else { var getPartyByGtin = new GetPartyByGTIN() { requestedGtin = new[] { paddedGtin }, versionSpecified = false }; var partyByGtin = gepirProductService.GetPartyByGTIN(getPartyByGtin); var brand = new Brand { LastUpdated = DateTime.Now }; if (gepirProductService.gepirResponseHeaderValue.returnCode == 0 && partyByGtin != null && partyByGtin.partyDataLine != null && partyByGtin.partyDataLine.Length > 0) { //using (var companyRepository = _repositoryFactory.Build<IRepository<Company>, Company>()) //{ var gepirCompany = partyByGtin.partyDataLine[0]; Company company = null; var matchingCompanies = _companyRepository.Find(x => x.CompanyName == gepirCompany.partyName); if (!matchingCompanies.Any()) { company = _gepirCompanyMapper.Map(gepirCompany); _companyRepository.Add(company); _companyRepository.Persist(); } else if (matchingCompanies.Count() == 1) { company = matchingCompanies.First(); } brand.Owner = company; mappedProduct.Brand = brand; //} } } } catch (Exception exception) { Log.Error("Gepir router threw an exception.", exception); if (gepirProductService.gepirResponseHeaderValue != null) { Log.Error("Gepir returnCode:", gepirProductService.gepirResponseHeaderValue.returnCode); } return(null); } return(mappedProduct); }