public void Risk141WitsmlStore_GetFromStore_Can_Transform_Risk() { AddParents(); DevKit.AddAndAssert <RiskList, Risk>(Risk); // Re-initialize all capServer providers DevKit.Store.CapServerProviders = null; DevKit.Container.BuildUp(DevKit.Store); string typeIn, queryIn; var query = DevKit.List(DevKit.CreateQuery(Risk)); DevKit.SetupParameters <RiskList, Risk>(query, ObjectTypes.Risk, out typeIn, out queryIn); var options = OptionsIn.Join(OptionsIn.ReturnElements.All, OptionsIn.DataVersion.Version131); var request = new WMLS_GetFromStoreRequest(typeIn, queryIn, options, null); var response = DevKit.Store.WMLS_GetFromStore(request); Assert.IsFalse(string.IsNullOrWhiteSpace(response.XMLout)); Assert.AreEqual((short)ErrorCodes.Success, response.Result); var result = WitsmlParser.Parse(response.XMLout); var version = ObjectTypes.GetVersion(result.Root); Assert.AreEqual(OptionsIn.DataVersion.Version131.Value, version); }
/// <summary> /// Gets the objects of the specified query. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="objectType">Type of the object.</param> /// <param name="queryIn">The query in.</param> /// <param name="logXmlRequest">if set to <c>true</c> log XML request.</param> /// <param name="logXmlResponse">if set to <c>true</c> log XML response.</param> /// <param name="returnNullIfError">if set to <c>true</c> and if there was an error querying return null, else empty.</param> /// <param name="optionsIn">The options in.</param> /// <returns>The data objects.</returns> public IEnumerable <T> GetObjects <T>(string objectType, string queryIn, bool logXmlRequest = true, bool logXmlResponse = true, bool returnNullIfError = false, params OptionsIn[] optionsIn) where T : IDataObject { var result = ExecuteGetFromStoreQuery(objectType, queryIn, OptionsIn.Join(optionsIn), logXmlRequest, logXmlResponse); var dataObjects = (IEnumerable <T>)result?.Items ?? (returnNullIfError ? null : Enumerable.Empty <T>()); return(dataObjects?.OrderBy(x => x.Name)); }
/// <summary> /// Submits an asynchronous query to the WITSML server for a given function type. /// The results of a query are displayed in the Results and Messages tabs. /// </summary> /// <param name="functionType">Type of the function.</param> /// <param name="optionsIn">The options in.</param> /// <param name="isPartialQuery">if set to <c>true</c> [is partial query].</param> public void SubmitQuery(Functions functionType, string optionsIn = null, bool isPartialQuery = false) { // Trim query text before submitting request string xmlIn = XmlQuery.Text.Trim(); // Format the text of XmlQuery XmlQuery.SetText(xmlIn); _log.DebugFormat("Query submitted for function '{0}'", functionType); // Options In if (string.IsNullOrEmpty(optionsIn)) { optionsIn = GetOptionsIn(functionType, isPartialQuery); } else if (isPartialQuery) { var optionsInUpdated = new List <OptionsIn> { OptionsIn.ReturnElements.DataOnly }; var optionsInFromPreviousQuery = OptionsIn.Parse(optionsIn); foreach (var key in optionsInFromPreviousQuery.Keys) { if (key != OptionsIn.ReturnElements.All.Key && key != OptionsIn.ReturnElements.DataOnly.Key) { optionsInUpdated.Add(new OptionsIn(key, optionsInFromPreviousQuery[key])); } } optionsIn = OptionsIn.Join(optionsInUpdated.ToArray()); } // Output Request OutputRequestMessages(functionType, functionType == Functions.GetCap ? string.Empty : xmlIn, optionsIn); Runtime.ShowBusy(); Task.Run(async() => { // Call internal SubmitQuery method with references to all inputs and outputs. var result = await SubmitQuery(functionType, xmlIn, optionsIn); // Clear any previous query results if this is not a partial query if (!isPartialQuery) { ClearQueryResults(); } ShowSubmitResult(functionType, result, isPartialQuery); Runtime.ShowBusy(false); }); }
private void Trajectory141DataAdapter_GetFromStore_Results_Are_Limited_To_MaxReturnNodes_OptionsIn(int numberOfStations) { AddParents(); var maxDataNodes = 5; Trajectory.TrajectoryStation = DevKit.TrajectoryStations(maxDataNodes + numberOfStations, 0); DevKit.AddAndAssert(Trajectory); short errorCode; var result = DevKit.QueryWithErrorCode<TrajectoryList, Trajectory>( new Trajectory() { Uid = Trajectory.Uid, UidWell = Trajectory.UidWell, UidWellbore = Trajectory.UidWellbore }, out errorCode, ObjectTypes.Trajectory, null, OptionsIn.Join(OptionsIn.ReturnElements.All, OptionsIn.MaxReturnNodes.Eq(maxDataNodes))); Assert.AreEqual((short)ErrorCodes.ParialSuccess, errorCode, "Returning partial data."); Assert.IsNotNull(result); Assert.AreEqual(1, result.Count); var trajectory = result[0]; Assert.IsNotNull(trajectory); Assert.AreEqual(maxDataNodes, trajectory.TrajectoryStation.Count); }