Esempio n. 1
0
        public bool Connect()
        {
            BaseConst   cb = new BaseConst();
            PrivateData pd = new PrivateData();

            string query = String.Format("{0}={1};{2}={3};{4}={5};{6}={7};",
                                         cb.Server, pd.Server,
                                         cb.Username, pd.Username,
                                         cb.Password, pd.Password,
                                         cb.Database, pd.Database);

            try
            {
                mysql = new MySqlConnection(query);
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }

            //mysql = new MySqlConnection(query);

            //if (mysql == null)
            //    return false;
            //else
            //    return true;
        }
Esempio n. 2
0
        //methods
        public bool Read()
        {
            BaseConst   cb = new BaseConst();
            PrivateData pd = new PrivateData();

            string query = String.Format("{0}={1};{2}={3};{4}={5};{6}={7};",
                                         cb.Server, pd.Server,
                                         cb.Username, pd.Username,
                                         cb.Password, pd.Password,
                                         cb.Database, pd.Database);

            try
            {
                mysql = new MySqlConnection(query);
                mysql.Open();

                query = "SELECT * FROM `launcher`";
                MySqlCommand    sqlcmd = new MySqlCommand(query, mysql);
                MySqlDataReader reader = sqlcmd.ExecuteReader();

                while (reader.Read())
                {
                    this.hash = reader["hash"].ToString();
                }

                reader.Close();
                mysql.Close();
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Esempio n. 3
0
        //methods
        public bool Read()
        {
            BaseConst   cb = new BaseConst();
            PrivateData pd = new PrivateData();

            string query = String.Format("{0}={1};{2}={3};{4}={5};{6}={7};",
                                         cb.Server, pd.Server,
                                         cb.Username, pd.Username,
                                         cb.Password, pd.Password,
                                         cb.Database, pd.Database);

            try
            {
                this.sqlConnection = new MySqlConnection(query);
                sqlConnection.Open();

                query      = "SELECT * FROM `launcher` WHERE `id`=1 LIMIT 1";
                sqlCommand = new MySqlCommand(query, sqlConnection);
                MySqlDataReader reader = sqlCommand.ExecuteReader();

                reader.Read();

                this.slideNumber  = Convert.ToInt32(reader[LauncherColumn.Slide].ToString());
                this.hashLauncher = reader[LauncherColumn.Launcher].ToString();
                this.hashUpdate   = reader[LauncherColumn.Update].ToString();
#if LAUNCHER_INFO
                this.titleLauncher       = reader[LauncherColumn.Title].ToString();
                this.typeLauncher        = reader[LauncherColumn.Type].ToString();
                this.dateLauncher        = reader[LauncherColumn.Date].ToString();
                this.licenseLauncher     = reader[LauncherColumn.License].ToString();
                this.copyrightLauncher   = reader[LauncherColumn.Copyright].ToString();
                this.developerLauncher   = reader[LauncherColumn.Developer].ToString();
                this.descriptionLauncher = reader[LauncherColumn.Description].ToString();
#endif
                reader.Close();
                sqlConnection.Close();

                return(true);
            }
            catch (MySqlException ex)
            {
                return(false);

                /*string message = "Došlo je do greške pri pokušaju čitanja launcher podataka iz baze.\n" +
                 *               "Greška: " + ex.Message;
                 * throw new Exception(message);*/
            }
        }
Esempio n. 4
0
        //methods
        public bool Read()
        {
            BaseConst   cb = new BaseConst();
            PrivateData pd = new PrivateData();

            string query = String.Format("{0}={1};{2}={3};{4}={5};{6}={7};",
                                         cb.Server, pd.Server,
                                         cb.Username, pd.Username,
                                         cb.Password, pd.Password,
                                         cb.Database, pd.Database);

            try
            {
                sqlConnection = new MySqlConnection(query);
                sqlConnection.Open();

                query      = "SELECT * FROM `server` WHERE `id`=1 LIMIT 1";
                sqlCommand = new MySqlCommand(query, sqlConnection);
                MySqlDataReader reader = sqlCommand.ExecuteReader();

                reader.Read();

                this.locked    = Boolean.Parse(reader[ServerColumn.Lock].ToString());
                this.working   = Boolean.Parse(reader[ServerColumn.Work].ToString());
                this.address   = reader[ServerColumn.Address].ToString();
                this.password  = reader[ServerColumn.Password].ToString();
                this.teamspeak = reader[ServerColumn.Teamspeak].ToString();
                this.website   = reader[ServerColumn.Website].ToString();
                this.forum     = reader[ServerColumn.Forum].ToString();
                this.facebook  = reader[ServerColumn.Facebook].ToString();
                this.youtube   = reader[ServerColumn.Youtube].ToString();
                this.email     = reader[ServerColumn.Email].ToString();

                reader.Close();
                sqlConnection.Close();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Esempio n. 5
0
        //methods
        public void Send()
        {
            BaseConst   cb = new BaseConst();
            PrivateData pd = new PrivateData();

            string query = String.Format("{0}={1};{2}={3};{4}={5};{6}={7};",
                                         cb.Server, pd.Server,
                                         cb.Username, pd.Username,
                                         cb.Password, pd.Password,
                                         cb.Database, pd.Database);

            try
            {
                this.sqlCommand    = new MySqlCommand();
                this.sqlConnection = new MySqlConnection(query);

                sqlConnection.Open();
                sqlCommand.Connection = sqlConnection;

                if (appRun == 0)
                {
                    sqlCommand.CommandText = "INSERT INTO `users_app` VALUES(NULL, @address, @name, @date, @run, @login)";
                    sqlCommand.Prepare();

                    sqlCommand.Parameters.AddWithValue("@address", ipAddress);
                    sqlCommand.Parameters.AddWithValue("@name", userName);
                    sqlCommand.Parameters.AddWithValue("@date", Date());
                    sqlCommand.Parameters.AddWithValue("@run", ++appRun);
                    sqlCommand.Parameters.AddWithValue("@login", appLogin);
                }
                else
                {
                    sqlCommand.CommandText = String.Format("UPDATE `users_app` SET date='{0}', run='{1}' WHERE `address`='{2}' AND `name`='{3}'", Date(), ++appRun, ipAddress, userName);
                }

                sqlCommand.ExecuteNonQuery();
                sqlConnection.Close();
            }
            catch (Exception)
            {
            }
        }
Esempio n. 6
0
        public void Read()
        {
            BaseConst   cb = new BaseConst();
            PrivateData pd = new PrivateData();


            string query = String.Format("{0}={1};{2}={3};{4}={5};{6}={7};",
                                         cb.Server, pd.Server,
                                         cb.Username, pd.Username,
                                         cb.Password, pd.Password,
                                         cb.Database, pd.Database);

            try
            {
                this.sqlConnection = new MySqlConnection(query);
                sqlConnection.Open();

                query      = String.Format("SELECT * FROM `users_app` WHERE `address` = '{0}' AND `name` = '{1}'", ipAddress, userName);
                sqlCommand = new MySqlCommand(query, sqlConnection);
                MySqlDataReader reader = sqlCommand.ExecuteReader();
                if (reader.FieldCount > 0)
                {
                    reader.Read();
                    this.appRun   = Convert.ToInt32(reader["run"].ToString());
                    this.appLogin = Convert.ToInt32(reader["login"].ToString());
                }
                else
                {
                    this.appRun   = 0;
                    this.appLogin = 0;
                }

                reader.Close();
                sqlConnection.Close();
            }
            catch (Exception)
            {
            }
        }