You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// Gets the product information of the connected Kepware server, which includes
58
+
/// product name and version information. This caches the value during <see cref="KepwareApiClient.TestConnectionAsync(CancellationToken)"/>
59
+
/// and <see cref="KepwareApiClient.GetProductInfoAsync(CancellationToken)"/> and cached for future use.
60
+
/// It will return null if there is no cached value.
61
+
/// </summary>
62
+
publicProductInfo?ProductInfo=>m_productInfo;
63
+
54
64
/// <summary>
55
65
/// Gets the client options for the Kepware server connection.
56
66
/// </summary>
@@ -141,7 +151,7 @@ public async Task<bool> TestConnectionAsync(CancellationToken cancellationToken
141
151
if(!response.IsSuccessStatusCode)
142
152
{
143
153
m_logger.LogWarning("Failed to connect to {ClientName}-client at {BaseAddress}, Reason: {ReasonPhrase}",ClientName,m_httpClient.BaseAddress,response.ReasonPhrase);
144
-
m_isConnected=null;// set connection state to null if we cannot connect
154
+
ClearConnectionState();// set connection state to null if we cannot connect
m_logger.LogWarning("Failed to connect to {ClientName}-client at {BaseAddress}, Reason: {String}",ClientName,m_httpClient.BaseAddress,"Server Status Check Failed");
158
-
m_isConnected=null;// set connection state to null if we cannot connect
168
+
ClearConnectionState();// set connection state to null if we cannot connect
// If we do not have valid credentials, we assume the connection is not healthy
183
193
if(m_hasValidCredentials!=true)
184
194
{
185
-
m_isConnected=null;// set connection state to null if we cannot connect or credentials are invalid
195
+
ClearConnectionState();// set connection state to null if we cannot connect or credentials are invalid
186
196
m_logger.LogWarning("Connection to {ClientName}-client at {BaseAddress} failed because credentials are invalid",ClientName,m_httpClient.BaseAddress);
187
197
returnfalse;
188
198
}
189
199
190
-
m_logger.LogInformation("Successfully connected to {ClientName}-client: {ProductName} {ProductVersion} on {BaseAddress}",ClientName,prodInfo?.ProductName,prodInfo?.ProductVersion,m_httpClient.BaseAddress);
200
+
m_logger.LogInformation("Successfully connected to {ClientName}-client: {ProductName} {ProductVersion} on {BaseAddress}",ClientName,m_productInfo?.ProductName,m_productInfo?.ProductVersion,m_httpClient.BaseAddress);
191
201
192
202
m_isConnected=true;// set connection state to true if we have a valid product info and credentials
193
203
returnm_isConnected.Value;// return true if we have a valid connection
/// <returns>A task that represents the asynchronous operation. The task result contains the product information.</returns>
222
+
/// <returns>A task that represents the asynchronous operation. The task result contains the product information. <see cref="Kepware.Api.Model.ProductInfo"/></returns>
0 commit comments