public override ApplicationRecordDataType[] FindApplications( string applicationUri ) { base.FindApplications(applicationUri); List <ApplicationRecordDataType> records = new List <ApplicationRecordDataType>(); string nextPageLink = null; do { IList <ApplicationRecordApiModel> results; var pagedResults = _opcVaultServiceClient.ListApplications(applicationUri, nextPageLink); results = pagedResults.Applications; foreach (var result in results) { LocalizedText[] names = null; if (result.ApplicationName != null) { names = new LocalizedText[] { result.ApplicationName }; } StringCollection discoveryUrls = null; var endpoints = result.DiscoveryUrls; if (endpoints != null) { discoveryUrls = new StringCollection(); foreach (var endpoint in endpoints) { discoveryUrls.Add(endpoint); } } string[] capabilities = null; if (result.ServerCapabilities != null) { capabilities = result.ServerCapabilities.Split(','); } NodeId appNodeId = OpcVaultClientHelper.GetNodeIdFromServiceId(result.ApplicationId, NamespaceIndex); records.Add(new ApplicationRecordDataType() { ApplicationId = appNodeId, ApplicationUri = result.ApplicationUri, ApplicationType = (ApplicationType)result.ApplicationType, ApplicationNames = new LocalizedTextCollection(names), ProductUri = result.ProductUri, DiscoveryUrls = discoveryUrls, ServerCapabilities = capabilities }); } nextPageLink = pagedResults.NextPageLink; } while (nextPageLink != null); return(records.ToArray()); }
public override ApplicationRecordDataType GetApplication( NodeId applicationId ) { base.GetApplication(applicationId); string id = OpcVaultClientHelper.GetServiceIdFromNodeId(applicationId, NamespaceIndex); ApplicationRecordApiModel result; try { result = _opcVaultServiceClient.GetApplication(id); } catch { return(null); } var names = new List <LocalizedText>(); foreach (var applicationName in result.ApplicationNames) { names.Add(new LocalizedText(applicationName.Locale, applicationName.Text)); } StringCollection discoveryUrls = null; var endpoints = result.DiscoveryUrls; if (endpoints != null) { discoveryUrls = new StringCollection(); foreach (var endpoint in endpoints) { discoveryUrls.Add(endpoint); } } var capabilities = new StringCollection(); if (!String.IsNullOrWhiteSpace(result.ServerCapabilities)) { capabilities.AddRange(result.ServerCapabilities.Split(',')); } NodeId appNodeId = OpcVaultClientHelper.GetNodeIdFromServiceId(result.ApplicationId, NamespaceIndex); return(new ApplicationRecordDataType() { ApplicationId = appNodeId, ApplicationUri = result.ApplicationUri, ApplicationType = (ApplicationType)result.ApplicationType, ApplicationNames = new LocalizedTextCollection(names), ProductUri = result.ProductUri, DiscoveryUrls = discoveryUrls, ServerCapabilities = capabilities }); }
public override void UnregisterApplication(NodeId applicationId) { base.UnregisterApplication(applicationId); string id = OpcVaultClientHelper.GetServiceIdFromNodeId(applicationId, NamespaceIndex); try { _opcVaultServiceClient.UnregisterApplication(id); } catch { throw new ArgumentException("A record with the specified application id does not exist.", nameof(applicationId)); } }
public override NodeId RegisterApplication( ApplicationRecordDataType application ) { bool isUpdate = true; string applicationId = null; NodeId appNodeId = base.RegisterApplication(application); if (NodeId.IsNull(appNodeId)) { isUpdate = false; } else { applicationId = OpcVaultClientHelper.GetServiceIdFromNodeId(appNodeId, NamespaceIndex); } string capabilities = base.ServerCapabilities(application); ApplicationRecordApiModel applicationModel = new ApplicationRecordApiModel( ApplicationState.New, (Microsoft.Azure.IIoT.OpcUa.Api.Vault.Models.ApplicationType)application.ApplicationType, applicationId ) { ApplicationUri = application.ApplicationUri, ApplicationName = application.ApplicationNames[0].Text, //ApplicationType = (ApplicationType)application.ApplicationType, ProductUri = application.ProductUri, ServerCapabilities = capabilities }; if (application.DiscoveryUrls != null) { applicationModel.DiscoveryUrls = application.DiscoveryUrls.ToArray(); } if (application.ApplicationNames != null && application.ApplicationNames.Count > 0) { var applicationNames = new List <ApplicationNameApiModel>(); foreach (var applicationName in application.ApplicationNames) { applicationNames.Add(new ApplicationNameApiModel() { Locale = applicationName.Locale, Text = applicationName.Text }); } applicationModel.ApplicationNames = applicationNames.ToArray(); } if (isUpdate) { applicationModel = _opcVaultServiceClient.UpdateApplication(applicationId, applicationModel); } else { applicationModel = _opcVaultServiceClient.RegisterApplication(applicationModel); applicationId = applicationModel.ApplicationId; } return(OpcVaultClientHelper.GetNodeIdFromServiceId(applicationId, NamespaceIndex)); }