/// <summary> /// Shows the object properties. /// </summary> /// <param name="result">The WITSML query result.</param> private void ShowObjectProperties(WitsmlResult result) { Action <WitsmlException> errorHandler = ex => { var exception = ex.GetBaseException(); var message = exception == ex ? ex.Message : string.Format("{0}{2}{2}{1}", ex.Message, exception.Message, Environment.NewLine); OutputMessages(string.Empty, string.Empty, 0, GetErrorText((short)ex.ErrorCode, message)); }; //Bind data grid with the last set of results only when partial results are returned or when auto query is checked or cancelled, var bindDataGrid = result.ReturnCode == 1 || (result.ReturnCode == 2 && !Model.RetrievePartialResults) || (AutoQueryProvider != null && AutoQueryProvider.IsCancelled); Task.Run(() => { try { ResultControl.ObjectProperties.SetCurrentObject( result.ObjectType, result.XmlOut, Model.WitsmlVersion, bindDataGrid, Model.KeepGridData, Model.IsRequestObjectSelectionCapability, errorHandler); } catch (WitsmlException ex) { _log.WarnFormat("Error parsing query response: {0}{2}{2}{1}", result.XmlOut, ex, Environment.NewLine); errorHandler(ex); } }); }
private void LogResponse(Functions function, string objectType, string xmlIn, string optionsIn, string xmlOut, short returnCode, string suppMsgOut) { var result = new WitsmlResult( objectType: objectType, xmlIn: xmlIn, optionsIn: optionsIn, capClientIn: null, xmlOut: xmlOut, messageOut: suppMsgOut, returnCode: returnCode); Task.Run(() => { Parent.Parent.ClearQueryResults(); Parent.Parent.ShowSubmitResult(function, result); }); }
/// <summary> /// Logs and displays the results of a WITSML submitted query. /// </summary> /// <param name="functionType">Type of the function.</param> /// <param name="result">The WITSML Store API method result.</param> /// <param name="isPartialQuery">if set to <c>true</c> [is partial query].</param> internal void ShowSubmitResult(Functions functionType, WitsmlResult result, bool isPartialQuery = false) { var xmlOut = result.XmlOut; if (functionType == Functions.GetFromStore) { xmlOut = ProcessQueryResult(result.XmlOut, result.OptionsIn); } else if (functionType == Functions.UpdateInStore || functionType == Functions.DeleteFromStore) { var description = ((ErrorCodes)result.ReturnCode).GetDescription(); result = new WitsmlResult(result.ObjectType, result.XmlIn, result.OptionsIn, result.CapClientIn, xmlOut, description, result.ReturnCode); } _log.DebugFormat("Query returned with{3}{3}xmlOut: {0}{3}{3}suppMsgOut: {1}{3}{3}optionsIn: {2}{3}{3}", GetLogStringText(xmlOut), GetLogStringText(result.MessageOut), GetLogStringText(result.OptionsIn), Environment.NewLine); // Output query results to the Results tab OutputResults(xmlOut, result.MessageOut, result.ReturnCode, isPartialQuery); // Append these results to the Messages tab OutputMessages(xmlOut, result.MessageOut, result.ReturnCode); // Show data object on the Properties tab if (functionType == Functions.GetFromStore && result.ReturnCode > 0) { ShowObjectProperties(result); SubmitAutoQuery(result); } else // If there are any errors { if (AutoQueryProvider != null) { AutoQueryProvider = null; } } }
/// <summary> /// Submits the automatic query. /// </summary> /// <param name="result">The result.</param> private void SubmitAutoQuery(WitsmlResult result) { var model = GetModel(); // Do not execute an auto-query: // ... if the Partial Success return code is missing, or // ... if the user has not selected to retrieve parital results, or // ... if the current auto-query operation has been cancelled by the user if (result.ReturnCode <= 1 || !model.RetrievePartialResults || (AutoQueryProvider != null && AutoQueryProvider.IsCancelled)) { AutoQueryProvider = null; return; } if (AutoQueryProvider == null) { AutoQueryProvider = new GrowingObjectQueryProvider <WitsmlSettings>(model, result.ObjectType, XmlQuery.Text); } //... update the query using the original XmlOut XmlQuery.SetText(AutoQueryProvider.UpdateDataQuery(result.XmlOut)); // Submit the query if one was returned. if (!string.IsNullOrEmpty(XmlQuery.Text)) { // Change return elements to requested AutoQueryProvider.Context.RetrievePartialResults = true; //... and Submit a Query for the next set of data. SubmitQuery(Functions.GetFromStore, result.OptionsIn, true); } else { AutoQueryProvider = null; } }