Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the Outbound Rules for the specified destination MX and optionally IP Address.
        /// </summary>
        /// <param name="mxRecord">MXRecord for the destination MX.</param>
        /// <param name="mtaIpAddress">Outbound IP Address</param>
        /// <param name="mxPatternID">OUT: the ID of MxPattern that caused match.</param>
        /// <returns></returns>
        public static IList <OutboundRule> GetRules(MXRecord mxRecord, VirtualMTA mtaIpAddress, out int mxPatternID)
        {
            // Get the data from the database. This needs to be cleverer and reload every x minutes.
            if (OutboundRuleManager._MXPatterns == null)
            {
                OutboundRuleManager._MXPatterns = OutboundRuleDB.GetOutboundRulePatterns();
            }
            if (OutboundRuleManager._Rules == null)
            {
                OutboundRuleManager._Rules = OutboundRuleDB.GetOutboundRules();
            }

            int patternID = OutboundRuleManager.GetMxPatternID(mxRecord, mtaIpAddress);

            mxPatternID = patternID;
            return((from r in OutboundRuleManager._Rules
                    where r.OutboundMxPatternID == patternID
                    select r).ToList());
        }
Exemplo n.º 3
0
        //
        // GET: /OutboundRules/Edit?id=
        public ActionResult Edit(int id = WebInterfaceParameters.OUTBOUND_RULES_NEW_PATTERN_ID)
        {
            OutboundMxPattern    pattern = null;
            IList <OutboundRule> rules   = null;

            if (id != WebInterfaceParameters.OUTBOUND_RULES_NEW_PATTERN_ID)
            {
                pattern = OutboundRuleDB.GetOutboundRulePatterns().Single(p => p.ID == id);
                rules   = OutboundRuleDB.GetOutboundRules().Where(r => r.OutboundMxPatternID == id).ToList();
            }
            else
            {
                pattern = new OutboundMxPattern();
                rules   = OutboundRuleDB.GetOutboundRules().Where(r => r.OutboundMxPatternID == MtaParameters.OUTBOUND_RULES_DEFAULT_PATTERN_ID).ToList();
            }


            IList <VirtualMTA> vMtas = VirtualMtaDB.GetVirtualMtas();

            return(View(new OutboundRuleModel(rules, pattern, vMtas)));
        }
Exemplo n.º 4
0
        //
        // GET: /OutboundRules/Edit?id=
        public ActionResult Edit(int id = WebInterfaceParameters.OUTBOUND_RULES_NEW_PATTERN_ID)
        {
            OutboundMxPattern      pattern = null;
            OutboundRuleCollection rules   = null;

            if (id != WebInterfaceParameters.OUTBOUND_RULES_NEW_PATTERN_ID)
            {
                pattern = OutboundRuleDB.GetOutboundRulePatterns().Single(p => p.ID == id);
                rules   = new OutboundRuleCollection(OutboundRuleDB.GetOutboundRules().Where(r => r.OutboundMxPatternID == id).ToArray());
            }
            else
            {
                pattern = new OutboundMxPattern();
                rules   = new OutboundRuleCollection(OutboundRuleDB.GetOutboundRules().Where(r => r.OutboundMxPatternID == MantaMTA.Core.MtaParameters.OUTBOUND_RULES_DEFAULT_PATTERN_ID));
            }


            VirtualMTACollection vMtas = MantaMTA.Core.DAL.VirtualMtaDB.GetVirtualMtas();

            return(View(new OutboundRuleModel(rules, pattern, vMtas)));
        }
Exemplo n.º 5
0
 //
 // GET: /OutboundRules/
 public ActionResult Index()
 {
     return(View(OutboundRuleDB.GetOutboundRulePatterns()));
 }