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); } } }
public IDnsSettings AddDns(int dnsId, IMailServerFactory factory) { IDnsSettings dnsRecords; using (var dbContextWithTran = TeamlabDnsDal.CreateMailDbContext(true)) { var dnsDto = TeamlabDnsDal.LinkDnsToDomain(dnsId, Id, dbContextWithTran.DbManager); var txtName = Server.SetupInfo.DnsPresets.CurrentOrigin; dnsRecords = factory.CreateDnsSettings(dnsDto.id, dnsDto.tenant, dnsDto.user, Name, dnsDto.dkim_selector, dnsDto.dkim_private_key, dnsDto.dkim_public_key, txtName, dnsDto.domain_chek, txtName, dnsDto.spf, Server.SetupInfo.DnsPresets.MxHost, Server.SetupInfo.DnsPresets.MxPriority, Server.Logger); var dkimBase = new DkimRecordBase(dnsRecords.DkimSelector, dnsRecords.DkimPrivateKey, dnsRecords.DkimPublicKey); _AddDkim(dkimBase); dbContextWithTran.CommitTransaction(); } return dnsRecords; }
protected abstract void _AddDkim(DkimRecordBase dkimToAdd);
protected override void _AddDkim(DkimRecordBase dkimToAdd) { }