private void mapCallectionAddressDetail(ExpressShipmentModel shipmment, CollectionDetails collectionDetails) { collectionDetails.contactDetails = new ContactDetails() { contactName = shipmment.ShipFrom.FirstName + " " + shipmment.ShipFrom.LastName, telephone = shipmment.ShipFrom.Phone }; collectionDetails.address = new Address() { organisation = shipmment.ShipFrom.CompanyName, street = shipmment.ShipFrom.Address, town = shipmment.ShipFrom.City, locality = shipmment.ShipFrom.Address2, countryCode = shipmment.ShipFrom.Country.Code2, county = shipmment.ShipFrom.Country.Name, postcode = shipmment.ShipFrom.PostCode, }; if (collectionDetails.address.street.Length > 35) { collectionDetails.address.street = collectionDetails.address.street.Substring(0, 35); } if (collectionDetails.address.locality.Length > 35) { collectionDetails.address.locality = collectionDetails.address.locality.Substring(0, 35); } }
public string GetAWBNumber(ExpressShipmentModel expressBookingDetail, ExpressShipmentRequest frayteShipmentRequest) { frayteShipmentRequest.AWBNumber = frayteShipmentRequest.AWBNumber.Replace(" ", ""); string awbNo = string.Empty; if (!string.IsNullOrEmpty(frayteShipmentRequest.AWBNumber)) { if (frayteShipmentRequest.AWBNumber.Substring(0, 3) == frayteShipmentRequest.Security.AccountNumber.Substring(0, 3)) { var ISCheckAwb = dbContext.Expresses.Where(a => a.AWBBarcode == frayteShipmentRequest.AWBNumber).FirstOrDefault(); if (ISCheckAwb != null) { throw new Exception("AWB already exist in system"); } else { awbNo = GetAwb(expressBookingDetail, frayteShipmentRequest, frayteShipmentRequest.AWBNumber, "UI"); } } else { throw new Exception("AWB Format is wrong"); } } else { awbNo = GetAwb(expressBookingDetail, frayteShipmentRequest, "", "NoNUI"); } return(awbNo); }
private void mapDeliveryAddressDetail(ExpressShipmentModel shipment, DeliveryDetails deliveryDetail) { deliveryDetail.contactDetails = new ContactDetails() { contactName = shipment.ShipTo.FirstName + " " + shipment.ShipTo.LastName, telephone = shipment.ShipTo.Phone }; deliveryDetail.address = new Address() { organisation = shipment.ShipTo.CompanyName, street = shipment.ShipTo.Address, town = shipment.ShipTo.City, locality = shipment.ShipTo.Address2, countryCode = shipment.ShipTo.Country.Code2, county = shipment.ShipTo.Country.Name, postcode = shipment.ShipTo.PostCode, }; deliveryDetail.notificationDetails = new NotificationDetails() { email = shipment.ShipTo.Email, mobile = shipment.ShipTo.Phone, }; if (deliveryDetail.address.street.Length > 35) { deliveryDetail.address.street = deliveryDetail.address.street.Substring(0, 35); } if (deliveryDetail.address.locality.Length > 35) { deliveryDetail.address.locality = deliveryDetail.address.locality.Substring(0, 35); } }
public DPDRequestModel MapExpressBookingDetailToShipmentRequestDto(ExpressShipmentModel shipment) { try { //ShipFromAddress var collectionDetails = new CollectionDetails(); mapCallectionAddressDetail(shipment, collectionDetails); //ShipToAddress var deliveryDetails = new DeliveryDetails(); mapDeliveryAddressDetail(shipment, deliveryDetails); DPDRequestModel dpdShipmentRequest = new DPDRequestModel(); dpdShipmentRequest.DraftShipmentId = shipment.ExpressId; dpdShipmentRequest.collectionDate = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss"); dpdShipmentRequest.collectionOnDelivery = false; dpdShipmentRequest.invoice = null; dpdShipmentRequest.consolidate = false; dpdShipmentRequest.job_id = null; dpdShipmentRequest.consignment = new List <Consignment>(); int TotalNumberParcel = 0; foreach (var item in shipment.Packages) { TotalNumberParcel += item.CartonValue; } dpdShipmentRequest.consignment.Add(new Consignment { consignmentNumber = null, consignmentRef = null, parcels = new List <Parcels>(), collectionDetails = collectionDetails, deliveryDetails = deliveryDetails, networkCode = shipment.Service.NetworkCode, numberOfParcels = TotalNumberParcel, totalWeight = shipment.Service.ActualWeight, customsValue = null, deliveryInstructions = "Please deliver with shipment owner", liability = false, liabilityValue = null, parcelDescription = string.Join("-", shipment.Packages.Select(x => x.Content.ToString()).ToArray()), shippingRef1 = shipment.FrayteNumber + "-" + shipment.ShipmentReference, shippingRef2 = "", shippingRef3 = "", }); return(dpdShipmentRequest); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Shipment is not created " + ex.Message)); return(null); } }
public EAMRequestModel MapExpressBookingDetailToShipmentRequestDto(ExpressShipmentModel expressBookingDetail) { EAMRequestModel eamRequest = new EAMRequestModel() { ShipperAddress1 = expressBookingDetail.ShipFrom.Address, ShipperAddress2 = expressBookingDetail.ShipFrom.Address2, ShipperAddress3 = "", ShipperContact = string.Concat(expressBookingDetail.ShipFrom.FirstName + " ", expressBookingDetail.ShipFrom.LastName), ShipperCompany = string.IsNullOrWhiteSpace(expressBookingDetail.ShipFrom.CompanyName) ? string.Concat(expressBookingDetail.ShipFrom.FirstName + " ", expressBookingDetail.ShipFrom.LastName) : expressBookingDetail.ShipFrom.CompanyName, ShipperCountry = expressBookingDetail.ShipFrom.Country.Code2, ShipperPostcode = string.IsNullOrEmpty(expressBookingDetail.ShipFrom.PostCode) ? "" : expressBookingDetail.ShipFrom.PostCode, ShipperTelephone = expressBookingDetail.ShipFrom.Phone, ShipperTown = string.IsNullOrEmpty(expressBookingDetail.ShipFrom.City) ? "" : expressBookingDetail.ShipFrom.City, Account = "", Password = "", CustomerTransactionId = expressBookingDetail.AWBNumber.Replace(" ", ""), Hawb = expressBookingDetail.AWBNumber.Replace(" ", ""), Service = expressBookingDetail.Service.NetworkCode, Mawb = "", Date = DateTime.UtcNow.ToString("dd/MM/yyyy"), Company = string.IsNullOrWhiteSpace(expressBookingDetail.ShipTo.CompanyName) ? string.Concat(expressBookingDetail.ShipTo.FirstName + " ", expressBookingDetail.ShipTo.LastName) : expressBookingDetail.ShipTo.CompanyName, Contact = string.Concat(expressBookingDetail.ShipTo.FirstName + " ", expressBookingDetail.ShipTo.LastName), Address1 = expressBookingDetail.ShipTo.Address, Address2 = expressBookingDetail.ShipTo.Address2, Address3 = "", Town = string.IsNullOrEmpty(expressBookingDetail.ShipTo.City) ? "" : expressBookingDetail.ShipTo.City, Country = expressBookingDetail.ShipTo.Country.Code2, Postcode = string.IsNullOrEmpty(expressBookingDetail.ShipTo.PostCode) ? "" : expressBookingDetail.ShipTo.PostCode, telephone = expressBookingDetail.ShipTo.Phone, noOfPieces = expressBookingDetail.Packages.Sum(t => t.CartonValue).ToString(), Weight = expressBookingDetail.Service.ActualWeight, DoxNonDox = expressBookingDetail.ParcelType.ParcelType == "Parcel" ? "NDX" : "DOX", Description = string.Join("-", expressBookingDetail.Packages.Select(x => x.Content.ToString()).ToArray()) + "-" + expressBookingDetail.ShipmentReference, Value = expressBookingDetail.Packages.Sum(t => t.Value).ToString(), Currency = expressBookingDetail.DeclaredCurrency.CurrencyCode, Agent = "", Notes = "JUST A TEST" }; if (expressBookingDetail.Service.RateType == FrayteCourierCompany.EAMTNT) { eamRequest.Agent = "TNT economy service"; } else if (expressBookingDetail.Service.RateType == FrayteCourierCompany.EAMDHL) { eamRequest.Agent = "DHL express service"; } else if (expressBookingDetail.Service.RateType == FrayteCourierCompany.EAMFedEx) { eamRequest.Agent = "Fedex Economy service"; } return(eamRequest); }
public FrayteManifestName FrayteMAWB(ExpressShipmentModel shipment, string moduleType) { FrayteManifestName result = new FrayteManifestName(); try { var data = new FRAYTEAWBRepository().GetFrayteMAWBPDFDataSource(shipment.ExpressId, moduleType); Report.Generator.ReportTemplate.Express.FrayteMAWB report = new Report.Generator.ReportTemplate.Express.FrayteMAWB(); report.DataSource = data; if (System.IO.Directory.Exists(HttpContext.Current.Server.MapPath("~/PackageLabel/Express/" + shipment.ExpressId))) { string fileName = shipment.Service.HubCarrier == FrayteShortName.FrayteDomesticJP ? FrayteShortName.FrayteDomesticJP + "_" + shipment.TrackingNo.Replace(" ", "") + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (All)" + ".pdf" : FrayteShortName.FrayteDomesticSG + "_" + shipment.TrackingNo.Replace(" ", "") + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (All)" + ".pdf"; string filePath = AppSettings.WebApiPath + "/PackageLabel/Express/" + shipment.ExpressId + "/" + fileName; string filePhysicalPath = HttpContext.Current.Server.MapPath("~/PackageLabel/Express/" + shipment.ExpressId + "/" + fileName); new ExpressRepository().UpdateExpressLogisticlabel(shipment.ExpressId, fileName); new ExpressRepository().SaveExpressDetailPackagelabel(shipment.ExpressId); if (File.Exists(filePhysicalPath)) { File.Delete(filePhysicalPath); } report.ExportToPdf(filePhysicalPath); result.FileName = fileName; result.FilePath = filePath; } else { System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath("~/PackageLabel/Express/" + shipment.ExpressId)); string fileName = shipment.Service.HubCarrier == FrayteShortName.FrayteDomesticJP ? FrayteShortName.FrayteDomesticJP + "_" + shipment.TrackingNo.Replace(" ", "") + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (All)" + ".pdf" : FrayteShortName.FrayteDomesticSG + "_" + shipment.TrackingNo.Replace(" ", "") + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (All)" + ".pdf"; string filePath = AppSettings.WebApiPath + "/PackageLabel/Express/" + shipment.ExpressId + "/" + fileName; string filePhysicalPath = HttpContext.Current.Server.MapPath("~/PackageLabel/Express/" + shipment.ExpressId + "/" + fileName); new ExpressRepository().UpdateExpressLogisticlabel(shipment.ExpressId, fileName); new ExpressRepository().SaveExpressDetailPackagelabel(shipment.ExpressId); if (File.Exists(filePhysicalPath)) { File.Delete(filePhysicalPath); } report.ExportToPdf(filePhysicalPath); result.FileName = fileName; result.FilePath = filePath; } return(result); } catch (Exception e) { return(result); } }
public string GetAwb(ExpressShipmentModel expressBookingDetail, ExpressShipmentRequest frayteShipmentRequest, string AwbNo, string AwbFrom) { string Awbno = string.Empty; if (AwbFrom == "NoNUI") { AwbAgain: var awbNo = frayteShipmentRequest.Security.AccountNumber.Substring(0, 3).ToString() + new Random().Next(100000000, 999999999); var Result = dbContext.Expresses.Where(a => a.AWBBarcode == awbNo).FirstOrDefault(); if (Result == null) { ScanInitalAwbModel SIAM = new ScanInitalAwbModel(); SIAM.AwbNumber = awbNo; SIAM.MobileEventId = 1; SIAM.ScannedBy = GetCustomerDetail(frayteShipmentRequest.Security.AccountNumber).CustomerId; var AwbDetial = new ExpressScannedAWBRepository().CollectionScanMobileAwb(SIAM); expressBookingDetail.ExpressId = AwbDetial.ExpressId; Awbno = AwbDetial.AwbNumber; expressBookingDetail.ShipmentStatusId = dbContext.Expresses.Where(a => a.ExpressId == AwbDetial.ExpressId).FirstOrDefault().ShipmentStatusId; } else { goto AwbAgain; } } else { var Result = dbContext.Expresses.Where(a => a.AWBBarcode == AwbNo).FirstOrDefault(); if (Result == null) { ScanInitalAwbModel SIAM = new ScanInitalAwbModel(); SIAM.AwbNumber = AwbNo; SIAM.MobileEventId = 1; SIAM.ScannedBy = GetCustomerDetail(frayteShipmentRequest.Security.AccountNumber).CustomerId; var AwbDetial = new ExpressScannedAWBRepository().CollectionScanMobileAwb(SIAM); expressBookingDetail.ExpressId = AwbDetial.ExpressId; Awbno = AwbDetial.AwbNumber; expressBookingDetail.ShipmentStatusId = dbContext.Expresses.Where(a => a.ExpressId == AwbDetial.ExpressId).FirstOrDefault().ShipmentStatusId; } } return(Awbno); }
public DPDChRequestModel MapExpressBookingDetailToShipmentRequestDto(ExpressShipmentModel shipment) { var ShipFrom = new ExpressRepository().getHubAddress(shipment.ShipTo.Country.CountryId, shipment.ShipTo.PostCode, shipment.ShipTo.State); DPDChRequestModel dpdChRequest = new DPDChRequestModel() { UserName = "", Password = "", AuthToken = "", Shipper = new ContactDetail() { Company = ShipFrom.CompanyName, Contact = string.IsNullOrWhiteSpace(ShipFrom.FirstName + " " + ShipFrom.LastName) ? ShipFrom.CompanyName : ShipFrom.FirstName + " " + ShipFrom.LastName, Address1 = ShipFrom.Address, Address2 = ShipFrom.Address2, Address3 = "", Town = ShipFrom.City, Country = ShipFrom.Country.Code2, Postcode = ShipFrom.PostCode, Telephone = ShipFrom.Phone //Company = "Total Freight Management GmbH", //Contact = "", //Address1 = "Fracht West", //Address2 = "Entrance 1, 2nd Fl., Office 2-327", //Address3 = "", //Town = "Zurich Airport", //Country = "CH", //Postcode = "8058", //Telephone = "+41 44 816 40 50" }, Recipient = new ContactDetail() { Company = shipment.ShipTo.CompanyName, Contact = shipment.ShipTo.FirstName.Trim() + " " + shipment.ShipTo.LastName, Address1 = shipment.ShipTo.Address, Address2 = shipment.ShipTo.Address2, Address3 = "", Town = shipment.ShipTo.City, Country = shipment.ShipTo.Country.Code2, Postcode = shipment.ShipTo.PostCode, Telephone = "+41" + " " + shipment.ShipTo.Phone, }, ReferenceNumber1 = shipment.FrayteNumber + "-" + shipment.ShipmentReference, ReferenceNumber2 = "", Channel = 1, OrderType = "consignment", Product = "CL", SendingDepot = "", Value = "*****@*****.**" }; dpdChRequest.Package = new List <DPDPackage>(); for (int i = 0; i < shipment.Packages.Count; i++) { for (int j = 0; j < shipment.Packages[i].CartonValue; j++) { //Convert weight gm to 10 unit DPDPackage parcel = new DPDPackage(); if (shipment.PakageCalculatonType == FraytePakageCalculationType.kgtoCms) { parcel.ReferenceNumber1 = shipment.ShipmentReference; parcel.ReferenceNumber2 = ""; parcel.Volume = ""; parcel.Weight = ((shipment.Packages[i].Weight * 1000) / 10).ToString("0.##"); } else if (shipment.PakageCalculatonType == FraytePakageCalculationType.LbToInchs) { parcel.ReferenceNumber1 = shipment.ShipmentReference; parcel.ReferenceNumber2 = ""; parcel.Volume = ""; parcel.Weight = ((shipment.Packages[i].Weight * 453.592m) / 10).ToString("0.##"); } dpdChRequest.Package.Add(parcel); } } return(dpdChRequest); }
// New API Integration public SkyPostalRequest MapExpressBookingDetailToShipmentRequestDto(ExpressShipmentModel ExpressBookingDetail) { SkyPostalRequest request = new SkyPostalRequest(); request.user_info = new UserInfo(); request.user_info.user_code = 441; request.user_info.user_key = "209ff2c85bc69dbdee8af67c244f8728"; request.user_info.app_key = "0zqZl26OtlLK4oFeWh6QO890yN9ltP"; request.shipment_info = new ShipmentInfo(); request.shipment_info.copa_id = 665; request.shipment_info.ssa_copa_id = 0; request.shipment_info.box_id = ExpressBookingDetail.Service.CourierAccountNo; // Merchant info request.shipment_info.merchant = new Merchant(); request.shipment_info.merchant.name = "FRAYTE LOGISTICS LTD"; request.shipment_info.merchant.email = ""; request.shipment_info.merchant.address = null; // Merchant Return Addrress request.shipment_info.merchant.return_address = null; // Merchant Phone request.shipment_info.merchant.phone = new List <MerchantPhone>(); MerchantPhone mp = new MerchantPhone(); mp.phone_type = 1; mp.phone_number = ExpressBookingDetail.ShipFrom.Phone; request.shipment_info.merchant.phone.Add(mp); //Shipper Info request.shipment_info.shipper = new Shipper(); request.shipment_info.shipper.name = ExpressBookingDetail.ShipFrom.FirstName + " " + ExpressBookingDetail.ShipFrom.LastName; request.shipment_info.shipper.email = ExpressBookingDetail.ShipFrom.Email; request.shipment_info.shipper.shipperaddress = new ShipperAddress(); request.shipment_info.shipper.shipperaddress.address_01 = ExpressBookingDetail.ShipFrom.Address; request.shipment_info.shipper.shipperaddress.address_02 = ExpressBookingDetail.ShipFrom.Address2; request.shipment_info.shipper.shipperaddress.address_03 = null; request.shipment_info.shipper.shipperaddress.city_code = 0; request.shipment_info.shipper.shipperaddress.city_name = ExpressBookingDetail.ShipFrom.City; request.shipment_info.shipper.shipperaddress.country_code = 0; request.shipment_info.shipper.shipperaddress.county_code = 0; request.shipment_info.shipper.shipperaddress.county_name = ExpressBookingDetail.ShipFrom.Country.Name; request.shipment_info.shipper.shipperaddress.state_code = 0; request.shipment_info.shipper.shipperaddress.zip_code = ExpressBookingDetail.ShipFrom.PostCode; request.shipment_info.shipper.shipperaddress.country_iso_code = ExpressBookingDetail.ShipFrom.Country.Code2; request.shipment_info.shipper.shipperaddress.country_name = ExpressBookingDetail.ShipFrom.Country.Name; request.shipment_info.shipper.shipperaddress.neighborhood = null; request.shipment_info.shipper.shipperaddress.state_name = ExpressBookingDetail.ShipFrom.State; // Shipper Return Address request.shipment_info.shipper.return_address = null; request.shipment_info.shipper.phone = new List <ShipperPhone>(); ShipperPhone sp = new ShipperPhone(); sp.phone_type = 1; sp.phone_number = ExpressBookingDetail.ShipFrom.Phone; request.shipment_info.shipper.phone.Add(sp); // Sender Address request.shipment_info.sender = new Sender(); request.shipment_info.sender.name = ExpressBookingDetail.ShipFrom.FirstName + " " + ExpressBookingDetail.ShipFrom.LastName; request.shipment_info.sender.email = ExpressBookingDetail.ShipFrom.Email; request.shipment_info.sender.SenderAddress = new SenderAddress(); request.shipment_info.sender.SenderAddress.address_01 = ExpressBookingDetail.ShipFrom.Address; request.shipment_info.sender.SenderAddress.address_02 = ExpressBookingDetail.ShipFrom.Address2; request.shipment_info.sender.SenderAddress.address_03 = null; request.shipment_info.sender.SenderAddress.city_code = 0; request.shipment_info.sender.SenderAddress.city_name = ExpressBookingDetail.ShipFrom.City; request.shipment_info.sender.SenderAddress.country_code = 0; request.shipment_info.sender.SenderAddress.county_code = 0; request.shipment_info.sender.SenderAddress.county_name = ExpressBookingDetail.ShipFrom.Country.Name; request.shipment_info.sender.SenderAddress.state_code = 0; request.shipment_info.sender.SenderAddress.zip_code = ExpressBookingDetail.ShipFrom.PostCode; request.shipment_info.sender.SenderAddress.country_iso_code = ExpressBookingDetail.ShipFrom.Country.Code2; request.shipment_info.sender.SenderAddress.country_name = ExpressBookingDetail.ShipFrom.Country.Name; request.shipment_info.sender.SenderAddress.neighborhood = null; request.shipment_info.sender.SenderAddress.state_name = ExpressBookingDetail.ShipFrom.State; // Shipper Return Address request.shipment_info.sender.return_address = new ReturnAddress(); request.shipment_info.sender.return_address = null; request.shipment_info.sender.phone = new List <ShipperPhone>(); ShipperPhone ph = new ShipperPhone(); ph.phone_type = 1; ph.phone_number = ExpressBookingDetail.ShipFrom.Phone; request.shipment_info.sender.phone.Add(ph); //Consignee Address request.shipment_info.consignee = new Consignee(); request.shipment_info.consignee.first_name = ExpressBookingDetail.ShipTo.FirstName; request.shipment_info.consignee.last_name = ExpressBookingDetail.ShipTo.LastName; request.shipment_info.consignee.email = ExpressBookingDetail.ShipTo.Email; request.shipment_info.consignee.id_number = ExpressBookingDetail.ExpressId.ToString(); //Consignee Address request.shipment_info.consignee.address = new ConsigneeAddress(); request.shipment_info.consignee.address.address_01 = ExpressBookingDetail.ShipTo.Address; request.shipment_info.consignee.address.address_02 = ExpressBookingDetail.ShipTo.Address2; request.shipment_info.consignee.address.address_03 = null; request.shipment_info.consignee.address.city_code = 0; request.shipment_info.consignee.address.city_name = ExpressBookingDetail.ShipTo.City; request.shipment_info.consignee.address.country_code = 0; request.shipment_info.consignee.address.country_iso_code = ExpressBookingDetail.ShipTo.Country.Code2; request.shipment_info.consignee.address.country_name = ExpressBookingDetail.ShipTo.Country.Name; request.shipment_info.consignee.address.county_code = 0; request.shipment_info.consignee.address.county_name = ExpressBookingDetail.ShipTo.Country.Name; request.shipment_info.consignee.address.neighborhood = null; request.shipment_info.consignee.address.state_code = 0; request.shipment_info.consignee.address.state_name = ExpressBookingDetail.ShipTo.State; request.shipment_info.consignee.address.zip_code = ExpressBookingDetail.ShipTo.PostCode; //Consignee Phone request.shipment_info.consignee.phone = new List <ConsigneePhone>(); ConsigneePhone phn = new ConsigneePhone(); phn.phone_type = 1; phn.phone_number = ExpressBookingDetail.ShipTo.Phone; request.shipment_info.consignee.phone.Add(phn); request.shipment_info.options = new Options(); request.shipment_info.options.generate_label_default = false; request.shipment_info.options.include_label_data = false; request.shipment_info.options.include_label_image = false; request.shipment_info.options.insurance_code = 0; request.shipment_info.options.manifest_type = "DDP"; request.shipment_info.options.rate_service_code = 0; request.shipment_info.options.zpl_encode_base64 = true; request.shipment_info.options.include_label_zpl = false; request.shipment_info.data = new Data(); request.shipment_info.data.currency_iso_code = ExpressBookingDetail.DeclaredCurrency.CurrencyCode; request.shipment_info.data.dimension_01 = ExpressBookingDetail.Packages[0].Length; request.shipment_info.data.dimension_02 = ExpressBookingDetail.Packages[0].Height; request.shipment_info.data.dimension_03 = ExpressBookingDetail.Packages[0].Width; request.shipment_info.data.dimension_unit = ExpressBookingDetail.PakageCalculatonType == "kgToCms" ? "CM" : "IN"; request.shipment_info.data.discount = 0; request.shipment_info.data.external_tracking = ExpressBookingDetail.AWBNumber.Replace(" ", "") + "-" + ExpressBookingDetail.ShipmentReference; request.shipment_info.data.freight = 0; request.shipment_info.data.insurance = 0; request.shipment_info.data.reference_date = DateTime.UtcNow.ToString("yyyy-MM-dd"); request.shipment_info.data.reference_number_01 = ""; request.shipment_info.data.reference_number_02 = ""; request.shipment_info.data.reference_number_03 = ""; request.shipment_info.data.tax = 0; request.shipment_info.data.weight = ExpressBookingDetail.Service.ActualWeight; request.shipment_info.data.weight_unit = ExpressBookingDetail.PakageCalculatonType == "kgToCms" ? "KG" : "LB"; request.shipment_info.data.value = ExpressBookingDetail.DeclaredValue; request.shipment_info.data.items = new List <Item>(); Item my = new Item(); my.description = ExpressBookingDetail.Packages[0].Content; my.family_product = ""; my.hs_code = ""; my.imei_number = ""; my.quantity = ExpressBookingDetail.Packages[0].CartonValue; my.serial_number = ""; my.tax = 0; my.value = ExpressBookingDetail.Packages[0].Value; my.weight = ExpressBookingDetail.Packages[0].Weight; request.shipment_info.data.items.Add(my); return(request); }
public ExpressShipmentModel MappingFrayteRequestToExpressBookingDetail(ExpressShipmentRequest frayteShipmentRequest) { ExpressShipmentModel expressBookingDetail = new ExpressShipmentModel(); try { var customerfrom = GetCustomerDetail(frayteShipmentRequest.Security.AccountNumber); var country = GetCountry(frayteShipmentRequest.ShipFrom.Address.CountryCode); CheckServiceCode(frayteShipmentRequest); //Entry in DB for AwbNumber(Shipment PickedUp) expressBookingDetail.AWBNumber = GetAWBNumber(expressBookingDetail, frayteShipmentRequest); expressBookingDetail.ActualWeight = frayteShipmentRequest.Package.Sum(a => a.Weight); expressBookingDetail.ShipFrom = new ExpressAddressModel() { CompanyName = frayteShipmentRequest.ShipFrom.CompanyName, Address = frayteShipmentRequest.ShipFrom.Address.Address1, Address2 = frayteShipmentRequest.ShipFrom.Address.Address2, City = frayteShipmentRequest.ShipFrom.Address.City, Email = frayteShipmentRequest.ShipFrom.Email, PostCode = frayteShipmentRequest.ShipFrom.Address.Postcode, State = frayteShipmentRequest.ShipFrom.Address.State, Area = frayteShipmentRequest.ShipFrom.Address.Area, Phone = frayteShipmentRequest.ShipFrom.Phone, Country = new FrayteCountryCode() { Code = country.CountryCode, Code2 = country.CountryCode2, CountryId = country.CountryId, Name = country.CountryName, TimeZoneDetail = null }, CustomerId = customerfrom.CustomerId, FirstName = frayteShipmentRequest.ShipFrom.FirstName, LastName = frayteShipmentRequest.ShipFrom.LastName, IsMailSend = false, }; var country1 = GetCountry(frayteShipmentRequest.ShipTo.Address.CountryCode); expressBookingDetail.ShipTo = new ExpressAddressModel() { CompanyName = frayteShipmentRequest.ShipTo.CompanyName, Address = frayteShipmentRequest.ShipTo.Address.Address1, Address2 = frayteShipmentRequest.ShipTo.Address.Address2, City = frayteShipmentRequest.ShipTo.Address.City, Email = frayteShipmentRequest.ShipTo.Email, PostCode = frayteShipmentRequest.ShipTo.Address.Postcode, State = frayteShipmentRequest.ShipTo.Address.State, Area = frayteShipmentRequest.ShipTo.Address.Area, Phone = frayteShipmentRequest.ShipTo.Phone, Country = new FrayteCountryCode() { Code = country1.CountryCode, Code2 = country1.CountryCode2, CountryId = country1.CountryId, Name = country1.CountryName, TimeZoneDetail = null }, CustomerId = customerfrom.CustomerId, FirstName = frayteShipmentRequest.ShipTo.FirstName, LastName = frayteShipmentRequest.ShipTo.LastName, IsMailSend = false, }; expressBookingDetail.DeclaredCurrency = new CurrencyType() { CurrencyCode = customerfrom.CurrencyCode, CurrencyDescription = "", }; expressBookingDetail.Packages = new List <ExpressPackageModel>(); foreach (var package in frayteShipmentRequest.Package) { var item = new ExpressPackageModel() { CartonValue = package.CartoonValue, Height = Frayte.Services.CommonConversion.ConvertToDecimal(package.Height), Length = Frayte.Services.CommonConversion.ConvertToDecimal(package.Length), Width = Frayte.Services.CommonConversion.ConvertToDecimal(package.Width), Content = package.ShipmentContents, Weight = package.Weight, Value = package.DeclaredValue }; expressBookingDetail.Packages.Add(item); } ; //expressBookingDetail.ParcelType = frayteShipmentRequest.par; if (frayteShipmentRequest.CustomInformation != null) { expressBookingDetail.CustomInformation = new ExpressCustomInformationModel() { ContentsType = frayteShipmentRequest.CustomInformation.ContentsType, RestrictionType = frayteShipmentRequest.CustomInformation.RestrictionType, ContentsExplanation = frayteShipmentRequest.CustomInformation.ContentsExplanation, RestrictionComments = frayteShipmentRequest.CustomInformation.RestrictionComments, CustomsCertify = true, CustomsSigner = frayteShipmentRequest.CustomInformation.CustomsSigner, NonDeliveryOption = frayteShipmentRequest.CustomInformation.NonDeliveryOption, }; } expressBookingDetail.Service = new HubService(); expressBookingDetail.Service = frayteShipmentRequest.Service; expressBookingDetail.PakageCalculatonType = frayteShipmentRequest.PackageCalculationType; expressBookingDetail.CustomerId = customerfrom.CustomerId; expressBookingDetail.PayTaxAndDuties = frayteShipmentRequest.PaymentPartyTaxAndDuties; expressBookingDetail.CreatedBy = customerfrom.CustomerId; expressBookingDetail.DeclaredValue = expressBookingDetail.Packages.Sum(a => a.Value); //expressBookingDetail = new ReferenceDetail(); // expressBookingDetail.ReferenceDetail.CollectionDate = Convert.ToDateTime(frayteShipmentRequest.RequestedPickupDate); //expressBookingDetail.ReferenceDetail.CollectionTime = frayteShipmentRequest.RequestedPickupDate.HasValue ? frayteShipmentRequest.RequestedPickupDate.Value.ToString("HHmm") : ""; expressBookingDetail.ShipmentReference = frayteShipmentRequest.ShipmentReference; expressBookingDetail.ShipmentDescription = frayteShipmentRequest.ShipmentReference; //expressBookingDetail.Service = GetExpressService(frayteShipmentRequest.ServiceCode); //directBookingDetail.CustomerId = user != null && user.RoleId == (int)FrayteUserRole.UserCustomer ? user.CustomerId : customerfrom.CustomerId; //directBookingDetail.CreatedBy = user != null && user.RoleId == (int)FrayteUserRole.UserCustomer ? user.CreatedBy : customerfrom.CustomerId; //directBookingDetail.ShipmentStatusId = 12; //directBookingDetail.BookingStatusType = "Darft"; //directBookingDetail.PakageCalculatonType = frayteShipmentRequest.PackageCalculationType; //directBookingDetail.AddressType = frayteShipmentRequest.AddressType; return(expressBookingDetail); } catch (Exception ex) { throw (new FrayteApiException("MappingRequestError", ex)); } }
public BringRequestModel MapExpressBookingDetailToShipmentRequestDto(ExpressShipmentModel shipment) { BringRequestModel bringRequest = new BringRequestModel(); if (AppSettings.ApplicationMode == FrayteApplicationMode.Test) { bringRequest.testIndicator = true; } else { bringRequest.testIndicator = false; } bringRequest.schemaVersion = 1; bringRequest.consignments = new List <ConsignmentModel>(); var packages = new List <Models.Bring.Package>(); Models.Bring.Package package = new Models.Bring.Package(); for (int i = 0; i < shipment.Packages.Count; i++) { for (int j = 0; j < shipment.Packages[i].CartonValue; j++) { package.weightInKg = shipment.Packages[i].Weight.ToString("0.##"); package.goodsDescription = shipment.Packages[i].Content; package.dimensions = new Dimensions() { heightInCm = shipment.Packages[i].Height, lengthInCm = shipment.Packages[i].Length, widthInCm = shipment.Packages[i].Width, }; //package.containerId = shipment.FrayteNumber; package.containerId = shipment.AWBNumber.Replace(" ", "").Substring(0, 8); package.packageType = ""; package.numberOfItems = ""; //package.correlationId = "PACKAGE-" + shipment.FrayteNumber; package.correlationId = "PACKAGE-" + shipment.AWBNumber.Replace(" ", "").Substring(0, 8); packages.Add(package); } } var ShipFrom = new ExpressRepository().getHubAddress(shipment.ShipTo.Country.CountryId, shipment.ShipTo.PostCode, shipment.ShipTo.State); ConsignmentModel consign = new ConsignmentModel() { //shippingDateTime = DateTime.Now.AddDays(1).ToString("yyyy-MM-ddTHH:mm:ss"), shippingDateTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 13, 10, 10).AddDays(1).ToString("yyyy-MM-ddTHH:mm:ss"), parties = new Parties() { sender = new Sender() { name = string.IsNullOrWhiteSpace(ShipFrom.CompanyName) ? ShipFrom.FirstName + " " + ShipFrom.LastName : ShipFrom.CompanyName, addressLine = !string.IsNullOrEmpty(ShipFrom.Address) ? ShipFrom.Address.Trim() : "", addressLine2 = !string.IsNullOrEmpty(ShipFrom.Address2) ? ShipFrom.Address2.Trim() : "", additionalAddressInfo = "", postalCode = !string.IsNullOrEmpty(ShipFrom.PostCode) ? ShipFrom.PostCode.Trim() : "", city = !string.IsNullOrEmpty(ShipFrom.City) ? ShipFrom.City : "", countryCode = !string.IsNullOrEmpty(ShipFrom.Country.Code2) ? ShipFrom.Country.Code2 : "", //reference = shipment.FrayteNumber + "-" + shipment.ShipmentReference, reference = shipment.AWBNumber.Replace(" ", "") + "-" + shipment.ShipmentReference, contact = new Contact { name = string.IsNullOrEmpty(ShipFrom.FirstName + " " + ShipFrom.LastName) ? ShipFrom.CompanyName : ShipFrom.FirstName + " " + ShipFrom.LastName, email = string.IsNullOrEmpty(ShipFrom.Email) ? "*****@*****.**" : ShipFrom.Email, phoneNumber = ShipFrom.Phone } // name = "Priority Cargo AS", //addressLine = "Skur 97,Kongshavnveien 29,", //addressLine2 = "Kongshavnveien 29,", //additionalAddressInfo = "", //postalCode = "0193", //city = "Oslo", //countryCode = "NO", //reference = shipment.AWBNumber.Replace(" ", "").Substring(0, 8) + "-" + shipment.ShipmentReference, //contact = new Contact //{ // name = "Priority Cargo AS", // email = "*****@*****.**", // phoneNumber = "+47 9760 0402" //} }, recipient = new Recipient() { name = string.IsNullOrWhiteSpace(shipment.ShipTo.CompanyName) ? shipment.ShipTo.FirstName + " " + shipment.ShipTo.LastName : shipment.ShipTo.CompanyName, addressLine = shipment.ShipTo.Address, addressLine2 = shipment.ShipTo.Address2, additionalAddressInfo = "", postalCode = shipment.ShipTo.PostCode, city = shipment.ShipTo.City, countryCode = shipment.ShipTo.Country.Code2, reference = shipment.AWBNumber.Replace(" ", "").Substring(0, 8) + "-" + shipment.ShipmentReference, contact = new Contact { name = shipment.ShipTo.FirstName + " " + shipment.ShipTo.LastName, email = string.IsNullOrEmpty(shipment.ShipTo.Email) ? "*****@*****.**" : shipment.ShipTo.Email, phoneNumber = shipment.ShipTo.Phone } }, pickupPoint = null }, product = new Product() { id = "PA_DOREN", //customerNumber = shipment.Service.NetworkCode, customerNumber = shipment.Service.NetworkCode, services = null, customsDeclaration = shipment.CustomInformation.CatagoryOfItemExplanation, }, purchaseOrder = null, correlationId = null, packages = packages }; bringRequest.consignments.Add(consign); GetXMLFromRequestObject(bringRequest); return(bringRequest); }
public FrayteResult Generate_Seperate_PackageLabelPDF(int DirectShipmentId, ExpressShipmentModel shipment, IntegrtaionResult integrtaionResult) { FrayteResult result = new FrayteResult(); result.Errors = new List <string>(); List <string> list = new List <string>(); List <string> list1 = new List <string>(); var Packages = new ExpressRepository().GetPackageDetails(DirectShipmentId); if (Packages != null) { if (shipment.Service.HubCarrier != FrayteCourierCompany.AU && shipment.Service.HubCarrier.ToUpper() != FrayteCourierCompany.SKYPOSTAL && shipment.Service.HubCarrier != FrayteCourierCompany.BRING && shipment.Service.HubCarrier != FrayteCourierCompany.DPDCH && shipment.Service.HubCarrier != FrayteCourierCompany.EAM && shipment.Service.HubCarrier.ToUpper() != FrayteCourierCompany.CANADAPOST && shipment.Service.HubCarrier != FrayteCourierCompany.Hermes) { foreach (var pack in Packages) { var packageTracking = getPackageImamagePath(pack.ExpressDetailId); if (packageTracking != null && packageTracking.Count > 0) { foreach (var data in packageTracking) { list.Add(data.PackageLabelName); list1.Add(data.PackageLabelName); var resultReport = new Report.Generator.ManifestReport.PackageLabelReport().ExpressGenerateAllLabelReport(DirectShipmentId, null, list1, shipment.Service.HubCarrier, ""); if (!resultReport.Status) { result.Status = false; result.Errors.Add("All the labels Pdf are not generated for " + DirectShipmentId.ToString()); } list1.Remove(data.PackageLabelName); } } else { result.Status = false; result.Errors.Add("All the labels Pdf are not generated for " + DirectShipmentId.ToString()); } } } string RateType = shipment.Service.RateType; string CourierCompany = shipment.Service.HubCarrier; string TrackingNo = new ExpressRepository().GetTrackingNo(DirectShipmentId); string labelName = string.Empty; if (shipment.Service.HubCarrier == FrayteCourierCompany.Yodel) { labelName = FrayteShortName.Yodel; } else if (shipment.Service.HubCarrier == FrayteCourierCompany.Hermes) { labelName = FrayteShortName.Hermes; } else if (shipment.Service.HubCarrier == FrayteCourierCompany.UKMail) { labelName = FrayteShortName.UKMail; } else if (shipment.Service.HubCarrier == FrayteCourierCompany.DHL) { labelName = FrayteShortName.DHL; } else if (shipment.Service.HubCarrier == FrayteCourierCompany.TNT) { labelName = FrayteShortName.TNT; } else if (shipment.Service.HubCarrier == FrayteCourierCompany.UPS) { labelName = FrayteShortName.UPS; } else if (shipment.Service.HubCarrier == FrayteCourierCompany.DPD) { labelName = FrayteShortName.DPD; } else if (shipment.Service.HubCarrier == FrayteCourierCompany.AU) { labelName = FrayteShortName.AU; } else if (shipment.Service.HubCarrier.ToUpper() == FrayteCourierCompany.SKYPOSTAL) { labelName = FrayteShortName.SKYPOSTAL; } else if (shipment.Service.HubCarrier == FrayteCourierCompany.BRING) { labelName = FrayteShortName.BRING; } else if (shipment.Service.HubCarrier == FrayteCourierCompany.EAM) { labelName = FrayteShortName.EAM; } else if (shipment.Service.HubCarrier.ToUpper() == FrayteCourierCompany.CANADAPOST) { labelName = FrayteShortName.CANADAPOST; } string LogisticLabel = string.Empty; int totalCartoonValue = shipment.Packages.Sum(k => k.CartonValue); if (!string.IsNullOrEmpty(shipment.Service.RateType)) { if (TrackingNo.Contains("Order_")) { var Trackinginfo = TrackingNo.Replace("Order_", ""); LogisticLabel = labelName + "_" + Trackinginfo + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (All)" + ".pdf"; } else { if (shipment.Service.HubCarrier == FrayteCourierCompany.DPD || shipment.Service.HubCarrier == FrayteCourierCompany.TNT) { if (shipment.Service.HubCarrier == FrayteCourierCompany.DPD) { for (int i = 0; i < integrtaionResult.PieceTrackingDetails.Count; i++) { int numberofpiece = i + 1; string Image = labelName + "_" + integrtaionResult.PieceTrackingDetails[i].PieceTrackingNumber + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (" + numberofpiece + " of " + totalCartoonValue + ")" + ".html"; LogisticLabel += Image + ";"; } } else { for (int i = 1; i <= totalCartoonValue; i++) { string Image = labelName + "_" + TrackingNo + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (" + i + " of " + totalCartoonValue + ")" + ".html"; LogisticLabel += Image + ";"; } } } else { if (shipment.Service.HubCarrier == FrayteCourierCompany.AU || shipment.Service.HubCarrier.ToUpper() == FrayteCourierCompany.SKYPOSTAL || shipment.Service.HubCarrier == FrayteCourierCompany.BRING || shipment.Service.HubCarrier == FrayteCourierCompany.DPDCH || shipment.Service.HubCarrier.Contains(FrayteCourierCompany.EAM) || shipment.Service.HubCarrier.ToUpper() == FrayteCourierCompany.CANADAPOST) { LogisticLabel = integrtaionResult.PieceTrackingDetails[0].LabelName; } else { LogisticLabel = labelName + "_" + TrackingNo + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (All)" + ".pdf"; } } } } else { if (TrackingNo.Contains("Order_")) { var Trackinginfo = TrackingNo.Replace("Order_", ""); LogisticLabel = labelName + "_" + Trackinginfo + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (All)" + ".pdf"; } else { if (shipment.Service.HubCarrier == FrayteCourierCompany.DPD || shipment.Service.HubCarrier == FrayteCourierCompany.TNT) { if (shipment.Service.HubCarrier == FrayteCourierCompany.DPD) { for (int i = 1; i <= integrtaionResult.PieceTrackingDetails.Count; i++) { int numberofpiece = i + 1; string Image = labelName + "_" + integrtaionResult.PieceTrackingDetails[i].PieceTrackingNumber + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (" + numberofpiece + " of " + totalCartoonValue + ")" + ".html"; LogisticLabel += Image + ";"; } } else { for (int i = 1; i <= totalCartoonValue; i++) { string Image = labelName + "_" + TrackingNo + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (" + i + " of " + totalCartoonValue + ")" + ".html"; LogisticLabel += Image + ";"; } } } else { if (shipment.Service.HubCarrier == FrayteCourierCompany.AU || shipment.Service.HubCarrier.ToUpper() == FrayteCourierCompany.SKYPOSTAL || shipment.Service.HubCarrier == FrayteCourierCompany.BRING || shipment.Service.HubCarrier == FrayteCourierCompany.DPDCH || shipment.Service.HubCarrier == FrayteCourierCompany.EAM || shipment.Service.HubCarrier.ToUpper() == FrayteCourierCompany.CANADAPOST) { LogisticLabel = integrtaionResult.PieceTrackingDetails[0].LabelName; } else { LogisticLabel = labelName + "_" + TrackingNo + "_" + DateTime.Now.ToString("dd_MM_yyyy") + " (All)" + ".pdf"; } } } } if (shipment.Service.HubCarrier == FrayteCourierCompany.DHL) { var shipmentImange = new ExpressRepository().GetShipmentImage(DirectShipmentId); list.Add(shipmentImange.LogisticLabelImage); } // After Creting label save in DirectShipmentTable if (shipment.Service.HubCarrier != FrayteCourierCompany.DPD && shipment.Service.HubCarrier.ToUpper() != FrayteCourierCompany.TNT && shipment.Service.HubCarrier != FrayteCourierCompany.AU && shipment.Service.HubCarrier.ToUpper() != FrayteCourierCompany.SKYPOSTAL && shipment.Service.HubCarrier != FrayteCourierCompany.BRING && shipment.Service.HubCarrier != FrayteCourierCompany.DPDCH && shipment.Service.HubCarrier != FrayteCourierCompany.EAM && shipment.Service.HubCarrier.ToUpper() != FrayteCourierCompany.CANADAPOST && shipment.Service.HubCarrier != FrayteCourierCompany.Hermes) { var Result = new Report.Generator.ManifestReport.PackageLabelReport().ExpressGenerateAllLabelReport(DirectShipmentId, shipment, list, shipment.Service.HubCarrier, LogisticLabel); result.Status = true; if (Result.Status) { new ExpressRepository().SaveLogisticLabel(DirectShipmentId, LogisticLabel); result.Status = true; } } else { new ExpressRepository().SaveLogisticLabel(DirectShipmentId, LogisticLabel); result.Status = true; } } else { result.Status = false; result.Errors.Add("All the labels Pdf are not generated for " + DirectShipmentId.ToString()); } return(result); }
public void MappingFrayteResponseToExpressBookingDetail(ExpressShipmentModel ExpressDetail, IntegrtaionResult intResult, ExpressShipmentResponseModel Response) { Response.ShipmentBookingId = ExpressDetail.ExpressId; Response.Status = true; Response.Description = ""; Response.AWBNumber = ExpressDetail.AWBNumber.Substring(0, 3) + " " + ExpressDetail.AWBNumber.Substring(3, 3) + " " + ExpressDetail.AWBNumber.Substring(6, 3) + " " + ExpressDetail.AWBNumber.Substring(9, 3); Response.TrackingNumber = intResult.TrackingNumber.Replace("Order_", ""); Response.CreatedOn = DateTime.UtcNow.ToString("dd-MMM-yyyy"); Response.Currency = ExpressDetail.DeclaredCurrency.CurrencyCode; Response.FromAddress = new FromAddressDto() { CompanyName = ExpressDetail.ShipFrom.CompanyName, FirstName = ExpressDetail.ShipFrom.FirstName, LastName = ExpressDetail.ShipFrom.LastName, Email = ExpressDetail.ShipFrom.Email, Phone = ExpressDetail.ShipFrom.Phone, Address = new ShipAddressDto() { Address1 = ExpressDetail.ShipFrom.Address, Address2 = ExpressDetail.ShipFrom.Address2, Area = ExpressDetail.ShipFrom.Area, City = ExpressDetail.ShipFrom.City, CountryCode = ExpressDetail.ShipFrom.Country.Code, Postcode = ExpressDetail.ShipFrom.PostCode, State = ExpressDetail.ShipFrom.State } }; Response.ToAddress = new ToAddressDto() { CompanyName = ExpressDetail.ShipTo.CompanyName, FirstName = ExpressDetail.ShipTo.FirstName, LastName = ExpressDetail.ShipTo.LastName, Email = ExpressDetail.ShipTo.Email, Phone = ExpressDetail.ShipTo.Phone, Address = new ShipAddressDto() { Address1 = ExpressDetail.ShipTo.Address, Address2 = ExpressDetail.ShipTo.Address2, Area = ExpressDetail.ShipTo.Area, City = ExpressDetail.ShipTo.City, CountryCode = ExpressDetail.ShipTo.Country.Code, Postcode = ExpressDetail.ShipTo.PostCode, State = ExpressDetail.ShipTo.State } }; Response.CustomInfo = new ApiCustomInformation() { ContentsType = ExpressDetail.CustomInformation.ContentsType, ContentsExplanation = ExpressDetail.CustomInformation.ContentsExplanation, RestrictionType = ExpressDetail.CustomInformation.RestrictionType, RestrictionComments = ExpressDetail.CustomInformation.RestrictionComments, CustomsSigner = ExpressDetail.CustomInformation.CustomsSigner, NonDeliveryOption = ExpressDetail.CustomInformation.NonDeliveryOption, }; var FilesArray = Directory.GetFiles(AppSettings.WebApiPath + "/PackageLabel/Express/" + ExpressDetail.ExpressId); if (FilesArray.Length > 0) { var AllFile = FilesArray.Where(a => a.Contains("All")).FirstOrDefault(); if (!string.IsNullOrEmpty(AllFile)) { Response.AllLlabelUrl = AppSettings.LabelVirtualPath + "/PackageLabel/Express/" + FilesArray.Where(a => a.Contains("All")).FirstOrDefault().Split('/').LastOrDefault(); } else { Response.AllLlabelUrl = AppSettings.LabelVirtualPath + "/PackageLabel/Express/" + FilesArray.FirstOrDefault().Split('/').LastOrDefault(); } } else { Response.AllLlabelUrl = ""; } }
public void MappingExpressCourierPieceDetail(IntegrtaionResult integrtaionResult, ExpressShipmentModel expessBookingDetail, int ExpressShipmentid) { if (ExpressShipmentid > 0) { int k = 0, i = 0; List <int> _shiId = new List <int>(); foreach (var Obj in expessBookingDetail.Packages) { _shiId = new DirectShipmentRepository().GetExpressDirectShipmentDetailID(ExpressShipmentid); for (int j = 1; j <= Obj.CartonValue; j++) { integrtaionResult.PieceTrackingDetails[k].DirectShipmentDetailId = _shiId[i]; k++; } i++; } } }
public FrayteResult ExpressGenerateAllLabelReport(int DirectShipmentId, ExpressShipmentModel directBookingDetail, List <string> imgList, string CourierName, string LogisticLabel) { FrayteResult result = new FrayteResult(); try { List <PdfImage> imglist = new List <PdfImage>(); if (AppSettings.LabelSave == "") { PdfImage pbimage; foreach (var img in imgList) { pbimage = new PdfImage(); pbimage.FullPath = AppSettings.WebApiPath + "/PackageLabel/Express/" + DirectShipmentId + "/" + img; imglist.Add(pbimage); } string pdfPath = string.Empty; if (directBookingDetail != null) { pdfPath = AppSettings.WebApiPath + "/PackageLabel/Express/" + DirectShipmentId + "/" + LogisticLabel; } else { string[] ff = imgList[0].ToString().Split('.'); string name = ff[0].ToString(); pdfPath = AppSettings.WebApiPath + "/PackageLabel/Express/" + DirectShipmentId + "/" + name + ".pdf"; } if (File.Exists(pdfPath)) { File.Delete(pdfPath); } if (!System.IO.Directory.Exists(AppSettings.WebApiPath + "/PackageLabel/Express/" + DirectShipmentId)) { System.IO.Directory.CreateDirectory(AppSettings.WebApiPath + "/PackageLabel/Express/" + DirectShipmentId); } if (CourierName == FrayteCourierCompany.TNT) { ReportTemplate.Other.TNTImagesToPDFReport report = new ReportTemplate.Other.TNTImagesToPDFReport(); report.DataSource = imglist; DevExpress.XtraPrinting.PdfExportOptions pdfOptions = report.ExportOptions.Pdf; pdfOptions.ImageQuality = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest; pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b; report.ExportToPdf(pdfPath, pdfOptions); result.Status = true; } else { ReportTemplate.Other.DHLImageToPDFReport dhlReport = new ReportTemplate.Other.DHLImageToPDFReport(); dhlReport.DataSource = imglist; DevExpress.XtraPrinting.PdfExportOptions pdfOptions = dhlReport.ExportOptions.Pdf; pdfOptions.ImageQuality = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest; pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b; dhlReport.ExportToPdf(pdfPath, pdfOptions); result.Status = true; } return(result); } else { PdfImage pbimage; foreach (var img in imgList) { pbimage = new PdfImage(); if (AppSettings.ShipmentCreatedFrom == "BATCH") { pbimage.FullPath = AppSettings.LabelFolder + "/Express/" + DirectShipmentId + "/" + img; } else { pbimage.FullPath = HttpContext.Current.Server.MapPath(AppSettings.LabelFolder + "/Express/") + DirectShipmentId + "/" + img; } imglist.Add(pbimage); } string pdfPath = string.Empty; if (directBookingDetail != null) { if (AppSettings.ShipmentCreatedFrom == "BATCH") { pdfPath = AppSettings.LabelFolder + "/Express/" + DirectShipmentId + "/" + LogisticLabel; } else { pdfPath = HttpContext.Current.Server.MapPath("~/PackageLabel/Express/" + DirectShipmentId + "/") + LogisticLabel; } } else { string[] ff = imgList[0].ToString().Split('.'); string name = ff[0].ToString(); if (AppSettings.ShipmentCreatedFrom == "BATCH") { pdfPath = AppSettings.LabelFolder + "/Express/" + DirectShipmentId + "/" + name + ".pdf"; } else { pdfPath = HttpContext.Current.Server.MapPath(AppSettings.LabelFolder + "/Express/") + DirectShipmentId + "/" + name + ".pdf"; } } if (File.Exists(pdfPath)) { File.Delete(pdfPath); } if (AppSettings.ShipmentCreatedFrom == "BATCH") { if (!System.IO.Directory.Exists(AppSettings.LabelFolder + "/Express/" + DirectShipmentId)) { System.IO.Directory.CreateDirectory(AppSettings.LabelFolder + "/Express/" + DirectShipmentId); } } else { if (!System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(AppSettings.LabelFolder + "/Express") + "/" + DirectShipmentId)) { System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(AppSettings.LabelFolder + "/Express") + "/" + DirectShipmentId); } } if (CourierName == FrayteCourierCompany.TNT) { ReportTemplate.Other.TNTImagesToPDFReport report = new ReportTemplate.Other.TNTImagesToPDFReport(); report.DataSource = imglist; DevExpress.XtraPrinting.PdfExportOptions pdfOptions = report.ExportOptions.Pdf; pdfOptions.ImageQuality = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest; pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b; report.ExportToPdf(pdfPath, pdfOptions); result.Status = true; } else { ReportTemplate.Other.DHLImageToPDFReport dhlReport = new ReportTemplate.Other.DHLImageToPDFReport(); dhlReport.DataSource = imglist; DevExpress.XtraPrinting.PdfExportOptions pdfOptions = dhlReport.ExportOptions.Pdf; pdfOptions.ImageQuality = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest; pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b; dhlReport.ExportToPdf(pdfPath, pdfOptions); result.Status = true; } return(result); } } catch (Exception ex) { result.Status = false; return(result); } }
public USPSRequest MapExpressShipmentToUSPSShipmentRequest(ExpressShipmentModel shipment) { USPSRequest request = new USPSRequest(); try { request.header = new USPSHeader(); request.header.key = ""; request.header.version = ""; request.shipment = new USPSShipment(); request.shipment.date = DateTime.Now.ToString("yyyy-MM-dd"); request.shipment.labelType = "PNG"; request.shipment.mailClass = "EX"; request.shipment.packageType = "LEGAL FLAT RATE ENV"; request.shipment.weight = shipment.Service.ActualWeight; request.shipment.dimensions = new USPSDimensions(); request.shipment.dimensions.height = shipment.Packages.FirstOrDefault().Height; request.shipment.dimensions.length = shipment.Packages.FirstOrDefault().Length; request.shipment.dimensions.width = shipment.Packages.FirstOrDefault().Width; request.shipment.sender = new USPSSenderAddress(); request.shipment.sender.address1 = shipment.ShipFrom.Address; request.shipment.sender.address2 = shipment.ShipFrom.Address2; request.shipment.sender.city = shipment.ShipFrom.City; request.shipment.sender.company = shipment.ShipFrom.CompanyName; request.shipment.sender.country = shipment.ShipFrom.Country.Code2; request.shipment.sender.name = shipment.ShipFrom.FirstName + " " + shipment.ShipFrom.LastName; request.shipment.sender.phone = shipment.ShipFrom.Phone; request.shipment.sender.state = dbContext.CountryStates.Where(x => x.CountryId == shipment.ShipFrom.Country.CountryId && x.StateName == shipment.ShipFrom.State).FirstOrDefault().StateCode; request.shipment.sender.zip = shipment.ShipFrom.PostCode; request.shipment.sender.zip4 = "1111"; request.shipment.receiver = new USPSSenderAddress(); request.shipment.receiver.address1 = shipment.ShipTo.Address; request.shipment.receiver.address2 = shipment.ShipTo.Address2; request.shipment.receiver.city = shipment.ShipTo.City; request.shipment.receiver.company = shipment.ShipTo.CompanyName; request.shipment.receiver.country = shipment.ShipTo.Country.Code2; request.shipment.receiver.name = shipment.ShipTo.FirstName + " " + shipment.ShipTo.LastName; request.shipment.receiver.state = dbContext.CountryStates.Where(x => x.CountryId == shipment.ShipTo.Country.CountryId && x.StateName == shipment.ShipTo.State).FirstOrDefault().StateCode; request.shipment.receiver.zip = shipment.ShipTo.PostCode; request.shipment.receiver.zip4 = "1111"; request.shipment.options = new USPSOptions(); request.shipment.options.insurance = 0; request.shipment.options.signature = "N"; request.shipment.items = new List <USPSItems>(); foreach (var item in shipment.Packages) { if (item.CartonValue > 0) { for (int i = 0; i < item.CartonValue; i++) { USPSItems piece = new USPSItems(); if (shipment.PakageCalculatonType.ToUpper() == FraytePakageCalculationType.kgtoCms.ToUpper()) { piece.description = item.Content; piece.quantity = item.CartonValue; piece.unitValue = item.Value; piece.weight = (shipment.Packages[i].Weight) * 35.27396195M; piece.weightUnit = "oz"; } else if (shipment.PakageCalculatonType.ToUpper() == FraytePakageCalculationType.LbToInchs.ToUpper()) { piece.description = item.Content; piece.quantity = item.CartonValue; piece.unitValue = item.Value; piece.weight = (shipment.Packages[i].Weight) * 16; piece.weightUnit = "oz"; } request.shipment.items.Add(piece); } } } } catch (Exception ex) { } return(request); }
public List <ETowerRequestModel> MapExpressBookingDetailToShipmentRequestDto(ExpressShipmentModel expressBookingDetail) { List <ETowerRequestModel> eTowerRequest = new List <ETowerRequestModel>(); ETowerRequestModel etower = new ETowerRequestModel() { trackingNo = "", referenceNo = expressBookingDetail.AWBNumber.Replace(" ", ""), addressLine1 = expressBookingDetail.ShipTo.Address, addressLine2 = expressBookingDetail.ShipTo.Address2, addressLine3 = "", city = expressBookingDetail.ShipTo.City, country = expressBookingDetail.ShipTo.Country.Code2, description = string.Join("-", expressBookingDetail.Packages.Select(x => x.Content.ToString()).ToArray()), nativeDescription = "", email = expressBookingDetail.ShipTo.Email, facility = "", instruction = "Canada Post", invoiceCurrency = expressBookingDetail.DeclaredCurrency.CurrencyCode, invoiceValue = expressBookingDetail.Packages.Sum(k => k.Value), phone = expressBookingDetail.ShipTo.Phone, platform = "", postcode = expressBookingDetail.ShipTo.PostCode, recipientCompany = expressBookingDetail.ShipTo.CompanyName, recipientName = expressBookingDetail.ShipTo.FirstName + " " + expressBookingDetail.ShipTo.LastName, serviceCode = "", serviceOption = "Expedited", sku = "", state = expressBookingDetail.ShipTo.State, weightUnit = "KG", weight = expressBookingDetail.Service.BillingWeight, dimensionUnit = "CM", length = expressBookingDetail.Packages[0].Length, width = expressBookingDetail.Packages[0].Width, height = expressBookingDetail.Packages[0].Height, volume = 0, shipperName = expressBookingDetail.ShipFrom.FirstName + " " + expressBookingDetail.ShipFrom.LastName, shipperAddressLine1 = expressBookingDetail.ShipFrom.Address, shipperAddressLine2 = expressBookingDetail.ShipFrom.Address2, shipperAddressLine3 = "", shipperCity = expressBookingDetail.ShipFrom.City, shipperState = expressBookingDetail.ShipFrom.State, shipperPostcode = expressBookingDetail.ShipFrom.PostCode, shipperCountry = expressBookingDetail.ShipFrom.Country.Code2, shipperPhone = expressBookingDetail.ShipFrom.Phone, recipientTaxId = "", authorityToLeave = "", incoterm = "DDP", lockerService = "", extendData = new ExtendData { nationalNumber = "", nationalIssueDate = "", cyrillicName = "", imei = "", isImei = true, vendorid = "", gstexemptioncode = "", abnnumber = "", sortCode = "", }, }; etower.orderItems = new List <OrderItem>(); var count = 1; for (int i = 0; i < expressBookingDetail.Packages.Count; i++) { OrderItem order = new OrderItem() { itemNo = count.ToString(), sku = expressBookingDetail.AWBNumber.Replace(" ", "") + "*" + count + "-" + expressBookingDetail.Packages.Count, description = expressBookingDetail.Packages[i].Content, nativeDescription = expressBookingDetail.FrayteNumber + "-" + expressBookingDetail.ShipmentReference, hsCode = expressBookingDetail.AWBNumber.Replace(" ", ""), originCountry = expressBookingDetail.ShipFrom.Country.Name, unitValue = (expressBookingDetail.Packages[i].Value / expressBookingDetail.Packages[i].CartonValue), itemCount = expressBookingDetail.Packages[i].CartonValue, weight = expressBookingDetail.Packages[i].Weight, productURL = "" }; count++; etower.orderItems.Add(order); } eTowerRequest.Add(etower); return(eTowerRequest); }