private async Task <bool> CanConnectUsingBasic(Connection connection) { try { var proxy = new WITSMLWebServiceConnection(connection.Uri, WMLSVersion.WITSML141); if (!string.IsNullOrWhiteSpace(connection.Username)) { proxy.Username = connection.Username; proxy.SetSecurePassword(connection.SecurePassword); } connection.SetServerCertificateValidation(); proxy.GetVersion(); _log.Debug("Witsml connection test passed"); return(await Task.FromResult(true)); } catch (Exception ex) { _log.Error("Witsml connection test failed: {0}", ex); return(await Task.FromResult(false)); } }
private void Connect(string url, double timeoutInMinutes, WMLSVersion version) { Connection = new WITSMLWebServiceConnection(url, version) { UseDefaultNetworkCredentials = true, Timeout = (int)(60000 * timeoutInMinutes) }; }
/// <summary> /// WitsmlQuery /// </summary> /// <param name="context"></param> public WitsmlQuery(WitsmlContext context) { Context = context; Logger = LogManager.GetLogger(GetType()); Query = WITSMLWebServiceConnection.BuildEmptyQuery <TList>(); Queryable = LinqExtender.Queryable.Select(this, x => x); Options = new Dictionary <string, string>(); // update Version property modifed by BuildEmptyQuery Query.SetVersion(context.DataSchemaVersion); }
public void SettingsViewModel_GetVersions_Can_Get_Supported_Versions() { WITSMLWebServiceConnection proxy = new WITSMLWebServiceConnection(_validWitsmlUri, WMLSVersion.WITSML141); Connection connection = new Connection { Uri = _validWitsmlUri }; var versions = _settingsViewModel.GetVersions(proxy, connection); Assert.IsTrue(!string.IsNullOrEmpty(versions)); }
/// <summary> /// Builds an emtpy WITSML query for the specified data object type and data schema version. /// </summary> /// <param name="connection">The WITSML connection.</param> /// <param name="type">The data object type.</param> /// <param name="version">The data schema version.</param> /// <returns>An <see cref="IEnergisticsCollection"/> instance.</returns> public static IEnergisticsCollection BuildEmptyQuery(this WITSMLWebServiceConnection connection, Type type, string version) { var method = connection.GetType() .GetMethod("BuildEmptyQuery", BindingFlags.Static | BindingFlags.Public) .MakeGenericMethod(type); var query = method.Invoke(null, null) as IEnergisticsCollection; query.SetVersion(version); return(query); }
/// <summary> /// Creates a WITSMLWebServiceConnection for the current connection uri and WITSML version. /// </summary> /// <param name="connection">The connection.</param> /// <param name="version">The WITSML version.</param> /// <returns>A <see cref="WITSMLWebServiceConnection"/> instance.</returns> public static WITSMLWebServiceConnection CreateProxy(this Connection connection, WMLSVersion version) { //_log.DebugFormat("A new Proxy is being created with URI: {0}; WitsmlVersion: {1};", connection.Uri, version); var proxy = new WITSMLWebServiceConnection(connection.Uri, version); proxy.Timeout *= 5; if (!string.IsNullOrWhiteSpace(connection.Username)) { proxy.Username = connection.Username; proxy.SetSecurePassword(connection.SecurePassword); } return(proxy); }
public void Extensions_BuildEmtpyQuery_Returns_An_Empty_Query() { var connection = new WITSMLWebServiceConnection(string.Empty, WMLSVersion.WITSML131); var collection131 = new Energistics.DataAccess.WITSML131.DtsMeasurementList(); var query = connection.BuildEmtpyQuery(collection131.GetType(), "1.3.1.1"); Assert.IsNotNull(query); connection = new WITSMLWebServiceConnection(string.Empty, WMLSVersion.WITSML141); var collection141 = new Energistics.DataAccess.WITSML141.LogList(); query = connection.BuildEmtpyQuery(collection141.GetType(), "1.4.1.1"); Assert.IsNotNull(query); }
protected DevKitAspect(string url, WMLSVersion version, TestContext context) { ConnectionUrl = url; Container = ContainerFactory.Create(); Container.BuildUp(this); ContextProviders.ForEach(x => x.Configure(this, context)); Store = new WitsmlStore(); Store.Container = Container; Container.BuildUp(Store); Proxy = new WITSMLWebServiceConnection(ConnectionUrl, version); Proxy.Timeout *= 5; Template = new DataObjectTemplate(); }
/// <summary> /// Gets the supported versions from the server. /// </summary> /// <param name="proxy">The proxy.</param> /// <param name="connection">The connection.</param> /// <param name="throwOnError">if set to <c>true</c> throw on error.</param> /// <returns>The supported versions.</returns> internal string GetVersions(WITSMLWebServiceConnection proxy, Connection connection, bool throwOnError = true) { // Update proxy connection settings connection.UpdateProxy(proxy); var parent = Parent?.Parent; var supportedVersions = string.Empty; // Output Request for GetVersion parent?.OutputRequestMessages(Functions.GetVersion, null, parent?.GetOptionsIn(Functions.GetVersion)); try { supportedVersions = proxy.GetVersion(); _log.DebugFormat("Supported versions '{0}' found on WITSML server with uri '{1}'", supportedVersions, connection.Uri); } catch (Exception ex) { _log.WarnFormat("Exception getting versions on WITSML server with uri '{0}' : '{1}'", connection.Uri, ex.Message); if (throwOnError) { throw; } parent?.OutputError("Error connecting to server.", ex); return(supportedVersions); } if (parent == null) { return(supportedVersions); } parent.ClearQueryResults(); parent.OutputResults(null, supportedVersions, 0); parent.OutputMessages(null, supportedVersions, 0); return(supportedVersions); }
public TList Query <TList>() where TList : IEnergisticsCollection { return(WITSMLWebServiceConnection .BuildEmptyQuery <TList>() .SetVersion(DataSchemaVersion)); }
/// <summary> /// Updates a WITSMLWebServiceConnection for the current connection settings. /// </summary> /// <param name="connection">The connection.</param> /// <param name="proxy">The WITSML web service proxy.</param> /// <returns>The <see cref="WITSMLWebServiceConnection"/> instance.</returns> public static WITSMLWebServiceConnection UpdateProxy(this Connection connection, WITSMLWebServiceConnection proxy) { proxy.Proxy = connection.CreateWebProxy(); proxy.Url = connection.Uri; proxy.Timeout *= 5; connection.SetServerCertificateValidation(); if (!string.IsNullOrWhiteSpace(connection.Username)) { if (connection.PreAuthenticate) { proxy.Headers = connection.GetAuthorizationHeader(); proxy.IsPreAuthenticationEnabled = connection.PreAuthenticate; } else { proxy.Username = connection.Username; proxy.SetSecurePassword(connection.SecurePassword); } } return(proxy); }
/// <summary> /// Initializes a new instance of the <see cref="WitsmlQueryContext"/> class. /// </summary> /// <param name="connection">The witsml web service connection.</param> /// <param name="version">The version.</param> public WitsmlQueryContext(WITSMLWebServiceConnection connection, WMLSVersion version) : base(connection, version) { }
/// <summary> /// Initializes a new instance of the <see cref="WitsmlContext"/> class. /// </summary> /// <param name="connection">The connection.</param> /// <param name="version">The version.</param> protected WitsmlContext(WITSMLWebServiceConnection connection, WMLSVersion version) : this() { Connection = connection; SetDataSchemaVersion(version); }
/// <summary> /// Updates a WITSMLWebServiceConnection for the current connection settings. /// </summary> /// <param name="connection">The connection.</param> /// <param name="proxy">The WITSML web service proxy.</param> /// <returns>The <see cref="WITSMLWebServiceConnection"/> instance.</returns> public static WITSMLWebServiceConnection UpdateProxy(this Connection connection, WITSMLWebServiceConnection proxy) { proxy.Proxy = connection.CreateWebProxy(); proxy.Url = connection.Uri; proxy.Timeout *= 5; proxy.AcceptCompressedResponses = connection.SoapAcceptCompressedResponses; proxy.CompressRequests = connection.SoapRequestCompressionMethod == CompressionMethods.Gzip; connection.SetServerCertificateValidation(); if (!string.IsNullOrWhiteSpace(connection.Username)) { if (connection.PreAuthenticate) { proxy.Headers = connection.GetAuthorizationHeader(); proxy.IsPreAuthenticationEnabled = connection.PreAuthenticate; } else { proxy.Username = connection.Username; proxy.SetSecurePassword(connection.SecurePassword); } } return(proxy); }