public void PrintPdfFromOrder(string amazonIdentifier)
        {
            var labelService = new LabelService(GetShipmentProviders(_company), _log, _time, _dbFactory, _emailService, new PdfMakerByIText(_log), AddressService.Default);

            using (var db = new UnitOfWork(_log))
            {
                var orderIds = from o in db.Orders.GetAll()
                               where o.AmazonIdentifier == amazonIdentifier
                               select o.Id;

                //var batchDto = db.OrderBatches.Get(734);

                var shippingList = db.OrderShippingInfos.GetOrderInfoWithItems(_weightService, orderIds.ToList(), (SortMode)SortMode.ByLocation, unmaskReferenceStyle: false, includeSourceItems: false)
                                   .ToList();
                shippingList = SortHelper.Sort(shippingList, SortMode.ByShippingMethodThenLocation).ToList();

                var mailList = db.MailLabelInfos.GetAllAsDto().Where(m => orderIds.Contains(m.OrderId)).ToList();
                shippingList.AddRange(mailList);

                var result = new PrintLabelResult();
                labelService.BuildPdfFile(shippingList.Where(sh => !String.IsNullOrEmpty(sh.LabelPath)).ToList(),
                                          new string[] { },
                                          null,
                                          AppSettings.LabelDirectory,
                                          ref result);
            }
        }
        public void PrintScanForm()
        {
            var outputDirectory = AppSettings.LabelDirectory;
            var labelService    = new LabelService(GetShipmentProviders(_company), _log, _time, _dbFactory, _emailService, _pdfMaker, AddressService.Default);

            var scanFormRelativePath = new string[] { "~\\ScanForms\\scanform_9475711201080820619182.jpg" };

            Console.WriteLine(scanFormRelativePath);

            var result = new PrintLabelResult();

            labelService.BuildPdfFile(new List <OrderShippingInfoDTO>(),
                                      scanFormRelativePath,
                                      null,
                                      outputDirectory,
                                      ref result);
        }
        public void PrintPdfFromOrders()
        {
            var labelService = new LabelService(GetShipmentProviders(_company), _log, _time, _dbFactory, _emailService, new PdfMakerByIText(_log), AddressService.Default);

            using (var db = new UnitOfWork(_log))
            {
                var batchId = 1887;

                var orderIds = from o in db.Orders.GetAll()
                               join sh in db.OrderShippingInfos.GetAll() on o.Id equals sh.OrderId
                               where o.BatchId == batchId &&
                               sh.IsActive &&
                               (sh.ShippingMethodId == ShippingUtils.DhlExpressWorldWideShippingMethodId ||
                                sh.ShippingMethodId == ShippingUtils.AmazonDhlExpressMXShippingMethodId)
                               select o.Id;

                var batchDto = db.OrderBatches.Get(batchId);

                var shippingList = db.OrderShippingInfos.GetOrderInfoWithItems(_weightService, orderIds.ToList(), (SortMode)SortMode.ByLocation, unmaskReferenceStyle: false, includeSourceItems: false)
                                   .ToList();
                shippingList = SortHelper.Sort(shippingList, SortMode.ByShippingMethodThenLocation).ToList();

                var mailList = db.MailLabelInfos.GetAllAsDto().Where(m => orderIds.Contains(m.OrderId)).ToList();
                shippingList.AddRange(mailList);

                var result = new PrintLabelResult();
                labelService.BuildPdfFile(shippingList.Where(sh => !String.IsNullOrEmpty(sh.LabelPath)).ToList(),
                                          new string[] { },
                                          new BatchInfoToPrint()
                {
                    BatchId          = batchDto.Id,
                    BatchName        = batchDto.Name,
                    Date             = _time.GetAmazonNowTime(),
                    NumberOfPackages = shippingList.Count
                },
                                          AppSettings.LabelDirectory,
                                          ref result);
            }
        }
        public void PrintPdfFromBatch(long batchId)
        {
            var labelService = new LabelService(GetShipmentProviders(_company), _log, _time, _dbFactory, _emailService, new PdfMakerByIText(_log), AddressService.Default);

            using (var db = new UnitOfWork(_log))
            {
                var orderIds = db.OrderBatches.GetOrderIdsForBatch(
                    batchId,
                    OrderStatusEnumEx.AllUnshippedWithShipped //for composing pdf file with all
                    );

                var batchDto = db.OrderBatches.Get(batchId);

                var shippingList = db.OrderShippingInfos.GetOrderInfoWithItems(_weightService, orderIds.ToList(), (SortMode)SortMode.ByLocation, unmaskReferenceStyle: false, includeSourceItems: false)
                                   .ToList();
                shippingList = SortHelper.Sort(shippingList, SortMode.ByShippingMethodThenLocation).Take(9).ToList().ToList();

                var result = new PrintLabelResult();
                labelService.BuildPdfFile(shippingList,
                                          new string[] { },
                                          new BatchInfoToPrint()
                {
                    BatchId          = batchId,
                    BatchName        = batchDto.Name,
                    NumberOfPackages = shippingList.Count,
                    Date             = _time.GetAmazonNowTime(),
                    Carriers         = shippingList.GroupBy(sh => sh.ShippingMethod.CarrierName)
                                       .Select(c => new {
                        Key   = c.Key,
                        Value = c.Count()
                    })
                                       .ToDictionary(d => d.Key, d => d.Value)
                },
                                          AppSettings.LabelDirectory,
                                          ref result);
            }
        }