private Tuple <string, string> GetDateTimeZone(int?UserId, DateTime?CreatedOn)
        {
            var customerDetail = dbContext.Users.Where(a => a.UserId == UserId).FirstOrDefault();
            var timeZone       = dbContext.Timezones.Where(p => p.TimezoneId == customerDetail.TimezoneId).FirstOrDefault();
            var Timezone       = new TimeZoneModal();

            if (timeZone != null)
            {
                Timezone.TimezoneId  = timeZone.TimezoneId;
                Timezone.Name        = timeZone.Name;
                Timezone.Offset      = timeZone.Offset;
                Timezone.OffsetShort = timeZone.OffsetShort;
            }

            var TimeZoneDetail = TimeZoneInfo.FindSystemTimeZoneById(timeZone.Name);
            var CreatedOn1     = UtilityRepository.UtcDateToOtherTimezone(CreatedOn.Value, CreatedOn.Value.TimeOfDay, TimeZoneDetail).Item1;

            return(Tuple.Create(CreatedOn1.ToString("dd-MMM-yyyy hh:mm"), "(" + Timezone.OffsetShort + ")"));
        }
Exemplo n.º 2
0
        public List <FrayteSystemAlert> GetSystemAlerts(TrackSystemAlert trackSystemAlert)
        {
            int SkipRows = 0;

            SkipRows = (trackSystemAlert.CurrentPage - 1) * trackSystemAlert.TakeRows;
            var result = dbContext.spGet_GetSystemAlerts(trackSystemAlert.OperationZoneId, trackSystemAlert.FromDate, trackSystemAlert.ToDate,
                                                         SkipRows, trackSystemAlert.TakeRows).ToList();
            List <FrayteSystemAlert> list = new List <FrayteSystemAlert>();

            if (result != null && result.Count > 0)
            {
                FrayteSystemAlert SystemAlertResult;
                foreach (var data in result)
                {
                    SystemAlertResult = new FrayteSystemAlert();
                    SystemAlertResult.SystemAlertId       = data.SystemAlertId;
                    SystemAlertResult.OperationZoneId     = data.OperationZoneId;
                    SystemAlertResult.Heading             = data.Heading;
                    SystemAlertResult.Description         = data.Description;
                    SystemAlertResult.FromDate            = data.FromDate;
                    SystemAlertResult.FromTime            = UtilityRepository.GetTimeZoneTime(data.FromTime);
                    SystemAlertResult.ToDate              = data.ToDate;
                    SystemAlertResult.ToTime              = UtilityRepository.GetTimeZoneTime(data.ToTime);
                    SystemAlertResult.IsActive            = data.IsActive;
                    SystemAlertResult.TotalRows           = data.TotalRows.Value;
                    SystemAlertResult.TimeZoneDetail      = new TimeZoneModal();
                    SystemAlertResult.TimeZoneDetail.Name = data.TimeZoneName;
                    if (data.TimezoneId.HasValue)
                    {
                        SystemAlertResult.TimeZoneDetail.TimezoneId = data.TimezoneId.Value;
                    }
                    SystemAlertResult.TimeZoneDetail.Offset      = data.TimeZoneOffset;
                    SystemAlertResult.TimeZoneDetail.OffsetShort = data.TimeZoneOffsetShort;
                    var TimeZoneInformation = TimeZoneInfo.FindSystemTimeZoneById(data.TimeZoneName);
                    SystemAlertResult.FromTime = UtilityRepository.UtcDateToOtherTimezone(data.FromDate, data.FromTime, TimeZoneInformation).Item2;
                    SystemAlertResult.FromDate = UtilityRepository.UtcDateToOtherTimezone(data.FromDate, data.FromTime, TimeZoneInformation).Item1;
                    SystemAlertResult.ToTime   = UtilityRepository.UtcDateToOtherTimezone(data.ToDate, data.ToTime, TimeZoneInformation).Item2;
                    SystemAlertResult.ToDate   = UtilityRepository.UtcDateToOtherTimezone(data.ToDate, data.ToTime, TimeZoneInformation).Item1;
                    list.Add(SystemAlertResult);
                }
            }
            return(list);
        }
        public List <ExpressReportBagLabel> GetBagLabelReportObj(int bagId, int userId)
        {
            List <ExpressReportBagLabel> list = new List <ExpressReportBagLabel>();

            try
            {
                var    user  = dbContext.Users.Find(userId);
                string refNO = CommonConversion.GetNewFrayteNumber();

                var bag = dbContext.ExpressBags.Find(bagId);

                if (bag != null)
                {
                    var sdf = (from r in dbContext.Expresses
                               join ed in dbContext.ExpressDetails on r.ExpressId equals ed.ExpressId
                               where r.BagId == bagId
                               select ed).ToList();

                    var hub = (from r in dbContext.Expresses
                               join h in dbContext.HubCarrierServices on r.HubCarrierServiceId equals h.HubCarrierServiceId
                               join hc in dbContext.HubCarriers on h.HubCarrierId equals hc.HubCarrierId
                               join hb in dbContext.Hubs on hc.HubId equals hb.HubId
                               join hu in dbContext.HubUsers on hb.HubId equals hu.HubId
                               join u in dbContext.Users on hu.UserId equals u.UserId
                               where r.BagId == bagId
                               select new
                    {
                        Code = hb.Code,
                        NotifyParty = u.CompanyName
                    }
                               ).FirstOrDefault();

                    ExpressReportBagLabel reportObj = new ExpressReportBagLabel();
                    reportObj.Ref              = refNO;
                    reportObj.Hub              = hub != null ? hub.Code : "";
                    reportObj.Destination      = hub != null ? hub.Code : "";
                    reportObj.ServiceType      = bag.Courier;
                    reportObj.DestinationAgent = hub != null ? hub.NotifyParty : "";
                    reportObj.TotalQty         = sdf.Count;
                    reportObj.BagWeight        = sdf != null?sdf.Sum(p => p.CartonQty *p.Weight) : 0;

                    reportObj.BagBarCode = bag.BagBarCode;

                    var userInfo = (from r in dbContext.Users
                                    join tz in dbContext.Timezones on r.TimezoneId equals tz.TimezoneId
                                    where r.UserId == userId
                                    select tz
                                    ).FirstOrDefault();

                    var UserTimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(userInfo.Name);

                    DateTime date = UtilityRepository.UtcDateToOtherTimezone(DateTime.UtcNow, DateTime.UtcNow.TimeOfDay, UserTimeZoneInfo).Item1;
                    string   time = UtilityRepository.GetFormattedTimeFromString(UtilityRepository.UtcDateToOtherTimezone(DateTime.UtcNow, DateTime.UtcNow.TimeOfDay, UserTimeZoneInfo).Item2);

                    // Append the created by time zone in time
                    reportObj.DateTime = date.ToString("dd-MMM-yy") + " " + time + " " + userInfo.OffsetShort;
                    list.Add(reportObj);
                }

                return(list);
            }
            catch (Exception ex)
            {
                return(list);
            }
        }
        public List <ExpressReportDriverManifest> GetDriverManifestReportObj(int tradelaneShipmentId, int userId)
        {
            List <ExpressReportDriverManifest> list = new List <ExpressReportDriverManifest>();

            try
            {
                var    user           = dbContext.Users.Find(userId);
                string refNO          = CommonConversion.GetNewFrayteNumber();
                var    customerDetail = (from r in dbContext.Users
                                         join s in dbContext.TradelaneShipments on r.UserId equals s.CustomerId
                                         where s.TradelaneShipmentId == tradelaneShipmentId
                                         select new
                {
                    CustomerName = r.CompanyName
                }).FirstOrDefault();

                var Result         = dbContext.ExpressManifests.Where(a => a.TradelaneShipmentId == tradelaneShipmentId).FirstOrDefault();
                var ShipmentDetail = new TradelaneBookingRepository().GetTradelaneBookingDetails(tradelaneShipmentId, "");
                var hub            = (from r in dbContext.ExpressManifests
                                      join h in dbContext.Hubs on r.HubId equals h.HubId
                                      where r.TradelaneShipmentId == tradelaneShipmentId
                                      select h
                                      ).FirstOrDefault();

                ExpressReportDriverManifest reportObj = new ExpressReportDriverManifest();
                reportObj.Ref                = refNO;
                reportObj.Barcode            = Result.BarCode;
                reportObj.DriverManifestName = "Destination Manifest-" + Result.BarCode + " (" + ShipmentDetail.ShipmentHandlerMethod.DisplayName + ")"; //       EMPM.ExportManifestName = "Origin Manifest-" + Result.BarCode + " (" + ShipmentDetail.ShipmentHandlerMethod.DisplayName + ")";
                reportObj.Hub                = hub.Code;
                reportObj.MAWB               = ShipmentDetail.AirlinePreference.AilineCode + " " + ShipmentDetail.MAWB.Substring(0, 4) + " " + ShipmentDetail.MAWB.Substring(4, 4);
                reportObj.PrintedBy          = user.ContactName;

                var userInfo = (from r in dbContext.Users
                                join tz in dbContext.Timezones on r.TimezoneId equals tz.TimezoneId
                                where r.UserId == userId
                                select tz
                                ).FirstOrDefault();

                var UserTimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(userInfo.Name);

                //UtilityRepository.UtcDateToOtherTimezone(shipment.CreatedOnUtc, shipment.CreatedOnUtc.TimeOfDay, UserTimeZoneInfo);

                DateTime date = UtilityRepository.UtcDateToOtherTimezone(DateTime.UtcNow, DateTime.UtcNow.TimeOfDay, UserTimeZoneInfo).Item1;
                string   time = UtilityRepository.GetFormattedTimeFromString(UtilityRepository.UtcDateToOtherTimezone(DateTime.UtcNow, DateTime.UtcNow.TimeOfDay, UserTimeZoneInfo).Item2);

                // Append the created by time zone in time
                reportObj.PrintedDateTime = date.ToString("dd-MMM-yy") + " " + time + " " + userInfo.OffsetShort;
                //reportObj.PuickUpAddress = UtilityRepository.ConcatinateAddress(ShipmentDetail.ShipFrom, "");

                if (hub != null)
                {
                    TradelBookingAdress address = new TradelBookingAdress();

                    address.Address     = hub.Address;
                    address.Address2    = hub.Address2;
                    address.City        = hub.City;
                    address.State       = hub.State;
                    address.PostCode    = hub.PostCode;
                    address.Country     = new FrayteCountryCode();
                    address.Phone       = hub.TelephoneNo;
                    address.CompanyName = hub.Name;
                    var country = dbContext.Countries.Where(p => p.CountryId == hub.CountryId).FirstOrDefault();
                    if (country != null)
                    {
                        address.Country.CountryId = country.CountryId;
                        address.Country.Code      = country.CountryCode;
                        address.Country.Code2     = country.CountryCode2;
                        address.Country.Name      = country.CountryName;
                    }
                    reportObj.PuickUpAddress = UtilityRepository.ConcatinateAddress(address, "");
                }
                //reportObj.PuickUpAddress = UtilityRepository.ConcatinateAddress(ShipmentDetail.ShipTo, "");

                reportObj.MAWBChargeableWeight = ShipmentDetail.HAWBPackages.Sum(p => p.TotalWeight * p.TotalCartons);
                reportObj.MAWBGrossWeight      = ShipmentDetail.HAWBPackages.Sum(p => p.TotalWeight * p.TotalCartons);

                if (ShipmentDetail.ShipmentHandlerMethod.ShipmentHandlerMethodId == 5)
                {
                    var shipmentAllocation = dbContext.TradelaneShipmentAllocations.Where(p => p.TradelaneShipmentId == tradelaneShipmentId && p.LegNum == "Leg2").OrderByDescending(p => p.TradelaneShipmentAllocationId).FirstOrDefault();

                    reportObj.FlightNumber = shipmentAllocation.FlightNumber;
                    var Airline = dbContext.Airlines.Find(shipmentAllocation.AirlineId);
                    if (Airline != null)
                    {
                        reportObj.Airline = Airline.AirLineName + " - " + Airline.CarrierCode3;
                    }
                    var timezone = dbContext.Timezones.Find(shipmentAllocation.TimezoneId);
                    if (timezone != null)
                    {
                        var TimeZoneInfor = TimeZoneInfo.FindSystemTimeZoneById(userInfo.Name);
                        //UtilityRepository.UtcDateToOtherTimezone(shipment.CreatedOnUtc, shipment.CreatedOnUtc.TimeOfDay, UserTimeZoneInfo);
                        DateTime date1 = UtilityRepository.UtcDateToOtherTimezone(DateTime.UtcNow, DateTime.UtcNow.TimeOfDay, TimeZoneInfor).Item1;
                        string   time1 = UtilityRepository.GetFormattedTimeFromString(UtilityRepository.UtcDateToOtherTimezone(DateTime.UtcNow, DateTime.UtcNow.TimeOfDay, TimeZoneInfor).Item2);
                        // Append the created by time zone in time
                        reportObj.ETA         = date1.ToString("dd-MMM-yy") + " " + time1;
                        reportObj.ETATimeZone = "(" + timezone.OffsetShort + ")";
                    }
                }
                else
                {
                    var shipmentAllocation = dbContext.TradelaneShipmentAllocations.Where(p => p.TradelaneShipmentId == tradelaneShipmentId).OrderByDescending(p => p.TradelaneShipmentAllocationId).FirstOrDefault();
                    reportObj.FlightNumber = shipmentAllocation.FlightNumber;
                    var Airline = dbContext.Airlines.Find(shipmentAllocation.AirlineId);
                    if (Airline != null)
                    {
                        reportObj.Airline = Airline.AirLineName + " - " + Airline.CarrierCode3;
                    }
                    var timezone = dbContext.Timezones.Find(shipmentAllocation.TimezoneId);
                    if (timezone != null)
                    {
                        var TimeZoneInfor = TimeZoneInfo.FindSystemTimeZoneById(userInfo.Name);
                        //UtilityRepository.UtcDateToOtherTimezone(shipment.CreatedOnUtc, shipment.CreatedOnUtc.TimeOfDay, UserTimeZoneInfo);
                        DateTime date1 = UtilityRepository.UtcDateToOtherTimezone(DateTime.UtcNow, DateTime.UtcNow.TimeOfDay, TimeZoneInfor).Item1;
                        string   time1 = UtilityRepository.GetFormattedTimeFromString(UtilityRepository.UtcDateToOtherTimezone(DateTime.UtcNow, DateTime.UtcNow.TimeOfDay, TimeZoneInfor).Item2);
                        // Append the created by time zone in time
                        reportObj.ETA         = date1.ToString("dd-MMM-yy") + " " + time1;
                        reportObj.ETATimeZone = "(" + timezone.OffsetShort + ")";
                    }
                }
                reportObj.CarrierBags = new List <ExpressReportDriverManifestBagDetail>();
                ExpressReportDriverManifestBagDetail mn;

                var detail = (from r in dbContext.ExpressManifests
                              join b in dbContext.ExpressBags on r.ExpressManifestId equals b.ManifestId
                              where r.TradelaneShipmentId == tradelaneShipmentId
                              select b).GroupBy(group => group.Courier).Select(p => new
                {
                    key  = p.Key,
                    data = p.Select(q => new
                    {
                        Id = q.DriverManifestId,
                        DriverManifestNumber = dbContext.ExpressDriverManifests.Where(a => a.ExpressDriverManifestId == q.DriverManifestId).FirstOrDefault().DriverManifestBarCode,
                        Carrier      = q.Courier,
                        BagBarCode   = q.BagBarCode,
                        BagId        = q.BagId,
                        BagNumber    = q.BagNumber,
                        HubCarrierId = q.HubCarrierId
                    }).ToList()
                }).ToList();

                if (detail.Count > 0)
                {
                    foreach (var item in detail)
                    {
                        int hubCarrierId = item.data[0].HubCarrierId.HasValue ? item.data[0].HubCarrierId.Value : 0;

                        var hubCarrier = dbContext.HubCarriers.Where(p => p.HubCarrierId == hubCarrierId).FirstOrDefault();
                        mn            = new ExpressReportDriverManifestBagDetail();
                        mn.Carrier    = item.key;
                        mn.CutOffTime = hubCarrier.CutOffTime;
                        mn.NoOfBags   = item.data.Count;

                        decimal totalWeight = 0.00M;
                        int     totalPieces = 0;
                        foreach (var item1 in item.data)
                        {
                            var ship = (from r in dbContext.Expresses
                                        join d in dbContext.ExpressDetails on r.ExpressId equals d.ExpressId
                                        where r.BagId == item1.BagId
                                        select d
                                        ).ToList();

                            totalPieces += ship.Count;
                            totalWeight  = ship.Sum(p => p.Weight * p.CartonQty);
                        }
                        mn.TotalPieces = totalPieces;
                        mn.TotalWeight = totalWeight;
                        reportObj.CarrierBags.Add(mn);
                    }
                    reportObj.CarrierManifests = new List <ExpressReportDriverCarrierManifest>();
                    ExpressReportDriverCarrierManifest cm;
                    foreach (var item in detail)
                    {
                        cm = new ExpressReportDriverCarrierManifest();
                        int hubCarrierId = item.data[0].HubCarrierId.HasValue ? item.data[0].HubCarrierId.Value : 0;
                        cm.CarrierManifestBarcoede = item.data.FirstOrDefault().DriverManifestNumber;
                        cm.CarrierManifest         = item.key + " - (" + item.data.FirstOrDefault().DriverManifestNumber + ")" + " Destination Manifest";
                        cm.CarrierBagDetails       = new List <ExpressReportCarrierBagDetail>();
                        ExpressReportCarrierBagDetail d;
                        var hubCarrier = dbContext.HubCarriers.Where(p => p.HubCarrierId == hubCarrierId).FirstOrDefault();

                        if (hubCarrier != null)
                        {
                            TradelBookingAdress address = new TradelBookingAdress();

                            address.Address     = hubCarrier.Address;
                            address.Address2    = hubCarrier.Address2;
                            address.City        = hubCarrier.City;
                            address.State       = hubCarrier.State;
                            address.PostCode    = hubCarrier.PostCode;
                            address.Country     = new FrayteCountryCode();
                            address.Phone       = hubCarrier.TelephoneNo;
                            address.CompanyName = hubCarrier.CompanyName;
                            var country = dbContext.Countries.Where(p => p.CountryId == hubCarrier.CountryId).FirstOrDefault();
                            if (country != null)
                            {
                                address.Country.CountryId = country.CountryId;
                                address.Country.Code      = country.CountryCode;
                                address.Country.Code2     = country.CountryCode2;
                                address.Country.Name      = country.CountryName;
                            }
                            cm.DropOffAddress = UtilityRepository.ConcatinateAddress(address, "");
                        }

                        foreach (var item1 in item.data)
                        {
                            d = new ExpressReportCarrierBagDetail();

                            d.BagNumber = item1.BagNumber;

                            var sdf = (from r in dbContext.Expresses
                                       join ed in dbContext.ExpressDetails on r.ExpressId equals ed.ExpressId
                                       where r.BagId == item1.BagId
                                       select ed
                                       ).ToList();
                            d.TotalPieces      = sdf.Count;
                            d.ExporterName     = customerDetail.CustomerName;
                            d.TotalWeight      = sdf.Sum(p => p.CartonQty * p.Weight);
                            d.Carrier          = item.key;
                            d.BagId            = item1.BagId;
                            d.TermAndCondition = hubCarrier.TermAndCondition;
                            cm.CarrierBagDetails.Add(d);
                        }
                        reportObj.CarrierManifests.Add(cm);
                    }
                }
                list.Add(reportObj);
                return(list);
            }
            catch (Exception ex)
            {
                return(list);
            }
        }
Exemplo n.º 5
0
        protected internal FrayteManifestName HKQuoteReport(FrayteQuotationReport item, decimal Volume, int CartoonQty, TimeZoneInfo TimeZoneInformation, string Time)
        {
            FrayteManifestName result = new FrayteManifestName();

            result.OfferValidity = item.OfferValidity;
            result.TransitTime   = item.TransitTime;
            ReportTemplate.Other.HKQuote report = new ReportTemplate.Other.HKQuote(item.ShipFrom.ToUpper(), item.ShipTo.ToUpper());

            report.Parameters["WebsiteUrl"].Value     = "www.frayte.com".ToUpper();
            report.Parameters["CustomerName"].Value   = item.CustomerName;
            report.Parameters["Information"].Value    = "Thank you for requesting a spot courier quote from FRAYTE GLOBAL we are pleased to present your personalised quote for [" + item.CompanyName + "] below:";
            report.Parameters["Currency"].Value       = item.QuoteCurrency;
            report.Parameters["ReferenceValue"].Value = "This quote is only valid for FRAYTE account number: " + UtilityRepository.FrayteAccountNo(item.FrayteAccountNo) + ". " +
                                                        "Quote issued on " + UtilityRepository.UtcDateToOtherTimezone(Convert.ToDateTime(item.QuoteIssueDate.Date), item.QuoteIssueDate.TimeOfDay, TimeZoneInformation).Item1.ToString("dd-MMM-yyyy") + " " + Time + " with reference number " + UtilityRepository.QuotationFileName(item.QuotationShipmentId.ToString(), item.OperationZoneId, ".pdf").Replace(".pdf", "") + ". " +
                                                        "As per your confirmation, this shipment DOES NOT contain dangerous goods of any type and any quantity. All quotes are excluding any applicable Import " +
                                                        "clearance duty and taxes which are charged against the shipment. The above quote is inclusive of the current fuel surcharge " +
                                                        "unless otherwise stated. Transit Time is in working days and can be subject to change. Multiple piece consignments " +
                                                        "may require palletising, this could increase the chargeable weight of the consignment.";
            report.Parameters["TotalPrice"].Value = Math.Round(item.TotalPrice, 2);
            report.Parameters["Days"].Value       = item.OfferValidity;
            report.Parameters["CartoonQty"].Value = CartoonQty;
            report.Parameters["PricePerKg"].Value = item.QuoteCurrency + " " + Math.Round((item.Rate + item.FuelSurcharge + item.SupplementryCharge) / (item.GrossWeight), 2).ToString("N", new System.Globalization.CultureInfo("en-US"));
            if (item.PackageCalculationType == FraytePakageCalculationType.kgtoCms)
            {
                if (item.GrossWeight > Volume)
                {
                    report.Parameters["GrossWeight"].Value = item.GrossWeight.ToString("N", new System.Globalization.CultureInfo("en-US")) + " " + "kg";
                }
                else
                {
                    report.Parameters["GrossWeight"].Value = Math.Round(Volume, 2).ToString("N", new System.Globalization.CultureInfo("en-US")) + " " + "kg";
                }
            }
            else
            {
                if (item.GrossWeight > Volume)
                {
                    report.Parameters["GrossWeight"].Value = item.GrossWeight.ToString("N", new System.Globalization.CultureInfo("en-US")) + " " + "lb.";
                }
                else
                {
                    report.Parameters["GrossWeight"].Value = Math.Round(Volume, 2).ToString("N", new System.Globalization.CultureInfo("en-US")) + " " + "lb.";
                }
            }
            report.Parameters["Volume"].Value      = Math.Round(Volume, 2).ToString("N", new System.Globalization.CultureInfo("en-US")) + " cbm";
            report.Parameters["Service"].Value     = item.Service;
            report.Parameters["Description"].Value = item.Description;

            report.Parameters["Rate"].Value          = item.QuoteCurrency + " " + Math.Round(item.Rate, 2).ToString("N", new System.Globalization.CultureInfo("en-US"));
            report.Parameters["FuelSurcharge"].Value = item.QuoteCurrency + " " + (item.FuelSurcharge).ToString("N", new System.Globalization.CultureInfo("en-US"));
            report.Parameters["Origin"].Value        = item.Origin;
            report.Parameters["Destination"].Value   = item.Destination;
            if (item.PackageCalculationType == FraytePakageCalculationType.kgtoCms)
            {
                report.Parameters["ChargeWeight"].Value = item.ChargeableWeight.ToString("N", new System.Globalization.CultureInfo("en-US")) + " " + "kg";
                result.TotalWeight = item.GrossWeight.ToString("N", new System.Globalization.CultureInfo("en-US")) + " " + "kg";
            }
            else
            {
                report.Parameters["ChargeWeight"].Value = item.ChargeableWeight.ToString("N", new System.Globalization.CultureInfo("en-US")) + " " + "lb.";
                result.TotalWeight = item.GrossWeight.ToString("N", new System.Globalization.CultureInfo("en-US")) + " " + "lb.";
            }
            report.Parameters["Total"].Value = item.QuoteCurrency + " " + Math.Round(item.TotalPrice, 2).ToString("N", new System.Globalization.CultureInfo("en-US"));

            PdfExportOptions options = new PdfExportOptions();

            options.ImageQuality      = PdfJpegImageQuality.Highest;
            options.PdfACompatibility = PdfACompatibility.None;

            report.ExportToPdf(HttpContext.Current.Server.MapPath(AppSettings.ReportFolder) + UtilityRepository.QuotationFileName(item.QuotationShipmentId.ToString(), item.OperationZoneId, ".pdf"), options);
            result.FileName  = UtilityRepository.QuotationFileName(item.QuotationShipmentId.ToString(), item.OperationZoneId, ".pdf");
            result.FilePath  = AppSettings.WebApiPath + "ReportFiles/" + UtilityRepository.QuotationFileName(item.QuotationShipmentId.ToString(), item.OperationZoneId, ".pdf");
            result.TotalCost = Convert.ToString(Math.Round(item.TotalPrice, 2)) + " " + item.QuoteCurrency;

            return(result);
        }
Exemplo n.º 6
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);
        }