Skip to content

Commit

Permalink
Updated usages
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsve committed Aug 7, 2023
1 parent 1f5e037 commit ceb30c9
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 59 deletions.
8 changes: 4 additions & 4 deletions Src/WitsmlExplorer.Api/Services/CredentialsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ public async Task<bool> VerifyAndCacheCredentials(IEssentialHeaders eh, bool kee
cacheId = httpContext.CreateWitsmlExplorerCookie();
}

var witsmlClient = new WitsmlClient(new WitsmlClientOptions
var witsmlClient = new WitsmlClient(options =>
{
Hostname = creds.Host.ToString(),
Credentials = new WitsmlCredentials(creds.UserId, creds.Password),
ClientCapabilities = _clientCapabilities
options.Hostname = creds.Host.ToString();
options.Credentials = new WitsmlCredentials(creds.UserId, creds.Password);
options.ClientCapabilities = _clientCapabilities;
});
await witsmlClient.TestConnectionAsync();

Expand Down
28 changes: 14 additions & 14 deletions Src/WitsmlExplorer.Api/Services/WitsmlClientProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ internal WitsmlClientProvider(IConfiguration configuration)
{
(string serverUrl, string username, string password) = GetCredentialsFromConfiguration(configuration);
_witsmlClient = new WitsmlClient(
new WitsmlClientOptions
options =>
{
Hostname = serverUrl,
Credentials = new WitsmlCredentials(username, password),
LogQueries = true
options.Hostname = serverUrl;
options.Credentials = new WitsmlCredentials(username, password);
options.LogQueries = true;
});
}

Expand All @@ -73,12 +73,12 @@ public IWitsmlClient GetClient()
{
_targetCreds = _credentialsService.GetCredentials(_httpHeaders, _httpHeaders.TargetServer, _httpHeaders.TargetUsername);
_witsmlClient = (_targetCreds != null && !_targetCreds.IsCredsNullOrEmpty())
? new WitsmlClient(new WitsmlClientOptions
? new WitsmlClient(options =>
{
Hostname = _targetCreds.Host.ToString(),
Credentials = new WitsmlCredentials(_targetCreds.UserId, _targetCreds.Password),
ClientCapabilities = _clientCapabilities,
LogQueries = _logQueries
options.Hostname = _targetCreds.Host.ToString();
options.Credentials = new WitsmlCredentials(_targetCreds.UserId, _targetCreds.Password);
options.ClientCapabilities = _clientCapabilities;
options.LogQueries = _logQueries;
})
: null;
}
Expand All @@ -91,12 +91,12 @@ public IWitsmlClient GetSourceClient()
{
_sourceCreds = _credentialsService.GetCredentials(_httpHeaders, _httpHeaders.SourceServer, _httpHeaders.SourceUsername);
_witsmlSourceClient = (_sourceCreds != null && !_sourceCreds.IsCredsNullOrEmpty())
? new WitsmlClient(new WitsmlClientOptions
? new WitsmlClient(options =>
{
Hostname = _sourceCreds.Host.ToString(),
Credentials = new WitsmlCredentials(_sourceCreds.UserId, _sourceCreds.Password),
ClientCapabilities = _clientCapabilities,
LogQueries = _logQueries
options.Hostname = _sourceCreds.Host.ToString();
options.Credentials = new WitsmlCredentials(_sourceCreds.UserId, _sourceCreds.Password);
options.ClientCapabilities = _clientCapabilities;
options.LogQueries = _logQueries;
})
: null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public WitsmlClientProvider()
try
{
(string serverUrl, string username, string password) = GetCredentialsFromConfiguration();
_witsmlClient = new Witsml.WitsmlClient(new WitsmlClientOptions
_witsmlClient = new Witsml.WitsmlClient(options =>
{
Hostname = serverUrl,
Credentials = new WitsmlCredentials(username, password),
ClientCapabilities = _clientCapabilities
options.Hostname = serverUrl;
options.Credentials = new WitsmlCredentials(username, password);
options.ClientCapabilities = _clientCapabilities;
});
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public LogObjectTests(ITestOutputHelper output)
{
_output = output;
WitsmlConfiguration config = ConfigurationReader.GetWitsmlConfiguration();
_client = new WitsmlClient(new WitsmlClientOptions
_client = new WitsmlClient(options =>
{
Hostname = config.Hostname,
Credentials = new WitsmlCredentials(config.Username, config.Password)
options.Hostname = config.Hostname;
options.Credentials = new WitsmlCredentials(config.Username, config.Password);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ public TrajectoryTests(ITestOutputHelper output)
{
_output = output;
WitsmlConfiguration config = ConfigurationReader.GetWitsmlConfiguration();
_client = new WitsmlClient(new WitsmlClientOptions
_client = new WitsmlClient(options =>
{
Hostname = config.Hostname,
Credentials = new WitsmlCredentials(config.Username, config.Password)
options.Hostname = config.Hostname;
options.Credentials = new WitsmlCredentials(config.Username, config.Password);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public partial class BhaRunTests
public BhaRunTests()
{
WitsmlConfiguration config = ConfigurationReader.GetWitsmlConfiguration();
_client = new WitsmlClient(new WitsmlClientOptions
_client = new WitsmlClient(options =>
{
Hostname = config.Hostname,
Credentials = new WitsmlCredentials(config.Username, config.Password)
options.Hostname = config.Hostname;
options.Credentials = new WitsmlCredentials(config.Username, config.Password);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public partial class FluidsReportTests
public FluidsReportTests()
{
WitsmlConfiguration config = ConfigurationReader.GetWitsmlConfiguration();
_client = new WitsmlClient(new WitsmlClientOptions
_client = new WitsmlClient(options =>
{
Hostname = config.Hostname,
Credentials = new WitsmlCredentials(config.Username, config.Password)
options.Hostname = config.Hostname;
options.Credentials = new WitsmlCredentials(config.Username, config.Password);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public class FormationMarkersTests
public FormationMarkersTests()
{
WitsmlConfiguration config = ConfigurationReader.GetWitsmlConfiguration();
_client = new WitsmlClient(new WitsmlClientOptions
_client = new WitsmlClient(options =>
{
Hostname = config.Hostname,
Credentials = new WitsmlCredentials(config.Username, config.Password)
options.Hostname = config.Hostname;
options.Credentials = new WitsmlCredentials(config.Username, config.Password);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ public class LogObjectTests
public LogObjectTests()
{
var config = ConfigurationReader.GetWitsmlConfiguration();
_client = new WitsmlClient(new WitsmlClientOptions
_client = new WitsmlClient(options =>
{
Hostname = config.Hostname,
Credentials = new WitsmlCredentials(config.Username, config.Password)
options.Hostname = config.Hostname;
options.Credentials = new WitsmlCredentials(config.Username, config.Password);
});
}

Expand Down Expand Up @@ -101,7 +101,7 @@ public async Task GetDepthDataObjectFromStoreAsync_ParseInvariant()
};

var result = await _client.GetFromStoreAsync(query, new OptionsIn(ReturnElements.All));
var witsmlLog = result.Logs.FirstOrDefault();
var witsmlLog = result.Logs.First();
var data = witsmlLog.LogData.Data;
data.First().GetRow(); // Test fails if parsing error on GetRow() due to incompatible culture setting.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public class MessageTests
public MessageTests()
{
WitsmlConfiguration config = ConfigurationReader.GetWitsmlConfiguration();
_client = new WitsmlClient(new WitsmlClientOptions
_client = new WitsmlClient(options =>
{
Hostname = config.Hostname,
Credentials = new WitsmlCredentials(config.Username, config.Password)
options.Hostname = config.Hostname;
options.Credentials = new WitsmlCredentials(config.Username, config.Password);
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Threading.Tasks;

using Witsml;
using Witsml.Data;
using Witsml.Data.MudLog;
using Witsml.ServiceReference;
using Witsml.Xml;
Expand All @@ -19,10 +18,10 @@ public partial class MudLogTests
public MudLogTests()
{
WitsmlConfiguration config = ConfigurationReader.GetWitsmlConfiguration();
_client = new WitsmlClient(new WitsmlClientOptions
_client = new WitsmlClient(options =>
{
Hostname = config.Hostname,
Credentials = new WitsmlCredentials(config.Username, config.Password)
options.Hostname = config.Hostname;
options.Credentials = new WitsmlCredentials(config.Username, config.Password);
});
}

Expand All @@ -34,7 +33,7 @@ public async Task GetMudLogSerializesCorrectly()
string wellUid = "8c77de13-4fad-4b2e-ba3d-7e6b0e35a394";
string wellboreUid = "44e7a064-c2f2-4a3a-9259-5ab92085e110";
string mudLogUid = "integration_test";
WitsmlMudLogs queryExisting = MudLogQueries.QueryById(wellUid, wellboreUid, new string[] { mudLogUid });
WitsmlMudLogs queryExisting = MudLogQueries.QueryById(wellUid, wellboreUid, new[] { mudLogUid });
WitsmlMudLogs serverMudLog = await _client.GetFromStoreAsync(queryExisting, new OptionsIn(ReturnElements.All));
string responseXml = XmlHelper.Serialize(serverMudLog);
string serverMudLogXml = TestUtils.CleanResponse(responseXml);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Threading.Tasks;

using Witsml;
using Witsml.Data;
using Witsml.Data.Rig;
using Witsml.ServiceReference;
using Witsml.Xml;
Expand All @@ -19,10 +18,11 @@ public partial class RigTests
public RigTests()
{
WitsmlConfiguration config = ConfigurationReader.GetWitsmlConfiguration();
_client = new WitsmlClient(new WitsmlClientOptions

_client = new WitsmlClient(options =>
{
Hostname = config.Hostname,
Credentials = new WitsmlCredentials(config.Username, config.Password)
options.Hostname = config.Hostname;
options.Credentials = new WitsmlCredentials(config.Username, config.Password);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public partial class TrajectoryTests
public TrajectoryTests()
{
WitsmlConfiguration config = ConfigurationReader.GetWitsmlConfiguration();
_client = new WitsmlClient(new WitsmlClientOptions
_client = new WitsmlClient(options =>
{
Hostname = config.Hostname,
Credentials = new WitsmlCredentials(config.Username, config.Password)
options.Hostname = config.Hostname;
options.Credentials = new WitsmlCredentials(config.Username, config.Password);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public partial class TubularTests
public TubularTests()
{
WitsmlConfiguration config = ConfigurationReader.GetWitsmlConfiguration();
_client = new WitsmlClient(new WitsmlClientOptions
_client = new WitsmlClient(options =>
{
Hostname = config.Hostname,
Credentials = new WitsmlCredentials(config.Username, config.Password)
options.Hostname = config.Hostname;
options.Credentials = new WitsmlCredentials(config.Username, config.Password);
});
}

Expand Down

0 comments on commit ceb30c9

Please sign in to comment.