public bool AccountExists(string mailboxName) { Tree users = AMSHelper.GetUsersConfig(); AmsMailbox accnt = new AmsMailbox(mailboxName); return(accnt.Load(users)); }
public MailGroup GetGroup(string groupName) { Tree config = AMSHelper.GetUsersConfig(); AmsMailbox amsGroup = new AmsMailbox(groupName); if (amsGroup.Load(config)) { amsGroup.LoadAccountConfig(); return(amsGroup.ToMailGroup()); } return(null); }
public MailAccount GetAccount(string mailboxName) { Tree config = AMSHelper.GetUsersConfig(); AmsMailbox amsMailbox = new AmsMailbox(mailboxName); if (amsMailbox.Load(config)) { amsMailbox.LoadAccountConfig(); return(amsMailbox.ToMailAccount()); } return(null); }
public bool GroupExists(string groupName) { Tree config = AMSHelper.GetUsersConfig(); AmsMailbox amsGroup = new AmsMailbox(groupName); if (amsGroup.Load(config)) { amsGroup.LoadAccountConfig(); return(amsGroup.IsMailGroup()); } return(false); }
public void CreateAccount(MailAccount mailbox) { Tree users = AMSHelper.GetUsersConfig(); AmsMailbox accnt = new AmsMailbox(mailbox.Name); if (accnt.Load(users)) { throw new Exception("Mailbox is already registered."); } accnt.Read(mailbox); if (!accnt.Save(users)) { throw new Exception("Couldn't create a mailbox."); } }
public void DeleteGroup(string groupName) { Tree config = AMSHelper.GetUsersConfig(); AmsMailbox amsGroup = new AmsMailbox(groupName); if (amsGroup.Load(config)) { if (!amsGroup.Delete(config)) { throw new Exception("Couldn't delete specified mail group."); } } else { throw new Exception("Couldn't find specified mail group."); } }
public void DeleteAccount(string mailboxName) { Tree config = AMSHelper.GetUsersConfig(); AmsMailbox amsMailbox = new AmsMailbox(mailboxName); if (amsMailbox.Load(config)) { if (!amsMailbox.Delete(config)) { throw new Exception("Couldn't delete a specified account."); } } else { throw new Exception("Couldn't load account settings."); } }
public void CreateGroup(MailGroup group) { Tree users = AMSHelper.GetUsersConfig(); AmsMailbox amsGroup = new AmsMailbox(group.Name); if (amsGroup.Load(users)) { throw new Exception("Mail group is already exists."); } amsGroup.Read(group); if (!amsGroup.Save(users)) { throw new Exception("Couldn't create a mail group."); } }
public static AmsMailbox[] GetMailboxes(Tree config, string domainName) { List <AmsMailbox> list = new List <AmsMailbox>(); foreach (TreeNode node in config.ChildNodes) { string account = node["user"]; string amsDomain = node["domain"]; if (string.Compare(amsDomain, domainName, true) == 0) { AmsMailbox mb = new AmsMailbox(string.Concat(account, "@", amsDomain)); mb.Load(node); mb.LoadAccountConfig(); list.Add(mb); } } return(list.ToArray()); }
public void UpdateGroup(MailGroup group) { Tree config = AMSHelper.GetUsersConfig(); AmsMailbox amsGroup = new AmsMailbox(group.Name); if (amsGroup.Load(config)) { amsGroup.LoadAccountConfig(); amsGroup.Read(group); if (!amsGroup.Save(config)) { throw new Exception("Couldn't update specified mail group."); } } else { throw new Exception("Couldn't find specified mail group."); } }
public void UpdateAccount(MailAccount mailbox) { Tree config = AMSHelper.GetUsersConfig(); AmsMailbox amsMailbox = new AmsMailbox(mailbox.Name); if (amsMailbox.Load(config)) { amsMailbox.LoadAccountConfig(); amsMailbox.Read(mailbox); if (!amsMailbox.Save(config)) { throw new Exception("Couldn't update specified mailbox."); } } else { throw new Exception("Couldn't find specified mailbox."); } }