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)); } }
public async Task <GetSFCancelOrderServiceResponse> getSFCancelOrderServiceResponse(SFCancelOrderServiceRequest sFCancelOrderServiceRequest) { GetSFCancelOrderServiceResponse getSFCancelOrderServiceResponse = new GetSFCancelOrderServiceResponse(); try { string toVerifyText = sFCancelOrderServiceRequest.RequestOrderXMLMessage + sFCancelOrderServiceRequest.Checkword; System.Security.Cryptography.MD5 hs = System.Security.Cryptography.MD5.Create(); byte[] base64Encryption = hs.ComputeHash(System.Text.Encoding.UTF8.GetBytes(toVerifyText)); string base64VeirificatioCode = Convert.ToBase64String(base64Encryption); Dictionary <String, String> map = new Dictionary <string, string>(); map.Add("xml", sFCancelOrderServiceRequest.RequestOrderXMLMessage); map.Add("verifyCode", base64VeirificatioCode); map.Add("checkCode", sFCancelOrderServiceRequest.Checkword); IEnumerable <KeyValuePair <string, string> > keyValuePairs = new List <KeyValuePair <string, string> >(); keyValuePairs = map; string resultContent = string.Empty; HttpClient httpClient = null; if (string.Equals(MapProxy.WebProxyEnable, false.ToString(), StringComparison.OrdinalIgnoreCase)) { httpClient = new HttpClient(); } else { httpClient = new HttpClient(GetHttpClientHandler()); } using (var client = httpClient) { client.BaseAddress = new Uri(sFCancelOrderServiceRequest.BaseURI); var content = new FormUrlEncodedContent(keyValuePairs); var result = await client.PostAsync(sFCancelOrderServiceRequest.RequestURI, content); resultContent = await result.Content.ReadAsStringAsync(); getSFCancelOrderServiceResponse.OrderResponse = resultContent; getSFCancelOrderServiceResponse.Response = true; } } catch (Exception exception) { getSFCancelOrderServiceResponse.exception = exception; await 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 = exception.InnerException.ToString(), LogRequest = JsonConvert.SerializeObject(sFCancelOrderServiceRequest), LogResponse = null } }); } return(getSFCancelOrderServiceResponse); }
public static GetSFCancelOrderServiceResponse SFExpressCancelOrder(SFCancelOrderServiceRequest sFCancelOrderServiceRequest) { GetSFCancelOrderServiceResponse getSFCancelOrderServiceResponse = new SFExpressProxy().getSFCancelOrderServiceResponse(sFCancelOrderServiceRequest).Result; return(getSFCancelOrderServiceResponse); }
public async Task <GetSFCancelOrderServiceResponse> getSFCancelOrderServiceResponse(SFCancelOrderServiceRequest sFCancelOrderServiceRequest) { GetSFCancelOrderServiceResponse getSFCancelOrderServiceResponse = new GetSFCancelOrderServiceResponse(); try { string toVerifyText = sFCancelOrderServiceRequest.RequestOrderXMLMessage + sFCancelOrderServiceRequest.AccessNumber; System.Security.Cryptography.MD5 hs = System.Security.Cryptography.MD5.Create(); byte[] base64Encryption = hs.ComputeHash(System.Text.Encoding.UTF8.GetBytes(toVerifyText)); string base64VeirificatioCode = Convert.ToBase64String(base64Encryption); Dictionary <String, String> map = new Dictionary <string, string>(); map.Add("xml", sFCancelOrderServiceRequest.RequestOrderXMLMessage); map.Add("verifyCode", base64VeirificatioCode); map.Add("checkCode", sFCancelOrderServiceRequest.Checkword); IEnumerable <KeyValuePair <string, string> > keyValuePairs = new List <KeyValuePair <string, string> >(); keyValuePairs = map; string resultContent = string.Empty; HttpClient httpClient = null; if (string.Equals(MapProxy.WebProxyEnable, false.ToString(), StringComparison.OrdinalIgnoreCase)) { httpClient = new HttpClient(); } else { httpClient = new HttpClient(GetHttpClientHandler()); } using (var client = httpClient) { client.BaseAddress = new Uri(sFCancelOrderServiceRequest.BaseURI); var content = new FormUrlEncodedContent(keyValuePairs); var result = await client.PostAsync(sFCancelOrderServiceRequest.RequestURI, content); resultContent = await result.Content.ReadAsStringAsync(); getSFCancelOrderServiceResponse.OrderResponse = resultContent; getSFCancelOrderServiceResponse.Response = true; } } catch (Exception exception) { getSFCancelOrderServiceResponse.exception = exception; } return(getSFCancelOrderServiceResponse); }