private static AddressValidationRequest CreateAddressValidationRequest(ShipServiceInfo clsService, AddressInfo clsAddress)
        {
            // Build the AddressValidationRequest
            AddressValidationRequest request = new AddressValidationRequest();

            request.WebAuthenticationDetail = new WebAuthenticationDetail();
            request.WebAuthenticationDetail.UserCredential          = new WebAuthenticationCredential();
            request.WebAuthenticationDetail.UserCredential.Key      = clsService.AccountKey;
            request.WebAuthenticationDetail.UserCredential.Password = clsService.AccountPassword;
            //request.WebAuthenticationDetail.ParentCredential = new WebAuthenticationCredential();
            //request.WebAuthenticationDetail.ParentCredential.Key = clsService.AccountKey;
            //request.WebAuthenticationDetail.ParentCredential.Password = clsService.AccountPassword;

            request.ClientDetail = new ClientDetail();
            request.ClientDetail.AccountNumber = clsService.AccountNumber;
            request.ClientDetail.MeterNumber   = clsService.MeterNumber;

            request.TransactionDetail = new TransactionDetail();
            request.TransactionDetail.CustomerTransactionId = clsService.OrderNumber; // The client will get the same value back in the reply

            // Version
            request.Version = new VersionId(); // Creates the Version element with all child elements populated

            request.InEffectAsOfTimestamp          = DateTime.Now;
            request.InEffectAsOfTimestampSpecified = true;

            SetAddress(request, clsAddress, clsService.OrderNumber);

            return(request);
        }
Exemplo n.º 2
0
        private static SmartPostCloseRequest CreateSmartPostCloseRequest(ShipServiceInfo clsService)
        {
            // Build the SmartPostCloseRequest
            SmartPostCloseRequest request = new SmartPostCloseRequest();

            request.WebAuthenticationDetail = SetWebAuthenticationDetail(clsService.AccountKey, clsService.AccountPassword);

            request.ClientDetail = new ClientDetail();
            request.ClientDetail.AccountNumber = clsService.AccountNumber;
            request.ClientDetail.MeterNumber   = clsService.MeterNumber;

            request.TransactionDetail = new TransactionDetail();

            string customerTransactionId = "SmartPostClose_" + DateTime.Now.ToString("yyyyMMddHHmmss");

            request.TransactionDetail.CustomerTransactionId = customerTransactionId;

            request.Version = new VersionId();

            request.HubId = clsService.HubId;

            // Request Jieun cci
            //request.CustomerManifestId = "XXX"; // Replace "XXX" with the CustomerManifestId

            request.DestinationCountryCode = "US";                 // SmartPost is available in the US
            request.PickUpCarrier          = CarrierCodeType.FXSP; // SmartPost uses FXSP carrier code type
            request.PickUpCarrierSpecified = true;

            return(request);
        }
Exemplo n.º 3
0
        private static void SetPackageLineItems(ProcessShipmentRequest request, ShipServiceInfo clsService, bool isCodShipment, string departmentID)
        {
            request.RequestedShipment.RequestedPackageLineItems    = new RequestedPackageLineItem[1];
            request.RequestedShipment.RequestedPackageLineItems[0] = new RequestedPackageLineItem();
            request.RequestedShipment.RequestedPackageLineItems[0].SequenceNumber = "1";

            // Package weight information
            request.RequestedShipment.RequestedPackageLineItems[0].Weight       = new Weight();
            request.RequestedShipment.RequestedPackageLineItems[0].Weight.Value = clsService.PackageWeight; // decimal
            request.RequestedShipment.RequestedPackageLineItems[0].Weight.Units = clsService.WeightUnit;    // WeightUnits.LB;

            // CustomerReferences
            // Jinbeom.p 2019.01.14 Customer DepartmentID 추가
            //request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences = new CustomerReference[2];
            request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences    = new CustomerReference[3];
            request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[0] = new CustomerReference();
            request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[0].CustomerReferenceType = CustomerReferenceType.P_O_NUMBER;
            request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[0].Value = clsService.OrderNumber;

            request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[1] = new CustomerReference();
            request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[1].CustomerReferenceType = CustomerReferenceType.CUSTOMER_REFERENCE;
            request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[1].Value = clsService.OrderNumber;

            // Jinbeom.p 2019.01.14 Customer DepartmentID 추가
            request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[2] = new CustomerReference();
            request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[2].CustomerReferenceType = CustomerReferenceType.DEPARTMENT_NUMBER;
            request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[2].Value = departmentID;

            // Set COD (Cash On Delivery)
            if (isCodShipment)
            {
                SetCOD(request, clsService);
            }
        }
Exemplo n.º 4
0
        private static void SetLabelDetails(ProcessShipmentRequest request, ShipServiceInfo clsService)
        {
            request.RequestedShipment.LabelSpecification                    = new LabelSpecification();
            request.RequestedShipment.LabelSpecification.ImageType          = clsService.LabelImageType;                          // ShippingDocumentImageType.ZPLII; // Use this line for a PDF label
            request.RequestedShipment.LabelSpecification.ImageTypeSpecified = true;
            request.RequestedShipment.LabelSpecification.LabelFormatType    = clsService.LabelFormatType;                         // LabelFormatType.COMMON2D;

            request.RequestedShipment.LabelSpecification.LabelStockType                    = clsService.LabelStockType;           // LabelStockType.STOCK_4X6;
            request.RequestedShipment.LabelSpecification.LabelStockTypeSpecified           = true;
            request.RequestedShipment.LabelSpecification.LabelPrintingOrientation          = clsService.LabelPrintingOrientation; // LabelPrintingOrientationType.BOTTOM_EDGE_OF_TEXT_FIRST;
            request.RequestedShipment.LabelSpecification.LabelPrintingOrientationSpecified = true;

            // *** 체크사항 (There is no below sorucecode on ship version v17)
            request.RequestedShipment.LabelSpecification.CustomerSpecifiedDetail = new CustomerSpecifiedLabelDetail();
            request.RequestedShipment.LabelSpecification.CustomerSpecifiedDetail.TermsAndConditionsLocalization = new Localization();
            request.RequestedShipment.LabelSpecification.CustomerSpecifiedDetail.TermsAndConditionsLocalization.LanguageCode = clsService.LanguageCode;     // "EN";
            request.RequestedShipment.LabelSpecification.CustomerSpecifiedDetail.TermsAndConditionsLocalization.LocaleCode   = clsService.LocaleCode;       // "US";

            /*
             * Requests customer-specific barcode on FedEx Ground and FedEx Home Delivery labels.
             * Valid values are:
             * 􀁸 NONE
             * 􀁸 COMMON_2D
             * 􀁸 SSCC_18
             * 􀁸 USPS
             * Note: USPS is applicable for FedEx SmartPost shipments.
             * request.RequestedShipment.LabelSpecification.CustomerSpecifiedDetail.SecondaryBarcode = SecondaryBarcodeType.COMMON_2D;
             */
        }
Exemplo n.º 5
0
        private static void SetSender(ProcessShipmentRequest request, ShipServiceInfo clsService)
        {
            request.RequestedShipment.Shipper                     = new Party();
            request.RequestedShipment.Shipper.Contact             = new Contact();
            request.RequestedShipment.Shipper.Contact.CompanyName = clsService.ShipperName;
            request.RequestedShipment.Shipper.Contact.PhoneNumber = clsService.ShipperPhoneNumber;

            request.RequestedShipment.Shipper.Address = new Address();
            if (string.IsNullOrEmpty(clsService.ShipperAddress2))
            {
                request.RequestedShipment.Shipper.Address.StreetLines = new string[1] {
                    clsService.ShipperAddress
                };
            }
            else
            {
                request.RequestedShipment.Shipper.Address.StreetLines = new string[2] {
                    clsService.ShipperAddress, clsService.ShipperAddress2
                };
            }

            request.RequestedShipment.Shipper.Address.City = clsService.ShipperCity;
            request.RequestedShipment.Shipper.Address.StateOrProvinceCode = clsService.ShipperStateCode;
            request.RequestedShipment.Shipper.Address.PostalCode          = clsService.ShipperPostalCode;
            request.RequestedShipment.Shipper.Address.CountryCode         = clsService.ShipperCountryCode;
        }
Exemplo n.º 6
0
        private string FedExCloseShipment(out bool isSuccess)
        {
            string retVal         = string.Empty;
            string retVal2        = string.Empty;
            string AccountCountry = cbFedExAccount.Text;

            isSuccess = false;

            bool fedExIsLive = false;

            F21.Service.ShipServiceInfo       closeServiceInfo = null;
            F21.Service.CloseShipmentResponse closeResponse    = null;
            F21.Service.CloseShipmentClient   closeService     = null;

            try
            {
                if (ConfigManager.GetAppSetting2("mode").Equals("production"))
                {
                    fedExIsLive = true;
                }

                decimal packageWeight = 0.00M;
                closeServiceInfo = new F21.Service.ShipServiceInfo(AccountCountry, fedExIsLive, packageWeight, false);

                closeService  = new CloseShipmentClient();
                closeResponse = closeService.CloseShipmentService(closeServiceInfo);

                isSuccess = closeResponse.isSuccess;

                if (closeResponse.ErrorMessage != "")
                {
                    retVal = string.Format("[FedExCloseShipment Error] {0}", Basic.IsNull(closeResponse.ErrorMessage, ""));
                }

                // Save FedEx Close Shipment Data
                string retValue2 = SaveFedExClose(closeServiceInfo, closeResponse);

                if (retVal != "")
                {
                    if (retVal2 != "")
                    {
                        retVal += "\r\n [Save Error] : " + retVal2;
                    }
                }
                else if (retVal2 != "")
                {
                    retVal = "[FedExCloseShipment Save Error] : " + retVal2;
                }
            }
            catch (Exception ex)
            {
                retVal = string.Format("[FedExCloseShipment Error] {0}", ex.Message);
            }

            return(retVal);
        }
Exemplo n.º 7
0
 private static void SetCOD(ProcessShipmentRequest request, ShipServiceInfo clsService)
 {
     request.RequestedShipment.RequestedPackageLineItems[0].SpecialServicesRequested = new PackageSpecialServicesRequested();
     request.RequestedShipment.RequestedPackageLineItems[0].SpecialServicesRequested.SpecialServiceTypes    = new PackageSpecialServiceType[1];
     request.RequestedShipment.RequestedPackageLineItems[0].SpecialServicesRequested.SpecialServiceTypes[0] = PackageSpecialServiceType.COD;
     //
     request.RequestedShipment.RequestedPackageLineItems[0].SpecialServicesRequested.CodDetail = new CodDetail();
     request.RequestedShipment.RequestedPackageLineItems[0].SpecialServicesRequested.CodDetail.CollectionType               = CodCollectionType.GUARANTEED_FUNDS;
     request.RequestedShipment.RequestedPackageLineItems[0].SpecialServicesRequested.CodDetail.CodCollectionAmount          = new Money();
     request.RequestedShipment.RequestedPackageLineItems[0].SpecialServicesRequested.CodDetail.CodCollectionAmount.Amount   = clsService.CODAmount;
     request.RequestedShipment.RequestedPackageLineItems[0].SpecialServicesRequested.CodDetail.CodCollectionAmount.Currency = clsService.Currency;
 }
Exemplo n.º 8
0
        private static ProcessShipmentRequest CreateShipmentRequest(ShipServiceInfo clsService, AddressInfo clsAddress, bool isCodShipment)
        {
            // Build the ShipmentRequest
            ProcessShipmentRequest request = new ProcessShipmentRequest();

            // Set WebAuthenticationCredential
            request.WebAuthenticationDetail = SetWebAuthenticationDetail(clsService.AccountKey, clsService.AccountPassword);

            request.ClientDetail = new ClientDetail();
            request.ClientDetail.AccountNumber = clsService.AccountNumber;
            request.ClientDetail.MeterNumber   = clsService.MeterNumber;

            request.TransactionDetail = new TransactionDetail();
            request.TransactionDetail.CustomerTransactionId = clsService.OrderNumber; // The client will get the same value back in the response

            request.Version = new VersionId();

            // GROUND_HOME_DELIVERY ISSUE
            //RateRequest request = new RateRequest();

            //Set Shipment Details
            SetShipmentDetails(request, clsService);

            // Set Sender
            SetSender(request, clsService);

            // Set Recipient
            SetRecipient(request, clsAddress, clsService.ServiceType);

            // Set Payment
            SetPayment(request, clsService.PayorAccountNumber, clsService.CountryCode); // Payor CountryCode

            // Set Label Details
            SetLabelDetails(request, clsService);

            // Set Package Line Items
            SetPackageLineItems(request, clsService, isCodShipment, clsAddress.CartonId.Substring(2, 4));

            // FedEx_SmartPost
            if (clsService.ServiceType == ServiceType.SMART_POST)
            {
                SetSmartPostDetails(request, clsService.PackageWeight, clsService.HubId);
            }

            return(request);
        }
Exemplo n.º 9
0
        private static void SetShipmentDetails(ProcessShipmentRequest request, ShipServiceInfo clsService)
        {
            //2016.08.23 - Changed ShipTimestamp (minkyu.r)
            DateTime time_1      = DateTime.Now;
            string   cutOfftime  = DateTime.Now.ToShortDateString() + " 22:00";
            DateTime time_2      = DateTime.Parse(cutOfftime);
            int      timeCompare = DateTime.Compare(time_1, time_2);

            request.RequestedShipment = new RequestedShipment();

            //FedEx Service Issue. (The server is on central time so it thinks you are sending a ship request for “yesterday”)
            //[ERROR] Notification Code: 1935,  Notification Message: Invalid date entered
            if (timeCompare > 0)
            {
                request.RequestedShipment.ShipTimestamp = DateTime.Now.AddHours(+2);
            }
            else
            {
                request.RequestedShipment.ShipTimestamp = DateTime.Now;
            }

            //request.RequestedShipment.ShipTimestamp = DateTime.Now;     // Ship date and time
            request.RequestedShipment.DropoffType = DropoffType.REGULAR_PICKUP;

            request.RequestedShipment.ServiceType   = clsService.ServiceType;       // Service types are GROUND_HOME_DELIVERY, STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, ...
            request.RequestedShipment.PackagingType = PackagingType.YOUR_PACKAGING; // Packaging type FEDEX_BOK, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
            request.RequestedShipment.PackageCount  = "1";

            // 멕시코 소스코드 참조하여 추가함.
            request.RequestedShipment.TotalWeight       = new Weight();             // Total weight information
            request.RequestedShipment.TotalWeight.Value = clsService.PackageWeight; //1;
            request.RequestedShipment.TotalWeight.Units = clsService.WeightUnit;    // WeightUnits.LB;

            // Set HAL
            //bool isHALShipment = false;
            //if (isHALShipment)
            //    SetHAL(request);
        }
        public AddressServiceResponse ValidationServiceClient(ShipServiceInfo clsService, AddressInfo clsAddress)
        {
            string ClassificationType = string.Empty;
            string serviceURL         = string.Empty;

            AddressValidationService service = new AddressValidationService();

            F21.Service.AddressServiceResponse fedExResponse = new F21.Service.AddressServiceResponse();

            try
            {
                if (F21.Framework.ConfigManager.GetAppSetting2("mode").Equals("production", StringComparison.OrdinalIgnoreCase))
                {
                    serviceURL = F21.Framework.ConfigManager.GetAppSetting2("Live_FedExAddressUrl");
                }
                else
                {
                    serviceURL = F21.Framework.ConfigManager.GetAppSetting2("Test_FedExAddressUrl");
                }


                if (string.IsNullOrEmpty(serviceURL))
                {
                    fedExResponse.isSuccess    = false;
                    fedExResponse.ErrorMessage = "Address validation service url is empty.";

                    return(fedExResponse);
                }

                AddressValidationRequest request = CreateAddressValidationRequest(clsService, clsAddress);

                // Test URL : https://wsbeta.fedex.com:443/web-services/addressvalidation
                service.Url = serviceURL;

                AddressValidationReply reply = service.addressValidation(request);

                if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING)
                {
                    //FedExAddressClassificationType Enum
                    fedExResponse = ShowAddressValidationReply(reply);

                    fedExResponse.HighestSeverity = reply.HighestSeverity.ToString();
                    fedExResponse.isSuccess       = true;
                    fedExResponse.ErrorMessage    = "";
                }
                else
                {
                    fedExResponse.HighestSeverity = reply.HighestSeverity == null ? "" : reply.HighestSeverity.ToString();
                    fedExResponse.isSuccess       = false;

                    foreach (Notification notification in reply.Notifications)
                    {
                        System.Diagnostics.Debug.WriteLine(notification.Message);
                        fedExResponse.ErrorMessage = notification.Message;
                    }
                }
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
                throw ex;
            }
            catch (System.ServiceModel.CommunicationException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(fedExResponse);
        }
Exemplo n.º 11
0
        public CloseShipmentResponse CloseShipmentService(ShipServiceInfo clsService)
        {
            FedExWebServiceClient.CloseWebReference.CloseService service = new CloseService();
            F21.Service.CloseShipmentResponse closeResponse = new CloseShipmentResponse();

            string iResultCode    = string.Empty;
            string iResultMessage = string.Empty;
            string iErrorMessage  = string.Empty;
            string retValue       = string.Empty;
            string serviceURL     = string.Empty;
            string transactionId  = string.Empty;

            string noticeCode     = string.Empty;
            string noticeMessage  = string.Empty;
            string noticeSeverity = string.Empty;
            string noticeSource   = string.Empty;

            try
            {
                if (F21.Framework.ConfigManager.GetAppSetting2("mode").Equals("production", StringComparison.OrdinalIgnoreCase))
                {
                    serviceURL = F21.Framework.ConfigManager.GetAppSetting2("Live_FedExCloseUrl");
                }
                else
                {
                    serviceURL = F21.Framework.ConfigManager.GetAppSetting2("Test_FedExCloseUrl");
                }

                // Webservice URL
                service.Url = serviceURL;

                NameValueCollection nvcNotification = null;

                #region Ground Close
                GroundCloseWithDocumentsRequest request = CreateGroundCloseWithDocumentsRequest(clsService, out transactionId);
                closeResponse.TransactionId = Basic.IsNull(transactionId);
                //GroundCloseRequest request = CreateGroundCloseRequest();

                // [8/8/2016 jh.kim] Serialize To Soap
                System.Diagnostics.Debug.WriteLine(Encoding.Default.GetString(Serialize.serializeToSoap(request)));

                // Call the Close web service passing in a GroundCloseWithDocumentsRequest and returning a GroundCloseDocumentsReply
                GroundCloseDocumentsReply reply = service.groundCloseWithDocuments(request);

                // Call ShowNotifications(reply)
                nvcNotification = ShowNotifications(reply, out iResultMessage);

                // SUCCESS, NOTE, WARNING
                if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING)
                {
                    closeResponse.HighestSeverity = reply.HighestSeverity.ToString();

                    // Call ShowGroundCloseDocumentsReply(reply)
                    closeResponse = ShowGroundCloseDocumentsReply(reply, closeResponse);

                    if (nvcNotification["Code"].ToString() == "0000" && nvcNotification["Message"].ToString() == "Success")
                    {
                        closeResponse.isSuccess    = true;
                        closeResponse.ErrorMessage = Basic.IsNull(closeResponse.ErrorMessage, "");
                    }
                    else
                    {
                        closeResponse.isSuccess = false;

                        if (closeResponse.ErrorMessage == "")
                        {
                            closeResponse.ErrorMessage = "[FedEx Close Service : " + closeResponse.HighestSeverity + "]\r\nNotification Code: " + nvcNotification["Code"].ToString() + ",\r\nNotification Message: " + nvcNotification["Message"].ToString();
                        }
                        else
                        {
                            closeResponse.ErrorMessage = "[FedEx Close Service : " + closeResponse.HighestSeverity + "]\r\nNotification Code: " + nvcNotification["Code"].ToString() + ",\r\nNotification Message: " + nvcNotification["Message"].ToString() + "\r\n" + closeResponse.ErrorMessage;
                        }
                    }
                }
                else // ERROR, FAILURE
                {
                    closeResponse.HighestSeverity = Basic.IsNull(reply.HighestSeverity.ToString(), "Empty");

                    closeResponse.isSuccess    = false;
                    closeResponse.ErrorMessage = "[" + closeResponse.HighestSeverity + "] Notification Code: " + nvcNotification["Code"].ToString() + ",\r\nNotification Message: " + nvcNotification["Message"].ToString();
                }
                #endregion Ground Close


                foreach (string nvKey in nvcNotification.AllKeys)
                {
                    switch (nvKey)
                    {
                    case "Code":
                        closeResponse.NoticeCode = nvcNotification[nvKey].ToString();
                        break;

                    case "Message":
                        closeResponse.NoticeMessage = nvcNotification[nvKey].ToString();
                        break;

                    case "Severity":
                        closeResponse.NoticeSeverity = nvcNotification[nvKey].ToString();
                        break;

                    case "Source":
                        closeResponse.NoticeSource = nvcNotification[nvKey].ToString();
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
                throw ex;
            }
            catch (System.ServiceModel.CommunicationException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (service != null)
                {
                    service.Dispose();
                }
            }

            return(closeResponse);
        }
Exemplo n.º 12
0
        private static GroundCloseWithDocumentsRequest CreateGroundCloseWithDocumentsRequest(ShipServiceInfo clsService, out string transactionId)
        {
            // Build the CloseWithDocumentsRequest
            GroundCloseWithDocumentsRequest request = new GroundCloseWithDocumentsRequest();

            //Set WebAuthenticationCredential
            request.WebAuthenticationDetail = SetWebAuthenticationDetail(clsService.AccountKey, clsService.AccountPassword);

            request.ClientDetail = new ClientDetail();
            request.ClientDetail.AccountNumber = clsService.AccountNumber;
            request.ClientDetail.MeterNumber   = clsService.MeterNumber;

            request.TransactionDetail = new TransactionDetail();
            string customerTransactionId = "NWH_GroundClose_" + DateTime.Now.ToString("yyyyMMddHHmmss");

            request.TransactionDetail.CustomerTransactionId = customerTransactionId;
            transactionId = customerTransactionId;      // out string

            request.Version = new VersionId();

            //2016.08.23 - Changed CloseDate (minkyu.r)
            //[ERROR] Notification Code: 1935,  Notification Message: Invalid date entered
            DateTime time_1     = DateTime.Now;
            string   cutOfftime = DateTime.Now.ToShortDateString() + " 22:00";
            DateTime time_2     = DateTime.Parse(cutOfftime);
            int      time       = DateTime.Compare(time_1, time_2);

            if (time > 0)
            {
                request.CloseDate = DateTime.Now.AddHours(-2);
            }
            else
            {
                request.CloseDate = DateTime.Now;
            }
            //request.CloseDate = DateTime.Now;   //Convert.ToDateTime("2016-08-06");

            request.CloseDateSpecified         = true;
            request.CloseDocumentSpecification = new CloseDocumentSpecification();
            //request.CloseDocumentSpecification.CloseDocumentTypes = new CloseDocumentType[1] { CloseDocumentType.OP_950 };
            //request.CloseDocumentSpecification.Op950Detail = new Op950Detail();
            //request.CloseDocumentSpecification.Op950Detail.Format = new CloseDocumentFormat();
            //request.CloseDocumentSpecification.Op950Detail.Format.ImageType = ShippingDocumentImageType.PDF;
            //request.CloseDocumentSpecification.Op950Detail.Format.ImageTypeSpecified = true;

            request.CloseDocumentSpecification.CloseDocumentTypes = new CloseDocumentType[1] {
                CloseDocumentType.MANIFEST
            };
            request.CloseDocumentSpecification.ManifestDetail                           = new ManifestDetail();
            request.CloseDocumentSpecification.ManifestDetail.Format                    = new CloseDocumentFormat();
            request.CloseDocumentSpecification.ManifestDetail.Format.ImageType          = ShippingDocumentImageType.TEXT; //ShippingDocumentImageType.PDF;
            request.CloseDocumentSpecification.ManifestDetail.Format.ImageTypeSpecified = true;

            return(request);
        }
Exemplo n.º 13
0
        private static ShipServiceResponse ShowShipmentReply(bool isCodShipment, ProcessShipmentReply reply, ShipServiceInfo clsService, ShipServiceResponse objResponse, out string retVal)
        {
            //F21.Service.ShipServiceResponse objResponse = new F21.Service.ShipServiceResponse();
            retVal = string.Empty;

            try
            {
                // Carrier code types : FDXC(Cargo), FDXE(Express), FDXG(Ground), FXCC(Custom Critical), FXFX(Freight), FXSP - ? (Reference FedEx Document)
                // SmartPost Reply details
                if (clsService.ServiceType == ServiceType.SMART_POST)
                {
                    if (reply.CompletedShipmentDetail.SmartPostDetail.PickUpCarrierSpecified)
                    {
                        objResponse.SmartPickupCode = reply.CompletedShipmentDetail.SmartPostDetail.PickUpCarrier.ToString();
                    }

                    if (reply.CompletedShipmentDetail.SmartPostDetail.MachinableSpecified)
                    {
                        objResponse.SmartMachinable = reply.CompletedShipmentDetail.SmartPostDetail.Machinable;
                    }
                }

                // Details for each package
                if (reply.CompletedShipmentDetail.CompletedPackageDetails != null)
                {
                    System.Diagnostics.Debug.WriteLine("CompletedPackageDetails Array Length : " + reply.CompletedShipmentDetail.CompletedPackageDetails.Length);
                    foreach (CompletedPackageDetail packageDetail in reply.CompletedShipmentDetail.CompletedPackageDetails)
                    {
                        //Get Fedex TrackingNumber  (ShowTrackingDetails)
                        if (packageDetail.TrackingIds != null)
                        {
                            System.Diagnostics.Debug.WriteLine("TrackingIds Array Length : " + packageDetail.TrackingIds.Length);
                            for (int i = 0; i < packageDetail.TrackingIds.Length; i++)
                            {
                                // TrackingIdType (EXPRESS,FEDEX,FREIGHT,GROUND,USPS)
                                // Update ShipService version from v15 to v17
                                objResponse.TrackingIdType      = packageDetail.TrackingIds[i].TrackingIdType.ToString();
                                objResponse.FedexTrackingNumber = packageDetail.TrackingIds[i].TrackingNumber;
                                objResponse.FormId            = packageDetail.TrackingIds[i].FormId;
                                objResponse.UspsApplicationId = Basic.IsNull(packageDetail.TrackingIds[i].UspsApplicationId, "");

                                /*  (Comment out the below sourcecode)
                                 * if (packageDetail.TrackingIds[i].TrackingIdType == TrackingIdType.USPS)
                                 * {
                                 *  objResponse.USPSTrackingIdType = packageDetail.TrackingIds[i].TrackingIdType.ToString();
                                 *  objResponse.USPSTrackingNumber = packageDetail.TrackingIds[i].TrackingNumber;
                                 *  objResponse.USPSFormId = packageDetail.TrackingIds[i].FormId;
                                 * }
                                 * else
                                 * {
                                 *  objResponse.TrackingIdType = packageDetail.TrackingIds[i].TrackingIdType.ToString();
                                 *  objResponse.FedexTrackingNumber = packageDetail.TrackingIds[i].TrackingNumber;
                                 *  objResponse.FormId = packageDetail.TrackingIds[i].FormId;
                                 * }
                                 */
                            }
                        }
                        else
                        {
                            // Tracking Number Issue
                            retVal = "[ERROR] packageDetail.TrackingIds is null.";
                        }

                        //Get LabelString (ShowShipmentLabels)
                        if (packageDetail.Label.Parts != null)
                        {
                            if (clsService.LabelImageType == ShippingDocumentImageType.ZPLII)
                            {
                                // Get ZPL Label Strig
                                objResponse.FedexLabelString = ShowShipmentLabels(packageDetail);
                            }
                            else if (clsService.LabelImageType == ShippingDocumentImageType.PDF)
                            {
                                objResponse.FedexLabelString = ShowShipmentLabels3(isCodShipment, reply.CompletedShipmentDetail, packageDetail);
                            }
                            else
                            {
                                objResponse.FedexLabelString = ShowShipmentLabels(packageDetail);
                            }
                        }
                        else
                        {
                            retVal = retVal + " [ERROR] packageDetail.Label.Parts is null.";
                        }

                        // *** Check functon (ShowPackageRateDetails) Don't use package rate detalis information
                        // PackageRateDetails 에러가 종종 발생하기 때문에 주석 처리, TrackingNumber, ZplString Value 가 존재하면 정상 처리함.

                        /* (Comment out the below sourcecode)
                         * if (packageDetail.PackageRating.PackageRateDetails != null)
                         * {
                         *  System.Diagnostics.Debug.WriteLine("PackageRateDetails Array Length :" + packageDetail.PackageRating.PackageRateDetails.Length);
                         *  foreach (PackageRateDetail ratedPackage in packageDetail.PackageRating.PackageRateDetails)
                         *  {
                         *      System.Diagnostics.Debug.WriteLine("Billing weight :" + ratedPackage.BillingWeight.Value.ToString());
                         *      System.Diagnostics.Debug.WriteLine("Billing weight Units :" + ratedPackage.BillingWeight.Units.ToString());
                         *
                         *      objResponse.BillingWeight = ratedPackage.BillingWeight.Value;
                         *      objResponse.BillingWeightUnits = ratedPackage.BillingWeight.Units.ToString();
                         *
                         *      System.Diagnostics.Debug.WriteLine("Base charge : " + ratedPackage.BaseCharge.Amount + "-" + ratedPackage.BaseCharge.Currency);
                         *      System.Diagnostics.Debug.WriteLine("Total surcharge : " + ratedPackage.TotalSurcharges.Amount + "-" + ratedPackage.TotalSurcharges.Currency);
                         *
                         *      if (ratedPackage.Surcharges != null)
                         *      {
                         *          foreach (Surcharge surcharge in ratedPackage.Surcharges)
                         *          {
                         *              System.Diagnostics.Debug.WriteLine("Surcharge : " + surcharge.SurchargeType + " - " + surcharge.Amount.Amount + " - " + surcharge.Amount.Currency);
                         *          }
                         *      }
                         *
                         *      if (ratedPackage.NetCharge != null)
                         *      {
                         *          System.Diagnostics.Debug.WriteLine("Net charge : " + ratedPackage.NetCharge.Amount + "-" + ratedPackage.NetCharge.Currency);
                         *      }
                         *  }
                         * }
                         */
                        //---------------------------------------------------------------------------------------------------------------------------------------

                        // Get Barcode (ShowBarcodeDetails)
                        if (packageDetail.OperationalDetail.Barcodes != null)
                        {
                            if (packageDetail.OperationalDetail.Barcodes.StringBarcodes != null)
                            {
                                System.Diagnostics.Debug.WriteLine("StringBarcodes Array Length :" + packageDetail.OperationalDetail.Barcodes.StringBarcodes.Length);
                                for (int i = 0; i < packageDetail.OperationalDetail.Barcodes.StringBarcodes.Length; i++)
                                {
                                    //List<string> list = new List<string>();

                                    // String Barcode Types : ADDRESS, ASTRA, FEDEX_1D, GROUND, POSTAL,USPS
                                    // Update ShipService version from v15 to v17
                                    objResponse.Barcode     = packageDetail.OperationalDetail.Barcodes.StringBarcodes[i].Value;
                                    objResponse.BarcodeType = packageDetail.OperationalDetail.Barcodes.StringBarcodes[i].Type.ToString();

                                    /* (Comment out the below sourcecode)
                                     * if (packageDetail.OperationalDetail.Barcodes.StringBarcodes[i].Type == StringBarcodeType.USPS)
                                     * {
                                     *  objResponse.USPSBarcode = packageDetail.OperationalDetail.Barcodes.StringBarcodes[i].Value;
                                     *  objResponse.USPSBarcodeType = packageDetail.OperationalDetail.Barcodes.StringBarcodes[i].Type.ToString();
                                     * }
                                     * else
                                     * {
                                     *  objResponse.Barcode = packageDetail.OperationalDetail.Barcodes.StringBarcodes[i].Value;
                                     *  objResponse.BarcodeType = packageDetail.OperationalDetail.Barcodes.StringBarcodes[i].Type.ToString();
                                     * }
                                     */
                                    //Object reference not set to an instance of an object.
                                    //objResponse.ResponseStringBarcodes[i] = packageDetail.OperationalDetail.Barcodes.StringBarcodes[i].Value;
                                }
                            }

                            // Don't use BinaryBarcodes (Comment out the BinaryBarcodes sourcecode)

                            /*
                             * if (packageDetail.OperationalDetail.Barcodes.BinaryBarcodes != null)
                             * {
                             *  System.Diagnostics.Debug.WriteLine("BinaryBarcodes Array Length :" + packageDetail.OperationalDetail.Barcodes.BinaryBarcodes.Length);
                             *  for (int i = 0; i < packageDetail.OperationalDetail.Barcodes.BinaryBarcodes.Length; i++)
                             *  {
                             *      objResponse.BinaryBarcodeType = packageDetail.OperationalDetail.Barcodes.BinaryBarcodes[i].Type.ToString();
                             *  }
                             * }
                             */
                        }
                    }
                }

                // ShowPackageRouteDetails
                if (reply.CompletedShipmentDetail.OperationalDetail != null)
                {
                    ShipmentOperationalDetail routingDetail = reply.CompletedShipmentDetail.OperationalDetail;
                    objResponse.UrsaPrefixCode        = routingDetail.UrsaPrefixCode;
                    objResponse.UrsaSuffixCode        = routingDetail.UrsaSuffixCode;
                    objResponse.DestinationLocationId = routingDetail.DestinationLocationId;
                    objResponse.AirportId             = routingDetail.AirportId;


                    if (routingDetail.TransitTimeSpecified)
                    {
                        objResponse.TransitTime = routingDetail.TransitTime.ToString();
                    }

                    /*
                     * if (routingDetail.DeliveryDaySpecified)
                     * {
                     *  string DeliveryDay = routingDetail.DeliveryDay.ToString();
                     * }
                     *
                     * if (routingDetail.DeliveryDateSpecified)
                     * {
                     *  string DeliveryShortDate = routingDetail.DeliveryDate.ToShortDateString();
                     * }
                     */

                    //throw new Exception("Test Error");
                }
            }
            catch (Exception ex)
            {
                retVal = retVal + "[ShowShipmentReply Error] " + ex.Message;
            }

            return(objResponse);
        }
Exemplo n.º 14
0
        public ShipServiceResponse ShipClientService(ShipServiceInfo clsService, AddressInfo clsAddress)
        {
            FedExWebServiceClient.ShipServiceWebReference.ShipService service = new FedExWebServiceClient.ShipServiceWebReference.ShipService();
            ShipServiceResponse shipResponse = new ShipServiceResponse();

            string iResultCode    = string.Empty;
            string iResultMessage = string.Empty;
            string iErrorMessage  = string.Empty;
            string retValue       = string.Empty;
            string strApiUrl      = string.Empty;

            string noticeCode     = string.Empty;
            string noticeMessage  = string.Empty;
            string noticeSeverity = string.Empty;
            string noticeSource   = string.Empty;


            // WebService Url Setting
            retValue = GetWebserviceUrl(out strApiUrl);
            if (!string.IsNullOrEmpty(retValue))
            {
                shipResponse.isSuccess    = false;
                shipResponse.ErrorMessage = "[ERROR] Ship Webservice url is empty.\r\n  Error Message : " + retValue;

                return(shipResponse);
            }

            try
            {
                bool isCodShipment = clsService.IsCOD; // Don't use cash on delivery in US.

                // Create Shipment Request
                ProcessShipmentRequest request = CreateShipmentRequest(clsService, clsAddress, isCodShipment);

                // Webservice URL
                service.Url = strApiUrl;

                // Call the ship web service passing in a ProcessShipmentRequest and returning a ProcessShipmentReply

                System.Diagnostics.Debug.WriteLine(Encoding.Default.GetString(serializeToSoap(request)));

                ProcessShipmentReply reply = service.processShipment(request);

                // Call ShowNotifications(reply)
                NameValueCollection nvcNotification = ShowNotifications(reply, out iResultMessage);
                foreach (string nvKey in nvcNotification.AllKeys)
                {
                    switch (nvKey)
                    {
                    case "Code":
                        shipResponse.NoticeCode = nvcNotification[nvKey].ToString();
                        break;

                    case "Message":
                        shipResponse.NoticeMessage = nvcNotification[nvKey].ToString();
                        break;

                    case "Severity":
                        shipResponse.NoticeSeverity = nvcNotification[nvKey].ToString();
                        break;

                    case "Source":
                        shipResponse.NoticeSource = nvcNotification[nvKey].ToString();
                        break;

                    default:
                        break;
                    }
                }

                // SUCCESS, NOTE, WARNING
                if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING)
                {
                    shipResponse.HighestSeverity = reply.HighestSeverity.ToString();

                    //retVal = ShowNotifications(reply, out iResultCode, out iResultMessage);
                    // Call ShowNotifications(reply)

                    shipResponse = ShowShipmentReply(isCodShipment, reply, clsService, shipResponse, out retValue);

                    //shipResponse.ResultCode = iResultCode;
                    //shipResponse.ResultMessage = iResultMessage;

                    if (retValue.Equals(string.Empty))
                    {
                        shipResponse.isSuccess = true;
                    }
                    else
                    {
                        // Check FedexTrackingNumber (If Smart_Post service type)
                        if (!string.IsNullOrEmpty(shipResponse.FedexTrackingNumber) && !string.IsNullOrEmpty(shipResponse.FedexLabelString))
                        {
                            shipResponse.isSuccess = true;  // if exists Tracking number and Label string.
                        }
                        else
                        {
                            shipResponse.isSuccess = false;
                        }

                        shipResponse.ErrorMessage = "[ShowShipmentReply Error] " + retValue;
                    }
                }
                else // ERROR, FAILURE
                {
                    shipResponse.HighestSeverity = Basic.IsNull(reply.HighestSeverity.ToString(), "Empty");

                    shipResponse.isSuccess    = false;
                    shipResponse.ErrorMessage = "[" + shipResponse.HighestSeverity + "] Notification Code: " + shipResponse.NoticeCode + ",\r\nNotification Message: " + shipResponse.NoticeMessage;

                    //retVal = ShowNotifications(reply, out iResultMessage);

                    //if (retVal == "")
                    //{
                    //    shipResponse.ResultCode = iResultCode;
                    //    shipResponse.ResultMessage = iResultMessage;

                    //    shipResponse.isSuccess = false;
                    //    shipResponse.ErrorMessage = "[" + shipResponse.HighestSeverity + "] ResultCode: " + shipResponse.NoticeCode + ", ResultMsg: " + shipResponse.NoticeMessage;
                    //}
                    //else
                    //{
                    //    shipResponse.isSuccess = false;
                    //    shipResponse.ErrorMessage = retVal;
                    //}
                }

                //shipResponse.NoticeCode = noticeCode;
                //shipResponse.NoticeMessage = noticeMessage;
                //shipResponse.NoticeSeverity = noticeSeverity;
                //shipResponse.NoticeSource = noticeSource;
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
                throw ex;
            }
            catch (System.ServiceModel.CommunicationException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (service != null)
                {
                    service.Dispose();
                }
            }

            return(shipResponse);
        }