Ejemplo n.º 1
0
 public void ProcessAccount(Guid accountId, Guid?componentId = null, Guid?userId = null)
 {
     using (var dbContext = new DatabasesContext())
     {
         var accountDbContext = dbContext.GetAccountDbContext(accountId);
         ProcessAccount(accountId, accountDbContext, Logger, componentId, userId);
     }
 }
 public string GetComponentName()
 {
     if (string.IsNullOrEmpty(ComponentName))
     {
         if (ComponentId.HasValue)
         {
             using (var databasesContext = new DatabasesContext())
             {
                 var context    = databasesContext.GetAccountDbContext(AccountId); // todo нужно брать из текущего пользователя
                 var repository = context.GetComponentRepository();
                 var component  = repository.GetById(ComponentId.Value);
                 ComponentName = component.DisplayName;
             }
         }
     }
     return(ComponentName);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Отправка уведомления админам аккаунта
        /// </summary>
        public static void NotifyAccountAdmins(Guid accountId, string subject, string body, DatabasesContext dbContext)
        {
            var accountContext = dbContext.GetAccountDbContext(accountId);
            var userRepository = accountContext.GetUserRepository();

            var emailRepository = accountContext.GetSendEmailCommandRepository();

            var admins = userRepository.QueryAll().Where(x => x.Roles.Any(y => y.RoleId == RoleId.AccountAdministrators)).ToList();

            foreach (var admin in admins)
            {
                var letter = HtmlToLetter(body, admin);
                var emails = admin.UserContacts.Where(t => t.Type == UserContactType.Email).Select(t => t.Value).Distinct().ToList();
                foreach (var email in emails)
                {
                    emailRepository.Add(email, subject, letter, accountId);
                }
            }
        }