コード例 #1
0
 public IHttpActionResult TrackAndTraceDashboard(TrackAfterShipTracking track)
 {
     try
     {
         var tracker = new AftershipTrackingRepository().GetMultipleTrackings(track);
         return(Ok(tracker));
     }
     catch (Exception ex)
     {
         Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
     }
     return(null);
 }
コード例 #2
0
 public IHttpActionResult GetMultipleTrackings(int userId)
 {
     try
     {
         var tracker = new AftershipTrackingRepository().GetMultipleTrackings(userId);
         return(Ok(tracker));
     }
     catch (Exception ex)
     {
         Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
     }
     return(null);
 }
コード例 #3
0
 public IHttpActionResult GetTracking(string CarrierName, string TrackingNumber)
 {
     try
     {
         var tracker = new AftershipTrackingRepository().GetTracking(CarrierName, TrackingNumber);
         return(Ok(tracker));
     }
     catch (Exception ex)
     {
         Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
     }
     return(null);
 }
コード例 #4
0
        public IHttpActionResult GetTrackInfo(FrayteTrackDto frayteTrack)
        {
            if (!string.IsNullOrWhiteSpace(frayteTrack.TrackRequest.TrackingNumber))
            {
                FrayteShipmentTracking trayteShipmentTracking = new FrayteShipmentTracking();

                trayteShipmentTracking = new AftershipTrackingRepository().GetTracking(frayteTrack.TrackRequest.Courier, frayteTrack.TrackRequest.TrackingNumber);

                if (trayteShipmentTracking != null)
                {
                    return(Ok(trayteShipmentTracking));
                }
                else
                {
                    return(Ok(new { Status = true, Message = "There is No Tracking Information availble", }));
                }
            }
            return(Ok(new { Status = true, Message = "There is No Tracking Information availble", }));
        }
コード例 #5
0
        public IHttpActionResult ProcessWebHook(AftershipWebhookObject webHookDetail)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("AfterShip hit"));
            if (webHookDetail != null)
            {
                FrayteResult result = new FrayteResult();
                try
                {
                    dynamic json = Newtonsoft.Json.JsonConvert.SerializeObject(webHookDetail);
                    Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception(json));

                    new DirectShipmentRepository().UpdateShipmentStatus(webHookDetail.msg.custom_fields.module_type, webHookDetail.msg.tag, webHookDetail.msg.title);
                    new DirectShipmentRepository().UpdateShipmentDetail(webHookDetail.msg.delivery_time, webHookDetail.msg.shipment_delivery_date, webHookDetail.msg.signed_by, webHookDetail.msg.title, webHookDetail.msg.custom_fields.module_type);
                    Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Status updtaed"));

                    if (webHookDetail.msg.custom_fields.module_type == FrayteShipmentServiceType.DirectBooking)
                    {
                        result = new AftershipTrackingRepository().SendTrackingStatusEmail(webHookDetail);
                    }
                    Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Email sent"));
                }
                catch (Exception ex)
                {
                    Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                }
                if (result.Status)
                {
                    return(Ok(result));
                }
                else
                {
                    return(BadRequest());
                }
            }
            else
            {
                return(BadRequest());
            }
        }
コード例 #6
0
        public List <TradelaneTracking> GetTracking(string Numbers)
        {
            List <TradelaneTracking>      TrackingList = new List <TradelaneTracking>();
            List <TradelaneTrackingModel> TTModel      = new List <TradelaneTrackingModel>();
            List <FrayteShipmentTracking> FSTList      = new List <FrayteShipmentTracking>();
            List <FrayteShipmentTracking> FSTDBList    = new List <FrayteShipmentTracking>();
            List <FrayteShipmentTracking> FSTBagList   = new List <FrayteShipmentTracking>();

            var Result = !string.IsNullOrEmpty(Numbers) ? Numbers.Split(',') : null;

            if (Result != null && Result.Length > 0)
            {
                foreach (var res in Result)
                {
                    string res1 = string.Empty;
                    if (res.Contains("MNESX"))
                    {
                        res1 = res;
                    }
                    else
                    {
                        res1 = res.Trim().Replace(" ", "");
                    }

                    if (res1 != null)
                    {
                        if (res1.Length > 10)
                        {
                            var MawbRes = new TradelaneShipmentRepository().GetMawbStr(res1);
                            if (!string.IsNullOrEmpty(MawbRes.Item1) && !string.IsNullOrEmpty(MawbRes.Item2))
                            {
                                res1 = MawbRes.Item2 + " " + MawbRes.Item1.Substring(0, 4) + " " + MawbRes.Item1.Substring(4, 4);
                            }
                        }

                        var NewResult1 = new TrackingRepository().GetShipmentDetail(res1);

                        if (NewResult1 != null)
                        {
                            if (NewResult1.TrackingType == "awb")
                            {
                                //Express
                                var TrackingType = "External";
                                var awbtracking  = new ExpresShipmentRepository().GetExpressAWBTracking(NewResult1.ShipmentId, TrackingType);
                                FSTList.Add(awbtracking);

                                TradelaneTracking tr = new TradelaneTracking();
                                tr.Status          = true;
                                tr.ModuleType      = "Express AWB";
                                tr.ExpressTracking = new List <FrayteShipmentTracking>();
                                tr.ExpressTracking = FSTList;
                                TrackingList.Add(tr);
                            }
                            else if (NewResult1.TrackingType == "bag")
                            {
                                //Express
                                var TrackingType = "External";
                                var bagtracking  = new ExpresShipmentRepository().GetExpressBagTracking(NewResult1.ShipmentId, TrackingType);
                                FSTBagList.Add(bagtracking);

                                TradelaneTracking tr = new TradelaneTracking();
                                tr.Status          = true;
                                tr.ModuleType      = "Express BAG";
                                tr.ExpressTracking = new List <FrayteShipmentTracking>();
                                tr.ExpressTracking = FSTBagList;
                                TrackingList.Add(tr);
                            }
                            else if (NewResult1.TrackingType == "exptn")
                            {
                                //Express
                                var TrackingType = "External";
                                var awbtracking  = new ExpresShipmentRepository().GetExpressAWBTracking(NewResult1.ShipmentId, TrackingType);
                                FSTList.Add(awbtracking);

                                TradelaneTracking tr = new TradelaneTracking();
                                tr.Status          = true;
                                tr.ModuleType      = "Express AWB";
                                tr.ExpressTracking = new List <FrayteShipmentTracking>();
                                tr.ExpressTracking = FSTList;
                                TrackingList.Add(tr);
                            }
                            else if (NewResult1.TrackingType == "expmn")
                            {
                                //Express
                                TradelaneTrackingModel TM = GetTradelaneShipmentTracking(NewResult1.ShipmentId);
                                TTModel.Add(TM);

                                TradelaneTracking tr = new TradelaneTracking();
                                tr.Status        = true;
                                tr.ModuleType    = "Express";
                                tr.Trackingmodel = new List <TradelaneTrackingModel>();
                                tr.Trackingmodel = TTModel;
                                TrackingList.Add(tr);
                            }
                            else if (NewResult1.TrackingType == "mawb")
                            {
                                //Tradelane
                                TradelaneTrackingModel TM = GetTradelaneShipmentTracking(NewResult1.ShipmentId);
                                TTModel.Add(TM);

                                TradelaneTracking tr = new TradelaneTracking();
                                tr.Status        = true;
                                tr.ModuleType    = "Tradelane";
                                tr.Trackingmodel = new List <TradelaneTrackingModel>();
                                tr.Trackingmodel = TTModel;
                                TrackingList.Add(tr);
                            }
                            else if (NewResult1.TrackingType == "tlfrn")
                            {
                                //Tradelane
                                TradelaneTrackingModel TM = GetTradelaneShipmentTracking(NewResult1.ShipmentId);
                                TTModel.Add(TM);

                                TradelaneTracking tr = new TradelaneTracking();
                                tr.Status        = true;
                                tr.ModuleType    = "Tradelane";
                                tr.Trackingmodel = new List <TradelaneTrackingModel>();
                                tr.Trackingmodel = TTModel;
                                TrackingList.Add(tr);
                            }
                            else if (NewResult1.TrackingType == "hawb")
                            {
                                //Tradelane
                                TradelaneTrackingModel TM = GetTradelaneShipmentTracking(NewResult1.ShipmentId);
                                TTModel.Add(TM);

                                TradelaneTracking tr = new TradelaneTracking();
                                tr.Status        = true;
                                tr.ModuleType    = "Tradelane";
                                tr.Trackingmodel = new List <TradelaneTrackingModel>();
                                tr.Trackingmodel = TTModel;
                                TrackingList.Add(tr);
                            }
                            else if (NewResult1.TrackingType == "dbtn")
                            {
                                //DirectBooking
                                var TrackingType   = dbContext.DirectShipments.Where(a => a.DirectShipmentId == NewResult1.ShipmentId).FirstOrDefault();
                                var TrackingNumber = TrackingType.TrackingDetail.Replace("Order_", "");
                                var TM             = new AftershipTrackingRepository().GetTracking(TrackingType.LogisticServiceType, TrackingNumber);
                                FSTDBList.Add(TM);

                                TradelaneTracking tr = new TradelaneTracking();
                                tr.Status      = true;
                                tr.ModuleType  = "DirectBooking";
                                tr.BagTracking = new List <FrayteShipmentTracking>();
                                tr.BagTracking = FSTDBList;
                                TrackingList.Add(tr);
                            }
                            else if (NewResult1.TrackingType == "dbfn")
                            {
                                //DirectBooking
                                var TrackingType   = dbContext.DirectShipments.Where(a => a.DirectShipmentId == NewResult1.ShipmentId).FirstOrDefault();
                                var TrackingNumber = TrackingType.TrackingDetail.Replace("Order_", "");
                                var TM             = new AftershipTrackingRepository().GetTracking(TrackingType.LogisticServiceType, TrackingNumber);
                                FSTDBList.Add(TM);

                                TradelaneTracking tr = new TradelaneTracking();
                                tr.Status      = true;
                                tr.ModuleType  = "DirectBooking";
                                tr.BagTracking = new List <FrayteShipmentTracking>();
                                tr.BagTracking = FSTDBList;
                                TrackingList.Add(tr);
                            }
                            else if (NewResult1.TrackingType == "dbIspcs")
                            {
                                //DirectBooking
                                var TrackingType   = dbContext.DirectShipments.Where(a => a.DirectShipmentId == NewResult1.ShipmentId).FirstOrDefault();
                                var TrackingNumber = TrackingType.TrackingDetail.Replace("Order_", "");
                                var TM             = new AftershipTrackingRepository().GetTracking(TrackingType.LogisticServiceType, TrackingNumber);
                                FSTDBList.Add(TM);

                                TradelaneTracking tr = new TradelaneTracking();
                                tr.Status      = true;
                                tr.ModuleType  = "DirectBooking";
                                tr.BagTracking = new List <FrayteShipmentTracking>();
                                tr.BagTracking = FSTDBList;
                                TrackingList.Add(tr);
                            }
                            else
                            {
                                TradelaneTracking tr = new TradelaneTracking();
                                tr.Status          = false;
                                tr.ModuleType      = null;
                                tr.Tracking        = null;
                                tr.BagTracking     = null;
                                tr.ExpressTracking = null;
                                tr.Trackingmodel   = null;
                                TrackingList.Add(tr);
                            }
                        }
                        else
                        {
                            TradelaneTracking tr = new TradelaneTracking();
                            tr.Status          = false;
                            tr.ModuleType      = null;
                            tr.Tracking        = null;
                            tr.BagTracking     = null;
                            tr.ExpressTracking = null;
                            tr.Trackingmodel   = null;
                            TrackingList.Add(tr);
                        }
                    }
                }
            }
            return(TrackingList);
        }
コード例 #7
0
        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());
        }