public bool AccountExists(string mailboxName) { Tree users = AMSHelper.GetUsersConfig(); AmsMailbox accnt = new AmsMailbox(mailboxName); return(accnt.Load(users)); }
public MailAccount[] GetAccounts(string domainName) { Tree config = AMSHelper.GetUsersConfig(); List <MailAccount> accounts = new List <MailAccount>(); AmsMailbox[] mbList = AmsMailbox.GetMailboxes(config, domainName); foreach (AmsMailbox mb in mbList) { accounts.Add(mb.ToMailAccount()); } return(accounts.ToArray()); }
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 MailGroup[] GetGroups(string domainName) { List <MailGroup> groups = new List <MailGroup>(); Tree config = AMSHelper.GetUsersConfig(); AmsMailbox[] amsGroups = AmsMailbox.GetMailGroups(config, domainName); foreach (AmsMailbox amsGroup in amsGroups) { groups.Add(amsGroup.ToMailGroup()); } return(groups.ToArray()); }
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 bool Delete(Tree config) { if (config.ChildNodes.Contains(domainConfig)) { config.ChildNodes.Remove(domainConfig); } Tree usersConfig = AMSHelper.GetUsersConfig(); List <TreeNode> nodesToDelete = new List <TreeNode>(); foreach (TreeNode node in usersConfig.ChildNodes) { if (string.Compare(node["domain"], domainName, true) == 0) { nodesToDelete.Add(node); } } while (nodesToDelete.Count > 0) { usersConfig.ChildNodes.Remove(nodesToDelete[0]); nodesToDelete.RemoveAt(0); } Tree listsConfig = AMSHelper.GetMailListsConfig(); foreach (TreeNode node in listsConfig.ChildNodes) { if (string.Compare(node["domain"], domainName, true) == 0) { nodesToDelete.Add(node); } } while (nodesToDelete.Count > 0) { listsConfig.ChildNodes.Remove(nodesToDelete[0]); nodesToDelete.RemoveAt(0); } return(AMSHelper.RemoveDomain(domainName) && AMSHelper.SetUsersConfig(usersConfig) && AMSHelper.SetMailListsConfig(listsConfig) && AMSHelper.SetDomainsConfig(config)); }
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."); } }