private void NewCommandHandler() { OpenFileDialog _of = new OpenFileDialog() { CheckFileExists = true, DefaultExt = "UANodeSet (.xml)|*.xml", Title = "Open OPC UA Address Space Model" }; if (!_of.ShowDialog().GetValueOrDefault(false)) { return; } DomainModelWrapper _dsc = m_domainsServices.CreateDefault(); _dsc.UniversalAddressSpaceLocator = _of.FileName; DomainConfirmation _confirmation = new DomainConfirmation(_dsc, true, m_Logger.Log) { Title = "Create Data Domain Model" }; bool _exitLoop = false; do { b_EditPopupRequest.Raise(_confirmation, x => { _exitLoop = x.Confirmed; }); if (_exitLoop) { _exitLoop = m_domainsServices.AddDomain(_confirmation.DomainConfigurationWrapper); } else { _exitLoop = true; } } while (!_exitLoop); }
internal DomainsManagementServices(IAssociationServices services) { m_IAssociationServices = services; m_DomainsObservableCollection = new DomainsObservableCollection(new DomainModelWrapper[] { CreateDefault() }); foreach (Association _as in services.GetAssociations()) { DomainModelWrapper _dw = m_DomainsObservableCollection.Where <DomainModelWrapper>(x => x.UniqueName == _as.AssociationConfigurationWrapper.PublisherId).FirstOrDefault <DomainModelWrapper>(); if (_dw == null) { DomainModel _new = new DomainModel() { AliasName = _as.DataSet.SymbolicName, Description = $"URI recovered from the DataSet AssociationName: {_as.DataSet.AssociationName}, SymbolicName: {_as.DataSet.SymbolicName}", DomainModelGuid = _as.AssociationConfigurationWrapper.PublisherId, DomainModelUri = new Uri(_as.DataSet.InformationModelURI), SemanticsDataCollection = new SemanticsDataIndex[] { NewSemanticsDataIndex(_as) } }; m_DomainsObservableCollection.Add(new DomainModelWrapper(_new)); } else { _dw.SemanticsDataCollection.Add(new SemanticsDataIndexWrapper(NewSemanticsDataIndex(_as))); } } ; }
/// <summary> /// Determines whether the specified domain has bee registered already. /// </summary> /// <param name="domain">The domain to check.</param> /// <returns><c>true</c> if the local dictionary contains the specified domain; otherwise, <c>false</c>.</returns> public bool Contains(DomainModelWrapper domain) { if (m_DomainsObservableCollection == null) { return(false); } return(m_DomainsObservableCollection.Where <DomainModelWrapper>(x => x.AliasName == domain.AliasName).Any <DomainModelWrapper>()); }
/// <summary> /// Initializes a new instance of the <see cref="DomainConfirmation" /> class. /// </summary> /// <param name="domain">The domain.</param> /// <param name="informationModelURIIsEnabled">if set to <c>true</c> information model URI text box is enabled.</param> /// <param name="log">A delegate capturing logging functionality.</param> internal DomainConfirmation(DomainModelWrapper domain, bool informationModelURIIsEnabled, Action <string, Category, Prism.Logging.Priority> log) { b_DomainConfigurationWrapper = domain; InformationModelURIIsEnabled = informationModelURIIsEnabled; Go2DiscoveryServiceURL = new CAS.Windows.Commands.WebDocumentationCommand(() => DomainConfigurationWrapper.UniversalDiscoveryServiceLocator); Go2AddressSpaceURL = new CAS.Windows.Commands.WebDocumentationCommand(() => DomainConfigurationWrapper.UniversalAddressSpaceLocator); m_LoggerAction = log; }
/// <summary> /// Adds the domain to the collection of well known domains. /// </summary> /// <param name="domain">The domain to be added to the list of available domains.</param> /// <exception cref="NotImplementedException"></exception> public bool AddDomain(DomainModelWrapper domain) { if (Contains(domain)) { return(false); } m_DomainsObservableCollection.Add(domain); return(true); }
internal void UpdateDataSet(DomainModelWrapper domainMode, SemanticsDataIndexWrapper selectedIndex, bool newVersion) { InformationModelURI = domainMode.URI.ToString(); Id = domainMode.UniqueName; ConfigurationGuid = Guid.NewGuid(); if (newVersion) { ConfigurationVersion.IncrementMajorVersion(); } DataSet = CreateDataSet(selectedIndex); DefaultDataSetWriterId = Convert.ToUInt16(domainMode.SemanticsDataCollection.IndexOf(selectedIndex)); MaxBufferTime = -1; RepositoryGroup = String.Empty; SymbolicName = selectedIndex.SymbolicName; }
private void AddCommandHandler() { DomainModelWrapper _dsc = null; DomainModelResolveViewModel _modeResolveConfirmation = new DomainModelResolveViewModel(m_Logger.Log) { Title = "Resolve Uri of Information Model to Data Domain Model Description" }; bool _exitLoop = false; do { b_ResoleUriToDomainModelPopupRequest.Raise(_modeResolveConfirmation, x => { _exitLoop = x.Confirmed; }); if (_exitLoop & _modeResolveConfirmation.ResolvedDomainModel != null) { _dsc = _modeResolveConfirmation.ResolvedDomainModel; } else { _exitLoop = true; } } while (!_exitLoop); if (_dsc == null) { return; } DomainConfirmation _confirmation = new DomainConfirmation(_dsc, false, m_Logger.Log) { Title = "Import Data Domain Model" }; do { b_EditPopupRequest.Raise(_confirmation, x => { _exitLoop = x.Confirmed; }); if (_exitLoop) { _exitLoop = m_domainsServices.AddDomain(_confirmation.DomainConfigurationWrapper); if (!_exitLoop) { MessageBox.Show("The data domain exist", "Add data domain failed", MessageBoxButton.OK, MessageBoxImage.Error); } } else { _exitLoop = true; } } while (!_exitLoop); }
//methods private async Task DomainDiscoveryAsync() { ClearUserInterface(); LogList.Clear(); Cursor _currentCursor = CurrentCursor; bool? _currentIsEnabled = CurrentIsEnabled; try { CurrentCursor = Cursors.Wait; CurrentIsEnabled = false; DomainModel _newDomainModel = null; using (UAOOI.DataDiscovery.DiscoveryServices.DataDiscoveryServices _service = new DataDiscoveryServices()) { _newDomainModel = await _service.ResolveDomainModelAsync (InformationModelURI, new Uri(Properties.Settings.Default.DataDiscoveryRootServiceUrl), (x, y, z) => m_LoggerAction(x, y.TraceEventType2Category(), z.Priority2Priority())); } string[] _segments = InformationModelURI.Segments; string _aliasName = String.Empty; if (_segments.Length >= 1) { _segments[0] = InformationModelURI.Host; _aliasName = String.Join(".", _segments).Replace("/", ""); } else { _aliasName = "Enter alias for this domain"; } ResolvedDomainModel = new DomainModelWrapper(_newDomainModel); } catch (System.Exception _e) { MessageBox.Show($"Error while resolving the domain description {_e}", "Resolving of Semantics Data", MessageBoxButton.OK, MessageBoxImage.Warning); } finally { CurrentCursor = _currentCursor; CurrentIsEnabled = _currentIsEnabled; } }
/// <summary> /// Creates a default domain descriptor. /// </summary> /// <returns>New <see cref="DomainModelWrapper" />.</returns> public DomainModelWrapper CreateDefault() { DomainModel _model = new DomainModel() { AliasName = "TempuriOrg", Description = "Starting point to created new Data Domain Model", DomainModelGuid = new Guid("3653281C-A77F-4A98-ACA4-C87A560EC124"), DomainModelUri = new Uri(@"http://tempuri.org/DefaultDomainSegment"), SemanticsDataCollection = new SemanticsDataIndex[] { } }; DomainModelWrapper _ret = new DomainModelWrapper(_model); int _i = 0; while (Contains(_ret)) { _ret.AliasName = $"TempuriOrg.{_i}"; _ret.UniqueName = Guid.NewGuid(); _ret.URI = new Uri($"http://tempuri.org/DefaultDomainSegment/{_i}"); _i++; } return(_ret); }
/// <summary> /// Removes the specified domain from the well known domains. /// </summary> /// <param name="domain">The domain to be removed from the list of available domains.</param> public void Remove(DomainModelWrapper domain) { m_DomainsObservableCollection.Remove(domain); }