public override ServerOnNetwork[] QueryServers( uint startingRecordId, uint maxRecordsToReturn, string applicationName, string applicationUri, string productUri, string[] serverCapabilities, out DateTime lastCounterResetTime) { lastCounterResetTime = DateTime.MinValue; List <ServerOnNetwork> records = new List <ServerOnNetwork>(); var query = new QueryApplicationsByIdApiModel( (int)startingRecordId, (int)maxRecordsToReturn, applicationName, applicationUri, QueryApplicationType.Server, productUri, serverCapabilities?.ToList() ); var resultModel = _opcVaultServiceClient.QueryApplicationsById(query); foreach (var application in resultModel.Applications) { if (application.DiscoveryUrls != null) { foreach (var discoveryUrl in application.DiscoveryUrls) { records.Add(new ServerOnNetwork() { RecordId = (uint)application.Id, ServerName = application.ApplicationName, DiscoveryUrl = discoveryUrl, ServerCapabilities = application.ServerCapabilities?.Split(",") }); } } } lastCounterResetTime = resultModel.LastCounterResetTime != null ? resultModel.LastCounterResetTime : DateTime.MinValue; return(records.ToArray()); }
public override ApplicationDescription[] QueryApplications( uint startingRecordId, uint maxRecordsToReturn, string applicationName, string applicationUri, uint applicationType, string productUri, string[] serverCapabilities, out DateTime lastCounterResetTime, out uint nextRecordId) { lastCounterResetTime = DateTime.MinValue; var records = new List <ApplicationDescription>(); var query = new QueryApplicationsByIdApiModel( (int)startingRecordId, (int)maxRecordsToReturn, applicationName, applicationUri, (QueryApplicationType)applicationType, productUri, serverCapabilities?.ToList() ); var resultModel = _opcVaultServiceClient.QueryApplicationsById(query); foreach (var application in resultModel.Applications) { records.Add(new ApplicationDescription() { ApplicationUri = application.ApplicationUri, ProductUri = application.ProductUri, ApplicationName = application.ApplicationName, ApplicationType = (ApplicationType)application.ApplicationType, GatewayServerUri = application.GatewayServerUri, DiscoveryProfileUri = application.DiscoveryProfileUri, DiscoveryUrls = application.DiscoveryUrls != null ? new StringCollection(application.DiscoveryUrls) : null }); } lastCounterResetTime = resultModel.LastCounterResetTime; nextRecordId = (uint)resultModel.NextRecordId; return(records.ToArray()); }
public async Task <QueryApplicationsByIdResponseApiModel> QueryApplicationsByIdAsync( [FromBody] QueryApplicationsByIdApiModel query) { if (query == null) { // query all query = new QueryApplicationsByIdApiModel(0, 0, null, null, 0, null, null, null); } var result = await _applicationDatabase.QueryApplicationsByIdAsync( query.StartingRecordId, query.MaxRecordsToReturn, query.ApplicationName, query.ApplicationUri, (uint)query.ApplicationType, query.ProductUri, query.ServerCapabilities, (Types.QueryApplicationState?) query.ApplicationState ); return(new QueryApplicationsByIdResponseApiModel(result)); }