Exemple #1
0
        protected override void When(DomainEvent domainEvent)
        {
            Boolean handled = false;
            IInternalEventHandler entityToApply = Leases;

            switch (domainEvent)
            {
            case DHCPv6ScopePropertiesUpdatedEvent e:
                Properties = e.Properties;
                break;

            case DHCPv6ScopeAddressPropertiesUpdatedEvent e:
                AddressRelatedProperties = e.AddressProperties;
                SetSuspendedState(true, false);
                break;

            case DHCPv6ScopeDescriptionUpdatedEvent e:
                Description = new ScopeDescription(e.Description);
                break;

            case DHCPv6ScopeNameUpdatedEvent e:
                Name = new ScopeName(e.Name);
                break;

            default:
                break;
            }

            if (handled == false)
            {
                ApplyToEnity(entityToApply, domainEvent);
            }
        }
Exemple #2
0
        public void ScopeDescription_FromString(String input)
        {
            ScopeDescription description = ScopeDescription.FromString(input);

            String result = description;

            Assert.Equal(input, result);
        }
Exemple #3
0
        public ServiceContext(Uri baseUri, ClientSettings settings, ScopeDescription rootScope)
        {
            this.baseUri        = baseUri;
            this.ClientSettings = settings;
            this.RootScope      = new ScopeViewModel(rootScope, null, this);
            this.SelectedScope  = this.RootScope;

            this.refreshCommand = new SimpleActionCommand(source => this.Refresh());
        }
Exemple #4
0
        public async Task <Boolean> Handle(UpdateDHCPv4ScopeCommand request, CancellationToken cancellationToken)
        {
            _logger.LogDebug("Handle started");

            var scope = _rootScope.GetScopeById(request.ScopeId);

            if (scope == DHCPv4Scope.NotFound)
            {
                return(false);
            }

            Guid?parentId          = scope.HasParentScope() == false ? new Guid?() : scope.ParentScope.Id;
            var  properties        = GetScopeProperties(request);
            var  addressProperties = GetScopeAddressProperties(request);

            if (request.Name != scope.Name)
            {
                _rootScope.UpdateScopeName(request.ScopeId, ScopeName.FromString(request.Name));
            }
            if (request.Description != scope.Description)
            {
                _rootScope.UpdateScopeDescription(request.ScopeId, ScopeDescription.FromString(request.Description));
            }
            if (request.ParentId != parentId)
            {
                _rootScope.UpdateParent(request.ScopeId, request.ParentId);
            }

            _rootScope.UpdateScopeResolver(request.ScopeId, GetResolverInformation(request));

            if (addressProperties != scope.AddressRelatedProperties)
            {
                _rootScope.UpdateAddressProperties(request.ScopeId, addressProperties);
            }

            if (properties != scope.Properties)
            {
                _rootScope.UpdateScopeProperties(request.ScopeId, properties);
            }

            Boolean result = await _store.Save(_rootScope);

            if (result == true)
            {
                var triggers = _rootScope.GetTriggers();

                if (triggers.Any() == true)
                {
                    await _serviceBus.Publish(new NewTriggerHappendMessage(triggers));

                    _rootScope.ClearTriggers();
                }
            }

            return(result);
        }
Exemple #5
0
        public void ScopeDescription_InvalidCharsEmpty()
        {
            List <String> inputs = new List <string> {
                "asfa`f`",
                "**~",
            };

            foreach (var invalidInput in inputs)
            {
                Assert.ThrowsAny <Exception>(() => ScopeDescription.FromString(invalidInput));
            }
        }
Exemple #6
0
        void Refresh()
        {
            // requery the root scope
            ScopeDescription rootScope = this.Client.CurrentScope.Get();

            this.RootScope = new ScopeViewModel(rootScope, null, this);
            this.SelectedScope.IsSelected = false;
            this.SelectedScope            = this.RootScope;
            this.RootScope.IsSelected     = true;
            this.RaisePropertyChanged("RootScopeAsCollection");

            ScopeNavigationController.Default.NavigateToScope(this.RootScope);
            ScopeNavigationController.Default.ClearHistory();
        }
Exemple #7
0
        public void ScopeDescription_StringEmpty()
        {
            List <String> inputs = new List <string> {
                null,
                String.Empty,
                "",
                "    ",
                "\n\r\t",
            };

            foreach (var invalidInput in inputs)
            {
                Assert.ThrowsAny <Exception>(() => ScopeDescription.FromString(invalidInput));
            }
        }
Exemple #8
0
        public ScopeViewModel(ScopeDescription scope, ScopeViewModel parentScope, ServiceContext context)
            : base(parentScope)
        {
            this.scope       = scope;
            this.parentScope = parentScope;
            this.context     = context;

            this.title = this.scope.Name();
            this.ShowActivitiesCommand       = new SimpleActionCommand(this.OnShowActivities);
            this.ShowWorkflowsCommand        = new SimpleActionCommand(this.OnShowWorkflows);
            this.ShowSecuritySettingsCommand = new SimpleActionCommand(this.OnShowSecuritySettings);

            if (this.scope.DefaultWorkflowConfiguration != null)
            {
                this.configurationViewModel   = new WorkflowConfigurationViewModel(this.scope.DefaultWorkflowConfiguration);
                this.ShowConfigurationCommand = new SimpleActionCommand(this.OnShowConfiguration);
            }
        }
Exemple #9
0
        public void ScopeDescription_ToLong()
        {
            Random random = new Random();
            Int32  max    = ScopeDescription.MaxLength;

            String inputToPass = random.GetAlphanumericString(max);
            String output      = ScopeDescription.FromString(inputToPass);

            Assert.Equal(inputToPass, output);

            List <String> inputs = new List <string> {
                random.GetAlphanumericString(max + 1),
                random.GetAlphanumericString(max + 2),
                random.GetAlphanumericString(max + random.Next(200, 400)),
            };

            foreach (var invalidInput in inputs)
            {
                Assert.ThrowsAny <Exception>(() => ScopeDescription.FromString(invalidInput));
            }
        }
Exemple #10
0
 public DHCPv4ScopeDescriptionUpdatedEvent(Guid scopeId, ScopeDescription description) : base(scopeId)
 {
     Description = description;
 }
Exemple #11
0
 internal WorkflowManagementClient CreateClient(ScopeDescription scope)
 {
     return(new WorkflowManagementClient(this.CreateUri(scope.Path), this.ClientSettings));
 }
Exemple #12
0
 public override Boolean UpdateScopeDescription(Guid id, ScopeDescription name)
 {
     CheckIfScopeExistsById(id);
     base.Apply(new DHCPv6ScopeDescriptionUpdatedEvent(id, name));
     return(true);
 }
 public static string Name(this ScopeDescription scope)
 {
     return(scope.IsRootScope() ? "(root)" : scope.Path.Split('/').Last());
 }
 public static bool IsRootScope(this ScopeDescription scope)
 {
     return(scope.Path == "/");
 }