public async Task <List <TicketIssueLevel_MailTemplateDTO> > SingleListMailTemplate([FromBody] TicketIssueLevel_MailTemplateFilterDTO TicketIssueLevel_MailTemplateFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            MailTemplateFilter MailTemplateFilter = new MailTemplateFilter();

            MailTemplateFilter.Skip      = 0;
            MailTemplateFilter.Take      = 20;
            MailTemplateFilter.OrderBy   = MailTemplateOrder.Id;
            MailTemplateFilter.OrderType = OrderType.ASC;
            MailTemplateFilter.Selects   = MailTemplateSelect.ALL;
            MailTemplateFilter.Id        = TicketIssueLevel_MailTemplateFilterDTO.Id;
            MailTemplateFilter.Code      = TicketIssueLevel_MailTemplateFilterDTO.Code;
            MailTemplateFilter.Name      = TicketIssueLevel_MailTemplateFilterDTO.Name;
            MailTemplateFilter.Content   = TicketIssueLevel_MailTemplateFilterDTO.Content;

            List <MailTemplate> MailTemplates = await MailTemplateService.List(MailTemplateFilter);

            List <TicketIssueLevel_MailTemplateDTO> TicketIssueLevel_MailTemplateDTOs = MailTemplates
                                                                                        .Select(x => new TicketIssueLevel_MailTemplateDTO(x)).ToList();

            return(TicketIssueLevel_MailTemplateDTOs);
        }
        private void SetTemplateExecute(object sender)
        {
            SimpleWorkAsync(async() =>
            {
                var uiWorkflow    = IoC.Resolve <IUiWorkflow>();
                var textService   = IoC.Resolve <ITextService>();
                var loadingScreen = await DialogCoordinator.Instance.ShowProgressAsync(uiWorkflow,
                                                                                       textService.Compile("Summery.Progress.ObtainTemplate.Title", CultureInfo.CurrentUICulture, out _).ToString(),
                                                                                       textService.Compile("Summery.Progress.ObtainTemplate.Message", CultureInfo.CurrentUICulture, out _).ToString()
                                                                                       );
                loadingScreen.SetIndeterminate();

                string newTemplate;
                try
                {
                    newTemplate = (await MailTemplateService.ObtainTemplate(SelectedTemplate));
                }
                catch (Exception e)
                {
                    await loadingScreen.CloseAsync();
                    await DialogCoordinator.Instance.ShowMessageAsync(uiWorkflow,
                                                                      textService.Compile("Application.Error.Title", CultureInfo.CurrentUICulture, out _).ToString(),
                                                                      textService.Compile("Summery.Error.Message", CultureInfo.CurrentUICulture, out _,
                                                                                          new FormattableArgument(SelectedTemplate.Header, false),
                                                                                          new FormattableArgument(e.Message, false)
                                                                                          ).ToString()
                                                                      );

                    return;
                }

                await loadingScreen.CloseAsync();
                if (newTemplate != null)
                {
                    if (((string.IsNullOrWhiteSpace(Template) == false && Template != newTemplate)
                         &&
                         (await DialogCoordinator.Instance.ShowMessageAsync(uiWorkflow,
                                                                            textService.Compile("Application.ConfirmQuestion.Title", CultureInfo.CurrentUICulture,
                                                                                                out _).ToString(),
                                                                            textService.Compile("Summery.Template.Confirm.Message", CultureInfo.CurrentUICulture,
                                                                                                out _).ToString(),
                                                                            MessageDialogStyle.AffirmativeAndNegative
                                                                            )) == MessageDialogResult.Negative))
                    {
                        return;
                    }
                    Template = newTemplate;
                }
            });
        }
Ejemplo n.º 3
0
        public double?GetSendedPercent()
        {
            if (CurrentUser == null)
            {
                return(null);
            }
            var template =
                MailTemplateService.GetAll().BySysName(MailTemplates.MailList);
            var type        = GetType(template);
            var queryable   = AddFilter(UserService.GetAll(), type);
            var allCount    = queryable.Count();
            var sendedCount = queryable.Where(x => x.UserID <= CurrentUser.GetValueOrDefault()).Count();

            return((sendedCount * 100.0) / allCount);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Send a mail when the user's password has been reset.
        /// </summary>
        ///
        /// <param name="user">
        /// User instance.
        /// </param>
        ///
        /// <param name="newPassword">
        /// New password.
        /// </param>
        private static async Task SendMailOnPasswordResetAsync(User user, string newPassword)
        {
            var templateService = new MailTemplateService("OnPasswordReset");

            var tokens = new Dictionary <string, object>()
            {
                { "%User.Username%", user.Username },
                { "%User.Email%", user.Email },
                { "%User.NewPassword%", newPassword },
                { "%User.PasswordQuestion%", user.PasswordQuestion },
                { "%User.PasswordResponse%", string.Concat(user.PasswordResponse[0], "*******") },
            };

            templateService.Load(user.Culture, tokens);

            await templateService.SendByMailAsync(user.Email, new SmtpServiceOptions { IsHtmlBody = true });
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Send a mail when the user's account has been created.
        /// </summary>
        ///
        /// <param name="user">
        /// User instance.
        /// </param>
        private static async Task SendMailOnUserCreatedAsync(User user)
        {
            var templateService = new MailTemplateService("OnUserCreated");             // Load WebServices\App_Data\MailTemplates\OnUserCreated.xml

            var tokens = new Dictionary <string, object>()
            {
                { "%User.Username%", user.Username },
                { "%User.Email%", user.Email },
                { "%User.Password%", user.Password },
                { "%User.PasswordQuestion%", user.PasswordQuestion },
                { "%User.PasswordResponse%", string.Concat(user.PasswordResponse[0], "*******") },
            };

            templateService.Load(user.Culture, tokens);

            await templateService.SendByMailAsync(user.Email, new SmtpServiceOptions { IsHtmlBody = true });
        }
Ejemplo n.º 6
0
        public SimpleUtils.Common.Tuple <MailTemplate, MailListType> GetTemplate()
        {
            var template =
                MailTemplateService.GetAll().BySysName(MailTemplates.MailList);

            ReplaceNewsBlocks(template);
            var dataLoadOptions = new DataLoadOptions();

            dataLoadOptions.LoadWith <Group>(g => g.BranchOffice);
            dataLoadOptions.LoadWith <Group>(g => g.Course);
            dataLoadOptions.LoadWith <Group>(g => g.DayShift);
            dataLoadOptions.LoadWith <BranchOffice>(g => g.City);
            GroupService.Context.LoadOptions = dataLoadOptions;
            ReplaceGroupBlocks(template);
            var bestGroupsBlock = GetGroupsBlock(true, null);

            template.Description = Regex.Replace(template.Description, BestGroupsPattern,
                                                 bestGroupsBlock);
            var mailListType = GetType(template);

            return(Tuple.New(template, mailListType));
        }
Ejemplo n.º 7
0
        static EmailLogic()
        {
            mailTemplateService = ObjectBuilder <MailTemplateService> .Build();

            mapper = MapBuilder.Build();
        }