public IntegrtaionResult MapEAMGlobalIntegrationResponse(EAMGlobalResponse eamPostalResponse, List <PackageDraft> Packages) { IntegrtaionResult integrtaionResult = new IntegrtaionResult(); if (eamPostalResponse.Status) { integrtaionResult.Status = true; integrtaionResult.CourierName = FrayteCourierCompany.EAM; integrtaionResult.TrackingNumber = eamPostalResponse.AWB; integrtaionResult.PickupRef = null; integrtaionResult.PieceTrackingDetails = new List <CourierPieceDetail>(); int counter = 0; for (int i = 0; i < Packages.Count(); i++) { for (int j = 0; j < Packages[i].CartoonValue; j++) { CourierPieceDetail obj = new CourierPieceDetail(); obj.DirectShipmentDetailId = 0; obj.PieceTrackingNumber = string.Concat(eamPostalResponse.AWB, counter); obj.ImageUrl = eamPostalResponse.LabelUrl; integrtaionResult.PieceTrackingDetails.Add(obj); counter++; } } } else { integrtaionResult.Error = new FratyteError(); integrtaionResult.Error.Service = new List <string>(); integrtaionResult.Error.Service.AddRange(eamPostalResponse.ERROR); integrtaionResult.Status = false; } return(integrtaionResult); }
public EAMGlobalResponse CreateShipment(string shipmentXml, int DraftShipmentId) { EAMGlobalResponse response = new EAMGlobalResponse(); var logisticIntegration = UtilityRepository.getLogisticIntegration(UtilityRepository.GetOperationZone().OperationZoneId, AppSettings.ApplicationMode, FrayteIntegration.EAM); if (logisticIntegration != null) { string serverUrl = logisticIntegration.ServiceUrl; string trackingCode = string.Empty; var shipmentPackageTrackingDetail = new List <FraytePackageTrackingDetail>(); //Send XML var shipmentResult = CallWebservice(shipmentXml, serverUrl); //utf-8 only try { var xmltag = "<?xml version=" + "'1.0'" + " encoding=" + "'UTF-8'" + " ?>"; shipmentResult = xmltag + @shipmentResult; var result = XDocument.Parse(shipmentResult); if (!string.IsNullOrWhiteSpace(shipmentResult) && !shipmentResult.Contains("ERROR")) { var label = (from r in result.Descendants("LABEL") select new { Lable = r.Element("LINK") != null ? r.Element("LINK").Value : "", AWB = r.Element("AWB") != null ? r.Element("AWB").Value : "" }).FirstOrDefault(); response.LabelUrl = label.Lable; response.Status = true; response.AWB = label.AWB; } else { var pickupxml = XDocument.Parse(shipmentResult); var ElementsList = pickupxml.Descendants("MESSAGE") .Select(x => new { ElementContent = x.Value }) .ToList(); response.ERROR = new List <string>(); foreach (var message in ElementsList) { response.ERROR.Add(message.ElementContent); } new DirectShipmentRepository().SaveEasyPosyPickUpObject(@shipmentResult, shipmentXml, DraftShipmentId); } } catch (Exception ex) { var pickupxml = XDocument.Parse(shipmentResult); var Error = (from r in pickupxml.Descendants("Condition") select new { ErrorCode = r.Element("ConditionCode") != null ? r.Element("ConditionCode").Value : "", ErrorDescription = r.Element("ConditionData") != null ? r.Element("ConditionData").Value : "", }).ToList(); new DirectShipmentRepository().SaveEasyPosyPickUpObject(@shipmentResult, shipmentXml, DraftShipmentId); } } return(response); }