public FrayteManifestName GenerateExpressTrackandTraceDetail(ExpressTrackandTrace trackdetail) { FrayteManifestName result = new FrayteManifestName(); string Name = ""; if (trackdetail.CustomerName == "ALL") { var OperationZone = UtilityRepository.GetOperationZone(); if (OperationZone.OperationZoneId == 1) { Name = "AllHK"; } else if (OperationZone.OperationZoneId == 2) { Name = "AllUK"; } } else { Name = trackdetail.CustomerName; } try { var track = new ExpressRepository().GetExpressTrackAndTraceDetail(trackdetail); if (track != null && track.Count > 0) { ReportTemplate.Other.AllUKReport rp = new ReportTemplate.Other.AllUKReport(); rp.DataSource = track; if (File.Exists(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "ExpressTrack&Trace" + "/" + Name + "_" + "Express_Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx")) { File.Delete(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "ExpressTrack&Trace" + "/" + Name + "_" + "Express_Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx"); rp.ExportToXlsx(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "ExpressTrack&Trace" + "/" + Name + "_" + "Express_Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx"); result.FileName = Name + "_" + "Express_Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx"; result.FilePath = AppSettings.WebApiPath + "ReportFiles/ExpressTrack&Trace/" + Name + "_" + "Express_Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx"; result.FileStatus = true; } else { System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder + "/" + "ExpressTrack&Trace" + "/")); rp.ExportToXlsx(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + "/" + "ExpressTrack&Trace" + "/" + Name + "_" + "Express_Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx"); result.FileName = Name + "_" + "Express_Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx"; result.FilePath = AppSettings.WebApiPath + "ReportFiles/ExpressTrack&Trace/" + Name + "_" + "Express_Track_Trace_Detail" + "_" + DateTime.Now.ToString("dd_MM_yyyy") + ".xlsx"; result.FileStatus = true; } } } catch (Exception ex) { } return(result); }
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); }
private string PackageLabelPath_EXS_E1(int expressId) { string attachments = string.Empty; var shipment = dbContext.Expresses.Find(expressId); if (shipment != null) { FrayteLogicalPhysicalPath path = new ExpressRepository().GetShipmentLogisticlabelPath(expressId); //= new ExpressRepository().GetShipmentAlllabelPath(expressId); string pdfFileName = string.Empty; string physycalpath = string.Empty; var collection = (from r in dbContext.ExpressDetails join l in dbContext.ExpressDetailPackageLabels on r.ExpressDetailId equals l.ExpressShipmentDetailId where r.ExpressId == expressId select l).ToList(); if (collection.Count > 0) { foreach (var item in collection) { if (path != null) { if (path.PhysicalPath.Contains("~")) { physycalpath = HttpContext.Current.Server.MapPath(path.PhysicalPath + "PackageLabel/Express/" + expressId + "/"); attachments += ";" + physycalpath + item.PackageLabelName.Replace(".jpg", ".pdf"); } else { attachments += ";" + path.PhysicalPath + "/PackageLabel/Express/" + expressId + "/" + item.PackageLabelName.Replace(".jpg", ".pdf");; } } else { physycalpath = HttpContext.Current.Server.MapPath("~/PackageLabel/Express/" + expressId + "/"); attachments += ";" + physycalpath + item.PackageLabelName.Replace(".jpg", ".pdf");; } } } if (path != null) { if (path.PhysicalPath.Contains("~")) { // For developement pdfFileName = AppSettings.WebApiPath + "PackageLabel/Express/" + expressId + "/"; physycalpath = HttpContext.Current.Server.MapPath(path.PhysicalPath + "PackageLabel/Express/" + expressId + "/"); attachments += ";" + physycalpath + shipment.LogisticLabel; } else { physycalpath = path.PhysicalPath + "/PackageLabel/Express/" + expressId + "/"; attachments += ";" + physycalpath + shipment.LogisticLabel; } } else { physycalpath = HttpContext.Current.Server.MapPath("~/PackageLabel/Express/" + expressId + "/"); attachments += ";" + physycalpath + shipment.LogisticLabel; } } return(attachments); }
public BringRequestModel MapDirectBookingDetailToShipmentRequestDto(DirectBookingShipmentDraftDetail directBookingDetail) { 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 < directBookingDetail.Packages.Count; i++) { for (int j = 0; j < directBookingDetail.Packages[i].CartoonValue; j++) { package.weightInKg = directBookingDetail.Packages[i].Weight.ToString("0.##"); package.goodsDescription = directBookingDetail.Packages[i].Content; package.dimensions = new Dimensions() { heightInCm = directBookingDetail.Packages[i].Height, lengthInCm = directBookingDetail.Packages[i].Length, widthInCm = directBookingDetail.Packages[i].Width, }; package.containerId = directBookingDetail.FrayteNumber; package.packageType = ""; package.numberOfItems = ""; package.correlationId = "PACKAGE-" + directBookingDetail.FrayteNumber; packages.Add(package); } } var ShipFrom = new ExpressRepository().getHubAddress(directBookingDetail.ShipTo.Country.CountryId, directBookingDetail.ShipTo.PostCode, directBookingDetail.ShipTo.State); ConsignmentModel consign = new ConsignmentModel() { shippingDateTime = DateTime.Now.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 = ShipFrom.Address, //addressLine2 = ShipFrom.Address2, //additionalAddressInfo = "", //postalCode = ShipFrom.PostCode, //city = ShipFrom.City, //countryCode = ShipFrom.Country.Code2, //reference = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1, //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 = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1, contact = new Contact { name = "Priority Cargo AS", email = "*****@*****.**", phoneNumber = "+47 9760 0402" } }, recipient = new Recipient() { name = string.IsNullOrWhiteSpace(directBookingDetail.ShipTo.CompanyName) ? directBookingDetail.ShipTo.FirstName + " " + directBookingDetail.ShipTo.LastName : directBookingDetail.ShipTo.CompanyName, addressLine = directBookingDetail.ShipTo.Address, addressLine2 = directBookingDetail.ShipTo.Address2, additionalAddressInfo = "", postalCode = directBookingDetail.ShipTo.PostCode, city = directBookingDetail.ShipTo.City, countryCode = directBookingDetail.ShipTo.Country.Code2, //reference = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1, reference = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1, contact = new Contact { name = directBookingDetail.ShipTo.FirstName + " " + directBookingDetail.ShipTo.LastName, email = string.IsNullOrEmpty(directBookingDetail.ShipTo.Email) ? "*****@*****.**" : directBookingDetail.ShipTo.Email, phoneNumber = directBookingDetail.ShipTo.Phone } }, pickupPoint = null }, product = new Product() { id = "PA_DOREN", customerNumber = directBookingDetail.CustomerRateCard.NetworkCode, services = null, customsDeclaration = directBookingDetail.CustomInfo.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 IHttpActionResult ExpressShipmentBooking(ExpressShipmentRequest Shipment) { try { List <FrayteUploadshipment> _upload = new ExpressShipmentRepository().JsonValidate(Shipment, FrayteCallingType.FrayteApi); if (_upload.Count > 0) { return(Ok(_upload[0].Errors)); } else { var shipment = new ExpressShipmentRepository().MappingFrayteRequestToExpressBookingDetail(Shipment); ExpressShipmentResponseModel ExpressResponse = new ExpressShipmentResponseModel(); ExpressShipmentModel model = new ExpressRepository().SaveShipment(shipment); if (shipment.Error.Status && model.ShipmentStatusId == (int)FrayteExpressShipmentStatus.Scanned) { #region Logistic Integration if (shipment.Service.HubCarrier == FrayteCourierCompany.DHL) { #region DHL Integration IntegrtaionResult result = new IntegrtaionResult(); //step 1. Mapping With express model to ShipmentRequestDto var shipmentRequestDto = new DHLRepository().MapExpressShipmentToDHLShipmentRequestDto(shipment); //Step 2. Create Xml string shipmentXML = string.Empty; //Version5.0 shipmentXML = new DHLRepository().CreateXMLForDHL(shipmentRequestDto); //Version 6.2 not in use // shipmentXML = new DHLUKRepositry().CreateXMLForDHLUK(shipmentRequestDto); string xml_in = string.Empty; xml_in = File.ReadAllText(@shipmentXML); //step 3. Create Shipment var DHLResponse = new DHLResponseDto(); DHLResponse = new DHLRepository().CreateShipment(xml_in, shipmentRequestDto); //step 4. Mapping ShipmentResonse to IntegrtaionResult result = new DHLRepository().MapDHLIntegrationResponse(DHLResponse); if (result.Status) { if (shipment.Service.HubCarrier == FrayteCourierCompany.DHL) { //Step 1.1 Mapping ShipmentResult to IntegrtaionResult try { new ExpressRepository().MappingCourierPieceDetail(result, shipment); } catch (Exception Ex) { throw (new FrayteApiException("MapDHLCourierPieceDetailError", Ex)); } } //Step3 : Save Main Tracking Number new ExpressRepository().SaveMainTrackingDetail(shipment, result, xml_in, ""); new ExpressRepository().SaveTrackingDetail(shipment, result); // AfterShipIntegration if (AppSettings.ApplicationMode == FrayteApplicationMode.Live) { FrayteAfterShipTracking aftershipTracking = new AftershipTrackingRepository().MapDirectShipmentObjToAfterShip(shipment.ExpressId, FrayteShipmentServiceType.Express); if (aftershipTracking != null && AppSettings.ApplicationMode == FrayteApplicationMode.Live) { //Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Integration in aftership")); new AftershipTrackingRepository().CreateTracking(aftershipTracking); } } //Step4: //Start downloading the images from DHL server and making PDF var count = 1; var totalpiece = result.PieceTrackingDetails.Count(); totalpiece = totalpiece - 1; foreach (var data in result.PieceTrackingDetails.Take(totalpiece)) { if (shipment.Service.HubCarrier == FrayteCourierCompany.DHL) { // Step3.1 data.LabelName = new DHLRepository().ExpressDownloadDHLImage(data, totalpiece, count, shipment.ExpressId); } if (!data.PieceTrackingNumber.Contains("AirwayBillNumber_")) { //Step3.2 new ExpressRepository().SavePackageDetail(data, result.CourierName); } count++; } var CourierPieceDetail = result.PieceTrackingDetails.Where(t => t.PieceTrackingNumber.Contains("AirwayBillNumber_")).FirstOrDefault(); if (CourierPieceDetail != null) { var data1 = new DHLRepository().ExpressDownloadDHLImage(CourierPieceDetail, totalpiece, 0, shipment.ExpressId); // save all dhl image new ExpressRepository().SaveLogisticLabelImage(shipment.ExpressId, data1); } if (result.Status) { var status = Generate_Seperate_PackageLabelPDF(shipment.ExpressId, shipment, result); // Send Booking confirmation email if (status.Status) { ExpressEmailModel emailModel = new ExpressEmailModel(); emailModel = new ExpressRepository().Fill_EXS_E1Model(emailModel, shipment); if (emailModel != null) { new ExpressRepository().SendEmail_EXS_E1(emailModel); } new ExpressShipmentRepository().MappingFrayteResponseToExpressBookingDetail(shipment, result, ExpressResponse); } } } else { shipment.Error = result.Error; } #endregion } if (shipment.Service.HubCarrier == FrayteCourierCompany.Yodel) { #region Yodel Integration //Map Direct Booking object with parcel hub objects Frayte.Services.Models.ParcelHub.ParcelHubShipmentRequest request = new ParcelHubRepository().MapExpressBookingDetailToShipmentRequest(shipment); //Create shipment in Parcel hub Frayte.Services.Models.ParcelHub.ParcelHubResponse response = new ParcelHubRepository().CreateShipment(request); if (response.Error.IsMailSend) { //Send error mail to developer shipment.Error = new FratyteError(); shipment.Error.Custom = new List <string>(); shipment.Error.Package = new List <string>(); shipment.Error.Address = new List <string>(); shipment.Error.Service = new List <string>(); shipment.Error.ServiceError = new List <string>(); shipment.Error.Miscellaneous = new List <string>(); shipment.Error.MiscErrors = new List <FrayteKeyValue>(); shipment.Error = response.Error; new DirectShipmentRepository().SaveExpressEasyPosyPickUpObject(Newtonsoft.Json.JsonConvert.SerializeObject(response.Error).ToString(), Newtonsoft.Json.JsonConvert.SerializeObject(shipment).ToString(), shipment.ExpressId); } else { //Mapping ShipmentResonse to IntegrtaionResult var result = new ParcelHubRepository().MappingExpressParcelHubToIntegrationResult(shipment, response, null); if (result.Status) { //Mapping ShipmentResult to IntegrtaionResult new ParcelHubRepository().MappingExpressCourierPieceDetail(result, shipment, shipment.ExpressId); //Save Package Label Tracking detail new ExpressRepository().SaveMainTrackingDetail(shipment, result, response.Request, response.Response); FratyteError Error = new ParcelHubRepository().DownloadExpressParcelHubPackageImage(shipment, result, shipment.ExpressId); //Start Making Final One pdf file for all package label Generate_Seperate_PackageLabelPDF(shipment.ExpressId, shipment, result); if (result.Status) { ExpressEmailModel emailModel = new ExpressEmailModel(); emailModel = new ExpressRepository().Fill_EXS_E1Model(emailModel, shipment); if (emailModel != null) { new ExpressRepository().SendEmail_EXS_E1(emailModel); } new ExpressShipmentRepository().MappingFrayteResponseToExpressBookingDetail(shipment, result, ExpressResponse); } shipment.Error = new FratyteError() { Status = result.Status, }; } else { if (result.Error.IsMailSend) { //Send error mail to developer shipment.Error = new FratyteError(); shipment.Error.Custom = new List <string>(); shipment.Error.Package = new List <string>(); shipment.Error.Address = new List <string>(); shipment.Error.Service = new List <string>(); shipment.Error.ServiceError = new List <string>(); shipment.Error.Miscellaneous = new List <string>(); shipment.Error.MiscErrors = new List <FrayteKeyValue>(); shipment.Error = result.Error; } } } #endregion } if (shipment.Service.HubCarrier == FrayteCourierCompany.Hermes) { #region Hermes Integration Frayte.Services.Models.ParcelHub.ParcelHubShipmentRequest request = new ParcelHubRepository().MapExpressBookingDetailToShipmentRequest(shipment); //Create shipment in Parcel hub Frayte.Services.Models.ParcelHub.ParcelHubResponse response = new ParcelHubRepository().CreateHermesShipment(request); if (response.Error.IsMailSend) { //Send error mail to developer shipment.Error = new FratyteError(); shipment.Error.Custom = new List <string>(); shipment.Error.Package = new List <string>(); shipment.Error.Address = new List <string>(); shipment.Error.Service = new List <string>(); shipment.Error.ServiceError = new List <string>(); shipment.Error.Miscellaneous = new List <string>(); shipment.Error.MiscErrors = new List <FrayteKeyValue>(); shipment.Error = response.Error; new DirectShipmentRepository().SaveExpressEasyPosyPickUpObject(Newtonsoft.Json.JsonConvert.SerializeObject(response.Error).ToString(), Newtonsoft.Json.JsonConvert.SerializeObject(shipment).ToString(), shipment.ExpressId); } else { //Mapping ShipmentResonse to IntegrtaionResult var result = new ParcelHubRepository().MappingExpressParcelHubToIntegrationResult(shipment, response, null); if (result.Status) { //Mapping ShipmentResult to IntegrtaionResult new ParcelHubRepository().MappingExpressCourierPieceDetail(result, shipment, shipment.ExpressId); //Save Package Label Tracking detail new ExpressRepository().SaveMainTrackingDetail(shipment, result, response.Request, response.Response); //Start Making Final One pdf file for all package label Generate_Seperate_PackageLabelPDF(shipment.ExpressId, shipment, result); if (result.Status) { ExpressEmailModel emailModel = new ExpressEmailModel(); emailModel = new ExpressRepository().Fill_EXS_E1Model(emailModel, shipment); if (emailModel != null) { new ExpressRepository().SendEmail_EXS_E1(emailModel); } new ExpressShipmentRepository().MappingFrayteResponseToExpressBookingDetail(shipment, result, ExpressResponse); } shipment.Error = new FratyteError() { Status = result.Status, }; } else { if (result.Error.IsMailSend) { //Send error mail to developer shipment.Error = new FratyteError(); shipment.Error.Custom = new List <string>(); shipment.Error.Package = new List <string>(); shipment.Error.Address = new List <string>(); shipment.Error.Service = new List <string>(); shipment.Error.ServiceError = new List <string>(); shipment.Error.Miscellaneous = new List <string>(); shipment.Error.MiscErrors = new List <FrayteKeyValue>(); shipment.Error = result.Error; } } } #endregion } if (shipment.Service.HubCarrier.ToUpper().Contains(FrayteCourierCompany.EAM)) { #region EAM Global Integration IntegrtaionResult result = new IntegrtaionResult(); if (shipment.Service.HubCarrier.ToUpper().Contains(FrayteCourierCompany.EAM)) { var shipmentRequestDto = new EAMGlobalRepository().MapExpressBookingDetailToShipmentRequestDto(shipment); string shipmentXML = new EAMGlobalRepository().CreateXMLForEAM(shipmentRequestDto); string xml_in = File.ReadAllText(@shipmentXML); //Create Shipment var shipmentResult = new EAMGlobalRepository().CreateShipment(xml_in, shipment.ExpressId); result = new EAMGlobalRepository().MapExpressEAMGlobalIntegrationResponse(shipmentResult, shipment.Packages); } if (result.Status) { if (shipment.Service.HubCarrier.ToUpper().Contains(FrayteCourierCompany.EAM)) { //Mapping ShipmentResult to IntegrtaionResult new ExpressRepository().MappingCourierPieceDetail(result, shipment); } //Save Package Label Tracking detail new ExpressRepository().SaveMainTrackingDetail(shipment, result, "", ""); //Start downloading the images from DPD server and making PDF var count = 1; foreach (var data in result.PieceTrackingDetails) { if (shipment.Service.HubCarrier.ToUpper().Contains(FrayteCourierCompany.EAM)) { //Step3.1 data.LabelName = new EAMGlobalRepository().DownloadExpressEAMImageTOPDF(data, result.PieceTrackingDetails.Count(), count, shipment.ExpressId, shipment.Service); } // Step3.2 new ExpressRepository().SavePackageDetail(data, result.CourierName); count++; } //Step:4 Generate PDF Generate_Seperate_PackageLabelPDF(shipment.ExpressId, shipment, result); if (result.Status) { ExpressEmailModel emailModel = new ExpressEmailModel(); emailModel = new ExpressRepository().Fill_EXS_E1Model(emailModel, shipment); if (emailModel != null) { new ExpressRepository().SendEmail_EXS_E1(emailModel); } new ExpressShipmentRepository().MappingFrayteResponseToExpressBookingDetail(shipment, result, ExpressResponse); } shipment.Error = new FratyteError() { Status = result.Status, }; } else { shipment.Error = result.Error; } #endregion } #endregion return(Ok(ExpressResponse)); } } } catch (Exception Ex) { string error = ReadException(Ex); ExpressErrorResponse Response = new FrayteApiErrorCodeRepository().SaveExpressApiError(error); return(Ok(Response)); } return(Ok()); }