public MailSignatureData SaveSignature(int mailboxId, string html, bool isActive) { if (!string.IsNullOrEmpty(html)) { var imagesReplacer = new StorageManager(Tenant, User, Log); html = imagesReplacer.ChangeEditorImagesLinks(html, mailboxId); } CacheEngine.Clear(User); var signature = new MailboxSignature { MailboxId = mailboxId, Tenant = Tenant, Html = html, IsActive = isActive }; using (var daoFactory = new DaoFactory()) { var result = daoFactory .CreateMailboxSignatureDao(Tenant, User) .SaveSignature(signature); if (result <= 0) { throw new Exception("Save failed"); } } return(ToMailMailSignature(signature)); }
public MailAutoreply UpdateAutoreply(int mailboxId, bool turnOn, bool onlyContacts, bool turnOnToDate, DateTime fromDate, DateTime toDate, string subject, string html) { if (fromDate == DateTime.MinValue) { throw new ArgumentException("Invalid parameter", "from"); } if (turnOnToDate && toDate == DateTime.MinValue) { throw new ArgumentException("Invalid parameter", "to"); } if (turnOnToDate && toDate < fromDate) { throw new ArgumentException("Wrong date interval, toDate < fromDate", "to, from"); } if (String.IsNullOrEmpty(html)) { throw new ArgumentException("Invalid parameter", "html"); } var imagesReplacer = new StorageManager(TenantId, Username); html = imagesReplacer.ChangeEditorImagesLinks(html, mailboxId); MailBoxManager.CachedAccounts.Clear(Username); return(MailBoxManager.UpdateOrCreateMailboxAutoreply(mailboxId, Username, TenantId, turnOn, onlyContacts, turnOnToDate, fromDate, toDate, subject, html)); }
public MailSignature UpdateSignature(int mailbox_id, string html, bool is_active) { if (!string.IsNullOrEmpty(html)) { var imagesReplacer = new StorageManager(TenantId, Username); html = imagesReplacer.ChangeEditorImagesLinks(html, mailbox_id); } MailBoxManager.CachedAccounts.Clear(Username); return(MailBoxManager.UpdateOrCreateMailboxSignature(mailbox_id, Username, TenantId, html, is_active)); }
public MailAutoreplyData SaveAutoreply(int mailboxId, bool turnOn, bool onlyContacts, bool turnOnToDate, DateTime fromDate, DateTime toDate, string subject, string html) { if (fromDate == DateTime.MinValue) { throw new ArgumentException(@"Invalid parameter", "fromDate"); } if (turnOnToDate && toDate == DateTime.MinValue) { throw new ArgumentException(@"Invalid parameter", "toDate"); } if (turnOnToDate && toDate < fromDate) { throw new ArgumentException(@"Wrong date interval, toDate < fromDate", "fromDate"); } if (string.IsNullOrEmpty(html)) { throw new ArgumentException(@"Invalid parameter", "html"); } var imagesReplacer = new StorageManager(TenantId, UserId); html = imagesReplacer.ChangeEditorImagesLinks(html, mailboxId); var autoreply = new MailboxAutoreply { MailboxId = mailboxId, Tenant = TenantId, FromDate = fromDate, ToDate = toDate, Html = html, OnlyContacts = onlyContacts, TurnOnToDate = turnOnToDate, Subject = subject, TurnOn = turnOn }; using (var daoFactory = new DaoFactory()) { var daoMailbox = daoFactory.CreateMailboxDao(); if (!daoMailbox.CanAccessTo( new СoncreteUserMailboxExp(mailboxId, TenantId, UserId))) { throw new AccessViolationException("Mailbox is not owned by user."); } var result = daoFactory.CreateMailboxAutoreplyDao(TenantId, UserId).SaveAutoreply(autoreply); if (result <= 0) { throw new InvalidOperationException(); } } var resp = new MailAutoreplyData(autoreply.MailboxId, autoreply.Tenant, autoreply.TurnOn, autoreply.OnlyContacts, autoreply.TurnOnToDate, autoreply.FromDate, autoreply.ToDate, autoreply.Subject, autoreply.Html); return(resp); }