Beispiel #1
0
        /// <summary>
        /// Called when a data object is selected.
        /// </summary>
        private void OnDataObjectSelected()
        {
            if (DataObject == null || DataObject == QueryTemplateText)
            {
                return;
            }

            var type  = ObjectTypes.GetObjectGroupType(DataObject, Model.WitsmlVersion);
            var query = Proxy.BuildEmtpyQuery(type, Model.WitsmlVersion);

            XmlQuery.SetText(WitsmlParser.ToXml(query));
        }
Beispiel #2
0
        /// <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);
            });
        }
Beispiel #3
0
        /// <summary>
        /// Called when a data object is selected.
        /// </summary>
        private void OnDataObjectSelected()
        {
            if (DataObject == null || DataObject == QueryTemplateText)
            {
                return;
            }

            var template = QueryTemplates.GetTemplate(DataObject, "WITSML", Model.WitsmlVersion, Model.ReturnElementType);

            XmlQuery.SetText(template.ToString(SaveOptions.OmitDuplicateNamespaces));

            // Reset drop down list
            Runtime.InvokeAsync(() => DataObject = QueryTemplateText);
        }
Beispiel #4
0
        /// <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;
            }
        }