Exemplo n.º 1
0
 private void mapCallectionAddressDetail(DirectBookingShipmentDraftDetail directBookingDetail, CollectionDetails collectionDetails)
 {
     collectionDetails.contactDetails = new ContactDetails()
     {
         contactName = directBookingDetail.ShipFrom.FirstName + " " + directBookingDetail.ShipFrom.LastName,
         telephone   = directBookingDetail.ShipFrom.Phone
     };
     collectionDetails.address = new Address()
     {
         organisation = directBookingDetail.ShipFrom.CompanyName,
         street       = directBookingDetail.ShipFrom.Address,
         town         = directBookingDetail.ShipFrom.City,
         locality     = directBookingDetail.ShipFrom.Address2,
         countryCode  = directBookingDetail.ShipFrom.Country.Code2,
         county       = directBookingDetail.ShipFrom.Country.Name,
         postcode     = directBookingDetail.ShipFrom.PostCode,
     };
     if (collectionDetails.address.street.Length > 35)
     {
         collectionDetails.address.street = collectionDetails.address.street.Substring(0, 35);
     }
     if (collectionDetails.address.locality.Length > 35)
     {
         collectionDetails.address.locality = collectionDetails.address.locality.Substring(0, 35);
     }
 }
        public IHttpActionResult SaveShipmentDraftForm(DirectBookingShipmentDraftDetail directBookingDetail)
        {
            // Change the model
            var GetShipmentInEcommDraftModel = new DirectShipmentRepository().SaveDirectBooking(directBookingDetail);

            return(Ok(GetShipmentInEcommDraftModel));
        }
Exemplo n.º 3
0
        private void mapDeliveryAddressDetail(DirectBookingShipmentDraftDetail directBookingDetail, DeliveryDetails deliveryDetail)
        {
            deliveryDetail.contactDetails = new ContactDetails()
            {
                contactName = directBookingDetail.ShipTo.FirstName + " " + directBookingDetail.ShipTo.LastName,
                telephone   = directBookingDetail.ShipTo.Phone
            };
            deliveryDetail.address = new Address()
            {
                organisation = directBookingDetail.ShipTo.CompanyName,
                street       = directBookingDetail.ShipTo.Address,
                town         = directBookingDetail.ShipTo.City,
                locality     = directBookingDetail.ShipTo.Address2,
                countryCode  = directBookingDetail.ShipTo.Country.Code2,
                county       = directBookingDetail.ShipTo.Country.Name,
                postcode     = directBookingDetail.ShipTo.PostCode,
            };
            deliveryDetail.notificationDetails = new NotificationDetails()
            {
                email  = directBookingDetail.ShipTo.Email,
                mobile = directBookingDetail.ShipTo.Phone,
            };

            if (deliveryDetail.address.street.Length > 35)
            {
                deliveryDetail.address.street = deliveryDetail.address.street.Substring(0, 35);
            }
            if (deliveryDetail.address.locality.Length > 35)
            {
                deliveryDetail.address.locality = deliveryDetail.address.locality.Substring(0, 35);
            }
        }
Exemplo n.º 4
0
        public DPDRequestModel MapDirectBookingDetailToShipmentRequestDto(DirectBookingShipmentDraftDetail directBookingDetail)
        {
            try
            {
                //ShipFromAddress
                var collectionDetails = new CollectionDetails();
                mapCallectionAddressDetail(directBookingDetail, collectionDetails);

                //ShipToAddress
                var deliveryDetails = new DeliveryDetails();
                mapDeliveryAddressDetail(directBookingDetail, deliveryDetails);


                DPDRequestModel dpdShipmentRequest = new DPDRequestModel();
                dpdShipmentRequest.DraftShipmentId      = directBookingDetail.DirectShipmentDraftId;
                dpdShipmentRequest.collectionDate       = directBookingDetail.ReferenceDetail.CollectionDate.Value.ToString("yyyy-MM-ddTHH:mm:ss");
                dpdShipmentRequest.collectionOnDelivery = false;
                dpdShipmentRequest.invoice     = null;
                dpdShipmentRequest.consolidate = false;
                dpdShipmentRequest.job_id      = null;
                dpdShipmentRequest.consignment = new List <Consignment>();
                int TotalNumberParcel = 0;
                foreach (var item in directBookingDetail.Packages)
                {
                    TotalNumberParcel += item.CartoonValue;
                }
                dpdShipmentRequest.consignment.Add(new Consignment
                {
                    consignmentNumber    = null,
                    consignmentRef       = null,
                    parcels              = new List <Parcels>(),
                    collectionDetails    = collectionDetails,
                    deliveryDetails      = deliveryDetails,
                    networkCode          = directBookingDetail.CustomerRateCard.NetworkCode,
                    numberOfParcels      = TotalNumberParcel,
                    totalWeight          = directBookingDetail.CustomerRateCard.Weight,
                    customsValue         = null,
                    deliveryInstructions = "Please deliver with shipment owner",
                    liability            = false,
                    liabilityValue       = null,
                    parcelDescription    = string.Join("-", directBookingDetail.Packages.Select(x => x.Content.ToString()).ToArray()),
                    shippingRef1         = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1,
                    shippingRef2         = directBookingDetail.ReferenceDetail.Reference2,
                    shippingRef3         = "",
                });


                return(dpdShipmentRequest);
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Shipment is not created " + ex.Message));
                return(null);
            }
        }
Exemplo n.º 5
0
        public EAMRequestModel MapDirectBookingDetailToShipmentRequestDto(DirectBookingShipmentDraftDetail directBookingDetail)
        {
            EAMRequestModel eamRequest = new EAMRequestModel()
            {
                ShipperAddress1       = directBookingDetail.ShipFrom.Address,
                ShipperAddress2       = directBookingDetail.ShipFrom.Address2,
                ShipperAddress3       = "",
                ShipperContact        = string.Concat(directBookingDetail.ShipFrom.FirstName + " ", directBookingDetail.ShipFrom.LastName),
                ShipperCompany        = string.IsNullOrWhiteSpace(directBookingDetail.ShipFrom.CompanyName) ? string.Concat(directBookingDetail.ShipFrom.FirstName + " ", directBookingDetail.ShipFrom.LastName) : directBookingDetail.ShipFrom.CompanyName,
                ShipperCountry        = directBookingDetail.ShipFrom.Country.Code2,
                ShipperPostcode       = string.IsNullOrEmpty(directBookingDetail.ShipFrom.PostCode) ? "" : directBookingDetail.ShipFrom.PostCode,
                ShipperTelephone      = directBookingDetail.ShipFrom.Phone,
                ShipperTown           = string.IsNullOrEmpty(directBookingDetail.ShipFrom.City) ? "" : directBookingDetail.ShipFrom.City,
                Account               = "",
                Password              = "",
                CustomerTransactionId = directBookingDetail.FrayteNumber,
                Hawb        = directBookingDetail.FrayteNumber,
                Service     = directBookingDetail.CustomerRateCard.NetworkCode,
                Mawb        = "",
                Date        = directBookingDetail.ReferenceDetail.CollectionDate.Value.ToString("dd/MM/yyyy"),
                Company     = string.IsNullOrWhiteSpace(directBookingDetail.ShipTo.CompanyName) ? string.Concat(directBookingDetail.ShipTo.FirstName + " ", directBookingDetail.ShipTo.LastName) : directBookingDetail.ShipTo.CompanyName,
                Contact     = string.Concat(directBookingDetail.ShipTo.FirstName + " ", directBookingDetail.ShipTo.LastName),
                Address1    = directBookingDetail.ShipTo.Address,
                Address2    = directBookingDetail.ShipTo.Address2,
                Address3    = "",
                Town        = string.IsNullOrEmpty(directBookingDetail.ShipTo.City) ? "" : directBookingDetail.ShipTo.City,
                Country     = directBookingDetail.ShipTo.Country.Code2,
                Postcode    = string.IsNullOrEmpty(directBookingDetail.ShipTo.PostCode) ? "" : directBookingDetail.ShipTo.PostCode,
                telephone   = directBookingDetail.ShipTo.Phone,
                noOfPieces  = directBookingDetail.Packages.Sum(t => t.CartoonValue).ToString(),
                Weight      = directBookingDetail.CustomerRateCard.Weight,
                DoxNonDox   = directBookingDetail.ParcelType.ParcelType == "Parcel" ? "NDX" : "DOX",
                Description = string.Join("-", directBookingDetail.Packages.Select(x => x.Content.ToString()).ToArray()) + "-" + directBookingDetail.ReferenceDetail.Reference1,
                Value       = directBookingDetail.Packages.Sum(t => t.Value).ToString(),
                Currency    = directBookingDetail.Currency.CurrencyCode,
                Agent       = "",
                Notes       = "JUST A TEST"
            };

            if (directBookingDetail.CustomerRateCard.CourierName == FrayteCourierCompany.EAMTNT)
            {
                eamRequest.Agent = "TNT economy service";
            }
            else if (directBookingDetail.CustomerRateCard.CourierName == FrayteCourierCompany.EAMDHL)
            {
                eamRequest.Agent = "DHL express service";
            }
            else if (directBookingDetail.CustomerRateCard.CourierName == FrayteCourierCompany.EAMFedEx)
            {
                eamRequest.Agent = "Fedex Economy service";
            }
            return(eamRequest);
        }
Exemplo n.º 6
0
        public bool SaveTrackingDetail(DirectBookingShipmentDraftDetail directBookingDetail, IntegrtaionResult result, int DirectShipmentid)
        {
            var count = 1;

            foreach (var Obj in result.PieceTrackingDetails)
            {
                Frayte.Services.Models.Package package = new Frayte.Services.Models.Package();
                package.DirectShipmentDetailId = Obj.DirectShipmentDetailId;
                package.LabelName = Obj.PieceTrackingNumber;
                new DirectShipmentRepository().SavePackageDetail(package, "", Obj.DirectShipmentDetailId, directBookingDetail.CustomerRateCard.CourierName, count);
                count++;
            }
            return(true);
        }
Exemplo n.º 7
0
        public void MappingCourierPieceDetail(IntegrtaionResult integrtaionResult, DirectBookingShipmentDraftDetail directBookingDetail, int DirectShipmentid)
        {
            if (DirectShipmentid > 0)
            {
                int        k = 0, i = 0;
                List <int> _shiId = new List <int>();

                _shiId = new DirectShipmentRepository().GetDirectShipmentDetailID(DirectShipmentid);
                for (i = 0; i < integrtaionResult.PieceTrackingDetails.Count(); i++)
                {
                    integrtaionResult.PieceTrackingDetails[i].DirectShipmentDetailId = _shiId[0];
                }
            }
        }
 public void MappingCourierPieceDetail(IntegrtaionResult integrtaionResult, DirectBookingShipmentDraftDetail directBookingDetail, int DirectShipmentid)
 {
     if (DirectShipmentid > 0)
     {
         int        k = 0, i = 0;
         List <int> _shiId = new List <int>();
         foreach (var Obj in directBookingDetail.Packages)
         {
             _shiId = new DirectShipmentRepository().GetDirectShipmentDetailID(DirectShipmentid);
             for (int j = 1; j <= Obj.CartoonValue; j++)
             {
                 integrtaionResult.PieceTrackingDetails[k].DirectShipmentDetailId = _shiId[i];
                 k++;
             }
             i++;
         }
     }
 }
Exemplo n.º 9
0
        public AURequestModel MapDirectBookingDetailToShipmentRequestDto(DirectBookingShipmentDraftDetail directBookingDetail)
        {
            try
            {
                AURequestModel au = new AURequestModel();
                //Address
                au.ShipFrom = MappShipFrom(directBookingDetail.ShipFrom);
                au.ShipTo   = MappShipTo(directBookingDetail.ShipTo);
                var referance = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1;

                var ProductDescription = string.Join("-", directBookingDetail.Packages.Select(x => x.Content.ToString()).ToArray());
                var productDescriptionWithSpecialInstrucation = ProductDescription + " SPI " + referance;
                //Addition
                au.ClientId              = "232";
                au.CustomerId            = "197";
                au.WarehouseId           = "221";
                au.UserId                = directBookingDetail.CustomerRateCard.CourierAccountNo;
                au.UserName              = "******";
                au.DirectShipmentDraftid = directBookingDetail.DirectShipmentDraftId;
                au.InvoiceNumber         = directBookingDetail.FrayteNumber;
                au.ProductDescription    = productDescriptionWithSpecialInstrucation;
                au.Quantity              = directBookingDetail.Packages.Sum(k => k.CartoonValue);
                au.Value              = directBookingDetail.Packages.Sum(k => k.Value);
                au.Weight             = directBookingDetail.CustomerRateCard.Weight;
                au.CollectionDate     = directBookingDetail.ReferenceDetail.CollectionDate.Value.ToString("MM/dd/yyyy");
                au.Currency           = directBookingDetail.Currency.CurrencyCode;
                au.DestinationCountry = "AUS";
                au.CarrierType        = "TOLLCARTONS";

                return(au);
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Shipment is not created " + ex.Message));
                return(null);
            }
        }
Exemplo n.º 10
0
        public DPDChRequestModel MapDirectBookingDetailToShipmentRequestDto(DirectBookingShipmentDraftDetail directBookingDetail)
        {
            var ShipFrom = new ExpressRepository().getHubAddress(directBookingDetail.ShipTo.Country.CountryId, directBookingDetail.ShipTo.PostCode, directBookingDetail.ShipTo.State);
            DPDChRequestModel dpdChRequest = new DPDChRequestModel()
            {
                UserName  = "",
                Password  = "",
                AuthToken = "",
                Shipper   = new ContactDetail()
                {
                    //Company = ShipFrom.CompanyName,
                    //Contact = string.IsNullOrWhiteSpace(ShipFrom.FirstName + " " + ShipFrom.LastName) ? ShipFrom.CompanyName : ShipFrom.FirstName + " " + ShipFrom.LastName,
                    //Address1 = ShipFrom.Address,
                    //Address2 = ShipFrom.Address2,
                    //Address3 = "",
                    //Town = ShipFrom.City,
                    //Country = ShipFrom.Country.Code2,
                    //Postcode = ShipFrom.PostCode,
                    //Telephone = ShipFrom.Phone

                    Company   = "Total Freight Management GmbH",
                    Contact   = "",
                    Address1  = "Fracht West",
                    Address2  = "Entrance 1, 2nd Fl., Office 2-327",
                    Address3  = "",
                    Town      = "Zurich Airport",
                    Country   = "CH",
                    Postcode  = "8058",
                    Telephone = "+41 44 816 40 50"
                },
                Recipient = new ContactDetail()
                {
                    Company   = directBookingDetail.ShipTo.CompanyName,
                    Contact   = directBookingDetail.ShipTo.FirstName.Trim() + " " + directBookingDetail.ShipTo.LastName,
                    Address1  = directBookingDetail.ShipTo.Address,
                    Address2  = directBookingDetail.ShipTo.Address2,
                    Address3  = "",
                    Town      = directBookingDetail.ShipTo.City,
                    Country   = directBookingDetail.ShipTo.Country.Code2,
                    Postcode  = directBookingDetail.ShipTo.PostCode,
                    Telephone = "+41" + " " + directBookingDetail.ShipTo.Phone,
                },
                ReferenceNumber1 = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1,
                ReferenceNumber2 = directBookingDetail.ReferenceDetail.Reference2,
                Channel          = 1,
                OrderType        = "consignment",
                Product          = "CL",
                SendingDepot     = "",
                Value            = "*****@*****.**"
            };

            dpdChRequest.Package = new List <DPDPackage>();
            for (int i = 0; i < directBookingDetail.Packages.Count; i++)
            {
                for (int j = 0; j < directBookingDetail.Packages[i].CartoonValue; j++)
                {
                    //Convert weight gm to 10 unit
                    DPDPackage parcel = new DPDPackage();
                    if (directBookingDetail.PakageCalculatonType == FraytePakageCalculationType.kgtoCms)
                    {
                        parcel.ReferenceNumber1 = directBookingDetail.ReferenceDetail.Reference1;
                        parcel.ReferenceNumber2 = directBookingDetail.ReferenceDetail.Reference1;
                        parcel.Volume           = "";
                        parcel.Weight           = ((directBookingDetail.Packages[i].Weight * 1000) / 10).ToString("0.##");
                    }
                    else if (directBookingDetail.PakageCalculatonType == FraytePakageCalculationType.LbToInchs)
                    {
                        parcel.ReferenceNumber1 = directBookingDetail.ReferenceDetail.Reference1;
                        parcel.ReferenceNumber2 = directBookingDetail.ReferenceDetail.Reference1;
                        parcel.Volume           = "";
                        parcel.Weight           = ((directBookingDetail.Packages[i].Weight * 453.592m) / 10).ToString("0.##");
                    }
                    dpdChRequest.Package.Add(parcel);
                }
            }
            return(dpdChRequest);
        }
Exemplo n.º 11
0
        public SkyPostalRequestModel MapDirectBookingDetailToShipmentRequestDto(DirectBookingShipmentDraftDetail directBookingDetail)
        {
            SkyPostalRequestModel skyPostalRequestModel = new SkyPostalRequestModel();

            skyPostalRequestModel.Key                        = "";
            skyPostalRequestModel.method                     = "insert_order";
            skyPostalRequestModel.include_label_data         = "0";
            skyPostalRequestModel.include_label_zpl          = "1";
            skyPostalRequestModel.zpl_encode_base64          = "1";
            skyPostalRequestModel.include_label_base64_image = "0";
            skyPostalRequestModel.label_pdf_rotate           = "0";
            skyPostalRequestModel.header                     = new Header();
            skyPostalRequestModel.header.EXTR_TRACKING       = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1;
            skyPostalRequestModel.header.COUNTRY_CODE        = directBookingDetail.ShipTo.Country.Code2;
            skyPostalRequestModel.header.STATE_CODE          = 0;
            skyPostalRequestModel.header.CITY_CODE           = 0;
            skyPostalRequestModel.header.STATE_NAME          = directBookingDetail.ShipTo.State;
            skyPostalRequestModel.header.CITY_NAME           = directBookingDetail.ShipTo.City;
            skyPostalRequestModel.header.FIRST_NAME          = directBookingDetail.ShipTo.FirstName;
            skyPostalRequestModel.header.LAST_NAME           = directBookingDetail.ShipTo.LastName;
            skyPostalRequestModel.header.ADDRESS_CONSIGNEE   = directBookingDetail.ShipTo.Address;
            skyPostalRequestModel.header.ADDRESS2            = directBookingDetail.ShipTo.Address2;
            skyPostalRequestModel.header.ZIPCODE             = directBookingDetail.ShipTo.PostCode;
            skyPostalRequestModel.header.PHONE               = directBookingDetail.ShipTo.Phone;
            skyPostalRequestModel.header.MOBILE_PHONE        = directBookingDetail.ShipTo.Phone;
            skyPostalRequestModel.header.EMAIL               = directBookingDetail.ShipTo.Email;
            skyPostalRequestModel.header.ID_NUMBER           = directBookingDetail.DirectShipmentDraftId.ToString();
            skyPostalRequestModel.header.MERCHANT_NAME       = "FRAYTE LOGISTICS LTD";
            skyPostalRequestModel.header.MERCHANT_NUMBER     = 665;
            skyPostalRequestModel.header.MERCHANT_BOX        = directBookingDetail.CustomerRateCard.CourierAccountNo;
            if (directBookingDetail.CustomerRateCard.LogisticDescription == SKYPostalLogisticType.SkyPostalMexico)
            {
                skyPostalRequestModel.header.MERCHANT_CS_EMAIL = SKYPostalMerchantEmail.MexicoMerchantEmail;
            }
            if (directBookingDetail.CustomerRateCard.LogisticDescription == SKYPostalLogisticType.SkyPostalBrazil)
            {
                skyPostalRequestModel.header.MERCHANT_CS_EMAIL = SKYPostalMerchantEmail.BrazilMerchantEmail;
            }
            if (directBookingDetail.CustomerRateCard.LogisticDescription == SKYPostalLogisticType.SkyPostalChile)
            {
                skyPostalRequestModel.header.MERCHANT_CS_EMAIL = SKYPostalMerchantEmail.ChileMerchantEmail;
            }

            skyPostalRequestModel.header.MERCHANT_RETURN_ADDRESS = null;
            skyPostalRequestModel.header.MERCHANT_CS_NAME        = "FRAYTE Logistics Ltd";
            skyPostalRequestModel.header.ORDER_NUMBER            = directBookingDetail.ReferenceDetail.Reference1 + "-" + directBookingDetail.FrayteNumber;
            skyPostalRequestModel.header.ORDER_AMOUNT            = directBookingDetail.Packages.Sum(k => k.Value);
            skyPostalRequestModel.header.ORDER_DATE         = directBookingDetail.ReferenceDetail.CollectionDate.Value.ToString("dd/MM/yyyy");
            skyPostalRequestModel.header.INTERNAL_NUMBER    = directBookingDetail.FrayteNumber;
            skyPostalRequestModel.header.MANIFEST_TYPE      = "DDP";
            skyPostalRequestModel.header.CONSOLIDATED       = 0;
            skyPostalRequestModel.header.CURRENCY_ISO_CODE  = directBookingDetail.Currency.CurrencyCode;
            skyPostalRequestModel.header.SHIPMENT_FREIGHT   = 0;
            skyPostalRequestModel.header.SHIPMENT_INSURANCE = 0;
            skyPostalRequestModel.header.SHIPMENT_DISCOUNT  = 0;

            skyPostalRequestModel.detail = new List <PackageDetail>();

            foreach (var item in directBookingDetail.Packages)
            {
                PackageDetail package = new PackageDetail();

                package.HSC                = "";
                package.FMPR_CDG           = "";
                package.CONTENT_OF_PRODUCT = item.Content;
                package.PHYSICAL_WEIGHT    = item.Weight;
                package.WEIGHT_TYPE        = directBookingDetail.PakageCalculatonType == "kgToCms" ? "KG" : "LB";
                package.DIMEN_LENGTH       = item.Length;
                package.DIMEN_HEIGHT       = item.Height;
                package.DIMEN_WIDTH        = item.Width;
                package.DIMEN_UNIT         = directBookingDetail.PakageCalculatonType == "kgToCms" ? "CM" : "IN";
                package.MERCHANDISE_VALUE  = item.Value;
                package.QUANTITY           = item.CartoonValue;
                skyPostalRequestModel.detail.Add(package);
            }

            return(skyPostalRequestModel);
        }
Exemplo n.º 12
0
        public FrayteResult GenerateAllLabelReport(int DirectShipmentId, DirectBookingShipmentDraftDetail directBookingDetail, List <string> imgList, string CourierName, string LogisticLabel)
        {
            FrayteResult result = new FrayteResult();

            try
            {
                List <PdfImage> imglist = new List <PdfImage>();
                if (AppSettings.LabelSave == "")
                {
                    PdfImage pbimage;
                    foreach (var img in imgList)
                    {
                        pbimage          = new PdfImage();
                        pbimage.FullPath = AppSettings.WebApiPath + "/PackageLabel/" + DirectShipmentId + "/" + img;
                        imglist.Add(pbimage);
                    }

                    string pdfPath = string.Empty;
                    if (directBookingDetail != null)
                    {
                        pdfPath = AppSettings.WebApiPath + "/PackageLabel/" + DirectShipmentId + "/" + LogisticLabel;
                    }
                    else
                    {
                        string[] ff   = imgList[0].ToString().Split('.');
                        string   name = ff[0].ToString();
                        pdfPath = AppSettings.WebApiPath + "/PackageLabel/" + DirectShipmentId + "/" + name + ".pdf";
                    }
                    if (File.Exists(pdfPath))
                    {
                        File.Delete(pdfPath);
                    }
                    if (!System.IO.Directory.Exists(AppSettings.WebApiPath + "/PackageLabel/" + DirectShipmentId))
                    {
                        System.IO.Directory.CreateDirectory(AppSettings.WebApiPath + "/PackageLabel/" + DirectShipmentId);
                    }

                    if (CourierName == FrayteCourierCompany.TNT)
                    {
                        ReportTemplate.Other.TNTImagesToPDFReport report = new ReportTemplate.Other.TNTImagesToPDFReport();
                        report.DataSource = imglist;
                        DevExpress.XtraPrinting.PdfExportOptions pdfOptions = report.ExportOptions.Pdf;
                        pdfOptions.ImageQuality      = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest;
                        pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b;
                        report.ExportToPdf(pdfPath, pdfOptions);
                        result.Status = true;
                    }
                    else
                    {
                        ReportTemplate.Other.DHLImageToPDFReport dhlReport = new ReportTemplate.Other.DHLImageToPDFReport();
                        dhlReport.DataSource = imglist;
                        DevExpress.XtraPrinting.PdfExportOptions pdfOptions = dhlReport.ExportOptions.Pdf;
                        pdfOptions.ImageQuality      = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest;
                        pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b;
                        dhlReport.ExportToPdf(pdfPath, pdfOptions);
                        result.Status = true;
                    }

                    return(result);
                }
                else
                {
                    PdfImage pbimage;
                    foreach (var img in imgList)
                    {
                        pbimage = new PdfImage();
                        if (AppSettings.ShipmentCreatedFrom == "BATCH")
                        {
                            pbimage.FullPath = AppSettings.LabelFolder + "/" + DirectShipmentId + "/" + img;
                        }
                        else
                        {
                            pbimage.FullPath = HttpContext.Current.Server.MapPath(AppSettings.LabelFolder) + DirectShipmentId + "/" + img;
                        }

                        imglist.Add(pbimage);
                    }

                    string pdfPath = string.Empty;
                    if (directBookingDetail != null)
                    {
                        if (AppSettings.ShipmentCreatedFrom == "BATCH")
                        {
                            pdfPath = AppSettings.LabelFolder + "/" + DirectShipmentId + "/" + LogisticLabel;
                        }
                        else
                        {
                            pdfPath = HttpContext.Current.Server.MapPath("~/PackageLabel/" + DirectShipmentId + "/") + LogisticLabel;
                        }
                    }
                    else
                    {
                        string[] ff   = imgList[0].ToString().Split('.');
                        string   name = ff[0].ToString();
                        if (AppSettings.ShipmentCreatedFrom == "BATCH")
                        {
                            pdfPath = AppSettings.LabelFolder + "/" + DirectShipmentId + "/" + name + ".pdf";
                        }
                        else
                        {
                            pdfPath = HttpContext.Current.Server.MapPath(AppSettings.LabelFolder) + DirectShipmentId + "/" + name + ".pdf";
                        }
                    }
                    if (File.Exists(pdfPath))
                    {
                        File.Delete(pdfPath);
                    }
                    if (AppSettings.ShipmentCreatedFrom == "BATCH")
                    {
                        if (!System.IO.Directory.Exists(AppSettings.LabelFolder + "/" + DirectShipmentId))
                        {
                            System.IO.Directory.CreateDirectory(AppSettings.LabelFolder + "/" + DirectShipmentId);
                        }
                    }
                    else
                    {
                        if (!System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(AppSettings.LabelFolder) + "/" + DirectShipmentId))
                        {
                            System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(AppSettings.LabelFolder) + "/" + DirectShipmentId);
                        }
                    }
                    if (CourierName == FrayteCourierCompany.TNT)
                    {
                        ReportTemplate.Other.TNTImagesToPDFReport report = new ReportTemplate.Other.TNTImagesToPDFReport();
                        report.DataSource = imglist;
                        DevExpress.XtraPrinting.PdfExportOptions pdfOptions = report.ExportOptions.Pdf;
                        pdfOptions.ImageQuality      = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest;
                        pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b;
                        report.ExportToPdf(pdfPath, pdfOptions);
                        result.Status = true;
                    }
                    else
                    {
                        ReportTemplate.Other.DHLImageToPDFReport dhlReport = new ReportTemplate.Other.DHLImageToPDFReport();
                        dhlReport.DataSource = imglist;
                        DevExpress.XtraPrinting.PdfExportOptions pdfOptions = dhlReport.ExportOptions.Pdf;
                        pdfOptions.ImageQuality      = DevExpress.XtraPrinting.PdfJpegImageQuality.Highest;
                        pdfOptions.PdfACompatibility = DevExpress.XtraPrinting.PdfACompatibility.PdfA2b;
                        dhlReport.ExportToPdf(pdfPath, pdfOptions);
                        result.Status = true;
                    }

                    return(result);
                }
            }
            catch (Exception ex)
            {
                result.Status = false;

                return(result);
            }
        }
Exemplo n.º 13
0
        public BringRequestModel MapDirectBookingDetailToShipmentRequestDto(DirectBookingShipmentDraftDetail directBookingDetail)
        {
            BringRequestModel bringRequest = new BringRequestModel();

            if (AppSettings.ApplicationMode == FrayteApplicationMode.Test)
            {
                bringRequest.testIndicator = true;
            }
            else
            {
                bringRequest.testIndicator = false;
            }

            bringRequest.schemaVersion = 1;
            bringRequest.consignments  = new List <ConsignmentModel>();
            var packages = new List <Models.Bring.Package>();

            Models.Bring.Package package = new Models.Bring.Package();
            for (int i = 0; i < directBookingDetail.Packages.Count; i++)
            {
                for (int j = 0; j < directBookingDetail.Packages[i].CartoonValue; j++)
                {
                    package.weightInKg       = directBookingDetail.Packages[i].Weight.ToString("0.##");
                    package.goodsDescription = directBookingDetail.Packages[i].Content;
                    package.dimensions       = new Dimensions()
                    {
                        heightInCm = directBookingDetail.Packages[i].Height,
                        lengthInCm = directBookingDetail.Packages[i].Length,
                        widthInCm  = directBookingDetail.Packages[i].Width,
                    };
                    package.containerId   = directBookingDetail.FrayteNumber;
                    package.packageType   = "";
                    package.numberOfItems = "";
                    package.correlationId = "PACKAGE-" + directBookingDetail.FrayteNumber;
                    packages.Add(package);
                }
            }

            var ShipFrom             = new ExpressRepository().getHubAddress(directBookingDetail.ShipTo.Country.CountryId, directBookingDetail.ShipTo.PostCode, directBookingDetail.ShipTo.State);
            ConsignmentModel consign = new ConsignmentModel()
            {
                shippingDateTime = DateTime.Now.AddDays(1).ToString("yyyy-MM-ddTHH:mm:ss"),

                parties = new Parties()
                {
                    sender = new Sender()
                    {
                        //name = string.IsNullOrWhiteSpace(ShipFrom.CompanyName) ? ShipFrom.FirstName + " " + ShipFrom.LastName : ShipFrom.CompanyName,
                        //addressLine = ShipFrom.Address,
                        //addressLine2 = ShipFrom.Address2,
                        //additionalAddressInfo = "",
                        //postalCode = ShipFrom.PostCode,
                        //city = ShipFrom.City,
                        //countryCode = ShipFrom.Country.Code2,
                        //reference = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1,
                        //contact = new Contact
                        //{
                        //    name = string.IsNullOrEmpty(ShipFrom.FirstName + " " + ShipFrom.LastName) ? ShipFrom.CompanyName : ShipFrom.FirstName + " " + ShipFrom.LastName,
                        //    email = string.IsNullOrEmpty(ShipFrom.Email) ? "*****@*****.**" : ShipFrom.Email,
                        //    phoneNumber = ShipFrom.Phone
                        //}

                        name                  = "Priority Cargo AS",
                        addressLine           = "Skur 97,Kongshavnveien 29,",
                        addressLine2          = "Kongshavnveien 29,",
                        additionalAddressInfo = "",
                        postalCode            = "0193",
                        city                  = "Oslo",
                        countryCode           = "NO",
                        reference             = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1,
                        contact               = new Contact
                        {
                            name        = "Priority Cargo AS",
                            email       = "*****@*****.**",
                            phoneNumber = "+47 9760 0402"
                        }
                    },
                    recipient = new Recipient()
                    {
                        name                  = string.IsNullOrWhiteSpace(directBookingDetail.ShipTo.CompanyName) ? directBookingDetail.ShipTo.FirstName + " " + directBookingDetail.ShipTo.LastName : directBookingDetail.ShipTo.CompanyName,
                        addressLine           = directBookingDetail.ShipTo.Address,
                        addressLine2          = directBookingDetail.ShipTo.Address2,
                        additionalAddressInfo = "",
                        postalCode            = directBookingDetail.ShipTo.PostCode,
                        city                  = directBookingDetail.ShipTo.City,
                        countryCode           = directBookingDetail.ShipTo.Country.Code2,
                        //reference = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1,
                        reference = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1,
                        contact   = new Contact
                        {
                            name        = directBookingDetail.ShipTo.FirstName + " " + directBookingDetail.ShipTo.LastName,
                            email       = string.IsNullOrEmpty(directBookingDetail.ShipTo.Email) ? "*****@*****.**" : directBookingDetail.ShipTo.Email,
                            phoneNumber = directBookingDetail.ShipTo.Phone
                        }
                    },
                    pickupPoint = null
                },
                product = new Product()
                {
                    id                 = "PA_DOREN",
                    customerNumber     = directBookingDetail.CustomerRateCard.NetworkCode,
                    services           = null,
                    customsDeclaration = directBookingDetail.CustomInfo.CatagoryOfItemExplanation,
                },
                purchaseOrder = null,
                correlationId = null,
                packages      = packages
            };

            bringRequest.consignments.Add(consign);
            GetXMLFromRequestObject(bringRequest);
            return(bringRequest);
        }
Exemplo n.º 14
0
        public List <ETowerRequestModel> MapDirectBookingDetailToShipmentRequestDto(DirectBookingShipmentDraftDetail directBookingDetail)
        {
            List <ETowerRequestModel> eTowerRequest = new List <ETowerRequestModel>();

            ETowerRequestModel etower = new ETowerRequestModel()
            {
                trackingNo        = "",
                referenceNo       = directBookingDetail.FrayteNumber,
                addressLine1      = directBookingDetail.ShipTo.Address,
                addressLine2      = directBookingDetail.ShipTo.Address2,
                addressLine3      = "",
                city              = directBookingDetail.ShipTo.City,
                country           = directBookingDetail.ShipTo.Country.Code2,
                description       = string.Join("-", directBookingDetail.Packages.Select(x => x.Content.ToString()).ToArray()),
                nativeDescription = "",
                email             = directBookingDetail.ShipTo.Email,
                facility          = "",
                instruction       = "Canada Post",
                invoiceCurrency   = directBookingDetail.Currency.CurrencyCode,
                invoiceValue      = directBookingDetail.Packages.Sum(k => k.Value),
                phone             = directBookingDetail.ShipTo.Phone,
                platform          = "",
                postcode          = directBookingDetail.ShipTo.PostCode,
                recipientCompany  = directBookingDetail.ShipTo.CompanyName,
                recipientName     = directBookingDetail.ShipTo.FirstName + " " + directBookingDetail.ShipTo.LastName,
                serviceCode       = "",
                serviceOption     = "Expedited",
                sku                 = "",
                state               = directBookingDetail.ShipTo.State,
                weightUnit          = "KG",
                weight              = directBookingDetail.CustomerRateCard.Weight,
                dimensionUnit       = "CM",
                length              = directBookingDetail.Packages[0].Length,
                width               = directBookingDetail.Packages[0].Width,
                height              = directBookingDetail.Packages[0].Height,
                volume              = 0,
                shipperName         = directBookingDetail.ShipFrom.FirstName + " " + directBookingDetail.ShipFrom.LastName,
                shipperAddressLine1 = directBookingDetail.ShipFrom.Address,
                shipperAddressLine2 = directBookingDetail.ShipFrom.Address2,
                shipperAddressLine3 = "",
                shipperCity         = directBookingDetail.ShipFrom.City,
                shipperState        = directBookingDetail.ShipFrom.State,
                shipperPostcode     = directBookingDetail.ShipFrom.PostCode,
                shipperCountry      = directBookingDetail.ShipFrom.Country.Code2,
                shipperPhone        = directBookingDetail.ShipFrom.Phone,
                recipientTaxId      = "",
                authorityToLeave    = "",
                incoterm            = "DDP",
                lockerService       = "",
                extendData          = new ExtendData
                {
                    nationalNumber    = "",
                    nationalIssueDate = "",
                    cyrillicName      = "",
                    imei             = "",
                    isImei           = true,
                    vendorid         = "",
                    gstexemptioncode = "",
                    abnnumber        = "",
                    sortCode         = "",
                },
            };

            etower.orderItems = new List <OrderItem>();
            var count = 1;

            for (int i = 0; i < directBookingDetail.Packages.Count; i++)
            {
                OrderItem order = new OrderItem()
                {
                    itemNo            = count.ToString(),
                    sku               = directBookingDetail.FrayteNumber + "*" + count + "-" + directBookingDetail.Packages.Count,
                    description       = directBookingDetail.Packages[i].Content,
                    nativeDescription = directBookingDetail.FrayteNumber + "-" + directBookingDetail.ReferenceDetail.Reference1,
                    hsCode            = directBookingDetail.FrayteNumber,
                    originCountry     = directBookingDetail.ShipFrom.Country.Name,
                    unitValue         = (directBookingDetail.Packages[i].Value / directBookingDetail.Packages[i].CartoonValue),
                    itemCount         = directBookingDetail.Packages[i].CartoonValue,
                    weight            = directBookingDetail.Packages[i].Weight,
                    productURL        = ""
                };
                count++;
                etower.orderItems.Add(order);
            }
            eTowerRequest.Add(etower);
            return(eTowerRequest);
        }
Exemplo n.º 15
0
        public List <FrayteOfflineTracking> MapDirectShipmentObjTacking(int directShipmentid, DirectBookingShipmentDraftDetail directBooking)
        {
            List <FrayteOfflineTracking> list = new List <FrayteOfflineTracking>();
            FrayteOfflineTracking        track;

            if (directBooking != null)
            {
                track            = new FrayteOfflineTracking();
                track.ShipmentId = directShipmentid;
                track.Message    = "Shipment Received - Offline Parcel";
                track.CreatedOn  = DateTime.UtcNow;
                track.Location   = directBooking.ShipFrom.Country.Name;

                list.Add(track);

                if (directBooking.ReferenceDetail.CollectionDate.HasValue && !string.IsNullOrEmpty(directBooking.ReferenceDetail.CollectionTime))
                {
                    track            = new FrayteOfflineTracking();
                    track.ShipmentId = directShipmentid;
                    track.Message    = "Scheduled Pickup on " + directBooking.ReferenceDetail.CollectionDate.Value.ToString("dd-MMM-yyyy")
                                       + " at " + directBooking.ReferenceDetail.CollectionDate.Value.TimeOfDay.ToString("hh\\:mm");
                    track.CreatedOn = DateTime.UtcNow;
                    track.Location  = directBooking.ShipFrom.Country.Name;

                    list.Add(track);
                }
            }

            return(list);
        }