Exemple #1
0
        public ActionResult AddShippingProvider(int shippingProviderId, string shippingProviderMethodId, bool autoselect = false)
        {
            var orderInfo = OrderHelper.GetOrder() ?? OrderHelper.CreateOrder();

            if (autoselect)
            {
                ShippingProviderHelper.AutoSelectShippingProvider(orderInfo);

                orderInfo.Save();
            }
            else
            {
                if (shippingProviderId == 0 || string.IsNullOrEmpty(shippingProviderMethodId))
                {
                    Session.Add(Constants.ShippingProviderSessionKey, ProviderActionResult.NoCorrectInput);
                    return(CurrentUmbracoPage());
                }

                var result = orderInfo.AddShippingProvider(shippingProviderId, shippingProviderMethodId);

                orderInfo.Save();

                Session.Add(Constants.ShippingProviderSessionKey, result);
            }

            return(CurrentUmbracoPage());
        }
Exemple #2
0
        // POST api/<controller>
        public OrderModel Post(OrderInputModel model)
        {
            try {
                _orderHelper = new OrderHelper();

                return(_orderHelper.CreateOrder(model));
            }
            catch (Exception ex) {
                return(null);
            }
        }
Exemple #3
0
        /// <summary>
        /// Gets the basket.
        /// </summary>
        /// <returns></returns>
        public static IBasket GetBasket()
        {
            OrderHelper.LogThis("ENTRY GetBasket()");
            var order = OrderHelper.GetOrder();

            if (order == null)
            {
                order = OrderHelper.CreateOrder();
            }

            return(CreateBasketFromOrderInfo(order));
        }
Exemple #4
0
        public ActionResult UpdateOrderline(int orderLineId, int quantity, Dictionary <string, int> variants, Dictionary <string, string> property, int productId = 0)
        {
            var order = OrderHelper.GetOrder() ?? OrderHelper.CreateOrder();

            var orderUpdater = IO.Container.Resolve <IOrderUpdatingService>();


            if (productId > 0 || orderLineId > 0)
            {
                orderUpdater.AddOrUpdateOrderLine(order, orderLineId, productId, "update", quantity, variants.Select(v => v.Value), property);                 // unit test dat dit aangeroepen wordt
                orderUpdater.Save(order);
            }

            return(CurrentUmbracoPage());
        }
Exemple #5
0
        public ActionResult AddPaymentProvider(int paymentProviderId, string paymentProviderMethodId)
        {
            var orderInfo = OrderHelper.GetOrderInfo() ?? OrderHelper.CreateOrder();


            if (paymentProviderId == 0 || string.IsNullOrEmpty(paymentProviderMethodId))
            {
                Session.Add(Constants.ShippingProviderSessionKey, ProviderActionResult.NoCorrectInput);
                return(CurrentUmbracoPage());
            }

            var result = orderInfo.AddPaymentProvider(paymentProviderId, paymentProviderMethodId);

            orderInfo.Save();

            Session.Add(Constants.ShippingProviderSessionKey, result);


            return(CurrentUmbracoPage());
        }
Exemple #6
0
        public ActionResult AddCoupon(string couponCode)
        {
            var orderInfo = OrderHelper.GetOrder() ?? OrderHelper.CreateOrder();

            var saveOrder = true;

            CouponCodeResult result = orderInfo.AddCoupon(couponCode);

            if (result != CouponCodeResult.Success)
            {
                saveOrder = false;
            }

            if (saveOrder)
            {
                orderInfo.Save();
            }

            Session.Add(Constants.CouponCodeSessionKey, result);

            return(CurrentUmbracoPage());
        }
Exemple #7
0
        /// <summary>
        /// Create, Add, Update the orderline
        /// </summary>
        /// <param name="order"></param>
        /// <param name="orderLineId">The Id of the orderline</param>
        /// <param name="productId">The productId</param>
        /// <param name="action">The action (add, update, delete, deleteall)</param>
        /// <param name="itemCount">The amount of items to be added</param>
        /// <param name="variantsList">The variants ID's added to the pricing</param>
        /// <param name="fields">Custom Fields</param>
        /// <exception cref="System.ArgumentException">
        /// productId and orderLineId equal or lower to 0
        /// or
        /// itemCountToAdd can't be smaller than 0
        /// </exception>
        /// <exception cref="System.Exception">
        /// Orderline not found
        /// </exception>
        public void AddOrUpdateOrderLine(OrderInfo order, int orderLineId, int productId, string action, int itemCount, IEnumerable <int> variantsList, Dictionary <string, string> fields = null)
        {
            //todo: function is too long
            //   separate control and logic
            //todo: function needs testing
            // todo: DIP

            var isWishList = order != null && order.Status == OrderStatus.Wishlist;

            if (!_cmsApplication.RequestIsInCMSBackend(HttpContext.Current) && !isWishList)
            {
                if (order == null || order.Paid.GetValueOrDefault(false) || (order.Status != OrderStatus.PaymentFailed && order.Status != OrderStatus.Incomplete && order.Status != OrderStatus.WaitingForPayment))
                {
                    Log.Instance.LogDebug("Starting new order for user" + (order == null ? "" : ", previous order: " + order.UniqueOrderId));
                    order = OrderHelper.CreateOrder();
                }

                if (order.Status == OrderStatus.PaymentFailed || order.Status == OrderStatus.WaitingForPayment)
                {
                    Log.Instance.LogDebug("Orderstatus WILL BE CHANGED FROM: " + order.Status);
                    order.Status = OrderStatus.Incomplete;
                }
            }
            if (order == null)
            {
                return;
            }

            // clear some stored values so they can be recalculated
            order.ClearCachedValues();

            if (itemCount == 0 && action != "update")
            {
                itemCount = 1;
            }

            if (productId <= 0 && orderLineId <= 0)
            {
                throw new ArgumentException("productId <= 0 && orderLineId <= 0");
            }

            if (itemCount < 0)
            {
                throw new ArgumentException("itemCount can't be smaller than 0");
            }

            Log.Instance.LogDebug("AddOrUpdateOrderLine Before action");

            var variants = variantsList.Where(v => v != 0).OrderBy(v => v);

            OrderLine orderLine = null;

            if (orderLineId != 0 && action != "new")
            {
                orderLine = order.OrderLines.FirstOrDefault(line => line.OrderLineId == orderLineId);
            }
            if (orderLine == null && action != "new")
            {
                orderLine = order.OrderLines.FirstOrDefault(line => line.ProductInfo.Id == productId && line.VariantsMatch(variants));
            }
            if (orderLineId != 0 && orderLine == null && action != "new")
            {
                throw new Exception("Orderline not found");
            }

            if (productId == 0 && orderLine != null)
            {
                productId = orderLine.ProductInfo.Id;
            }

            if (action == "add" || action == "new")
            {
                action = "update";
                if (orderLine != null)
                {
                    itemCount = (int)(orderLine.ProductInfo.ItemCount + itemCount);
                }
            }

            Log.Instance.LogDebug("AddOrUpdateOrderLine Before stock");

            if (productId != 0 && !isWishList)
            {
                var requestedItemCount = itemCount;
                var tooMuchStock       = false;

                var localization = StoreHelper.CurrentLocalization;
                var product      = _productService.GetById(productId, localization);
                if (product == null)
                {
                    Log.Instance.LogError("AddOrUpdateOrderLine can't find product with Id " + productId);
                }

                var higherItemList = new List <int>();
                foreach (var variant in variantsList.Select(variantId => _productVariantService.GetById(variantId, localization)))
                {
                    if (variant != null && variant.StockStatus && !variant.BackorderStatus && variant.Stock < requestedItemCount)
                    {
                        higherItemList.Add(variant.Id);
                        var stock = variant.Stock;
                        itemCount    = stock;
                        tooMuchStock = true;
                    }
                }

                if (product != null && !product.UseVariantStock && product.StockStatus && !product.BackorderStatus && product.Stock < itemCount)
                {
                    higherItemList.Add(product.Id);

                    itemCount    = product.Stock;
                    tooMuchStock = true;
                }

                if (HttpContext.Current != null && higherItemList.Any())
                {                 // todo: dit moet ook in handleobject komen
                    Session.Add(Constants.OrderedItemcountHigherThanStockKey, higherItemList);
                }

                if (HttpContext.Current != null)                 // todo: better decoupling
                {
                    ClientErrorHandling.SetOrClearErrorMessage(!tooMuchStock, "Ordered higher quantity than available stock. Updated the basked to available stock count", "Stock", requestedItemCount.ToString());
                }
            }

            if (itemCount < 1)
            {
                itemCount = 0;
            }

            if (action == "update" && itemCount == 0)
            {
                action = "delete";
            }

            Log.Instance.LogDebug("AddOrUpdateOrderLine Before update");

            #region update

            if (action == "update")
            {
                var beforeUpdatedEventArgs = order.FireBeforeOrderLineUpdatedEvent(orderLine);

                if (beforeUpdatedEventArgs == null || !beforeUpdatedEventArgs.Cancel)                 // todo: test the cancel
                {
                    if (orderLine == null)
                    {
                        order.FireBeforeOrderLineCreatedEvent();

                        if (orderLineId == 0)
                        {
                            orderLine = OrderProduct(productId, variants, itemCount, order);

                            if (!order.OrderLines.Any())
                            {
                                orderLine.OrderLineId = 1;
                            }
                            else
                            {
                                var firstOrDefault = order.OrderLines.OrderByDescending(x => x.OrderLineId).FirstOrDefault();
                                if (firstOrDefault != null)
                                {
                                    var highestOrderLineId = firstOrDefault.OrderLineId;
                                    orderLine.OrderLineId = highestOrderLineId + 1;
                                }
                            }
                        }
                        if (orderLine == null)
                        {
                            throw new Exception("Order line not found");
                        }

                        order.OrderLines.Add(orderLine);

                        order.FireAfterOrderLineCreatedEvent(orderLine);
                    }

                    if (orderLineId != 0)
                    {
                        orderLine.ProductInfo.ItemCount = itemCount;                         // todo: double with a few lines below?

                        // onderstaande regel gooit variants weg als ze niet in de lijst met ids zitten, dat is by design
                        orderLine.ProductInfo.ProductVariants = variants.Select(
                            variant => new ProductVariantInfo(DomainHelper.GetProductVariantById(variant), orderLine.ProductInfo, itemCount)).ToList();
                    }



                    orderLine.ProductInfo.ChangedOn = DateTime.Now;
                    orderLine.ProductInfo.ItemCount = itemCount;

                    UpdateProductInfoDiscountInformation(orderLine.ProductInfo);

                    foreach (var variant in orderLine.ProductInfo.ProductVariants)
                    {
                        variant.ChangedOn = DateTime.Now;
                    }

                    order.FireAfterOrderLineUpdatedEvent(orderLine);
                }

                //Log.Instance.LogDebug("AddOrUpdateOrderLine() UPDATE END: " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"));
            }

            #endregion

            #region delete

            if (action == "delete")
            {
                BeforeOrderLineDeletedEventArgs beforeDeletedEventArgs = order.FireBeforeOrderLineDeletedEvent(orderLine);

                if (beforeDeletedEventArgs == null || !beforeDeletedEventArgs.Cancel)
                {
                    order.OrderLines.Remove(orderLine);

                    order.FireAfterOrderLineDeletedEvent();
                }
            }

            #endregion

            // UPDATE SHIPPING & SET UPDATESHIPPINGCOSTS TO TRUE AFTER BASKET UPDATE
            //Log.Instance.LogDebug( "AddOrUpdateOrderLine() AutoSelectShippingProvider START: " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"));
            //AutoSelectShippingProvider();
            //Log.Instance.LogDebug( "AddOrUpdateOrderLine() AutoSelectShippingProvider END: " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"));
            order.ShippingCostsMightBeOutdated = true;
            //Log.Instance.LogDebug( "AddOrUpdateOrderLine() function END: " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"));

            if (fields == null)
            {
                return;
            }

            var xDoc = new XDocument(new XElement("Fields"));
            Log.Instance.LogDebug("AddOrUpdateOrderLine Before xdoc");

            if (orderLine != null && orderLine.ProductInfo != null && orderLine.ProductInfo.CatalogProduct != null)
            {
                AddFieldsToXDocumentBasedOnCMSDocumentType(xDoc, fields, orderLine.ProductInfo.CatalogProduct.NodeTypeAlias());
                orderLine._customData = xDoc;
            }
        }
        protected void DocumentAfterPublish(Document sender, PublishEventArgs e)
        {
            // when thinking about adding something here, consider ContentOnAfterUpdateDocumentCache!

            if (sender.Level > 2)
            {
                if (sender.ContentType.Alias == Order.NodeAlias || sender.Parent != null && (OrderedProduct.IsAlias(sender.ContentType.Alias) || sender.Parent.Parent != null && OrderedProductVariant.IsAlias(sender.ContentType.Alias)))
                {
                    var orderDoc = sender.ContentType.Alias == Order.NodeAlias ? sender : (OrderedProduct.IsAlias(sender.ContentType.Alias) && !OrderedProductVariant.IsAlias(sender.ContentType.Alias) ? new Document(sender.Parent.Id) : new Document(sender.Parent.Parent.Id));

                    if (orderDoc.ContentType.Alias != Order.NodeAlias)
                    {
                        throw new Exception("There was an error in the structure of the order documents");
                    }

                    // load existing orderInfo (why..? => possibly to preserve information not represented in the umbraco documents)

                    if (string.IsNullOrEmpty(orderDoc.getProperty("orderGuid").Value.ToString()))
                    {
                        Store store    = null;
                        var   storeDoc = sender.GetAncestorDocuments().FirstOrDefault(x => x.ContentType.Alias == OrderStoreFolder.NodeAlias);

                        if (storeDoc != null)
                        {
                            store = StoreHelper.GetAllStores().FirstOrDefault(x => x.Name == storeDoc.Text);
                        }

                        if (store == null)
                        {
                            store = StoreHelper.GetAllStores().FirstOrDefault();
                        }

                        var orderInfo = OrderHelper.CreateOrder(store);
                        IO.Container.Resolve <IOrderNumberService>().GenerateAndPersistOrderNumber(orderInfo);
                        orderInfo.Status = OrderStatus.Confirmed;
                        orderInfo.Save();

                        sender.SetProperty("orderGuid", orderInfo.UniqueOrderId.ToString());
                        sender.Save();
                    }
                    else
                    {
                        var orderGuid = Guid.Parse(orderDoc.getProperty("orderGuid").Value.ToString());

                        var orderInfo = OrderHelper.GetOrderInfo(orderGuid);

                        var order = new Order(orderDoc.Id);
                        orderInfo.CustomerEmail     = order.CustomerEmail;
                        orderInfo.CustomerFirstName = order.CustomerFirstName;
                        orderInfo.CustomerLastName  = order.CustomerLastName;

                        var dictionaryCustomer = orderDoc.GenericProperties.Where(x => x.PropertyType.Alias.StartsWith("customer")).ToDictionary(customerProperty => customerProperty.PropertyType.Alias, customerProperty => customerProperty.Value.ToString());
                        orderInfo.AddCustomerFields(dictionaryCustomer, CustomerDatatypes.Customer);

                        var dictionaryShipping = orderDoc.GenericProperties.Where(x => x.PropertyType.Alias.StartsWith("shipping")).ToDictionary(property => property.PropertyType.Alias, property => property.Value.ToString());
                        orderInfo.AddCustomerFields(dictionaryShipping, CustomerDatatypes.Shipping);

                        var dictionarExtra = orderDoc.GenericProperties.Where(x => x.PropertyType.Alias.StartsWith("extra")).ToDictionary(property => property.PropertyType.Alias, property => property.Value.ToString());
                        orderInfo.AddCustomerFields(dictionarExtra, CustomerDatatypes.Extra);

                        //orderInfo.SetVATNumber(order.CustomerVATNumber); happens in AddCustomerFields
                        var orderPaidProperty = order.Document.getProperty("orderPaid");
                        if (orderPaidProperty != null && orderPaidProperty.Value != null)
                        {
                            orderInfo.Paid = orderPaidProperty.Value == "1";
                        }

                        // load data recursively from umbraco documents into order tree
                        orderInfo.OrderLines = orderDoc.Children.Select(d =>
                        {
                            var fields = d.GenericProperties.Where(x => !OrderedProduct.DefaultProperties.Contains(x.PropertyType.Alias)).ToDictionary(s => s.PropertyType.Alias, s => d.GetProperty <string>(s.PropertyType.Alias));

                            var xDoc = new XDocument(new XElement("Fields"));

                            OrderUpdatingService.AddFieldsToXDocumentBasedOnCMSDocumentType(xDoc, fields, d.ContentType.Alias);

                            var orderedProduct = new OrderedProduct(d.Id);

                            var productInfo             = new ProductInfo(orderedProduct, orderInfo);
                            productInfo.ProductVariants = d.Children.Select(cd => new ProductVariantInfo(new OrderedProductVariant(cd.Id), productInfo, productInfo.Vat)).ToList();
                            return(new OrderLine(productInfo, orderInfo)
                            {
                                _customData = xDoc
                            });
                        }).ToList();

                        // store order
                        IO.Container.Resolve <IOrderRepository>().SaveOrderInfo(orderInfo);
                    }
                    // cancel does give a warning message balloon in Umbraco.
                    //e.Cancel = true;

                    //if (sender.ContentType.Alias != Order.NodeAlias)
                    //{
                    //	orderDoc.Publish(new User(0));
                    //}

                    //if (orderDoc.ParentId != 0)
                    //{
                    BasePage.Current.ClientTools.SyncTree(sender.Parent.Path, false);
                    BasePage.Current.ClientTools.ChangeContentFrameUrl(string.Concat("editContent.aspx?id=", sender.Id));
                    //}
                    //orderDoc.delete();
                    BasePage.Current.ClientTools.ShowSpeechBubble(BasePage.speechBubbleIcon.success, "Order Updated!", "This order has been updated!");
                }
            }
        }
Exemple #9
0
        public Dictionary <string, string> CreateOrder()
        {
            //get each order json pdf from FTP location

            var jsonFiles = new DirectoryInfo(_localProcessingPath + "\\Input\\").GetFiles("*.json");

            if (!jsonFiles.Any())
            {
                return(new Dictionary <string, string>());
            }

            Dictionary <string, string> processingSummary = new Dictionary <string, string>();

            foreach (var jsonFile in jsonFiles)
            {
                string json = "";
                SiteflowOrder.RootObject jsonObject = new SiteflowOrder.RootObject();
                bool exceptionJsonRead = false;
                try
                {
                    jsonObject = ReadJsonFile(jsonFile, ref json);
                }
                catch (Exception e)
                {
                    exceptionJsonRead = true;
                }

                if (exceptionJsonRead)
                {
                    processingSummary.Add(Path.GetFileName(jsonFile.FullName), "JSON structure issue- Order failed");
                    File.Delete(_localProcessingPath + "\\ProcessedInput\\" + Path.GetFileName(jsonFile.FullName));
                    continue;
                }

                var customerName = "";

                customerName = SetCustomerName(jsonObject, customerName);

                var sourceOrderId = "";
                try
                {
                    sourceOrderId = jsonObject.orderData.sourceOrderId;
                }
                catch
                {
                    processingSummary.Add(Path.GetFileNameWithoutExtension(jsonFile.FullName),
                                          "Error- Json structure issue");


                    if (File.Exists(_localProcessingPath + "\\ProcessedInput\\" + Path.GetFileName(jsonFile.FullName)))
                    {
                        File.Delete(_localProcessingPath + "\\ProcessedInput\\" + Path.GetFileName(jsonFile.FullName));
                    }

                    File.Move(jsonFile.FullName,
                              _localProcessingPath + "\\ProcessedInput\\" + Path.GetFileName(jsonFile.FullName));
                    continue;
                }

                var itemFound = _orderHelper.DoesOrderExists(sourceOrderId);

                if (itemFound)
                {
                    if (File.Exists(_localProcessingPath + "\\ProcessedInput\\" +
                                    Path.GetFileName(jsonFile.FullName)))
                    {
                        File.Delete(_localProcessingPath + "\\ProcessedInput\\" +
                                    Path.GetFileName(jsonFile.FullName));
                    }

                    File.Move(jsonFile.FullName,
                              _localProcessingPath + "\\ProcessedInput\\" + Path.GetFileName(jsonFile.FullName));

                    processingSummary.Add(sourceOrderId,
                                          "Order exists in database and order has already been pushed to siteflow");
                    continue;
                }

                if (jsonObject.orderData.shipments.Count > 0 && jsonObject.orderData.shipments[0].shipTo != null)
                {
                    if (string.IsNullOrEmpty(jsonObject.orderData.shipments[0].shipTo.address1) ||
                        string.IsNullOrEmpty(jsonObject.orderData.shipments[0].shipTo.town) ||
                        string.IsNullOrEmpty(jsonObject.orderData.shipments[0].shipTo.postcode))
                    {
                        if (File.Exists(_localProcessingPath + "\\ProcessedInput\\" +
                                        Path.GetFileName(jsonFile.FullName)))
                        {
                            File.Delete(_localProcessingPath + "\\ProcessedInput\\" +
                                        Path.GetFileName(jsonFile.FullName));
                        }

                        File.Move(jsonFile.FullName,
                                  _localProcessingPath + "\\ProcessedInput\\" + Path.GetFileName(jsonFile.FullName));

                        processingSummary.Add(sourceOrderId, "Error - Incomplete Address");
                        continue;
                    }
                }

                var orderDatetime = SetOrderDatetime(jsonObject);

                decimal orderTotal   = 0M;
                decimal deliveryCost = 0M;
                string  email        = "";
                string  telephone    = "";
                string  originalJson = json;

                ////create order and order details, address entry in database
                var orderId = _orderHelper.CreateOrder(sourceOrderId, orderDatetime, orderTotal, deliveryCost,
                                                       email, telephone, originalJson);

                var itemCount = jsonObject.orderData.items.Count;

                foreach (var item in jsonObject.orderData.items)
                {
                    var sourceItemId = item.sourceItemId;
                    var sku          = item.sku;

                    if (string.IsNullOrEmpty(sku))
                    {
                        if (processingSummary.ContainsKey(sourceOrderId))
                        {
                            processingSummary[sourceOrderId] += "NULL SKU - Order failed";
                        }
                        else
                        {
                            processingSummary.Add(sourceOrderId, "NULL SKU - Order failed");
                        }

                        break;
                    }

                    var qty    = item.quantity;
                    var pdfUri = item.components[0].path;

                    bool staticOrder = pdfUri != null && pdfUri.ToLower().Contains("static");

                    var pdfName = "";
                    if (staticOrder)
                    {
                        pdfName = pdfUri.Split('/').Last();
                    }

                    var partArray = pdfUri.Split(new char[] { '-' });

                    var pdfCount = 1;

                    if (itemCount > 1)
                    {
                        if (partArray.Length == 2)
                        {
                            partArray[1] = partArray[1].Replace(".pdf", "");

                            try
                            {
                                pdfCount = Convert.ToInt32(partArray[1]);
                            }
                            catch (Exception e)
                            {
                                pdfCount = 1;
                            }
                        }
                    }

                    bool hasMediaClipItem = !string.IsNullOrEmpty(item.supplierPartAuxiliaryId);

                    if (hasMediaClipItem)
                    {
                        staticOrder = false;
                    }

                    MediaClipFilesDownload(hasMediaClipItem, jsonObject, pdfCount);

                    var substrate = item.components[0].attributes.Substrate;

                    var pdfPath = _localProcessingPath + "/PDFS/";

                    var staticPdfPath = ConfigurationManager.AppSettings["StaticPDFPath"];

                    if (!sku.ToLower().Contains("photobook"))
                    {
                        if (staticOrder)
                        {
                            if (!File.Exists(staticPdfPath + pdfName))
                            {
                                //send email
                                processingSummary.Add(sourceOrderId + "-" + sourceItemId,
                                                      staticPdfPath + pdfName + " not found in static folder");

                                if (processingSummary.ContainsKey(sourceOrderId))
                                {
                                    processingSummary[sourceOrderId] += "Order failed";
                                }
                                else
                                {
                                    processingSummary.Add(sourceOrderId, "Order failed");
                                }

                                continue;
                            }

                            File.Copy(staticPdfPath + pdfName, pdfPath + sourceItemId + ".PDF", true);
                        }
                        else
                        {
                            if (!File.Exists(_localProcessingPath + "/PDFS/" + sourceOrderId + "-" + (pdfCount) +
                                             ".PDF"))
                            {
                                processingSummary.Add(sourceOrderId + "-" + sourceItemId,
                                                      sourceOrderId + "-" + (pdfCount) + ".PDF" + " PDF not found");

                                if (processingSummary.ContainsKey(sourceOrderId))
                                {
                                    processingSummary[sourceOrderId] += "Order failed";
                                }
                                else
                                {
                                    processingSummary.Add(sourceOrderId, "Order failed");
                                }

                                continue;
                            }

                            File.Copy(_localProcessingPath + "/PDFS/" + sourceOrderId + "-" + (pdfCount) + ".PDF",
                                      pdfPath + sourceItemId + ".PDF", true);
                        }
                    }

                    string orderfileName      = pdfPath + sourceItemId + ".PDF";
                    string ordersubstrateName = substrate;
                    string orderbarcode       = sourceItemId;
                    string orderorderId       = sourceOrderId;
                    string orderQty           = Convert.ToString(qty);

                    var originalOrderInputPath = ConfigurationManager.AppSettings["OriginalOrderInputPath"];

                    var finalPdfPath = originalOrderInputPath + "/Processed/" + orderorderId + "_" + orderbarcode +
                                       ".PDF";

                    if (sku.ToLower().Contains("photobook"))
                    {
                        PhotobookProcessing(sourceOrderId, originalOrderInputPath, orderorderId, orderbarcode, item);
                    }
                    else
                    {
                        File.Copy(_localProcessingPath + "/PDFS/" + sourceOrderId + "-" + (pdfCount) + ".PDF", finalPdfPath, true);
                        item.components[0].path =
                            "https://smilepdf.espsmile.co.uk/pdfs/Processed/" + orderorderId +
                            "_" + orderbarcode + ".PDF";
                    }

                    _orderHelper.AddOrderItem(orderId, sku, sourceItemId, qty, substrate, finalPdfPath);
                }

                var serializedResultJson = JsonConvert.SerializeObject(
                    jsonObject,
                    new JsonSerializerSettings {
                    NullValueHandling = NullValueHandling.Ignore
                });


                var goodOrder = IsGoodOrder(processingSummary, sourceOrderId);

                if (goodOrder)
                {
                    _orderHelper.SubmitModifiedSiteflowJson(orderId, serializedResultJson);
                }


                var fileName = Path.GetFileName(jsonFile.FullName);

                if (File.Exists(_localProcessingPath + "\\ProcessedInput\\" + fileName))
                {
                    File.Delete(_localProcessingPath + "\\ProcessedInput\\" + fileName);
                }

                File.Move(jsonFile.FullName.ToString(), _localProcessingPath + "\\ProcessedInput\\" + fileName);

                if (!processingSummary.ContainsKey(sourceOrderId))
                {
                    processingSummary.Add(sourceOrderId, "OK");
                }
            }

            return(processingSummary);
        }