示例#1
0
        protected override void _AddDkim(DkimRecordBase dkimToAdd)
        {
            var dbManager = new PostfixAdminDbManager(Server.Id, Server.ConnectionString);
            using (var db = dbManager.GetAdminDb())
            {
                var dkimId = db.ExecuteScalar<int>(
                    new SqlQuery(DkimTable.name)
                        .Select(DkimTable.Columns.id)
                        .Where(DkimTable.Columns.domain_name, Name));

                if (dkimId == 0)
                {
                    var insertDkim = new SqlInsert(DkimTable.name)
                        .InColumnValue(DkimTable.Columns.domain_name, Name)
                        .InColumnValue(DkimTable.Columns.selector, dkimToAdd.Selector)
                        .InColumnValue(DkimTable.Columns.private_key, dkimToAdd.PrivateKey)
                        .InColumnValue(DkimTable.Columns.public_key, dkimToAdd.PublicKey);
                    db.ExecuteNonQuery(insertDkim);
                }
                else
                {
                    var updateDkim = new SqlUpdate(DkimTable.name)
                        .Where(DkimTable.Columns.id, dkimId)
                        .Set(DkimTable.Columns.selector, dkimToAdd.Selector)
                        .Set(DkimTable.Columns.private_key, dkimToAdd.PrivateKey)
                        .Set(DkimTable.Columns.public_key, dkimToAdd.PublicKey);
                    db.ExecuteNonQuery(updateDkim);
                }

            }
        }
示例#2
0
        protected override void _RemoveAlias(MailAddressBase aliasToRemove)
        {
            var removeMailboxAlias = new SqlDelete(AliasTable.name)
                .Where(AliasTable.Columns.address, aliasToRemove.ToString());

            var dbManager = new PostfixAdminDbManager(Server.Id, Server.ConnectionString);
            using (var db = dbManager.GetAdminDb())
            {
                db.ExecuteNonQuery(removeMailboxAlias);
            }
        }
示例#3
0
        protected override void _AddAlias(MailAddressBase aliasToAdd)
        {
            var insertMailboxAlias = new SqlInsert(AliasTable.name)
                .InColumnValue(AliasTable.Columns.address, aliasToAdd.ToString())
                .InColumnValue(AliasTable.Columns.redirect, Address.ToString())
                .InColumnValue(AliasTable.Columns.domain, aliasToAdd.Domain.Name)
                .InColumnValue(AliasTable.Columns.created, aliasToAdd.DateCreated)
                .InColumnValue(AliasTable.Columns.modified, aliasToAdd.DateCreated)
                .InColumnValue(AliasTable.Columns.active, true)
                .InColumnValue(AliasTable.Columns.is_group, false);

            var dbManager = new PostfixAdminDbManager(Server.Id, Server.ConnectionString);
            using (var db = dbManager.GetAdminDb())
            {
                 db.ExecuteNonQuery(insertMailboxAlias);
            }
        }
 private IDbManager GetDb()
 {
     var dbProvider = new PostfixAdminDbManager(Server.Id, Server.ConnectionString);
     return dbProvider.GetAdminDb();
 }