private void RefreshReportExecute(object sender)
        {
            SimpleWorkAsync(async() =>
            {
                var addressCompiled = MailComposer.ToAddressExpression.Compile();
                var compiledFromAddressExpression = MailComposer.FromAddressExpression.Compile();
                var compiledFromNameExpression    = MailComposer.FromNameExpression.Compile();

                var data             = new Dictionary <string, object>();
                data["failedToSend"] = SummeryStepViewModel.Result.SendFailed.Select(e =>
                {
                    return(new Dictionary <string, object>()
                    {
                        {
                            "ComposeValues", MailComposer.Compose(e.Key, null, addressCompiled, null, null,
                                                                  compiledFromAddressExpression,
                                                                  compiledFromNameExpression).Result
                        },
                        { "FailReason", e.Value.ErrorText }
                    });
                }).ToArray();
                data["numSuccess"] = SummeryStepViewModel.Result.SendSuccessfully;
                data["startedAt"]  = SummeryStepViewModel.CreatedAt;
                data["doneAt"]     = SummeryStepViewModel.FinishedAt;

                var template = await File.ReadAllTextAsync("SendReportTemplate.mdoc.html");
                Report       = (await(await Parser.ParseWithOptionsAsync(new ParserOptions(template)))
                                .CreateAndStringifyAsync(data));
            });
        }
Пример #2
0
 public UserController(
     IConfiguration configuration,
     CryptoProvider crypto,
     KeyManager keyManager,
     MongoDatabase mongo,
     Operator @operator,
     ILogger <UserController> logger,
     MailComposer composer
     ) : base(configuration, crypto, keyManager, mongo, @operator, logger)
 {
     _composer = composer;
 }
Пример #3
0
        public IActionResult RequestUserPassword([FromBody] string email)
        {
            string result;

            try
            {
                result = mLoginRepository.AddLoginRequest(email);
            }
            catch (UserException ex)
            {
                return(NotFound(new ApiResponse(null)
                {
                    Message = ex.Message
                }));
            }
            var url    = Url.Action(ValidateRequestEndpoint, values: new { token = result });
            var apiUrl = "/api" + url;
            var letter = MailComposer.ComposeChangePasswordLetter(apiUrl);

            // todo sending mail, for now just showing the letter, but by design apiUrl is to be returned
            return(Json(new ApiResponse(apiUrl)));
        }
Пример #4
0
        private async Task SendMails()
        {
            CreatedAt     = DateTime.Now;
            IsProcessing  = true;
            StopRequested = new CancellationTokenSource();

            var done = new CancellationTokenSource();
            var task = Task.Run(async() =>
            {
                while (!done.IsCancellationRequested)
                {
                    await Task.Delay(250, done.Token);
                    SendPropertyChanged(() => Progress);
                }
            }, done.Token);

            try
            {
                Result = await MailComposer.ComposeAndSend(this, StopRequested.Token);
            }
            catch (Exception e)
            {
                if (StopRequested.IsCancellationRequested)
                {
                    return;
                }

                var uiWorkflow  = IoC.Resolve <IUiWorkflow>();
                var textService = IoC.Resolve <ITextService>();

                await DialogCoordinator.Instance.ShowMessageAsync(uiWorkflow,
                                                                  textService.Compile("Application.Error.Title", CultureInfo.CurrentUICulture, out _).ToString(),
                                                                  textService.Compile("Summery.Error.Message", CultureInfo.CurrentUICulture, out _,
                                                                                      new FormattableArgument(e.Message, false)).ToString()
                                                                  );

                return;
            }
            finally
            {
                IsProcessing = false;
                done.Cancel();
            }

            FinishedAt = DateTime.Now;
            ViewModelAction(() =>
            {
                SendPropertyChanged(() => Progress);
                IsProcessed    = true;
                NextButtonText = new UiLocalizableString("Application.Navigation.Forward");
                Commands.Add(new MenuBarCommand(ResetCommand)
                {
                    Content = new UiLocalizableString("Summery.Commands.Reset"),
                    Tag     = "AfterButton.ResetCommand",
                    Dock    = Dock.Left
                });
                Commands.Add(new MenuBarCommand(SaveSendReportCommand)
                {
                    Content = new UiLocalizableString("Summery.Commands.Report"),
                    Tag     = "AfterButton.ReportCommand",
                });
            });
        }