示例#1
0
        public bool Update(UpdateSettingsViewModel viewModel)
        {
            if (viewModel.ClientIdleTimeout < 0 ||
                viewModel.ReceiveTimeout < 0 ||
                viewModel.SendTimeout < 0)
            {
                return(false);
            }

            List <IPAddress> relayingIps = new List <IPAddress>();

            foreach (string str in viewModel.IpAddressesForRelaying)
            {
                relayingIps.Add(IPAddress.Parse(str));
            }

            CfgPara.SetClientIdleTimeout(viewModel.ClientIdleTimeout);
            CfgPara.SetReceiveTimeout(viewModel.ReceiveTimeout);
            CfgPara.SetSendTimeout(viewModel.SendTimeout);
            CfgPara.SetDefaultVirtualMtaGroupID(viewModel.DefaultVirtualMtaGroupID);
            CfgPara.SetEventForwardingHttpPostUrl(viewModel.EventUrl);
            CfgPara.SetDaysToKeepSmtpLogsFor(viewModel.DaysToKeepSmtpLogsFor);
            CfgPara.SetMaxTimeInQueueMinutes(viewModel.MaxTimeInQueueHours * 60);
            CfgPara.SetRetryIntervalBaseMinutes(viewModel.RetryIntervalBase);
            CfgRelayingPermittedIP.SetRelayingPermittedIPAddresses(relayingIps.ToArray());
            CfgPara.SetReturnPathLocalDomain(viewModel.ReturnPathLocalDomainID);

            var domains = CfgLocalDomains.GetLocalDomainsArray();

            CfgLocalDomains.ClearLocalDomains();
            foreach (string localDomain in viewModel.LocalDomains)
            {
                if (string.IsNullOrWhiteSpace(localDomain))
                {
                    continue;
                }
                LocalDomain ld = domains.SingleOrDefault(d => d.Hostname.Equals(localDomain, StringComparison.OrdinalIgnoreCase));
                if (ld == null)
                {
                    ld = new LocalDomain {
                        Hostname = localDomain.Trim()
                    }
                }
                ;
                CfgLocalDomains.Save(ld);
            }

            return(true);
        }
    }
示例#2
0
        public bool Update(int clientIdleTimeout, int receiveTimeout, int sendTimeout, int defaultVirtualMtaGroupID, string eventUrl, int daysToKeepSmtpLogsFor,
                           int maxTimeInQueueHours, int retryIntervalBase, string[] ipAddressesForRelaying, int returnPathLocalDomainID, string[] localDomains)
        {
            if (clientIdleTimeout < 0 ||
                receiveTimeout < 0 ||
                sendTimeout < 0)
            {
                return(false);
            }

            List <IPAddress> relayingIps = new List <IPAddress>();

            foreach (string str in ipAddressesForRelaying)
            {
                relayingIps.Add(IPAddress.Parse(str));
            }

            CfgPara.SetClientIdleTimeout(clientIdleTimeout);
            CfgPara.SetReceiveTimeout(receiveTimeout);
            CfgPara.SetSendTimeout(sendTimeout);
            CfgPara.SetDefaultVirtualMtaGroupID(defaultVirtualMtaGroupID);
            CfgPara.SetEventForwardingHttpPostUrl(eventUrl);
            CfgPara.SetDaysToKeepSmtpLogsFor(daysToKeepSmtpLogsFor);
            CfgPara.SetMaxTimeInQueueMinutes(maxTimeInQueueHours * 60);
            CfgPara.SetRetryIntervalBaseMinutes(retryIntervalBase);
            CfgRelayingPermittedIP.SetRelayingPermittedIPAddresses(relayingIps.ToArray());
            CfgPara.SetReturnPathLocalDomain(returnPathLocalDomainID);

            LocalDomainCollection domains = CfgLocalDomains.GetLocalDomainsArray();

            CfgLocalDomains.ClearLocalDomains();
            foreach (string localDomain in localDomains)
            {
                if (string.IsNullOrWhiteSpace(localDomain))
                {
                    continue;
                }
                LocalDomain ld = domains.SingleOrDefault(d => d.Hostname.Equals(localDomain, StringComparison.OrdinalIgnoreCase));
                if (ld == null)
                {
                    ld = new LocalDomain {
                        Hostname = localDomain.Trim()
                    }
                }
                ;
                CfgLocalDomains.Save(ld);
            }
            return(true);
        }
    }