Пример #1
0
        public void SaveOrders(IEnumerable <Order> orders)
        {
            var allOrders = orders.ToList();

            if (!allOrders.Any())
            {
                return;
            }

            var detailList      = new List <ManhattanPickTicketDetail>();
            var headerList      = new List <ManhattanPickTicketHeader>();
            var instructionList = new List <ManhattanPickTicketInstruction>();

            var warehouseNumber  = _configuration.GetKey <string>(ConfigurationKey.WarehouseNumber);
            var companyNumber    = _configuration.GetKey <string>(ConfigurationKey.CompanyNumber);
            var warehouseAddress = _configuration.GetWarehouseAddress();

            var controlNumber      = _configuration.GetBatchControlNumber();
            var batchControlNumber = warehouseNumber + controlNumber.ToString("D8");

            foreach (var order in allOrders)
            {
                order.BillingAddress = warehouseAddress;

                headerList.Add(new ManhattanPickTicketHeader(order, batchControlNumber, companyNumber, warehouseNumber, "CDS", _countryReader, _carrierRepository));
                detailList.AddRange(CombineItems(order, batchControlNumber, companyNumber, warehouseNumber));
                var instructionControlNumber = 1;
                foreach (var instruction in order.SpecialInstructions)
                {
                    instructionList.Add(new ManhattanPickTicketInstruction("VA", "VA", instruction, batchControlNumber, order.ControlNumber, instructionControlNumber));
                    instructionControlNumber++;
                }
                instructionList.AddRange(GetGlobalInstructions(order, batchControlNumber, instructionControlNumber));
            }

            var headerPath      = _configuration.GetPath(ManhattanDataFileType.PickHeader, controlNumber);
            var detailPath      = _configuration.GetPath(ManhattanDataFileType.PickDetail, controlNumber);
            var instructionPath = _configuration.GetPath(ManhattanDataFileType.PickSpecialInstructions, controlNumber);

            _headerFileRepository.Save(headerList, headerPath);
            _detailFileRepository.Save(detailList, detailPath);
            _instructionFileRepository.Save(instructionList, instructionPath);

            _transferControlManager.SaveTransferControl(batchControlNumber,
                                                        new List <string> {
                headerPath, detailPath, instructionPath
            },
                                                        _jobRepository.GetJob(JobKey.PickJob).JobId);
        }
Пример #2
0
 public long GetBatchControlNumber()
 {
     return(_configurationManager.GetBatchControlNumber());
 }