コード例 #1
0
        public void InitiateDiscussion(InitiateDiscussionCommand command)
        {
            ApplicationServiceLifeCycle.Begin();
            try
            {
                var product = this.productRepository.Get(new TenantId(command.TenantId), new ProductId(command.ProductId));
                if (product == null)
                {
                    throw new InvalidOperationException(
                              string.Format("Unknown product of tenant id: {0} and product id: {1}.", command.TenantId, command.ProductId));
                }

                product.InitiateDiscussion(new DiscussionDescriptor(command.DiscussionId));

                this.productRepository.Save(product);

                var processId = ProcessId.ExistingProcessId(product.DiscussionInitiationId);

                var tracker = this.processTrackerRepository.Get(command.TenantId, processId);

                tracker.MarkProcessCompleted();

                this.processTrackerRepository.Save(tracker);

                ApplicationServiceLifeCycle.Success();
            }
            catch (Exception ex)
            {
                ApplicationServiceLifeCycle.Fail(ex);
            }
        }
コード例 #2
0
        public void ChangeTeamMemberEmailAddress(ChangeTeamMemberEmailAddressCommand command)
        {
            var tenantId = new TenantId(command.TenantId);

            ApplicationServiceLifeCycle.Begin();
            try
            {
                var productOwner = this.productOwnerRepository.Get(tenantId, command.Username);
                if (productOwner != null)
                {
                    productOwner.ChangeEmailAddress(command.EmailAddress, command.OccurredOn);
                    this.productOwnerRepository.Save(productOwner);
                }

                var teamMember = this.teamMemberRepository.Get(tenantId, command.Username);
                if (teamMember != null)
                {
                    teamMember.ChangeEmailAddress(command.EmailAddress, command.OccurredOn);
                    this.teamMemberRepository.Save(teamMember);
                }

                ApplicationServiceLifeCycle.Success();
            }
            catch (Exception ex)
            {
                ApplicationServiceLifeCycle.Fail(ex);
            }
        }
コード例 #3
0
        string NewProductWith(string tenantId, string productOwnerId, string name, string description, DiscussionAvailability discussionAvailability)
        {
            var tid       = new TenantId(tenantId);
            var productId = default(ProductId);

            ApplicationServiceLifeCycle.Begin();
            try
            {
                productId = this.productRepository.GetNextIdentity();

                var productOwner = this.productOwnerRepository.Get(tid, productOwnerId);

                var product = new Product(tid, productId, productOwner.ProductOwnerId, name, description, discussionAvailability);

                this.productRepository.Save(product);

                ApplicationServiceLifeCycle.Success();
            }
            catch (Exception ex)
            {
                ApplicationServiceLifeCycle.Fail(ex);
            }
            // TODO: handle null properly
            return(productId.Id);
        }
コード例 #4
0
        public void ChangeTeamMemberName(ChangeTeamMemberNameCommand command)
        {
            var tenantId = new TenantId(command.TenantId);

            ApplicationServiceLifeCycle.Begin();
            try
            {
                var productOwner = _productOwnerRepository.Get(tenantId, command.Username);
                if (productOwner != null)
                {
                    productOwner.ChangeName(command.FirstName, command.LastName, command.OccurredOn);
                    _productOwnerRepository.Save(productOwner);
                }

                var teamMember = _teamMemberRepository.Get(tenantId, command.Username);
                if (teamMember != null)
                {
                    teamMember.ChangeName(command.FirstName, command.LastName, command.OccurredOn);
                    _teamMemberRepository.Save(teamMember);
                }

                ApplicationServiceLifeCycle.Success();
            }
            catch (Exception ex)
            {
                ApplicationServiceLifeCycle.Fail(ex);
            }
        }
コード例 #5
0
 public void PublishNotifications()
 {
     ApplicationServiceLifeCycle.Begin(false);
     try
     {
         this.notificationPublisher.PublishNotifications();
         ApplicationServiceLifeCycle.Success();
     }
     catch (Exception ex)
     {
         ApplicationServiceLifeCycle.Fail(ex);
     }
 }
コード例 #6
0
        void RequestProductDiscussionFor(Product product)
        {
            ApplicationServiceLifeCycle.Begin();
            try
            {
                product.RequestDiscussion(RequestDiscussionIfAvailable());

                this.productRepository.Save(product);

                ApplicationServiceLifeCycle.Success();
            }
            catch (Exception ex)
            {
                ApplicationServiceLifeCycle.Fail(ex);
            }
        }
コード例 #7
0
        public void CheckForTimedOutProccesses()
        {
            ApplicationServiceLifeCycle.Begin();
            try
            {
                var trackers = this.processTrackerRepository.GetAllTimedOut();

                foreach (var tracker in trackers)
                {
                    tracker.InformProcessTimedOut();
                    this.processTrackerRepository.Save(tracker);
                }

                ApplicationServiceLifeCycle.Success();
            }
            catch (Exception ex)
            {
                ApplicationServiceLifeCycle.Fail(ex);
            }
        }
コード例 #8
0
        public void DisableTeamMember(DisableTeamMemberCommand command)
        {
            var tenantId = new TenantId(command.TenantId);

            ApplicationServiceLifeCycle.Begin();
            try
            {
                var teamMember = this.teamMemberRepository.Get(tenantId, command.Username);
                if (teamMember != null)
                {
                    teamMember.Disable(command.OccurredOn);
                    this.teamMemberRepository.Save(teamMember);
                }
                ApplicationServiceLifeCycle.Success();
            }
            catch (Exception ex)
            {
                ApplicationServiceLifeCycle.Fail(ex);
            }
        }
コード例 #9
0
        public void EnableProductOwner(EnableProductOwnerCommand command)
        {
            var tenantId = new TenantId(command.TenantId);

            ApplicationServiceLifeCycle.Begin();
            try
            {
                var productOwner = this.productOwnerRepository.Get(tenantId, command.Username);
                if (productOwner != null)
                {
                    productOwner.Enable(command.OccurredOn);
                }
                else
                {
                    productOwner = new ProductOwner(tenantId, command.Username, command.FirstName, command.LastName, command.EmailAddress, command.OccurredOn);
                    this.productOwnerRepository.Save(productOwner);
                }
                ApplicationServiceLifeCycle.Success();
            }
            catch (Exception ex)
            {
                ApplicationServiceLifeCycle.Fail(ex);
            }
        }
コード例 #10
0
        public void StartDiscussionInitiation(StartDiscussionInitiationCommand command)
        {
            ApplicationServiceLifeCycle.Begin();
            try
            {
                var product = this.productRepository.Get(new TenantId(command.TenantId), new ProductId(command.ProductId));
                if (product == null)
                {
                    throw new InvalidOperationException(
                              string.Format("Unknown product of tenant id: {0} and product id: {1}.", command.TenantId, command.ProductId));
                }

                var timedOutEventName = typeof(ProductDiscussionRequestTimedOut).Name;

                var tracker = new TimeConstrainedProcessTracker(
                    tenantId: command.TenantId,
                    processId: ProcessId.NewProcessId(),
                    description: "Create discussion for product: " + product.Name,
                    originalStartTime: DateTime.UtcNow,
                    allowableDuration: 5L * 60L * 1000L,
                    totalRetriesPermitted: 3,
                    processTimedOutEventType: timedOutEventName);

                this.processTrackerRepository.Save(tracker);

                product.StartDiscussionInitiation(tracker.ProcessId.Id);

                this.productRepository.Save(product);

                ApplicationServiceLifeCycle.Success();
            }
            catch (Exception ex)
            {
                ApplicationServiceLifeCycle.Fail(ex);
            }
        }
コード例 #11
0
        public void TimeOutProductDiscussionRequest(TimeOutProductDiscussionRequestCommand command)
        {
            ApplicationServiceLifeCycle.Begin();
            try
            {
                var processId = ProcessId.ExistingProcessId(command.ProcessId);

                var tenantId = new TenantId(command.TenantId);

                var product = this.productRepository.GetByDiscussionInitiationId(tenantId, processId.Id);

                SendEmailForTimedOutProcess(product);

                product.FailDiscussionInitiation();

                this.productRepository.Save(product);

                ApplicationServiceLifeCycle.Success();
            }
            catch (Exception ex)
            {
                ApplicationServiceLifeCycle.Fail(ex);
            }
        }