Exemple #1
0
        public void Read(MailList maillist)
        {
            nodeConfig["domain"]                   = AmsMailbox.GetDomainName(maillist.Name);
            nodeConfig["enabled"]                  = maillist.Enabled ? "1" : "0";
            nodeConfig["user"]                     = AmsMailbox.GetAccountName(maillist.Name);
            nodeConfig["triggertext"]              = "TRIGGER";
            nodeConfig["usetriggeredreplyto"]      = "0";
            nodeConfig["triggeredreplyto"]         = string.Empty;
            nodeConfig["usetriggeredfrom"]         = string.Empty;
            nodeConfig["triggeredfrom"]            = string.Empty;
            nodeConfig["maxtriggersperday"]        = "100";
            nodeConfig["useonlymemberscantrigger"] = "0";
            nodeConfig["maxaddresses"]             = "5000";

            // copy mail list members
            TreeNode addresses = listConfig.ChildNodes["addresses"];

            if (addresses == null)
            {
                addresses          = new TreeNode();
                addresses.NodeName = "addresses";
                listConfig.ChildNodes.Add(addresses);
            }
            addresses.ChildNodes.Clear();

            foreach (string member in maillist.Members)
            {
                TreeNode node = new TreeNode(addresses);
                node.NodeValue = member;
                addresses.ChildNodes.Add(node);
            }
        }
Exemple #2
0
        public static bool SetAccountDelivery(Tree config, string mailboxName)
        {
            string account        = AmsMailbox.GetAccountName(mailboxName);
            string domain         = AmsMailbox.GetDomainName(mailboxName);
            string deliveryConfig = string.Format(AccountDeliveryFile, domain, account);

            return(SaveAmsConfigurationFile(config, deliveryConfig));
        }
Exemple #3
0
        public static Tree GetAccountDelivery(string mailboxName)
        {
            string account        = AmsMailbox.GetAccountName(mailboxName);
            string domain         = AmsMailbox.GetDomainName(mailboxName);
            string deliveryConfig = string.Format(AccountDeliveryFile, domain, account);

            return(ReadAmsConfigurationFile(deliveryConfig));
        }
Exemple #4
0
        public static bool SetMailingListConfig(Tree config, string maillistName)
        {
            string domain     = AmsMailbox.GetDomainName(maillistName);
            string account    = AmsMailbox.GetAccountName(maillistName);
            string listConfig = Path.Combine(AMSLocation, string.Format(MailListConfigFile, domain, account));

            return(SaveAmsConfigurationFile(config, listConfig));
        }
Exemple #5
0
        public bool Save(Tree config)
        {
            if (!config.ChildNodes.Contains(nodeConfig))
            {
                nodeConfig["file"] = string.Format(AMSHelper.MailListConfigFile, AmsMailbox.GetDomainName(maillistName), AmsMailbox.GetAccountName(maillistName));
                config.ChildNodes.Add(nodeConfig);
            }

            return(AMSHelper.SetMailListsConfig(config) &&
                   AMSHelper.SetMailingListConfig(listConfig, maillistName));
        }
Exemple #6
0
        public bool Load(TreeNode configNode)
        {
            string account = AmsMailbox.GetAccountName(maillistName);
            string domain  = AmsMailbox.GetDomainName(maillistName);

            string amsUser   = configNode["user"];
            string amsDomain = configNode["domain"];

            if (string.Compare(amsUser, account, true) == 0 &&
                string.Compare(amsDomain, domain, true) == 0)
            {
                nodeConfig = configNode;
                return(true);
            }

            return(false);
        }
Exemple #7
0
        public static bool RemoveMailList(string maillistName)
        {
            bool   succeed        = false;
            string account        = AmsMailbox.GetAccountName(maillistName);
            string domain         = AmsMailbox.GetDomainName(maillistName);
            string maillistConfig = Path.Combine(AMSLocation, string.Format(MailListConfigFile, domain, account));

            try
            {
                File.Delete(maillistConfig);
                succeed = true;
            }
            catch (Exception ex)
            {
                Log.WriteError(ex.Message, ex);
            }

            return(succeed);
        }
Exemple #8
0
        public static bool RemoveAccount(string mailboxName)
        {
            bool   succeed    = false;
            string account    = AmsMailbox.GetAccountName(mailboxName);
            string domain     = AmsMailbox.GetDomainName(mailboxName);
            string accountDir = Path.Combine(AMSLocation, string.Format(AccountFolder, domain, account));

            try
            {
                Directory.Delete(accountDir, true);
                succeed = true;
            }
            catch (Exception ex)
            {
                Log.WriteError(ex);
            }

            return(succeed);
        }
Exemple #9
0
        public bool Load(Tree config)
        {
            string account = AmsMailbox.GetAccountName(maillistName);
            string domain  = AmsMailbox.GetDomainName(maillistName);

            foreach (TreeNode node in config.ChildNodes)
            {
                string amsUser   = node["user"];
                string amsDomain = node["domain"];

                if (string.Compare(amsUser, account, true) == 0 &&
                    string.Compare(amsDomain, domain, true) == 0)
                {
                    nodeConfig = node;
                    return(true);
                }
            }

            return(false);
        }