public async Task <ExecutionResult> Execute(ExecuteContext <ISendUserSetupEmailArguments> context)
        {
            try
            {
                var sendEndpoint = await context.GetSendEndpoint(NotificationServiceConstants.SendEmailNotificationUri);

                var args = context.Arguments;
                var bcc  = new List <string> {
                    _office365ServiceSettings.CloudPlusSupportEmail, _office365ServiceSettings.CloudPlusEngineeringEmail
                };
                await sendEndpoint.Send <ISendEmailCommand>(
                    new
                {
                    UserName          = args.UserPrincipalName,
                    To                = args.UserPrincipalName,
                    EmailTemplateType = EmailTemplateType.Office365UserSetUp,
                    BCC               = bcc
                });
            }
            catch (Exception ex)
            {
                this.Log().Error("Error executing SendUserSetupEmailActivity", ex);
            }

            return(context.Completed());
        }
        private async Task SendTransitionUserAndLicensesCommand(
            ExecuteContext <ITransitionDispatchCreatingUsersArguments> context, Office365UserModel office365User,
            UserModel user, RoleModel userRole, Office365TransitionProductItemModel item, bool keepLicences)
        {
            var arguments = context.Arguments;

            var isNewLicenses = !(item.Admin || item.RemoveLicenses);

            var userAndLicenseEndpoint = Office365ServiceConstants.QueueOffice365TransitionUserAndLicenseUri;
            var sendEndpoint           = await context.GetSendEndpoint(userAndLicenseEndpoint);

            await sendEndpoint.Send <IOffice365TransitionUserAndLicensesCommand>(new
            {
                arguments.CompanyId,
                arguments.Office365CustomerId,
                CloudPlusUserExist = user != null,
                office365User.UserPrincipalName,
                office365User.Office365UserId,
                office365User.FirstName,
                office365User.LastName,
                office365User.DisplayName,
                KeepLicences = keepLicences,
                UserRoles    = new List <string> {
                    "Company Administrator"
                },
                Roles = new List <int> {
                    userRole.Id
                },
                item.Password,
                item.RecommendedProductItem.CloudPlusProductIdentifier,
                IsNewLicenses = isNewLicenses,
                item.Admin,
            });
        }
        public async Task <ExecutionResult> Execute(ExecuteContext <Activity2Args> context)
        {
            if (context.Arguments.Name.Contains("error"))
            {
                throw new Exception("Unknown error...");
            }

            if (context.Arguments.Name.Contains("test"))
            {
                var endpoint = await context.GetSendEndpoint(context.Arguments.ResponseAddress);

                await endpoint.Send <ISimpleFailResponse>(new { Reason = "Something went wrong..." });

                throw new Exception("Something went wrong error...");
            }

            Console.WriteLine("Completing Activity2...");
            return(context.CompletedWithVariables(
                       new
            {
                CustomerDetails = new CustomerDetails()
                {
                    Name = "Hello " + context.Arguments.Name
                }
            }));
        }
        private async Task SendDeletePartnerPlatformUserCommand(
            ExecuteContext <ITransitionDispatchCreatingUsersArguments> context, Office365UserModel office365User)
        {
            var arguments = context.Arguments;

            var deleteUserEndpoint = await context.GetSendEndpoint(Office365ServiceConstants.QueueOffice365UserAssignLicenseUri);

            await deleteUserEndpoint.Send <IOffice365TransitionDeletePartnerPlatformUserCommand>(new
            {
                arguments.Office365CustomerId,
                office365User.Office365UserId
            });
        }
        public async Task <ExecutionResult> Execute(ExecuteContext <TakeProductArgument> context)
        {
            logger.LogInformation($"Take Product Courier called for order {context.Arguments.OrderId}");
            var uri          = QueueNames.GetMessageUri(nameof(TakeProductTransactionMessage));
            var sendEndpoint = await context.GetSendEndpoint(uri);

            //await sendEndpoint.Send<TakeProductTransactionMessage>(new
            //{
            //    ProductBaskets = context.Arguments.Baskets
            //});
            await requestClient.GetResponse <IRequestResult>(new { ProductBaskets = context.Arguments.Baskets });

            return(context.Completed(new { Baskets = context.Arguments.Baskets, OrderId = context.Arguments.OrderId }));
        }
        public async Task <ExecutionResult> Execute(ExecuteContext <PaymentArgument> context)
        {
            logger.LogInformation($"Payment Courier called for order {context.Arguments.OrderId}");
            var uri          = QueueNames.GetMessageUri(nameof(WithdrawCustomerCreditMessage));
            var sendEndpoint = await context.GetSendEndpoint(uri);

            await sendEndpoint.Send <WithdrawCustomerCreditMessage>(new
            {
                Credit     = context.Arguments.Credit,
                CustomerId = context.Arguments.CustomerId,
                OrderId    = context.Arguments.OrderId
            });

            return(context.Completed(new { CustomerId = context.Arguments.CustomerId, Credit = context.Arguments.Credit }));
        }
Exemple #7
0
        public async Task <ExecutionResult> Execute(ExecuteContext <ISendDomainVerifiedEmailArguments> context)
        {
            try
            {
                var sendEndpoint = await context.GetSendEndpoint(NotificationServiceConstants.SendEmailNotificationUri);

                var arguments = context.Arguments;

                if (arguments.IsDomainPrimary)
                {
                    await sendEndpoint.Send <ISendEmailCommand>(
                        new
                    {
                        arguments.CompanyId,
                        To = arguments.Email,
                        arguments.Domain,
                        EmailTemplateType = EmailTemplateType.Office365PrimaryDomainVerifiedSetUp
                    });
                }
                else
                {
                    await sendEndpoint.Send <ISendEmailCommand>(
                        new
                    {
                        arguments.CompanyId,
                        To = arguments.Email,
                        arguments.Domain,
                        EmailTemplateType = EmailTemplateType.Office365AdditionalDomainVerified
                    });
                }
            }
            catch (Exception ex)
            {
                this.Log().Error("Error occured SendDomainVerifiedEmailActivity", ex);
            }

            return(context.Completed());
        }
Exemple #8
0
        public async Task Evaluate()
        {
            RoutingSlipBuilder builder = CreateRoutingSlipBuilder(_routingSlip);

            Build(builder);

            RoutingSlip routingSlip = builder.Build();

            await PublishActivityEvents(routingSlip, builder).ConfigureAwait(false);

            if (HasNextActivity(routingSlip))
            {
                ISendEndpoint endpoint = await _context.GetSendEndpoint(routingSlip.GetNextExecuteAddress()).ConfigureAwait(false);

                await _context.Forward(endpoint, routingSlip).ConfigureAwait(false);
            }
            else
            {
                DateTime completedTimestamp = _context.Timestamp + _duration;
                TimeSpan completedDuration  = completedTimestamp - _routingSlip.CreateTimestamp;

                await _publisher.PublishRoutingSlipCompleted(completedTimestamp, completedDuration, routingSlip.Variables).ConfigureAwait(false);
            }
        }
        public async Task <ExecutionResult> Execute(ExecuteContext <ISendCustomerDomainTxtRecordsArguments> context)
        {
            try
            {
                var arguments    = context.Arguments;
                var sendEndpoint = await context.GetSendEndpoint(NotificationServiceConstants.SendEmailNotificationUri);

                await sendEndpoint.Send <ISendEmailCommand>(
                    new
                {
                    arguments.CompanyId,
                    arguments.Domain,
                    To                = arguments.Email,
                    TxtRecord         = arguments.TxtRecords,
                    EmailTemplateType = EmailTemplateType.Office365CustomerServiceEnabled
                });
            }
            catch (Exception ex)
            {
                this.Log().Error("Error occured sending Office365CustomerServiceEnabled email template!", ex);
            }

            return(context.Completed());
        }
Exemple #10
0
        public async Task <ExecutionResult> Execute(ExecuteContext <ICompanyCreatedArguments> context)
        {
            try
            {
                var sendEndpoint = await context.GetSendEndpoint(NotificationServiceConstants.SendEmailNotificationUri);

                var args = context.Arguments;
                if (args.SendWelcomeLetters)
                {
                    if (args.Company.Type == CompanyType.Customer)
                    {
                        if (args.PasswordSetupMethod == PasswordSetupMethod.GeneratePasswordViaLink)
                        {
                            var tempResetLink = await _passwordService.GetPasswordResetLink(args.UserId, args.Email);

                            await sendEndpoint.Send <ISendEmailCommand>(
                                new
                            {
                                UserName          = args.Email,
                                TempResetLink     = tempResetLink,
                                To                = args.PasswordSetupEmail,
                                Recipients        = args.PasswordSetupEmail == args.Email ? null : new List <string>(new string[] { args.Email }),
                                EmailTemplateType = EmailTemplateType.WelcomeCompanyCustomerPasswordViaEmail
                            });
                        }
                        else
                        {
                            if (args.SendPlainPasswordViaEmail)
                            {
                                await sendEndpoint.Send <ISendEmailCommand>(
                                    new
                                {
                                    UserName = args.Email,
                                    args.Password,
                                    To = args.PasswordSetupEmail,
                                    EmailTemplateType = EmailTemplateType.WelcomeCompanyCustomerSendPlainPasswordViaEmail
                                });
                            }
                            else
                            {
                                var userSendEmail = string.IsNullOrWhiteSpace(args.AlternativeEmail) ? args.Company.Email : args.AlternativeEmail;


                                await sendEndpoint.Send <ISendEmailCommand>(
                                    new
                                {
                                    UserName = args.Email,
                                    args.Password,
                                    To = userSendEmail,
                                    EmailTemplateType = EmailTemplateType.WelcomeCompanyCustomer
                                });
                            }
                        }
                    }
                    else
                    {
                        if (args.PasswordSetupMethod == PasswordSetupMethod.GeneratePasswordViaLink)
                        {
                            var tempResetLink = await _passwordService.GetPasswordResetLink(args.UserId, args.Email);

                            await sendEndpoint.Send <ISendEmailCommand>(
                                new
                            {
                                UserName          = args.Email,
                                TempResetLink     = tempResetLink,
                                To                = args.PasswordSetupEmail,
                                Recipients        = args.PasswordSetupEmail == args.Email ? null : new List <string>(new string[] { args.Email }),
                                EmailTemplateType = EmailTemplateType.WelcomeCompanyResellerPasswordViaEmail
                            });
                        }
                        else
                        {
                            if (args.SendPlainPasswordViaEmail)
                            {
                                await sendEndpoint.Send <ISendEmailCommand>(
                                    new
                                {
                                    UserName = args.Email,
                                    args.Password,
                                    To = args.PasswordSetupEmail,
                                    EmailTemplateType = EmailTemplateType.WelcomeCompanyResellerSendPlainPasswordViaEmail
                                });
                            }
                            else
                            {
                                var userSendEmail = string.IsNullOrWhiteSpace(args.AlternativeEmail) ? args.Company.Email : args.AlternativeEmail;

                                await sendEndpoint.Send <ISendEmailCommand>(
                                    new
                                {
                                    UserName = args.Email,
                                    args.Password,
                                    To = userSendEmail,
                                    EmailTemplateType = EmailTemplateType.WelcomeCompanyReseller
                                });
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.Log().Error("Error executing CompanyCreatedActivity", ex);
            }

            return(context.Completed());
        }