public MockServer(ServerSetup setup) : base(setup) { _serverData = MockServerData.GetInstance(); _serverData.Domains.Clear(); _serverData.Mailboxes.Clear(); _serverData.Groups.Clear(); _domainDal = new WebDomainDal(setup.Tenant); _mailboxDal = new MailboxDal(setup.Tenant, SetupInfo.Limits.MailboxMaxCountPerUser); _mailgroupDal = new MailGroupDal(setup.Tenant); _mailaddressDal = new MailAddressDal(setup.Tenant); var domains = _domainDal.GetTenantDomains(); foreach (var domain in domains) { _serverData.Domains.Add(new WebDomainBase(domain.name)); } var mailboxesDto = _mailboxDal.GetMailboxes(); foreach (var mailboxDto in mailboxesDto) { var aliasList = _mailaddressDal.GetMailboxAliases(mailboxDto.mailbox.id) .Select( aliasDto => new MailAddressBase(aliasDto.name, new WebDomainBase(aliasDto.domain.name))) .ToList(); var resultMailbox = new MailboxBase( new MailAccountBase(mailboxDto.mailbox.address), //Its not login. It adress. Needed only for testing new MailAddressBase(mailboxDto.mailbox_address.name, new WebDomainBase(mailboxDto.mailbox_address.domain.name)), aliasList); _serverData.Mailboxes.Add(resultMailbox); } var groupsDto = _mailgroupDal.GetMailGroups(); foreach (var resultGroup in from groupDto in groupsDto let groupAddresses = groupDto.addresses.Select(address => new MailAddressBase(address.name, new WebDomainBase ( address .domain .name))) .ToList() select new MailGroupBase( new MailAddressBase(groupDto.address.name, new WebDomainBase(groupDto.address.domain.name)), groupAddresses)) { _serverData.Groups.Add(resultGroup); } }
public PostfixServer(ServerSetup setup) : base(setup) { _dbManager = new PostfixAdminDbManager(setup.ServerId, setup.ConnectionString); var json = JObject.Parse(setup.ConnectionString); if (json["Api"] != null) { _serverApi = new ServerApi { server_ip = json["Api"]["Server"].ToString(), port = Convert.ToInt32(json["Api"]["Port"].ToString()), protocol = json["Api"]["Protocol"].ToString(), version = json["Api"]["Version"].ToString(), token = json["Api"]["Token"].ToString() }; } }
protected MailServerBase(ServerSetup setup) { _setup = setup; }
protected ServerModel(ServerSetup setup) : base(setup) { }
public abstract MailServerBase CreateServer(ServerSetup setup);
public override MailServerBase CreateServer(ServerSetup setup) { return new PostfixServer(setup); }
public override MailServerBase CreateServer(ServerSetup setup) { return new MockServer(setup); }