private FileTransferConfigurationModel getFileTransferConfigurationModel(PurchaseOrderHeader poh, FileRecipient fileRecipient) { FileTransferConfigurationModel template = null; switch (fileRecipient) { case FileRecipient.Warehouse: LocationModel warehouse = null; if (poh.LocationId != null) { warehouse = LookupService.FindLocationModel(poh.LocationId.Value, false); } if (warehouse != null) { template = DataTransferService.FindFileTransferConfigurationForWarehouseModel(warehouse, FileTransferDataType.WarehousePurchase); } break; case FileRecipient.FreightForwarder: FreightForwarderModel freightForwarder = null; if (poh.FreightForwarderId != null) { freightForwarder = LookupService.FindFreightForwarderModel(poh.FreightForwarderId.Value, false); } if (freightForwarder != null) { template = DataTransferService.FindFileTransferConfigurationForFreightForwarder(freightForwarder, FileTransferDataType.FreightForwarderPurchase); } break; } return(template); }
private Error createDocuments(CompanyModel company, List <PickHeaderModel> picks) { var error = new Error(); var pick = picks.FirstOrDefault(); // Validation ensures that there will always be at least one pick var location = LookupService.FindLocationModel(pick.LocationId.Value, false); if (location != null && location.LocationIdentification.ToLower() == "warehouse") { // Warehouse requires supporting PDF document // TBD: The type of PDF is specified in the customer record // Combined orders can only be for the same customer, so there will only // ever be one customer, irrespective of single or combined picks. var customer = db.FindCustomer(pick.CustomerId ?? 0); if (customer == null) { error.SetRecordError("Customer", pick.CustomerId ?? 0); } else { var template = LookupService.FindDocumentTemplateModel(customer.ShippingTemplateId ?? 0); var config = DataTransferService.FindFileTransferConfigurationForWarehouseModel(location, FileTransferDataType.WarehousePick); if (config == null) { error.SetError(EvolutionResources.errCannotDropOrderNoDataTransfer, pick.Id.ToString(), location.LocationName); } else { var pdfFile = MediaServices.GetMediaFolder(MediaFolder.Temp, company.Id) + DataTransferService.GetTargetFileName(config, "", pick.Id).ChangeExtension(".pdf"); string outputFile = ""; error = CreatePickDocumentPdf(pick, template, pdfFile, false, ref outputFile, int.MaxValue); pick.PickFiles.Add(outputFile); // TBD: Add the document to the sale notes/attachments } } } return(error); }