示例#1
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);
        }
示例#2
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);
        }