public void AssetTransferSearch( AssetTransferSearch assetTransferSearch) { assetTransferSearch.ResponseMessage = new ResponseMessage(HttpStatusCode.InternalServerError); string message; try { var continueProcessing = false; sapConnect.MakeNonSsoConnection(); if (sapConnect.r3Connection == null || sapConnect.r3Connection.IsOpen == false) { message = "Non SSo Connection returned no connection"; Log.Error(message); assetTransferSearch.ResponseMessage = new ResponseMessage(HttpStatusCode.InternalServerError, message); } else { continueProcessing = true; Log.Information("Connection established successfully."); } if (continueProcessing) { new bapiCalls().SapAssetTransferSearch(sapConnect.r3Connection, assetTransferSearch); } } catch (Exception exception) { Log.Error(exception, "Error Getting Non SSO Ticket: exception"); } }
// POST api/searchasset public HttpResponseMessage Post( [FromBody] AssetTransferSearch assetTransferSearch) { var result = new HttpResponseMessage(HttpStatusCode.InternalServerError); try { if (assetTransferSearch == null) { assetTransferSearch = new AssetTransferSearch("", "", "", null, "", null, new ResponseMessage( HttpStatusCode.BadRequest, "Fixed asset transfer search web service call missing BODY parameters"), null); } else { Log.Information( "Call received - parameters: {params}", JsonConvert.SerializeObject(assetTransferSearch)); SapAccess sapAccess = null; try { sapAccess = new SapAccess(); this.Request.RegisterForDispose(sapAccess); sapAccess.AssetTransferSearch( assetTransferSearch); } finally { sapAccess?.Dispose(); } } } catch (Exception exception) { Log.Error(exception, "Error inside searchfixedassettransfer"); assetTransferSearch.ResponseMessage = new ResponseMessage(HttpStatusCode.InternalServerError, exception.Message); } finally { } result.Content = new StringContent( JsonConvert.SerializeObject(assetTransferSearch), System.Text.Encoding.UTF8, "application/json"); result.StatusCode = assetTransferSearch.ResponseMessage.responseCode; Log.Information( "Response - parameters: {params}", JsonConvert.SerializeObject(assetTransferSearch)); return(result); }