Пример #1
0
        //public List<TradelaneTrackingShipmentStatus> GetShipmentTrackingStatus(int TradelaneShipmentId)
        //{
        //    List<TradelaneTrackingShipmentStatus> TSL = new List<TradelaneTrackingShipmentStatus>();
        //    var TradelaneTracking = dbContext.TradelaneShipmentTrackings.Where(a => a.TradlaneShipmentId == TradelaneShipmentId).Select(a => a.AirportCode).ToList();
        //    var AirPortNew = TradelaneTracking.Distinct().ToList();

        //    if (AirPortNew != null && AirPortNew.Count > 0)
        //    {

        //        foreach (var APC in AirPortNew)
        //        {
        //            TradelaneTrackingShipmentStatus TTS = new TradelaneTrackingShipmentStatus();
        //            TTS.TrackingStatus = new List<TradelaneTrackingStatus>();
        //            var Tracking2 = dbContext.TradelaneShipmentTrackings.Where(a => a.TradlaneShipmentId == TradelaneShipmentId).GroupBy(a => a.AirportCode).ToList();
        //            var count = 1;
        //            foreach (var Tracking1 in Tracking2)
        //            {
        //                TTS.AirportCode = Tracking1.Key;
        //                var count1 = 0;
        //                foreach (var Tracking in Tracking1)
        //                {
        //                    var TS = new TradelaneTrackingStatus();
        //                    if (Tracking.AirportCode == APC && count == Tracking2.Count && count1 == 0)
        //                    {
        //                        TS.ShipmentCode = Tracking.TrackingCode;
        //                        TS.Pieces = Tracking.Pieces != null ? Tracking.Pieces.Value : 0;
        //                        TS.Date = Tracking.CreatedOnUtc != null ? Tracking.CreatedOnUtc : DateTime.MinValue;
        //                        TS.TotalWeight = Tracking.Weight != null ? Tracking.Weight.Value : 0;
        //                        TTS.TrackingStatus.Add(TS);
        //                    }
        //                    if (Tracking.AirportCode == APC && count == 1 && count1 == Tracking1.Count())
        //                    {
        //                        TS.ShipmentCode = Tracking.TrackingCode;
        //                        TS.Pieces = Tracking.Pieces != null ? Tracking.Pieces.Value : 0;
        //                        TS.Date = Tracking.CreatedOnUtc != null ? Tracking.CreatedOnUtc : DateTime.MinValue;
        //                        TS.TotalWeight = Tracking.Weight != null ? Tracking.Weight.Value : 0;
        //                        TTS.TrackingStatus.Add(TS);
        //                    }
        //                    if (Tracking.AirportCode == APC && count == 2 && count1 == 0)
        //                    {
        //                        TS.ShipmentCode = Tracking.TrackingCode;
        //                        TS.Pieces = Tracking.Pieces != null ? Tracking.Pieces.Value : 0;
        //                        TS.Date = Tracking.CreatedOnUtc != null ? Tracking.CreatedOnUtc : DateTime.MinValue;
        //                        TS.TotalWeight = Tracking.Weight != null ? Tracking.Weight.Value : 0;
        //                        TTS.TrackingStatus.Add(TS);
        //                    }
        //                    if (Tracking.AirportCode == APC && count == 2 && count1 == Tracking1.Count())
        //                    {
        //                        TS.ShipmentCode = Tracking.TrackingCode;
        //                        TS.Pieces = Tracking.Pieces != null ? Tracking.Pieces.Value : 0;
        //                        TS.Date = Tracking.CreatedOnUtc != null ? Tracking.CreatedOnUtc : DateTime.MinValue;
        //                        TS.TotalWeight = Tracking.Weight != null ? Tracking.Weight.Value : 0;
        //                        TTS.TrackingStatus.Add(TS);
        //                    }
        //                    if (Tracking.AirportCode == APC && count == 3 && count1 == 0)
        //                    {
        //                        TS.ShipmentCode = Tracking.TrackingCode;
        //                        TS.Pieces = Tracking.Pieces != null ? Tracking.Pieces.Value : 0;
        //                        TS.Date = Tracking.CreatedOnUtc != null ? Tracking.CreatedOnUtc : DateTime.MinValue;
        //                        TS.TotalWeight = Tracking.Weight != null ? Tracking.Weight.Value : 0;
        //                        TTS.TrackingStatus.Add(TS);
        //                    }
        //                    if (Tracking.AirportCode == APC && count == 3 && count1 == Tracking1.Count())
        //                    {
        //                        TS.ShipmentCode = Tracking.TrackingCode;
        //                        TS.Pieces = Tracking.Pieces != null ? Tracking.Pieces.Value : 0;
        //                        TS.Date = Tracking.CreatedOnUtc != null ? Tracking.CreatedOnUtc : DateTime.MinValue;
        //                        TS.TotalWeight = Tracking.Weight != null ? Tracking.Weight.Value : 0;
        //                        TTS.TrackingStatus.Add(TS);
        //                    }

        //                    count1++;
        //                }
        //            }
        //            TSL.Add(TTS);
        //        }
        //    }
        //    return TSL;
        //}

        public int GetTradelaneTracking(string Number, string NumberType)
        {
            var ReturnObj = 0;

            if (NumberType == "MAWB")
            {
                var MawbRes   = new TradelaneShipmentRepository().GetMawbStr(Number);
                var Mawb      = MawbRes.Item1;
                var AirlineId = MawbRes.Item2;
                if (!string.IsNullOrEmpty(AirlineId))
                {
                    var Airline  = dbContext.Airlines.Where(a => a.AirlineCode == AirlineId).FirstOrDefault();
                    var Shipment = dbContext.TradelaneShipments.Where(x => x.MAWB == Mawb && x.AirlineId == Airline.AirlineId).FirstOrDefault();
                    if (Shipment != null)
                    {
                        ReturnObj = Shipment.TradelaneShipmentId;
                    }
                }
                else
                {
                    var Shipment = dbContext.TradelaneShipments.Where(x => x.MAWB == Mawb).FirstOrDefault();
                    if (Shipment != null)
                    {
                        ReturnObj = Shipment.TradelaneShipmentId;
                    }
                }
            }
            else if (NumberType.Trim().Replace(" ", "") == "ShipmentReferenceNo")
            {
                var Result = dbContext.TradelaneShipments.Where(a => a.FrayteNumber == Number).FirstOrDefault();
                if (Result != null)
                {
                    ReturnObj = Result.TradelaneShipmentId;
                }
            }
            else if (NumberType.Trim().Replace(" ", "") == "HAWB")
            {
                var shipment = (from TSD in dbContext.TradelaneShipmentDetails
                                join TS in dbContext.TradelaneShipments
                                on TSD.TradelaneShipmentId equals TS.TradelaneShipmentId
                                where TSD.HAWB == Number
                                select new
                {
                    TS.TradelaneShipmentId
                }).FirstOrDefault();
                if (shipment != null && shipment.TradelaneShipmentId > 0)
                {
                    ReturnObj = shipment.TradelaneShipmentId;
                }
            }
            return(ReturnObj);
        }
Пример #2
0
        public TrackingModel ShipmentFilter(string FrayteNumber)
        {
            TrackingModel TGS = new TrackingModel();

            if (!string.IsNullOrEmpty(FrayteNumber))
            {
                if (FrayteNumber.ToUpper().Contains("TL"))
                {
                    TGS.ModuleType   = FrayteShipmentServiceType.TradeLaneBooking;
                    TGS.TrackingType = "FrayteNumber";
                }
                else if (!FrayteNumber.ToUpper().Contains("TL") && FrayteNumber.Length == 8)
                {
                    TGS.ModuleType   = FrayteShipmentServiceType.TradeLaneBooking;
                    TGS.TrackingType = "MAWB";
                }
                else if (!FrayteNumber.ToUpper().Contains("TL") && FrayteNumber.Length > 10)
                {
                    var MawbRes = new TradelaneShipmentRepository().GetMawbStr(FrayteNumber);
                    if (MawbRes != null && !string.IsNullOrEmpty(MawbRes.Item2))
                    {
                        TGS.ModuleType   = FrayteShipmentServiceType.TradeLaneBooking;
                        TGS.TrackingType = "MAWB";
                    }
                    else
                    {
                        TGS.ModuleType   = FrayteShipmentServiceType.DirectBooking;
                        TGS.TrackingType = "";
                    }
                }
                else
                {
                    TGS.ModuleType   = FrayteShipmentServiceType.DirectBooking;
                    TGS.TrackingType = "";
                }
            }
            return(TGS);
        }
        public List <TradelaneBookingReportMAWB> GetMAWBObj(int tradelaneShipmentId)
        {
            try
            {
                List <TradelaneBookingReportMAWB> list        = new List <TradelaneBookingReportMAWB>();
                TradelaneBookingReportMAWB        reportModel = new TradelaneBookingReportMAWB();
                var    ShipmentDetail = new TradelaneBookingRepository().GetTradelaneBookingDetails(tradelaneShipmentId, "");
                var    Custompdf      = new TradelaneShipmentRepository().GetMawbCustomizePdf(tradelaneShipmentId);
                string mawb           = string.Empty;
                if (!string.IsNullOrEmpty(ShipmentDetail.MAWB))
                {
                    if (ShipmentDetail.MAWB.Length == 8)
                    {
                        mawb = ShipmentDetail.MAWB.Substring(0, 4) + " " + ShipmentDetail.MAWB.Substring(3, 4);
                    }
                    else
                    {
                        mawb = ShipmentDetail.MAWB;
                    }
                }
                reportModel.MAWB                   = mawb;
                reportModel.ShipperAddress         = UtilityRepository.ConcatinateAddress(ShipmentDetail.ShipFrom, ShipmentDetail.DepartureAirport.AirportCode);
                reportModel.ShipperAccountNumber   = string.Empty;
                reportModel.ConsigneeAddress       = UtilityRepository.ConcatinateAddress(ShipmentDetail.ShipTo, ShipmentDetail.DestinationAirport.AirportCode);
                reportModel.ConsigneeAccountNumber = string.Empty;
                reportModel.NotifyParty            = ShipmentDetail.IsNotifyPartySameAsReceiver ? "NOTIFY: " + reportModel.ConsigneeAddress : "NOTIFY: " + UtilityRepository.ConcatinateAddress(ShipmentDetail.NotifyParty, "");
                reportModel.CarrierAgent           = string.Empty;
                reportModel.AirportofDeparture     = ShipmentDetail.ShipFrom.Country.Name;
                reportModel.DestinationAirport     = ShipmentDetail.DestinationAirport.AirportName;
                reportModel.DestinationAirportCode = ShipmentDetail.DestinationAirport.AirportCode;
                reportModel.CurencyCode            = ShipmentDetail.DeclaredCurrency.CurrencyCode;
                reportModel.AmountOfInsurance      = ShipmentDetail.InsuranceAmount.HasValue ? ShipmentDetail.InsuranceAmount.Value : 0;
                reportModel.MAWBCode               = ShipmentDetail.AirlinePreference.AilineCode;
                reportModel.MAWBWithCode           = ShipmentDetail.AirlinePreference.AilineCode + " " + mawb;
                reportModel.MAWBCountryCode        = ShipmentDetail.ShipFrom.Country.Code;
                reportModel.ShipmentDescription    = ShipmentDetail.ShipmentDescription;
                reportModel.Airline                = ShipmentDetail.AirlinePreference.AirLineName;

                reportModel.IssuingCarriersAgentNameandCity = Custompdf.IssuingCarriersAgentNameandCity;
                reportModel.AccountNo = Custompdf.AccountNo;
                reportModel.DeclaredValueForCarriage = Custompdf.DeclaredValueForCarriage;
                reportModel.DeclaredValueForCustoms  = Custompdf.DeclaredValueForCustoms;
                reportModel.ValuationCharge          = Custompdf.ValuationCharge;
                reportModel.Tax = Custompdf.Tax;
                reportModel.TotalOtherChargesDueAgent   = Custompdf.TotalOtherChargesDueAgent;
                reportModel.TotalOtherChargesDueCarrier = Custompdf.TotalOtherChargesDueCarrier;
                reportModel.OtherCharges            = Custompdf.OtherCharges;
                reportModel.ChargesAtDestination    = Custompdf.ChargesAtDestination;
                reportModel.TotalCollectCharges     = Custompdf.TotalCollectCharges;
                reportModel.CurrencyConversionRates = Custompdf.CurrencyConversionRates;
                reportModel.TotalPrepaid            = Custompdf.TotalPrepaid;
                reportModel.TotalCollect            = Custompdf.TotalCollect;
                reportModel.HandlingInformation     = Custompdf.HandlingInformation;
                reportModel.AgentsIATACode          = Custompdf.AgentsIATACode;

                if (UtilityRepository.GetOperationZone().OperationZoneId == 1)
                {
                    reportModel.IssuedBy  = "FRAYTE LOGISTICS LIMITED" + Environment.NewLine;
                    reportModel.IssuedBy += "501 5/F KWONG LOONG TAI BUILDING" + Environment.NewLine;
                    reportModel.IssuedBy += "1016-1018 TAI NAN WEST STREET" + ", " + "CHEUNG SHA WAN" + " ," + "HON";
                }
                else
                {
                    reportModel.IssuedBy  = "FRAYTE LOGISTICS LIMITED" + Environment.NewLine;
                    reportModel.IssuedBy += "501 5/F KWONG LOONG TAI BUILDING" + Environment.NewLine;
                    reportModel.IssuedBy += "1016-1018 TAI NAN WEST STREET" + ", " + "CHEUNG SHA WAN" + " ," + "HON";
                }

                List <HAWBTradelanePackage> package;
                var collection = (from r in dbContext.TradelaneShipmentDetails
                                  join s in dbContext.TradelaneShipments on r.TradelaneShipmentId equals s.TradelaneShipmentId
                                  select new
                {
                    HAWBNumber = s.HAWBNumber,
                    TradelaneShipmentId = r.TradelaneShipmentId,
                    TradelaneShipmentDetailId = r.TradelaneShipmentDetailId,
                    CartonNumber = r.CartonNumber,
                    CartonValue = r.CartonValue,
                    Length = r.Length,
                    Width = r.Width,
                    Height = r.Height,
                    Weight = r.Weight,
                    HAWB = r.HAWB
                }).Where(p => p.TradelaneShipmentId == tradelaneShipmentId).ToList();

                if (collection.Count > 0)
                {
                    package = collection.GroupBy(x => x.HAWB)
                              .Select(group => new HAWBTradelanePackage
                    {
                        TradelaneShipmentId = group.FirstOrDefault().TradelaneShipmentId,
                        HAWB            = group.Key,
                        HAWBNumber      = group.FirstOrDefault().HAWBNumber.HasValue ? group.FirstOrDefault().HAWBNumber.Value : 0,
                        TotalCartons    = group.Select(p => p.CartonValue).Sum(),
                        EstimatedWeight = group.Select(p => p.Weight * p.CartonValue).Sum(),
                        TotalVolume     = group.Select(p => (p.Length * p.Width * p.Height) * p.CartonValue).Sum(),
                        TotalWeight     = group.Select(p => p.Weight * p.CartonValue).Sum(),
                        Packages        = group.Select(subGroup => new TradelanePackage
                        {
                            CartonNumber = subGroup.CartonNumber,
                            CartonValue  = subGroup.CartonValue,
                            HAWB         = subGroup.HAWB,
                            Height       = subGroup.Height,
                            Length       = subGroup.Length,
                            TradelaneShipmentDetailId = subGroup.TradelaneShipmentDetailId,
                            TradelaneShipmentId       = subGroup.TradelaneShipmentId,
                            Weight = subGroup.Weight,
                            Width  = subGroup.Width
                        }).ToList()
                    }).ToList();
                }
                else
                {
                    return(null);
                }

                if (package != null)
                {
                    reportModel.TotalCartons    = package.Sum(p => p.TotalCartons);
                    reportModel.TotalWeight     = package.Sum(p => p.TotalWeight);
                    reportModel.EstimatedWeight = package.Sum(p => p.EstimatedWeight);
                    reportModel.TotalVolume     = reportModel.TotalVolume = ShipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? Math.Round(package.Sum(p => p.TotalVolume) / (100 * 100 * 100), 2) : Math.Round(package.Sum(p => p.TotalVolume) / (39.37M * 39.37M * 39.37M), 2);
                    reportModel.DimensionUnit   = ShipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? "CM" : "IN";
                    reportModel.WeightUnit      = ShipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? "KG" : "LB";
                    reportModel.VolumeUnit      = ShipmentDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? "CBM" : "CBM";

                    reportModel.ShipmentDescription += Environment.NewLine + "VOL " + reportModel.TotalVolume + " " + reportModel.VolumeUnit;
                    reportModel.ShipmentDescription += Environment.NewLine + "VOL WEIGHT = " + reportModel.TotalWeight + " " + reportModel.WeightUnit;
                    reportModel.CreatedOn            = DateTime.UtcNow;
                    reportModel.Signature            = "Frayte Logistics SPX";
                    reportModel.CreatedOnCountry     = "Hong Kong";
                }

                list.Add(reportModel);
                return(list);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Пример #4
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);
        }
Пример #5
0
        public TrackingModel GetShipmentDetail(string ModuleType, string TrackingType, string FrayteNumber)
        {
            TrackingModel     TGS = new TrackingModel();
            TradelaneShipment Shipment;

            if (!string.IsNullOrEmpty(FrayteNumber) && ModuleType == FrayteShipmentServiceType.TradeLaneBooking)
            {
                if (TrackingType == "FrayteNumber")
                {
                    Shipment = dbContext.TradelaneShipments.Where(x => x.FrayteNumber == FrayteNumber).FirstOrDefault();
                    if (Shipment != null && Shipment.TradelaneShipmentId > 0)
                    {
                        TGS.ModuleType   = FrayteShipmentServiceType.TradeLaneBooking;
                        TGS.ShipmentId   = Shipment.TradelaneShipmentId;
                        TGS.TrackingType = "frn";
                        goto End;
                    }
                }
                if (TrackingType == "MAWB")
                {
                    var MawbRes = new TradelaneShipmentRepository().GetMawbStr(FrayteNumber);
                    if (!string.IsNullOrEmpty(MawbRes.Item1) && !string.IsNullOrEmpty(MawbRes.Item2))
                    {
                        var Airline = dbContext.Airlines.Where(a => a.AirlineCode == MawbRes.Item2).FirstOrDefault();
                        Shipment = dbContext.TradelaneShipments.Where(x => x.MAWB == MawbRes.Item1 && x.AirlineId == Airline.AirlineId).FirstOrDefault();
                        if (Shipment != null)
                        {
                            TGS.ModuleType   = FrayteShipmentServiceType.TradeLaneBooking;
                            TGS.ShipmentId   = Shipment.TradelaneShipmentId;
                            TGS.TrackingType = "mawb";
                            goto End;
                        }
                    }
                    else
                    {
                        Shipment = dbContext.TradelaneShipments.Where(x => x.MAWB == MawbRes.Item1).FirstOrDefault();
                        if (Shipment != null)
                        {
                            TGS.ModuleType   = FrayteShipmentServiceType.TradeLaneBooking;
                            TGS.ShipmentId   = Shipment.TradelaneShipmentId;
                            TGS.TrackingType = "mawb";
                            goto End;
                        }
                    }
                }

                var shipment = (from TSD in dbContext.TradelaneShipmentDetails
                                join TS in dbContext.TradelaneShipments
                                on TSD.TradelaneShipmentId equals TS.TradelaneShipmentId
                                where TSD.HAWB == FrayteNumber
                                select new
                {
                    TS.TradelaneShipmentId
                }).FirstOrDefault();
                if (shipment != null && shipment.TradelaneShipmentId > 0)
                {
                    TGS.ModuleType   = FrayteShipmentServiceType.TradeLaneBooking;
                    TGS.ShipmentId   = shipment.TradelaneShipmentId;
                    TGS.TrackingType = "hawb";
                }
            }
            if (!string.IsNullOrEmpty(FrayteNumber) && string.IsNullOrEmpty(TGS.ModuleType) && string.IsNullOrEmpty(TGS.TrackingType))
            {
                var shipment = (from DSPD in dbContext.PackageTrackingDetails
                                join DSD in dbContext.DirectShipmentDetails
                                on DSPD.DirectShipmentDetailId equals DSD.DirectShipmentDetailId
                                join DS in dbContext.DirectShipments
                                on DSD.DirectShipmentId equals DS.DirectShipmentId
                                where DSPD.TrackingNo == FrayteNumber || DS.TrackingDetail.Contains(FrayteNumber)
                                select new
                {
                    DS.TrackingDetail,
                    DS.LogisticServiceType
                }).FirstOrDefault();
                if (shipment != null && !string.IsNullOrEmpty(shipment.TrackingDetail))
                {
                    TGS.ModuleType   = FrayteShipmentServiceType.DirectBooking;
                    TGS.TrackingType = "TrackingNo";
                    TGS.CarrierType  = shipment.LogisticServiceType;
                    TGS.Number       = shipment.TrackingDetail.Replace("Order_", "");
                    goto End;
                }
                var Result1 = dbContext.DirectShipments.Where(a => a.FrayteNumber == FrayteNumber).FirstOrDefault();
                if (Result1 != null)
                {
                    TGS.ModuleType   = FrayteShipmentServiceType.DirectBooking;
                    TGS.TrackingType = "FrayteNumber";
                    TGS.CarrierType  = Result1.LogisticServiceType;
                    TGS.Number       = Result1.TrackingDetail.Replace("Order_", "");
                    goto End;
                }
            }
End:
            return(TGS);
        }