public virtual ActionResult GetFile(string fileName)
        {
            LogI("GetFile, filename=" + fileName);

            var path = UrlHelper.GetLabelPath(fileName);

            return(File(path, "application/pdf", "label"));
        }
        public virtual ActionResult GetFile(string fileName)
        {
            LogI("GetFile, fileName=" + fileName);

            var path = UrlHelper.GetLabelPath(fileName);

            return(File(path, "image/jpeg", Path.GetFileName(path)));
        }
        public virtual ActionResult GetLabelPrintFile(long id)
        {
            LogI("GetLabelPrintFile, id=" + id);

            var labelFile = Db.LabelPrintPacks.Get(id);

            if (labelFile != null)
            {
                var model    = new LabelPrintPackViewModel(labelFile);
                var path     = UrlHelper.GetLabelPath(labelFile.FileName);
                var filename = model.IsReturn ? model.NumberOrPerson : "Label " + model.NumberOrPerson;
                return(File(path, FileHelper.GetMimeTypeByExt(Path.GetExtension(path)), filename + Path.GetExtension(path)));
            }

            return(new EmptyResult());
        }
Esempio n. 4
0
        public static void FillItemsWithAdditionalInfo(IUnitOfWork db,
                                                       IWeightService weightService,
                                                       string orderNumber,
                                                       IList <DTOOrderItem> orderItems)
        {
            var orderInfo        = db.ItemOrderMappings.GetOrderWithItems(weightService, orderNumber, true, includeSourceItems: false);
            var sourceOrderItems = orderInfo.Items;

            foreach (var orderItem in orderItems)
            {
                var sourceOrderItem = sourceOrderItems.FirstOrDefault(i => i.ItemOrderId == orderItem.ItemOrderId);
                if (sourceOrderItem != null)
                {
                    orderItem.SourceItemOrderId = sourceOrderItem.SourceItemOrderIdentifier;

                    if (orderItem.StyleItemId == sourceOrderItem.StyleItemId ||
                        orderItem.StyleEntityId == sourceOrderItem.StyleId)
                    {
                        orderItem.Title       = sourceOrderItem.Title;
                        orderItem.StyleSize   = sourceOrderItem.StyleSize;
                        orderItem.ItemPicture = sourceOrderItem.ItemPicture;
                        if (String.IsNullOrEmpty(orderItem.ItemPicture))
                        {
                            orderItem.ItemPicture = sourceOrderItem.StyleImage;
                        }
                        orderItem.Locations = sourceOrderItem.Locations;
                    }
                    if (orderItem.StyleItemId != sourceOrderItem.StyleItemId)
                    {
                        if (orderItem.StyleItemId.HasValue)
                        {
                            var styleItem = db.StyleItems.Get(orderItem.StyleItemId.Value);
                            if (styleItem != null)
                            {
                                orderItem.StyleSize = styleItem.Size;
                            }
                        }
                    }
                    if (orderItem.StyleEntityId != sourceOrderItem.StyleId)
                    {
                        if (orderItem.StyleEntityId.HasValue)
                        {
                            var style     = db.Styles.Get(orderItem.StyleEntityId.Value);
                            var locations =
                                db.StyleLocations.GetByStyleIdsAsDto(new List <long>()
                            {
                                orderItem.StyleEntityId.Value
                            });
                            if (style != null)
                            {
                                orderItem.Title       = style.Name;
                                orderItem.ItemPicture = style.Image;
                            }
                            orderItem.Locations = locations;
                        }
                    }
                    orderItem.ItemPicture = UrlHelper.GetThumbnailUrl(orderItem.ItemPicture,
                                                                      0,
                                                                      75,
                                                                      false,
                                                                      ImageHelper.NO_IMAGE_URL,
                                                                      convertToFullUrl: true);
                }
            }
        }
Esempio n. 5
0
        public IList <MessageString> Generate(ILogService log,
                                              ITime time,
                                              ILabelService labelService,
                                              IQuantityManager quantityManager,
                                              IUnitOfWork db,
                                              IWeightService weightService,
                                              IShippingService shippingService,
                                              bool sampleMode,
                                              DateTime when,
                                              long?by)
        {
            var results = new List <MessageString>();

            //Cancel privious
            if (CancelCurrentOrderLabel)
            {
                var cancelResults = CancelCurrentOrderLabels(log,
                                                             db,
                                                             labelService,
                                                             time,
                                                             OrderEntityId.Value,
                                                             sampleMode);

                results.AddRange(cancelResults);
            }

            //Print new
            var printResult = GenerateLabel(db,
                                            labelService,
                                            weightService,
                                            shippingService,
                                            this,
                                            time.GetAppNowTime(),
                                            by);

            if (printResult.Success)
            {
                //Remove from batch if unshipped
                var wasRemoved = RemoveFromBatchIfUnshipped(log,
                                                            db,
                                                            OrderEntityId.Value);
                if (wasRemoved)
                {
                    results.Add(MessageString.Success("Order was removed from batch"));
                }
            }

            //Processing print result
            Messages.AddRange(printResult.Messages.Select(m => MessageString.Error(m.Text)).ToList());
            IsPrinted             = printResult.Success;
            PrintedLabelPath      = printResult.Url;
            PrintedLabelUrl       = UrlHelper.GetPrintLabelPathById(printResult.PrintPackId);
            PrintedTrackingNumber = printResult.TrackingNumber;

            if (ReduceInventory)
            {
                AddQuantityOperation(log,
                                     db,
                                     quantityManager,
                                     OrderID,
                                     Items.Select(i => i.GetItemDto()).ToList(),
                                     time,
                                     by);

                results.Add(MessageString.Success("Inventory quantity was adjusted"));
            }

            //Add to track table
            if (ReasonCode == (int)MailLabelReasonCodes.ReturnLabelReasonCode)
            {
                AddToOrderTracking(log,
                                   db,
                                   OrderID,
                                   printResult.TrackingNumber,
                                   printResult.Carrier,
                                   when,
                                   by);

                results.Add(MessageString.Success("Tracking number was added to Track Orders list"));
            }

            if (OrderEntityId.HasValue &&
                !String.IsNullOrEmpty(OrderComment))
            {
                db.OrderComments.Add(new OrderComment()
                {
                    OrderId    = OrderEntityId.Value,
                    Message    = OrderComment, // "[System] Returned",
                    Type       = (int)CommentType.ReturnExchange,
                    CreateDate = when,
                    CreatedBy  = by
                });
                db.Commit();

                results.Add(MessageString.Success("Comment was added"));
            }

            if (printResult.Success && !string.IsNullOrEmpty(printResult.Url))
            {
                log.Info(string.Format("LabelPath for {0} order: {1}",
                                       string.IsNullOrEmpty(OrderID) ? "Ebay" : OrderID, printResult.Url));
            }


            if (printResult.Success && UpdateAmazon)
            {
                results.Add(MessageString.Success("Send the order update to the market was scheduled"));
            }

            return(results);
        }