Esempio n. 1
0
        public async Task <ActionResult> CancelOrderShipment([FromBody] SFOrderXMLRequest sFOrderXMLRequest)
        {
            //sFOrderXMLRequest.XMLMessage = "<Request service=\"OrderConfirmService\" lang=\"zh-CN\"><Head>LJ_T6NVV</Head><Body><OrderConfirm orderid=\"19066630505714563\" dealtype=\"2\"></OrderConfirm></Body></Request>";

            SFCancelOrderServiceRequest sFCancelOrderServiceRequest = new SFCancelOrderServiceRequest()
            {
                AccessNumber           = configuration["SFExpress:Access Number"],
                BaseURI                = configuration["SFExpress:Base URI"],
                Checkword              = configuration["SFExpress:Checkword"],
                RequestURI             = configuration["SFExpress:Cancel Order URI"],
                RequestOrderXMLMessage = sFOrderXMLRequest.XMLMessage,
            };

            GetSFCancelOrderServiceResponse getSFCancelOrderServiceResponse = QuincusService.SFExpressCancelOrder(sFCancelOrderServiceRequest);

            if (getSFCancelOrderServiceResponse.Response)
            {
                return(Ok(getSFCancelOrderServiceResponse.OrderResponse));
            }
            else
            {
                AuditEventEntry.WriteEntry(new Exception(getSFCancelOrderServiceResponse.exception.ToString()));
                return(Ok(getSFCancelOrderServiceResponse.exception));
            }
        }
        public async Task <ActionResult> CancelOrderShipment([FromBody] SFOrderXMLRequest sFOrderXMLRequest)
        {
            //sFOrderXMLRequest.XMLMessage = "<Request service=\"OrderConfirmService\" lang=\"zh-CN\"><Head>LJ_T6NVV</Head><Body><OrderConfirm orderid=\"19066630505714563\" dealtype=\"2\"></OrderConfirm></Body></Request>";

            SFCancelOrderServiceRequest sFCancelOrderServiceRequest = new SFCancelOrderServiceRequest()
            {
                AccessNumber           = configuration["SFExpress:Access Number"],
                BaseURI                = configuration["SFExpress:Base URI"],
                Checkword              = configuration["SFExpress:Checkword"],
                RequestURI             = configuration["SFExpress:Cancel Order URI"],
                RequestOrderXMLMessage = sFOrderXMLRequest.XMLMessage,
            };

            GetSFCancelOrderServiceResponse getSFCancelOrderServiceResponse = QuincusService.SFExpressCancelOrder(sFCancelOrderServiceRequest);

            if (getSFCancelOrderServiceResponse.Response)
            {
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                Task.Run(() => iCustomLog.AddLogEntry(new UPS.DataObjects.LogData.LogDataModel()
                {
                    apiTypes       = UPS.DataObjects.LogData.APITypes.SFExpress,
                    apiType        = Enum.GetName(typeof(UPS.DataObjects.LogData.APITypes), 1),
                    dateTime       = System.DateTime.Now,
                    LogInformation = new UPS.DataObjects.LogData.LogInformation()
                    {
                        LogException = null,
                        LogRequest   = JsonConvert.SerializeObject(sFOrderXMLRequest),
                        LogResponse  = JsonConvert.SerializeObject(getSFCancelOrderServiceResponse)
                    }
                }));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

                return(Ok(getSFCancelOrderServiceResponse.OrderResponse));
            }
            else
            {
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                Task.Run(() => iCustomLog.AddLogEntry(new UPS.DataObjects.LogData.LogDataModel()
                {
                    apiTypes       = UPS.DataObjects.LogData.APITypes.SFExpress,
                    apiType        = Enum.GetName(typeof(UPS.DataObjects.LogData.APITypes), 1),
                    dateTime       = System.DateTime.Now,
                    LogInformation = new UPS.DataObjects.LogData.LogInformation()
                    {
                        LogException = getSFCancelOrderServiceResponse.exception.InnerException.ToString(),
                        LogRequest   = JsonConvert.SerializeObject(sFOrderXMLRequest),
                        LogResponse  = null
                    }
                }));
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

                //AuditEventEntry.WriteEntry(new Exception(getSFCancelOrderServiceResponse.exception.ToString()));
                return(Ok(getSFCancelOrderServiceResponse.exception));
            }
        }