protected override void Process() { _monitoring.Notify(Name, 0); log.InfoFormat("Start processing Product Price Update"); var vendorIDsToProcess = VendorSettingsHelper.GetVendorIDsToExportToWehkamp(log); foreach (var vendorID in vendorIDsToProcess) { _monitoring.Notify(Name, vendorID); log.InfoFormat("Start processing Product Price Update for VendorID {0}", vendorID); var runDateTime = DateTime.Now; //Get all price updates that we need to export to Wehkamp var products = GetProductsWithChangedPricesData(vendorID); if (products == null || products.Count == 0) { log.InfoFormat("There are no price updates for VendorID {0}", vendorID); //Update last processed datetime for vendor VendorSettingsHelper.SetLastPriceExportDateTime(vendorID, runDateTime); continue; } log.InfoFormat("Processing {0} Product Price Updates records for VendorID {1}", products.Count, vendorID); //Add all products to the artikelInformatie file var priceChange = new prijsAanpassing { aanpassing = new List <prijsAanpassingAanpassing>() }; foreach (var product in products) { priceChange.aanpassing.Add(CreateNewPrijsAanpassingItem(product)); } //Save data to disk SavePriceChanges(vendorID, priceChange); //Process products which needs a price update file ProcessResendProductInformationToWehkampProducts(products); //Update last processed datetime for vendor VendorSettingsHelper.SetLastPriceExportDateTime(vendorID, runDateTime); log.InfoFormat("Finished processing Product Price Update for VendorID {0}", vendorID); } //end foreach (var vendorID in vendorIDsToProcess) log.InfoFormat("Finished processing Product Price Update"); _monitoring.Notify(Name, 1); }
/// <summary> /// Deserializes workflow markup into an prijsAanpassing object /// </summary> /// <param name="xml">string workflow markup to deserialize</param> /// <param name="obj">Output prijsAanpassing object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool Deserialize(string xml, out prijsAanpassing obj, out System.Exception exception) { exception = null; obj = default(prijsAanpassing); try { obj = Deserialize(xml); return(true); } catch (System.Exception ex) { exception = ex; return(false); } }
/// <summary> /// Deserializes xml markup from file into an prijsAanpassing object /// </summary> /// <param name="fileName">string xml file to load and deserialize</param> /// <param name="obj">Output prijsAanpassing object</param> /// <param name="exception">output Exception value if deserialize failed</param> /// <returns>true if this XmlSerializer can deserialize the object; otherwise, false</returns> public static bool LoadFromFile(string fileName, out prijsAanpassing obj, out System.Exception exception) { exception = null; obj = default(prijsAanpassing); try { obj = LoadFromFile(fileName); return(true); } catch (System.Exception ex) { exception = ex; return(false); } }
private void SavePriceChanges(int vendorID, prijsAanpassing priceChange) { var alliantieName = VendorSettingsHelper.GetAlliantieName(vendorID); var retailPartnerCode = VendorSettingsHelper.GetRetailPartnerCode(vendorID); var sequenceNumber = CommunicatorHelper.GetSequenceNumber(vendorID); priceChange.header.berichtDatumTijd = DateTime.Now; priceChange.header.berichtNaam = "prijsAanpassing"; priceChange.header.retailPartnerCode = retailPartnerCode; priceChange.header.bestandsNaam = string.Format("{0}{1}prijsAanpassing.xml", sequenceNumber, alliantieName); var messageIDPriceChange = MessageHelper.InsertMessage(MessageHelper.WehkampMessageType.ProductPriceUpdate, priceChange.header.bestandsNaam, vendorID); try { priceChange.SaveToFile(string.Format(Path.Combine(ConfigurationHelper.ProductPricesRootFolder, vendorID.ToString(CultureInfo.InvariantCulture), priceChange.header.bestandsNaam))); MessageHelper.UpdateMessageStatus(messageIDPriceChange, WehkampMessageStatus.Success); } catch (Exception ex) { log.Fatal("Error while saving Price Change file", ex); MessageHelper.UpdateMessageStatus(messageIDPriceChange, WehkampMessageStatus.Error); } }
public static bool LoadFromFile(string fileName, out prijsAanpassing obj) { System.Exception exception = null; return(LoadFromFile(fileName, out obj, out exception)); }
public static bool Deserialize(string xml, out prijsAanpassing obj) { System.Exception exception = null; return(Deserialize(xml, out obj, out exception)); }