Beispiel #1
0
        /// <summary>
        /// Gets all of the MantaEvents from the database.
        /// </summary>
        /// <returns>Collection of MantaEvent objects.</returns>
        public static IList <MantaEvent> GetEvents()
        {
            using (SqlConnection conn = MantaDB.GetSqlConnection())
            {
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = @"SELECT [evt].*, [bnc].evn_bounceCode_id, [bnc].evn_bounceEvent_message, [bnc].evn_bounceType_id
FROM man_evn_event AS [evt]
LEFT JOIN man_evn_bounceEvent AS [bnc] ON [evt].evn_event_id = [bnc].evn_event_id";
                return(DataRetrieval.GetCollectionFromDatabase <MantaEvent> (cmd, CreateAndFillMantaEventFromRecord));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets all of the Virtual MTA Groups from the database; doesn't include Virtual MTA objects.
        /// </summary>
        /// <returns></returns>
        public static IList <VirtualMtaGroup> GetVirtualMtaGroups()
        {
            using (SqlConnection conn = MantaDB.GetSqlConnection())
            {
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = @"
SELECT *
FROM man_ip_group";
                return(DataRetrieval.GetCollectionFromDatabase <VirtualMtaGroup>(cmd, CreateAndFillVirtualMtaGroup));
            }
        }
Beispiel #3
0
        /// <summary>
        /// Gets an array of the local domains from the database.
        /// All domains are toLowered!
        /// </summary>
        /// <returns></returns>
        public static IList <LocalDomain> GetLocalDomainsArray()
        {
            using (SqlConnection conn = MantaDB.GetSqlConnection())
            {
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = @"
SELECT *
FROM man_cfg_localDomain";
                return(DataRetrieval.GetCollectionFromDatabase <LocalDomain> (cmd, CreateAndFillLocalDomainFromRecord));
            }
        }
Beispiel #4
0
        /// <summary>
        /// Get the Outbound Rules from the database.
        /// </summary>
        /// <returns></returns>
        public static IList <OutboundRule> GetOutboundRules()
        {
            using (SqlConnection conn = MantaDB.GetSqlConnection())
            {
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = @"
SELECT *
FROM man_rle_rule";

                return(DataRetrieval.GetCollectionFromDatabase <OutboundRule>(cmd, CreateAndFillOutboundRule));
            }
        }
Beispiel #5
0
        /// <summary>
        /// Retrieves all BounceRules from the database.
        /// </summary>
        /// <returns>A BounceRulesCollection of all the Rules.</returns>
        public static BounceRulesCollection GetBounceRules()
        {
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlServer"].ConnectionString))
            {
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = @"
SELECT *
FROM man_evn_bounceRule
ORDER BY evn_bounceRule_executionOrder ASC";
                return(new BounceRulesCollection(DataRetrieval.GetCollectionFromDatabase <BounceRule>(cmd, CreateAndFillBounceRuleFromRecord)));
            }
        }
Beispiel #6
0
        /// <summary>
        /// Gets a collection of the Virtual MTAs that belong to a Virtual MTA Group from the database.
        /// </summary>
        /// <param name="groupID">ID of the Virtual MTA Group to get Virtual MTAs for.</param>
        /// <returns></returns>
        public static IList <VirtualMTA> GetVirtualMtasInVirtualMtaGroup(int groupID)
        {
            using (SqlConnection conn = MantaDB.GetSqlConnection())
            {
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = @"SELECT *
FROM man_ip_ipAddress as [ip]
WHERE [ip].ip_ipAddress_id IN (SELECT [grp].ip_ipAddress_id FROM man_ip_groupMembership as [grp] WHERE [grp].ip_group_id = @groupID) ";
                cmd.Parameters.AddWithValue("@groupID", groupID);
                return(DataRetrieval.GetCollectionFromDatabase <VirtualMTA>(cmd, CreateAndFillVirtualMtaFromRecord));
            }
        }
Beispiel #7
0
        /// <summary>
        /// Get the Outbound MX Patterns from the database.
        /// </summary>
        /// <returns></returns>
        public static IList <OutboundMxPattern> GetOutboundRulePatterns()
        {
            using (SqlConnection conn = MantaDB.GetSqlConnection())
            {
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = @"
SELECT *
FROM man_rle_mxPattern
ORDER BY rle_mxPattern_id DESC"; // Order descending so default -1 is always at the bottom!

                return(DataRetrieval.GetCollectionFromDatabase <OutboundMxPattern>(cmd, CreateAndFillOutboundMxPattern));
            }
        }
Beispiel #8
0
        /// <summary>
        /// Gets <param name="maxEventsToGet"/> amount of Events that need forwarding from the database.
        /// </summary>
        public static IList <MantaEvent> GetEventsForForwarding(int maxEventsToGet)
        {
            using (SqlConnection conn = MantaDB.GetSqlConnection())
            {
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = @"
SELECT TOP " + maxEventsToGet + @" [evt].*, [bnc].evn_bounceCode_id, [bnc].evn_bounceEvent_message, [bnc].evn_bounceType_id
FROM man_evn_event AS [evt]
LEFT JOIN man_evn_bounceEvent AS [bnc] ON [evt].evn_event_id = [bnc].evn_event_id
WHERE evn_event_forwarded = 0
ORDER BY evn_event_id ASC";
                return(DataRetrieval.GetCollectionFromDatabase <MantaEvent>(cmd, CreateAndFillMantaEventFromRecord));
            }
        }