コード例 #1
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);
        }
コード例 #2
0
        // FedEx_Ground / Smart_Post
        private static NameValueCollection ShowNotifications(GroundCloseDocumentsReply reply, out string resultMessage)
        {
            NameValueCollection nvNotification = new NameValueCollection();

            resultMessage = string.Empty;

            try
            {
                if (reply.Notifications[0] != null)
                {
                    Notification notification = reply.Notifications[0];

                    nvNotification.Add("Code", Basic.IsNull(notification.Code, ""));
                    nvNotification.Add("Message", Basic.IsNull(notification.Message, ""));
                    nvNotification.Add("Severity", Basic.IsNull(notification.Severity, ""));    //ERROR,FAILURE,NOTE,SUCCESS,WARNING
                    nvNotification.Add("Source", Basic.IsNull(notification.Source, ""));
                }
                else
                {
                    resultMessage = "[Error Notifications] reply.Notifications[0] is null.";
                }
            }
            catch (Exception ex)
            {
                resultMessage = "[Error ShowNotifications] " + ex.Message;
            }

            return(nvNotification);
        }
コード例 #3
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);
        }