Пример #1
0
        public void ImportDatabases(string domainName, ref StringBuilder _sb)
        {
            var client = new Client(Settings.Default.apiKey, Settings.Default.host, Settings.Default.port, false);
            var databaseList = _db.GetDatabases(domainName);

            foreach (var item in databaseList)
            {
                var result = client.AddDatabase(item.Domain, item.DbType, item.Name, "", "", -1);

                if (result.Code == 0)
                {
                    PrintAndLog(String.Format("\tDatabase Added: {0} ({1})", item.Name, item.DbType), ref _sb);

                    foreach (var user in item.Users)
                    {
                        var createUserResult = client.AddDatabaseUser(domainName, item.DbType, item.Name, user.Username, user.Password);

                        if(createUserResult.Code == 0)
                            PrintAndLog(String.Format("\t\tUser Added: {0}", item.Name), ref _sb);
                        else
                            PrintAndLog(String.Format("\t\tUser Add Error: {0} - {1}", item.Name, createUserResult.Message), ref _sb);
                    }
                }
                else
                {
                    PrintAndLog(String.Format("\tDatabase Error: {0} - {1}", item.Name, result.Message), ref _sb);
                }
            }
        }
        public void DomainDeleteTest()
        {
            string ApiKey = "1_885bd9d868494d078d4394809f5ca7ac";
            string apiHostdomain = "localhost";
            int port = 9715;
            bool ssl = false;

            Client target = new Client(ApiKey, apiHostdomain, port, ssl); // TODO: Initialize to an appropriate value
            string name = "demo1.com";
            ApiResult actual = target.DomainDelete(name);
            Assert.AreEqual(0, actual.Code);
        }
        public void DomainCreateTest()
        {
            string ApiKey = "1_885bd9d868494d078d4394809f5ca7ac";
            string apiHostdomain = "localhost";
            int port = 9715;
            bool ssl = false;
            Client target = new Client(ApiKey, apiHostdomain, port, ssl);

            string name = "demo1.com";
            string planAlias = "GOLD_PLAN";
            string username = "******";
            string password = "******";
            bool activedomainuser = false;
            string firstName = "Demo";
            string lastName = "Customer";
            string email = "*****@*****.**";

            ApiResult actual = target.DomainCreate(name, planAlias, username, password, activedomainuser, firstName, lastName, email);
            Assert.AreEqual(0, actual.Code);
        }
Пример #4
0
        public void ImportDomainAlias(string domainName, ref StringBuilder _sb)
        {
            var aliasList = _db.GetDomainAliases(domainName);
            var client = new Client(Settings.Default.apiKey, Settings.Default.host, Settings.Default.port, false);

            foreach (var item in aliasList)
            {
                var subdomainResult = client.AddAlias(item.Domain, item.Alias);

                if (subdomainResult.Code == 0)
                    PrintAndLog(String.Format("\tDomain Alias Added: {0}", item.Alias), ref _sb);
                else
                    PrintAndLog(String.Format("\tDomain Alias Error: {0} - {1}", item.Alias, subdomainResult.Message), ref _sb);
            }
        }
Пример #5
0
        public void ImportSubdomain(string domainName, ref StringBuilder _sb)
        {
            var subdomains = _db.GetSubdomains(domainName);
            var client = new Client(Settings.Default.apiKey, Settings.Default.host, Settings.Default.port, false);

            foreach (var item in subdomains)
            {
                var subDomainResult = client.AddSubDomain(item.Domain, item.Name, item.Login, item.Password);

                if (subDomainResult.Code == 0)
                    PrintAndLog(String.Format("\tSubdomain Added: {0}.{1}", item.Name, item.Domain), ref _sb);
                else
                    PrintAndLog(String.Format("\tSubdomain Error: {0}.{1}", item.Name, item.Domain), ref _sb);
            }
        }
Пример #6
0
        public void ImportEmails(string domainName, ref StringBuilder _sb)
        {
            var _quota = -1D;

            var client = new Client(Settings.Default.apiKey, Settings.Default.host, Settings.Default.port, false);
            var EmailList = _db.GetEmails(domainName);

            foreach (var item in EmailList.Where(m => m.DomainName == domainName))
            {
                if (Settings.Default.importEmails)
                {
                    _quota = item.Quota > 0 ? ((item.Quota / 8) / 1024) : item.Quota;
                    var result = client.AddMailBox(item.DomainName, item.Name, item.Password, item.Quota, item.Redirect, item.RedirectedEmail);

                    if (result.Code == 0)
                        PrintAndLog(String.Format("\tEmail Added: {0}", item.Name), ref _sb);
                    else
                        PrintAndLog(String.Format("\tEmail Error: {0} - {1}", item.Name, result.Message), ref _sb);
                }

                if (Settings.Default.CopyEmailFiles)
                    CopyEmailFiles(domainName, item.Name, ref _sb);
            }
        }
Пример #7
0
        public void ImportDomains()
        {
            var _sb = new StringBuilder();

            _sb.AppendFormat("API Key: {0}", Settings.Default.apiKey).AppendLine();
            _sb.AppendFormat("Reseller Name: {0}",Settings.Default.resellerName).AppendLine();
            _sb.AppendFormat("Start Time: {0}", DateTime.Now).AppendLine().AppendLine();

            var client = new Client(Settings.Default.apiKey, Settings.Default.host, Settings.Default.port, false);

            var domains = String.IsNullOrEmpty(Settings.Default.resellerName) ?
                                                    _db.GetDomains() :
                                                    _db.GetDomains().Where(m => m.ClientName == Settings.Default.resellerName);

            var domainFilter = GetDomainFilter();

            if (domainFilter.Any())
                domains = domains.Where(m => domainFilter.Contains(m.Name)).ToList();

            foreach (var item in domains)
            {
                var result = Settings.Default.importDomains ?
                    client.DomainCreate(item.Name, Settings.Default.domainPlanName, item.Username, item.Password,
                                            !String.IsNullOrEmpty(item.DomainPassword), expiration: item.Expiration) :
                    new ApiResult() { Code = 0, Message = "Domain Import is Disabled" };

                if (result.Code == 0)
                {
                    if(Settings.Default.importDomains)
                        PrintAndLog(String.Format("Domain Added: {0}", item.Name), ref _sb);

                    ImportEmails(item.Name, ref _sb);

                    if (Settings.Default.importDatabases)
                        ImportDatabases(item.Name, ref _sb);

                    if (Settings.Default.importSubdomains)
                        ImportSubdomain(item.Name, ref _sb);

                    if (Settings.Default.importDomainAlias)
                        ImportDomainAlias(item.Name, ref _sb);

                    if (Settings.Default.CopyFiles)
                        CopyHttpFiles(item.Name, ref _sb);
                }
                else
                {
                    PrintAndLog(String.Format("Domain Error: {0} - {1}", item.Name, result.Message), ref _sb);
                }
            }

            _sb.AppendLine().AppendFormat("End Time Time: {0}", DateTime.Now);

            WriteLog(_sb.ToString());
        }