예제 #1
0
        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);
            }
        }
예제 #2
0
        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()
                    };
            }
        }
예제 #3
0
 protected MailServerBase(ServerSetup setup)
 {
     _setup = setup;
 }
예제 #4
0
 protected ServerModel(ServerSetup setup)
     : base(setup)
 {
 }
예제 #5
0
 protected MailServerBase(ServerSetup setup)
 {
     _setup = setup;
 }
 public abstract MailServerBase CreateServer(ServerSetup setup);
예제 #7
0
 public override MailServerBase CreateServer(ServerSetup setup)
 {
     return new PostfixServer(setup);
 }
예제 #8
0
 public override MailServerBase CreateServer(ServerSetup setup)
 {
     return new MockServer(setup);
 }