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