Exemple #1
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);
        }
Exemple #2
0
        private static CloseShipmentResponse ShowSmartPostCloseReply(SmartPostCloseReply reply, CloseShipmentResponse shipResponse)
        {
            System.Diagnostics.Debug.WriteLine("SmartPost Close Reply details:");
            System.Diagnostics.Debug.WriteLine("SmartPost Close was processed.");

            return(shipResponse);
        }
Exemple #3
0
        private static CloseShipmentResponse ShowGroundCloseDocumentsReply(GroundCloseDocumentsReply reply, CloseShipmentResponse closeResponse)
        {
            string documentName = string.Empty;

            try
            {
                if (reply.CloseDocuments != null)
                {
                    System.Diagnostics.Debug.WriteLine("GroundCloseDocumentsReply details:");
                    int iterative = 0;

                    foreach (CloseDocument document in reply.CloseDocuments)
                    {
                        documentName = SaveDocument(document, iterative);
                        closeResponse.DocumentName = Basic.IsNull(documentName, "");
                    }
                }
                else
                {
                    closeResponse.ErrorMessage = "[ERROR] Ground CloseDocuments is null.";
                }
            }
            catch (Exception ex)
            {
                closeResponse.ErrorMessage = "[ERROR ShowGroundCloseDocumentsReply] " + ex.Message;
            }
            return(closeResponse);
        }
Exemple #4
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);
        }