Beispiel #1
0
        protected override void Process()
        {
            _monitoring.Notify(Name, 0);
            log.InfoFormat("Start processing Stock Return Request");

            var vendorIDsToProcess = VendorSettingsHelper.GetVendorIDsToExportToWehkamp(log);

            foreach (var vendorID in vendorIDsToProcess)
            {
                _monitoring.Notify(Name, vendorID);
                log.InfoFormat("Start processing Stock Return Request for VendorID {0}", vendorID);

                //Get all stock return request that we need to export to Wehkamp
                var stockReturns = GetStockReturnRequestData(vendorID);
                if (stockReturns == null || stockReturns.Count == 0)
                {
                    continue;
                }

                //Add all return requests to the retourAanvraag file
                var returnRequest = new retourAanvraag();

                log.InfoFormat("Start processing {0} Stock Return Requests for VendorID {1}", stockReturns.Count, vendorID);
                var start          = DateTime.Now;
                var processedCount = 0;
                foreach (var stockReturn in stockReturns)
                {
                    returnRequest.aanvraag.Add(CreateNewReturnRequestItem(stockReturn));

                    processedCount++;
                    if (DateTime.Now > start.AddSeconds(30))
                    {
                        log.InfoFormat("Processed {0} Stock Return Requests for VendorID {1}", processedCount, vendorID);
                        start = DateTime.Now;
                    }
                }

                //Save data to disk
                log.InfoFormat("Start saving Stock Return Requests");
                SaveStockReturn(vendorID, returnRequest);

                //Set all orders and orderlines as dispatched
                log.InfoFormat("Start setting Stock Return Requests as dispatched");
                SetReturnRequestsAsExportedToWehkamp(stockReturns);

                log.InfoFormat("Finished processing Stock Return Requests for VendorID {0}", vendorID);
            } //end foreach (var vendorID in vendorIDsToProcess)

            log.InfoFormat("Finished processing Stock Return Requests");
            _monitoring.Notify(Name, 1);
        }
Beispiel #2
0
 /// <summary>
 /// Deserializes workflow markup into an retourAanvraag object
 /// </summary>
 /// <param name="xml">string workflow markup to deserialize</param>
 /// <param name="obj">Output retourAanvraag 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 retourAanvraag obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(retourAanvraag);
     try
     {
         obj = Deserialize(xml);
         return(true);
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Deserializes xml markup from file into an retourAanvraag object
 /// </summary>
 /// <param name="fileName">string xml file to load and deserialize</param>
 /// <param name="obj">Output retourAanvraag 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 retourAanvraag obj, out System.Exception exception)
 {
     exception = null;
     obj       = default(retourAanvraag);
     try
     {
         obj = LoadFromFile(fileName);
         return(true);
     }
     catch (System.Exception ex)
     {
         exception = ex;
         return(false);
     }
 }
Beispiel #4
0
        private void SaveStockReturn(int vendorID, retourAanvraag stockReturnRequest)
        {
            var alliantieName     = VendorSettingsHelper.GetAlliantieName(vendorID);
            var retailPartnerCode = VendorSettingsHelper.GetRetailPartnerCode(vendorID);
            var sequenceNumber    = CommunicatorHelper.GetSequenceNumber(vendorID);

            stockReturnRequest.header.berichtDatumTijd  = DateTime.Now;
            stockReturnRequest.header.berichtNaam       = "retourAanvraag";
            stockReturnRequest.header.retailPartnerCode = retailPartnerCode;
            stockReturnRequest.header.bestandsNaam      = string.Format("{0}{1}retourAanvraag.xml", sequenceNumber, alliantieName);

            var messageID = MessageHelper.InsertMessage(MessageHelper.WehkampMessageType.StockReturnRequest, stockReturnRequest.header.bestandsNaam, vendorID);

            try
            {
                stockReturnRequest.SaveToFile(string.Format(Path.Combine(ConfigurationHelper.StockReturnRequestRootFolder, vendorID.ToString(CultureInfo.InvariantCulture), stockReturnRequest.header.bestandsNaam)));
                MessageHelper.UpdateMessageStatus(messageID, WehkampMessageStatus.Success);
            }
            catch (Exception ex)
            {
                log.Fatal("Error while saving retourAanvraag file", ex);
                MessageHelper.UpdateMessageStatus(messageID, WehkampMessageStatus.Error);
            }
        }
Beispiel #5
0
 public static bool LoadFromFile(string fileName, out retourAanvraag obj)
 {
     System.Exception exception = null;
     return(LoadFromFile(fileName, out obj, out exception));
 }
Beispiel #6
0
 public static bool Deserialize(string xml, out retourAanvraag obj)
 {
     System.Exception exception = null;
     return(Deserialize(xml, out obj, out exception));
 }