コード例 #1
0
        /// <summary>
        /// Processes the GetFromStore query result.
        /// </summary>
        /// <param name="xmlOut">The XML out.</param>
        /// <param name="optionsIn">The options in.</param>
        /// <returns>An XML string.</returns>
        private string ProcessQueryResult(string xmlOut, string optionsIn)
        {
            if (string.IsNullOrWhiteSpace(xmlOut))
            {
                return(xmlOut);
            }
            if (string.IsNullOrWhiteSpace(Model.OutputPath))
            {
                return(xmlOut);
            }

            var options        = OptionsIn.Parse(optionsIn);
            var returnElements = OptionsIn.GetValue(options, OptionsIn.ReturnElements.Requested);
            var outputPath     = new DirectoryInfo(Path.Combine(Model.OutputPath, returnElements)).FullName;

            var isAutoSave     = xmlOut.Length > Model.TruncateSize;
            var xmlOutOriginal = xmlOut;

            if (isAutoSave)
            {
                xmlOut = $"<!-- WARNING: Response larger than {Model.TruncateSize} characters -->";
            }
            else if (QueryResults.IsPrettyPrintAllowed && QueryResults.IsPrettyPrintEnabled)
            {
                var document = WitsmlParser.Parse(xmlOut);
                xmlOut = document.ToString();
            }

            if (Model.IsSaveQueryResponse || isAutoSave)
            {
                Task.Run(async() =>
                {
                    Runtime.ShowBusy();

                    try
                    {
                        var document = WitsmlParser.Parse(xmlOutOriginal);

                        outputPath = await SaveQueryResult(outputPath, document, Model.IsSplitResults);

                        if (isAutoSave)
                        {
                            var message = $"{Environment.NewLine}<!-- Results automatically saved to {outputPath} -->";
                            QueryResults.Append(message);
                        }
                    }
                    catch (Exception ex)
                    {
                        _log.Error("Error saving query results to file", ex);
                    }
                    finally
                    {
                        Runtime.ShowBusy(false);
                    }
                });
            }

            return(xmlOut);
        }
コード例 #2
0
        /// <summary>
        /// Requests the CascadedDelete OptionIn.
        /// </summary>
        /// <returns>The CascadedDelete value</returns>
        public bool CascadedDelete()
        {
            string value = OptionsIn.GetValue(Options, OptionsIn.CascadedDelete.False);
            bool   result;

            if (!bool.TryParse(value, out result))
            {
                result = false;
            }

            return(result);
        }
コード例 #3
0
        /// <summary>
        /// Requests the private group only.
        /// </summary>
        /// <returns></returns>
        public bool RequestPrivateGroupOnly()
        {
            string value = OptionsIn.GetValue(Options, OptionsIn.RequestPrivateGroupOnly.False);
            bool   result;

            if (!bool.TryParse(value, out result))
            {
                result = false;
            }

            return(result);
        }
コード例 #4
0
ファイル: WitsmlStore.cs プロジェクト: wdstest/witsml
        /// <summary>
        /// Returns the capServer object that describes the capabilities of the server for one Data Schema Version.
        /// </summary>
        /// <param name="request">The request object encapsulating the method input parameters.</param>
        /// <returns>A positive value indicates a success; a negative value indicates an error.</returns>
        public WMLS_GetCapResponse WMLS_GetCap(WMLS_GetCapRequest request)
        {
            try
            {
                WitsmlOperationContext.Current.Request = request.ToContext();
                EnsureCapServerProviders();

                _log.Debug(WebOperationContext.Current.ToLogMessage());
                _log.Debug(request.ToLogMessage());

                UserAuthorizationProvider.CheckSoapAccess();

                var options = OptionsIn.Parse(request.OptionsIn);
                var version = OptionsIn.GetValue(options, new OptionsIn.DataVersion(_defaultDataSchemaVersion));

                // return error if WITSML 1.3.1 not supported AND dataVersion not specified (required in WITSML 1.4.1)
                if (!_capServerMap.ContainsKey(OptionsIn.DataVersion.Version131.Value) && !options.ContainsKey(OptionsIn.DataVersion.Keyword))
                {
                    throw new WitsmlException(ErrorCodes.MissingDataVersion);
                }

                if (_capServerMap.ContainsKey(version))
                {
                    var response = new WMLS_GetCapResponse((short)ErrorCodes.Success, _capServerMap[version].ToXml(), string.Empty);
                    _log.Debug(response.ToLogMessage());
                    return(response);
                }

                throw new WitsmlException(ErrorCodes.DataVersionNotSupported, "Data schema version not supported: " + version);
            }
            catch (WitsmlException ex)
            {
                var response = new WMLS_GetCapResponse((short)ex.ErrorCode, string.Empty, ex.Message);
                _log.Error(response.ToLogMessage(_log.IsWarnEnabled));
                return(response);
            }
        }
コード例 #5
0
 /// <summary>
 /// Requests the object selection capability.
 /// </summary>
 /// <returns>The capability value.</returns>
 public string RequestObjectSelectionCapability()
 {
     return(OptionsIn.GetValue(Options, OptionsIn.RequestObjectSelectionCapability.None));
 }
コード例 #6
0
 /// <summary>
 /// Get the interval range inclusion.
 /// </summary>
 /// <returns>The IntervalRangeInclusion.</returns>
 public string IntervalRangeInclusion()
 {
     return(OptionsIn.GetValue(Options, OptionsIn.IntervalRangeInclusion.MinimumPoint));
 }
コード例 #7
0
 /// <summary>
 /// Get the ReturnElements.
 /// </summary>
 /// <returns>The ReturnElements.</returns>
 public string ReturnElements()
 {
     return(OptionsIn.GetValue(Options, OptionsIn.ReturnElements.Requested));
 }