public async Task <QueryResult> AddToStoreAsync <T>(T query, OptionsIn optionsIn = OptionsIn.Requested) where T : IWitsmlQueryType { try { var request = new WMLS_AddToStoreRequest { WMLtypeIn = query.TypeName, OptionsIn = optionsIn.GetName(), XMLin = XmlHelper.Serialize(query) }; var response = await client.WMLS_AddToStoreAsync(request); LogQueriesSentAndReceived(request.XMLin, response.IsSuccessful()); if (response.IsSuccessful()) { return(new QueryResult(true)); } var errorResponse = await client.WMLS_GetBaseMsgAsync(response.Result); var message = $"Error while adding to store: {response.Result} - {errorResponse.Result}. {response.SuppMsgOut}"; return(new QueryResult(false, message)); } catch (MessageSecurityException e) { const string message = "Request forbidden. Verify credentials"; Log.Error(e, message); return(new QueryResult(false, message)); } }
/// <summary> /// Converts a specific request object into a common structure. /// </summary> /// <param name="request">The AddToStore request object.</param> /// <returns>The request context instance.</returns> public static RequestContext ToContext(this WMLS_AddToStoreRequest request) { return(new RequestContext( function: Functions.AddToStore, objectType: request.WMLtypeIn, xml: request.XMLin, options: request.OptionsIn, capabilities: request.CapabilitiesIn)); }
/// <summary> /// Adds a WITSML data-object to the server. /// </summary> /// <param name="request">The request object encapsulating the method input parameters.</param> /// <returns> /// A positive value indicating success along with one or more WITSML data-objects from the server, or a negative value indicating an error. /// If successful the Uid of the inserted object is returned in the Response's SuppMsgOut. /// </returns> public WMLS_AddToStoreResponse WMLS_AddToStore(WMLS_AddToStoreRequest request) { return(_store.WMLS_AddToStore(request)); }