Exemple #1
0
        public static void InsertUrl(string url, bool Accepted)
        {
            if (Registry_Manage.GetUsername() != "null")
            {
                try
                {
                    if (url.Length < 32) //The maximum length of the url
                    {
                        using (MySqlConnection Connection = new MySqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]))
                        {
                            Connection.Open();
                            string InsertTraffic = "";


                            if (Accepted == true) //Checks if the url has been accepted or rejected
                            {
                                InsertTraffic = "INSERT INTO Traffic (Url,Time,Accepted) VALUES('" + url + "','" + DateTime.Now.ToString() + "','True');";
                            }
                            else
                            {
                                InsertTraffic = "INSERT INTO Traffic (Url,Time,Accepted) VALUES('" + url + "','" + DateTime.Now.ToString() + "','False');";
                            }


                            using (MySqlCommand Command = new MySqlCommand(InsertTraffic, Connection))
                            {
                                Command.ExecuteNonQuery();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Exemple #2
0
        public static string GetGuid()
        {
            string Guid = "";

            try
            {
                using (MySqlConnection Connection = new MySqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]))
                {
                    Connection.Open();
                    string          Query   = "SELECT * FROM accounts WHERE Username = '******'";
                    MySqlCommand    Command = new MySqlCommand(Query, Connection);
                    MySqlDataReader Reader  = Command.ExecuteReader();
                    while (Reader.Read())
                    {
                        Guid = Reader.GetString(0);
                    }

                    return(Guid);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return("null");
            }
        }