Beispiel #1
0
        public List <AuthServerInfo> GetSmtpsList()
        {
            List <AuthServerInfo> list      = new List <AuthServerInfo>();
            MySqlDataReader       sqlReader = GetQueryReader(
                @"SELECT Id,Host,Port,Login,Password,UseSSL,Name,Email
FROM smtpservers");

            while (sqlReader.Read())
            {
                AuthServerInfo smtpServ = new AuthServerInfo();

                smtpServ.Id     = sqlReader.GetInt32(0);        // id
                smtpServ.Host   = sqlReader.GetString(1);       // host
                smtpServ.Port   = sqlReader.GetInt32(2);        // port
                smtpServ.UseSSL = sqlReader.GetBoolean(5);      // SSL

                if (!sqlReader.IsDBNull(3))                     // login
                {
                    smtpServ.Login    = sqlReader.GetString(3); // login
                    smtpServ.Password = sqlReader.GetString(4); // pass
                }
                if (!sqlReader.IsDBNull(6))                     // name
                {
                    smtpServ.FromName = sqlReader.GetString(6);
                }

                smtpServ.FromAddr = sqlReader.GetString(7);

                list.Add(smtpServ);
            }
            sqlReader.Close();

            return(list);
        }
Beispiel #2
0
        public void AddSmtp(AuthServerInfo smtp)
        {
            string user, pass;

            user = pass = "******";

            if (!String.IsNullOrEmpty(smtp.Login))
            {
                user = "******" + smtp.Login + "'";

                if (smtp.Password == null)
                {
                    smtp.Password = "";
                }

                pass = "******" + smtp.Password + "'";
            }

            string fname =
                smtp.FromName == null ? "NULL" : "'{3}'";

            SendQuery(string.Format("INSERT smtpservers " +
                                    "SET Host='{0}',Port={1}," +
                                    "Login="******",Password="******",UseSSL={2},Name=" + fname + ",Email='{4}'",
                                    smtp.Host, smtp.Port,
                                    smtp.UseSSL ? 1 : 0, smtp.FromName, smtp.FromAddr));
        }
Beispiel #3
0
        public AuthServerInfo GetSmtpServerById(int id)
        {
            MySqlDataReader sqlReader = GetQueryReader(selectSmtpByIdQuery + id.ToString());

            if (sqlReader != null)
            {
                if (sqlReader.Read())
                {
                    AuthServerInfo servInf = new AuthServerInfo();
                    servInf.Id       = id;
                    servInf.Host     = sqlReader.GetString(0);               // Host
                    servInf.Port     = sqlReader.GetInt32(1);                // Port
                    servInf.Login    = sqlReader.GetString(2);               // login
                    servInf.Password = sqlReader.GetString(3);               // Password
                    servInf.UseSSL   = sqlReader.GetBoolean(4);              // UseSSL
                    if (!sqlReader.IsDBNull(5))
                    {
                        servInf.FromName = sqlReader.GetString(5);                 // name
                    }
                    servInf.FromAddr = sqlReader.GetString(6);                     // e-mail

                    sqlReader.Close();
                    return(servInf);
                }
            }

            throw new Exception("Smtp server data with id " + id.ToString() + " cannot be found");
        }
Beispiel #4
0
        public AuthServerInfo GetAnySmtp()
        {
            MySqlDataReader sqlReader = GetQueryReader(
                @"SELECT Host,Port,Login,Password,UseSSL,Name,Email
FROM smtpservers
ORDER BY RAND() LIMIT 1;");

            if (sqlReader != null)
            {
                if (sqlReader.Read())
                {
                    AuthServerInfo serverInfo = new AuthServerInfo(
                        sqlReader.GetString(0),
                        sqlReader.GetInt32(1),
                        sqlReader.GetString(2),
                        sqlReader.GetString(3),
                        sqlReader.GetBoolean(4));
                    if (!sqlReader.IsDBNull(5))
                    {
                        serverInfo.FromName = sqlReader.GetString(5);
                    }
                    serverInfo.FromAddr = sqlReader.GetString(6);

                    sqlReader.Close();
                    return(serverInfo);
                }
            }

            throw new Exception("Failed to aquire SMTP server parameters from database");
        }
Beispiel #5
0
 public Robot(int Id, string IP)
 {
     this.IP         = IP;
     this.Id         = Id;
     this.SmtpId     = 0;
     this.SmtpServer = null;
 }
Beispiel #6
0
 public Robot(string IP, int SmtpId, AuthServerInfo SmtpServer)
 {
     this.Id         = 0;
     this.IP         = IP;
     this.SmtpId     = SmtpId;
     this.SmtpServer = SmtpServer;
 }
Beispiel #7
0
        public bool EqualsNoId(object obj)
        {
            if (obj is AuthServerInfo)
            {
                AuthServerInfo asi = obj as AuthServerInfo;

                if (asi.Host != this.Host)
                {
                    return(false);
                }
                if (asi.Port != this.Port)
                {
                    return(false);
                }
                if (asi.Login != this.Login)
                {
                    return(false);
                }
                if (asi.Password != this.Password)
                {
                    return(false);
                }
                if (asi.UseSSL != this.UseSSL)
                {
                    return(false);
                }
                if (asi.FromAddr != this.FromAddr)
                {
                    return(false);
                }
                if (asi.FromName != this.FromName)
                {
                    return(false);
                }

                return(true);
            }
            return(false);
        }