/// <summary> /// Deserializes workflow markup into an aankomst object /// </summary> /// <param name="xml">string workflow markup to deserialize</param> /// <param name="obj">Output aankomst 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 aankomst obj, out System.Exception exception) { exception = null; obj = default(aankomst); try { obj = Deserialize(xml); return(true); } catch (System.Exception ex) { exception = ex; return(false); } }
/// <summary> /// Deserializes xml markup from file into an aankomst object /// </summary> /// <param name="fileName">string xml file to load and deserialize</param> /// <param name="obj">Output aankomst 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 aankomst obj, out System.Exception exception) { exception = null; obj = default(aankomst); try { obj = LoadFromFile(fileName); return(true); } catch (System.Exception ex) { exception = ex; return(false); } }
private void SaveShipmentInformation(int vendorID, aankomst shipment, PetaPoco.Database db = null) { var alliantieName = VendorSettingsHelper.GetAlliantieName(vendorID); var retailPartnerCode = VendorSettingsHelper.GetRetailPartnerCode(vendorID); var sequenceNumberShipment = CommunicatorHelper.GetSequenceNumber(vendorID); shipment.header.berichtDatumTijd = DateTime.Now; shipment.header.berichtNaam = "aankomst"; shipment.header.retailPartnerCode = retailPartnerCode; shipment.header.bestandsNaam = string.Format("{0}{1}aankomst.xml", sequenceNumberShipment, alliantieName); var messageIDShipment = MessageHelper.InsertMessage(MessageHelper.WehkampMessageType.ShipmentNotification, shipment.header.bestandsNaam, vendorID, db); try { shipment.SaveToFile(Path.Combine(ConfigurationHelper.ShipmentNotificationRootFolder, vendorID.ToString(CultureInfo.InvariantCulture), shipment.header.bestandsNaam)); MessageHelper.UpdateMessageStatus(messageIDShipment, WehkampMessageStatus.Success, db); } catch (Exception ex) { log.Fatal("Error while saving aankomst file", ex); MessageHelper.UpdateMessageStatus(messageIDShipment, WehkampMessageStatus.Error); } }
public static bool LoadFromFile(string fileName, out aankomst obj) { System.Exception exception = null; return(LoadFromFile(fileName, out obj, out exception)); }
public static bool Deserialize(string xml, out aankomst obj) { System.Exception exception = null; return(Deserialize(xml, out obj, out exception)); }
protected override void Process() { _monitoring.Notify(Name, 0); log.InfoFormat("Start processing Shipment Notification"); var vendorIDsToProcess = VendorSettingsHelper.GetVendorIDsToExportToWehkamp(log); foreach (var vendorID in vendorIDsToProcess) { _monitoring.Notify(Name, vendorID); log.InfoFormat("Start processing Shipment Notification for VendorID {0}", vendorID); var dummyProductIDsInFile = new List <int>(); //Get all products in shipment notification that we need to export to Wehkamp var products = GetShipmentNotificationProductInformationData(vendorID); if (products == null || products.Count == 0) { continue; } //Add all products to the artikelInformatie file that aren't sent to Wehkamp before var artInfo = new artikelInformatie(); //Add all products to the aankomst file var shipmentInfo = new aankomst(); foreach (var product in products) { shipmentInfo.aankomsten.Add(CreateNewShipmentItem(product, vendorID)); //Create dummy product if parentproduct isn't sent to Wehkamp (as dummy or regular product) if ((string.IsNullOrEmpty(product.ParentSentToWehkamp) || product.ParentSentToWehkamp.ToLower(CultureInfo.InvariantCulture) == "false") && (string.IsNullOrEmpty(product.ParentSentToWehkampAsDummy) || product.ParentSentToWehkampAsDummy.ToLower(CultureInfo.InvariantCulture) == "false") && !dummyProductIDsInFile.Contains(product.ParentProductID)) { var artikel = CreateNewDummyArtikelInformatieArtikel(product); var sizes = GetDummyProductSizes(vendorID, product.ParentProductID); foreach (var size in sizes) { artikel.maatlijst.Add(CreateNewDummyArtikelInformatieMaatGegevens(size)); } artInfo.artikel.Add(artikel); if (!dummyProductIDsInFile.Contains(product.ParentProductID)) { dummyProductIDsInFile.Add(product.ParentProductID); } if (!dummyProductIDsInFile.Contains(product.ProductID)) { dummyProductIDsInFile.Add(product.ProductID); } } } var orderIDs = products.Select(p => p.OrderID).Distinct().ToList(); using (var db = new PetaPoco.Database(Environments.Current.Connection, "System.Data.SqlClient")) { db.BeginTransaction(System.Data.IsolationLevel.ReadCommitted); db.CommandTimeout = 60; try { var updateOrdersSql = string.Format("UPDATE [Order] SET IsDispatched = 1, DispatchToVendorDate = getdate() WHERE OrderID IN ({0})", string.Join(",", orderIDs.ToArray())); db.Execute(updateOrdersSql); foreach (var orderID in orderIDs) { var id = orderID; var item = from p in products where p.OrderID == id select p; var orderLineIDs = item.Select(p => p.OrderLineID).Distinct().ToList(); var updateOrderLinesSql = string.Format("UPDATE [OrderLine] SET IsDispatched = 1, DispatchedToVendorID = {1} WHERE OrderLineID IN ({0})", string.Join(",", orderLineIDs.ToArray()), vendorID); db.Execute(updateOrderLinesSql); } //Save data to disk if (artInfo.artikel.Count != 0) { SaveProductInformation(vendorID, artInfo, db); //Set all dummy products as SentToAsDummyWehkamp = true SetDummyProductsAsSentAsDummyToWehkamp(dummyProductIDsInFile, db); } SaveShipmentInformation(vendorID, shipmentInfo, db); db.CompleteTransaction(); } catch (Exception e) { db.AbortTransaction(); log.AuditError("Something went wrong while updating the order dispatched status or saving the files in the wehkamp drives", e); } } log.InfoFormat("Finished processing Shipment Notification for VendorID {0}", vendorID); } //end foreach (var vendorID in vendorIDsToProcess) log.InfoFormat("Finished processing Shipment Notification"); _monitoring.Notify(Name, 1); }