public void PortalRenameNotify(String oldVirtualRootPath)
        {
            var tenant = CoreContext.TenantManager.GetCurrentTenant();

            var users = CoreContext.UserManager.GetUsers()
                        .Where(u => u.ActivationStatus.HasFlag(EmployeeActivationStatus.Activated));

            ThreadPool.QueueUserWorkItem(_ =>
            {
                try
                {
                    CoreContext.TenantManager.SetCurrentTenant(tenant);

                    foreach (var u in users)
                    {
                        var culture = string.IsNullOrEmpty(u.CultureName) ? tenant.GetCulture() : u.GetCulture();
                        Thread.CurrentThread.CurrentCulture   = culture;
                        Thread.CurrentThread.CurrentUICulture = culture;

                        client.SendNoticeToAsync(
                            Actions.PortalRename,
                            null,
                            new[] { StudioNotifyHelper.ToRecipient(u.ID) },
                            new[] { EMailSenderName },
                            null,
                            new TagValue(Tags.PortalUrl, oldVirtualRootPath),
                            new TagValue(Tags.UserDisplayName, u.DisplayUserName()));
                    }
                }
                catch (Exception ex)
                {
                    LogManager.GetLogger("ASC.Notify").Error(ex);
                }
            });
        }
 public void SendMsgBackupCompleted(Guid userId, string link)
 {
     client.SendNoticeToAsync(
         Actions.BackupCreated,
         null,
         new[] { StudioNotifyHelper.ToRecipient(userId) },
         new[] { EMailSenderName },
         null,
         new TagValue(Tags.OwnerName, CoreContext.UserManager.GetUsers(userId).DisplayUserName()));
 }
 public void SendMsgRemoveUserDataFailed(Guid recipientId, Guid fromUserId, string fromUserName, string message)
 {
     client.SendNoticeToAsync(
         Actions.RemoveUserDataFailed,
         null,
         new[] { StudioNotifyHelper.ToRecipient(recipientId) },
         new[] { EMailSenderName },
         null,
         new TagValue(Tags.UserName, DisplayUserSettings.GetFullUserName(recipientId)),
         new TagValue(Tags.FromUserName, fromUserName.HtmlEncode()),
         new TagValue(Tags.FromUserLink, GetUserProfileLink(fromUserId)),
         new TagValue(Tags.Message, message));
 }
 public void SendMsgReassignsCompleted(Guid recipientId, UserInfo fromUser, UserInfo toUser)
 {
     client.SendNoticeToAsync(
         Actions.ReassignsCompleted,
         null,
         new[] { StudioNotifyHelper.ToRecipient(recipientId) },
         new[] { EMailSenderName },
         null,
         new TagValue(Tags.UserName, DisplayUserSettings.GetFullUserName(recipientId)),
         new TagValue(Tags.FromUserName, fromUser.DisplayUserName()),
         new TagValue(Tags.FromUserLink, GetUserProfileLink(fromUser.ID)),
         new TagValue(Tags.ToUserName, toUser.DisplayUserName()),
         new TagValue(Tags.ToUserLink, GetUserProfileLink(toUser.ID)));
 }
 public void SendMsgRemoveUserDataCompleted(Guid recipientId, Guid fromUserId, string fromUserName, long docsSpace, long crmSpace, long mailSpace, long talkSpace)
 {
     client.SendNoticeToAsync(
         CoreContext.Configuration.CustomMode ? Actions.RemoveUserDataCompletedCustomMode : Actions.RemoveUserDataCompleted,
         null,
         new[] { StudioNotifyHelper.ToRecipient(recipientId) },
         new[] { EMailSenderName },
         null,
         new TagValue(Tags.UserName, DisplayUserSettings.GetFullUserName(recipientId)),
         new TagValue(Tags.FromUserName, fromUserName.HtmlEncode()),
         new TagValue(Tags.FromUserLink, GetUserProfileLink(fromUserId)),
         new TagValue("DocsSpace", FileSizeComment.FilesSizeToString(docsSpace)),
         new TagValue("CrmSpace", FileSizeComment.FilesSizeToString(crmSpace)),
         new TagValue("MailSpace", FileSizeComment.FilesSizeToString(mailSpace)),
         new TagValue("TalkSpace", FileSizeComment.FilesSizeToString(talkSpace)));
 }
        public void SendMsgRestoreCompleted(bool notifyAllUsers)
        {
            var owner = CoreContext.UserManager.GetUsers(CoreContext.TenantManager.GetCurrentTenant().OwnerId);

            var users =
                notifyAllUsers
                    ? CoreContext.UserManager.GetUsers(EmployeeStatus.Active).Select(u => StudioNotifyHelper.ToRecipient(u.ID)).ToArray()
                    : new[] { StudioNotifyHelper.ToRecipient(owner.ID) };

            client.SendNoticeToAsync(
                Actions.RestoreCompleted,
                null,
                users,
                new[] { EMailSenderName },
                null,
                new TagValue(Tags.OwnerName, owner.DisplayUserName()));
        }
        private void SendStorageEncryptionNotify(INotifyAction action, bool notifyAdminsOnly, string serverRootPath)
        {
            var users = notifyAdminsOnly
                    ? CoreContext.UserManager.GetUsersByGroup(Constants.GroupAdmin.ID)
                    : CoreContext.UserManager.GetUsers().Where(u => u.ActivationStatus.HasFlag(EmployeeActivationStatus.Activated));

            foreach (var u in users)
            {
                client.SendNoticeToAsync(
                    action,
                    null,
                    new[] { StudioNotifyHelper.ToRecipient(u.ID) },
                    new[] { EMailSenderName },
                    null,
                    new TagValue(Tags.UserName, u.FirstName.HtmlEncode()),
                    new TagValue(Tags.PortalUrl, serverRootPath),
                    new TagValue(Tags.ControlPanelUrl, GetControlPanelUrl(serverRootPath)));
            }
        }
        private void MigrationNotify(INotifyAction action, string region, string url, bool notify)
        {
            var users = CoreContext.UserManager.GetUsers()
                        .Where(u => notify ? u.ActivationStatus.HasFlag(EmployeeActivationStatus.Activated) : u.IsOwner())
                        .Select(u => StudioNotifyHelper.ToRecipient(u.ID))
                        .ToArray();

            if (users.Any())
            {
                client.SendNoticeToAsync(
                    action,
                    null,
                    users,
                    new[] { EMailSenderName },
                    null,
                    new TagValue(Tags.RegionName, TransferResourceHelper.GetRegionDescription(region)),
                    new TagValue(Tags.PortalUrl, url));
            }
        }
        private void MigrationNotify(INotifyAction action, string region, string url, bool notify, int?toTenantId = null)
        {
            var users = CoreContext.UserManager.GetUsers()
                        .Where(u => notify ? u.ActivationStatus.HasFlag(EmployeeActivationStatus.Activated) : u.IsOwner());

            if (users.Any())
            {
                var args = CreateArgs(region, url);
                if (action == Actions.MigrationPortalSuccessV115)
                {
                    foreach (var user in users)
                    {
                        var currentArgs = new List <ITagValue>(args);

                        var newTenantId     = toTenantId.HasValue ? toTenantId.Value : CoreContext.TenantManager.GetCurrentTenant().TenantId;
                        var hash            = CoreContext.Authentication.GetUserPasswordStamp(user.ID).ToString("s");
                        var confirmationUrl = url + "/" + CommonLinkUtility.GetConfirmationUrlRelative(newTenantId, user.Email, ConfirmType.PasswordChange, hash);

                        Func <string> greenButtonText = () => WebstudioNotifyPatternResource.ButtonSetPassword;
                        currentArgs.Add(TagValues.GreenButton(greenButtonText, confirmationUrl));

                        client.SendNoticeToAsync(
                            action,
                            null,
                            new IRecipient[] { user },
                            new[] { EMailSenderName },
                            null,
                            currentArgs.ToArray());
                    }
                }
                else
                {
                    client.SendNoticeToAsync(
                        action,
                        null,
                        users.Select(u => StudioNotifyHelper.ToRecipient(u.ID)).ToArray(),
                        new[] { EMailSenderName },
                        null,
                        args.ToArray());
                }
            }
        }