Exemple #1
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);
        }
Exemple #2
0
        public TradelaneTrackingModel GetTradelaneShipmentTracking(int TradelaneShipmentId)
        {
            TradelaneTrackingModel TTM = new TradelaneTrackingModel();

            TTM.TradelaneOperationalDetail = new List <TradelaneOperationslTrackingModel>();
            TTM.ShipmentDetail             = new TradelanePublicDetail();
            TTM.TradelaneStatus            = new List <TradelaneTrackingShipmentStatus>();
            try
            {
                TTM.TradelaneStatus = GetShipmentTrackingStatus(TradelaneShipmentId);

                var TB = new TradelaneBookingRepository().GetTradelaneBookingDetails(TradelaneShipmentId, "TradelaneShipmentBooking");

                var Res = dbContext.TradelaneShipmentDetails.Where(a => a.TradelaneShipmentId == TradelaneShipmentId).ToList();
                //var ShipmentDetail = dbContext.TradelaneShipments.Where(a => a.TradelaneShipmentId == TradelaneShipmentId).FirstOrDefault();
                if (TB != null)
                {
                    TTM.ShipmentDetail.CurrentStatus          = dbContext.ShipmentStatus.Where(a => a.ShipmentStatusId == TB.ShipmentStatusId).FirstOrDefault().DisplayStatusName;
                    TTM.ShipmentDetail.DepartureAirportCode   = TB.DepartureAirport.AirportCode;
                    TTM.ShipmentDetail.DestinationAirportCode = TB.DestinationAirport.AirportCode;
                    TTM.ShipmentDetail.EstimatedWeight        = Res.Sum(a => a.Weight);
                    TTM.ShipmentDetail.FrayteNumber           = TB.FrayteNumber;
                    TTM.ShipmentDetail.Mawb        = TB.AirlinePreference.AilineCode + " " + TB.MAWB.Substring(0, 4) + " " + TB.MAWB.Substring(4, 4) ?? "";
                    TTM.ShipmentDetail.TotalPieces = Res.Count;
                    TTM.ShipmentDetail.TotalVolume = TB.PakageCalculatonType == FraytePakageCalculationType.kgtoCms ? Math.Round((Res.Sum(p => p.Length * p.Weight * p.Height)) / (100 * 100 * 100), 2) : Math.Round((Res.Sum(p => p.Length * p.Weight * p.Height)) / (39.37M * 39.37M * 39.37M), 2);
                }

                var Result = dbContext.TradelaneShipmentTrackings.Where(a => a.TradlaneShipmentId == TradelaneShipmentId).ToList();

                if (Result != null && Result.Count > 0)
                {
                    foreach (var TM in Result)
                    {
                        TradelaneOperationslTrackingModel TlST = new TradelaneOperationslTrackingModel();
                        TlST.TradelaneShipmentTrackingId = TM.TradelaneShipmentTrackingId;
                        TlST.TradelaneShipmentId         = TM.TradlaneShipmentId;
                        TlST.Weight = TM.Weight != null ? TM.Weight.Value : 0;
                        TlST.Pieces = TM.Pieces != null ? TM.Pieces.Value : 0;
                        TlST.TrackingDescription = TM.TrackingDescription;
                        TlST.FlightNo            = TM.FlightNumber;
                        TlST.TrackingCode        = TM.TrackingCode;
                        TlST.CreatedOnUtc        = TM.CreatedOnUtc;
                        TlST.CreatedBy           = TM.CreatedBy;
                        TlST.AirportCode         = TM.AirportCode;
                        TTM.TradelaneOperationalDetail.Add(TlST);
                    }
                }
                else
                {
                }

                TTM.TradelaneTrackingDetail = new List <TradelaneUpdateTrackingModel>();

                TTM.TradelaneTrackingDetail = (from TS in dbContext.TradelaneFlightDetails
                                               where TS.TradelaneShipmentId == TradelaneShipmentId
                                               select new TradelaneUpdateTrackingModel
                {
                    TradelaneFlightId = TS.TradelaneFlightDetailId,
                    TradelaneShipmentId = TS.TradelaneShipmentId.Value,
                    FlightNo = TS.FlightNumber != null ? TS.FlightNumber : "",
                    DepartureDate = TS.DepartureDate,
                    DepartureTime = TS.DepartureDate != null ? TS.DepartureDate.Value.ToString() : "",
                    ArrivalDate = TS.ArrivalDate.Value,
                    ArrivalTime = TS.ArrivalDate != null ? TS.ArrivalDate.Value.ToString() : "",
                    BookingStatus = TS.BookingStatus,
                    DepartureAirportCode = TS.DepartureAirportCode,
                    DestinationAirportCode = TS.ArrivalAirportCode,
                    TotalPeices = TS.Pieces.Value,
                    TotalWeight = TS.TotalWeight.Value,
                    Volume = TS.TotalVolume.Value
                }).ToList();

                var Shipment = dbContext.TradelaneShipments.Where(a => a.TradelaneShipmentId == TradelaneShipmentId).FirstOrDefault();
                if (Shipment != null)
                {
                    var          user     = dbContext.Users.Where(a => a.UserId == Shipment.CustomerId).FirstOrDefault();
                    var          Timezone = dbContext.Timezones.Where(a => a.TimezoneId == user.TimezoneId).FirstOrDefault();
                    TimeZoneInfo TZM      = TimeZoneInfo.FindSystemTimeZoneById(Timezone.Name);

                    for (int i = 0; i < TTM.TradelaneTrackingDetail.Count; i++)
                    {
                        if (TTM.TradelaneTrackingDetail[i].DepartureDate != null)
                        {
                            TTM.TradelaneTrackingDetail[i].DepartureTime = UtilityRepository.UtcDateToOtherTimezone(TTM.TradelaneTrackingDetail[i].DepartureDate.Value, TTM.TradelaneTrackingDetail[i].DepartureDate.Value.TimeOfDay, TZM).Item2;
                            TTM.TradelaneTrackingDetail[i].DepartureDate = UtilityRepository.UtcDateToOtherTimezone(TTM.TradelaneTrackingDetail[i].DepartureDate.Value, TTM.TradelaneTrackingDetail[i].DepartureDate.Value.TimeOfDay, TZM).Item1;
                        }
                        if (TTM.TradelaneTrackingDetail[i].ArrivalDate != null)
                        {
                            TTM.TradelaneTrackingDetail[i].ArrivalTime = UtilityRepository.UtcDateToOtherTimezone(TTM.TradelaneTrackingDetail[i].ArrivalDate.Value, TTM.TradelaneTrackingDetail[i].ArrivalDate.Value.TimeOfDay, TZM).Item2;
                            TTM.TradelaneTrackingDetail[i].ArrivalDate = UtilityRepository.UtcDateToOtherTimezone(TTM.TradelaneTrackingDetail[i].ArrivalDate.Value, TTM.TradelaneTrackingDetail[i].ArrivalDate.Value.TimeOfDay, TZM).Item1;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(TTM);
        }