Exemplo n.º 1
0
        public MailDomain ToMailDomain()
        {
            if (domainConfig["mode"] == "0")
            {
                MailDomain domain = new MailDomain();

                domain.Enabled = domainConfig["enabled"] == "1" ? true : false;
                domain.Name    = domainConfig["domain"];

                if (domainConfig["usemaxusers"] == "1")
                {
                    domain.MaxDomainUsers = Convert.ToInt32(domainConfig["maxusers"]);
                }

                if (domainConfig["usemaxmailinglists"] == "1")
                {
                    domain.MaxLists = Convert.ToInt32(domainConfig["maxmailinglists"]);
                }

                if (domainConfig["usecatchcalluser"] == "1")
                {
                    domain.CatchAllAccount = domainConfig["catchalluser"];
                }

                return(domain);
            }

            return(null);
        }
Exemplo n.º 2
0
        public void CreateDomain(MailDomain domain)
        {
            Tree      domains   = AMSHelper.GetDomainsConfig();
            AmsDomain amsDomain = new AmsDomain(domain.Name);

            if (amsDomain.Load(domains))
            {
                throw new Exception("Domain is already registered.");
            }

            amsDomain.Read(domain);

            if (!amsDomain.Save(domains))
            {
                throw new Exception("Couldn't create a domain.");
            }
        }
Exemplo n.º 3
0
        public void UpdateDomain(MailDomain domain)
        {
            Tree      config    = AMSHelper.GetDomainsConfig();
            AmsDomain amsDomain = new AmsDomain(domain.Name);

            if (amsDomain.Load(config))
            {
                amsDomain.Read(domain);

                if (!amsDomain.Save(config))
                {
                    throw new Exception("Couldn't update specified domain.");
                }
            }
            else
            {
                throw new Exception("Couldn't find specified domain.");
            }
        }
Exemplo n.º 4
0
 public override void ChangeServiceItemsState(ServiceProviderItem[] items, bool enabled)
 {
     foreach (ServiceProviderItem item in items)
     {
         if (item is MailDomain)
         {
             try
             {
                 MailDomain domain = GetDomain(item.Name);
                 domain.Enabled = enabled;
                 // update mail domain
                 UpdateDomain(domain);
             }
             catch (Exception ex)
             {
                 Log.WriteError(String.Format("Error switching '{0}' mail domain", item.Name), ex);
             }
         }
     }
 }
Exemplo n.º 5
0
        public void Read(MailDomain domain)
        {
            domainConfig["enabled"] = domain.Enabled ? "1" : "0";
            domainConfig["domain"]  = domain.Name;
            domainConfig["mode"]    = "0";

            domainConfig["usemaxusers"] = (domain.MaxDomainUsers == 0) ? "0" : "1";
            domainConfig["maxusers"]    = (domain.MaxDomainUsers == 0) ? "0" : domain.MaxDomainUsers.ToString();

            domainConfig["usemaxmailinglists"] = (domain.MaxLists == 0) ? "0" : "1";
            domainConfig["maxmailinglists"]    = (domain.MaxLists == 0) ? "0" : domain.MaxLists.ToString();

            if (!string.IsNullOrEmpty(domain.CatchAllAccount))
            {
                domainConfig["usecatchcalluser"] = "******";
                domainConfig["catchalluser"]     = domain.CatchAllAccount;
            }
            else
            {
                domainConfig["usecatchcalluser"] = "******";
                domainConfig["catchalluser"]     = string.Empty;
            }
        }