Esempio n. 1
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());
        }
        //
        // 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)));
        }
Esempio n. 3
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)));
        }