예제 #1
0
        public bool Update(int patternID, string name, string description, int?virtualMTA, OutboundMxPatternType type, string patternValue, int maxConnections, int maxMessagesConn, int maxMessagesHour)
        {
            if (virtualMTA == -1)
            {
                virtualMTA = null;
            }

            OutboundMxPattern pattern = null;

            if (patternID == WebInterfaceLib.WebInterfaceParameters.OUTBOUND_RULES_NEW_PATTERN_ID)
            {
                pattern = new OutboundMxPattern();
            }
            else
            {
                pattern = MantaMTA.Core.DAL.OutboundRuleDB.GetOutboundRulePatterns().SingleOrDefault(p => p.ID == patternID);
            }
            if (pattern == null)
            {
                return(false);
            }

            pattern.Description = description.Trim();
            pattern.LimitedToOutboundIpAddressID = virtualMTA;
            pattern.Name  = name.Trim();
            pattern.Type  = type;
            pattern.Value = patternValue;
            pattern.ID    = OutboundRuleWebManager.Save(pattern);

            OutboundRuleWebManager.Save(new OutboundRule(pattern.ID, OutboundRuleType.MaxConnections, maxConnections.ToString()));
            OutboundRuleWebManager.Save(new OutboundRule(pattern.ID, OutboundRuleType.MaxMessagesConnection, maxMessagesConn.ToString()));
            OutboundRuleWebManager.Save(new OutboundRule(pattern.ID, OutboundRuleType.MaxMessagesPerHour, maxMessagesHour.ToString()));

            return(true);
        }
예제 #2
0
        public bool Update(UpdateOutboundRuleViewModel viewModel)
        {
            if (viewModel.VirtualMTA == -1)
            {
                viewModel.VirtualMTA = null;
            }

            OutboundMxPattern pattern = null;

            if (viewModel.PatternID == WebInterfaceParameters.OUTBOUND_RULES_NEW_PATTERN_ID)
            {
                pattern = new OutboundMxPattern();
            }
            else
            {
                pattern = OutboundRuleDB.GetOutboundRulePatterns().SingleOrDefault(p => p.ID == viewModel.PatternID);
            }
            if (pattern == null)
            {
                return(false);
            }

            pattern.Description = viewModel.Description.Trim();
            pattern.LimitedToOutboundIpAddressID = viewModel.VirtualMTA;
            pattern.Name  = viewModel.Name.Trim();
            pattern.Type  = viewModel.Type;
            pattern.Value = viewModel.PatternValue;
            pattern.ID    = OutboundRuleWebManager.Save(pattern);

            OutboundRuleWebManager.Save(new OutboundRule(pattern.ID, OutboundRuleType.MaxConnections, viewModel.MaxConnections.ToString()));
            OutboundRuleWebManager.Save(new OutboundRule(pattern.ID, OutboundRuleType.MaxMessagesConnection, viewModel.MaxMessagesConn.ToString()));
            OutboundRuleWebManager.Save(new OutboundRule(pattern.ID, OutboundRuleType.MaxMessagesPerHour, viewModel.MaxMessagesHour.ToString()));

            return(true);
        }