// Search the database for users that need to be processed. public MySqlDataReader GetCrawlList() { // Open the connection MySqlConnection connMySQL; string myConnectionString; // Create a new TripleDESCryptoServiceProvider object // to generate a key and initialization vector (IV). TrippleDESCSPCoder coder = new TrippleDESCSPCoder(); mEncryptedData = System.Convert.FromBase64String(Properties.Settings.Default.MySQL); myConnectionString = TrippleDESCSPCoder.DecryptTextFromMemory(mEncryptedData, coder.mEncryptKey, coder.mEncryptVector); try { connMySQL = new MySqlConnection(); connMySQL.ConnectionString = myConnectionString; connMySQL.Open(); } catch (MySqlException ex) { MessageBox.Show(ex.Message); return(null); } // SQL Statement to retrieve the users who need to be processed String strSQL = "select distinct u.ID from wp_xleb_users u "; strSQL += "left join wp_xleb_usermeta m on m.user_id = u.ID and m.meta_key = 'goes_status' "; strSQL += "left join goes_log l on u.ID = l.user_id "; strSQL += "where (m.meta_value = '1') "; strSQL += "and(l.last_run_date is null or(minute(timediff(last_run_date, now())) > 15)) "; // strSQL += "and l.user_id = 61"; // TODO: Remove this. // strSQL += "ORDER BY ID Desc LIMIT 1;"; // Run the Query MySqlCommand cmd = new MySqlCommand(); cmd.Connection = connMySQL; cmd.CommandType = CommandType.Text; cmd.CommandText = strSQL; MySqlDataReader dr; try { dr = cmd.ExecuteReader(); } catch (MySqlException ex) { MessageBox.Show(ex.Message); return(null); } return(dr); }
private void cmdDecrypt_Click(object sender, EventArgs e) { // Create a new TripleDESCryptoServiceProvider object // to generate a key and initialization vector (IV). TrippleDESCSPCoder coder = new TrippleDESCSPCoder(); mEncryptedData = System.Convert.FromBase64String(txtDecrypt.Text); txtEncrypt.Text = TrippleDESCSPCoder.DecryptTextFromMemory(mEncryptedData, coder.mEncryptKey, coder.mEncryptVector); txtDecrypt.Text = ""; }
private void cmdEncrypt_Click(object sender, EventArgs e) { // Create a new TrippleDESCPCoder object // to generate my private key and initialization vector (IV). TrippleDESCSPCoder coder = new TrippleDESCSPCoder(); mEncryptedData = TrippleDESCSPCoder.EncryptTextToMemory(txtEncrypt.Text, coder.mEncryptKey, coder.mEncryptVector); txtDecrypt.Text = System.Convert.ToBase64String(mEncryptedData); txtEncrypt.Text = ""; }
public static String DecryptSetting(String pValue) { // Create a new TripleDESCryptoServiceProvider object // to generate a key and initialization vector (IV). TrippleDESCSPCoder coder = new TrippleDESCSPCoder(); byte[] mEncryptedData = System.Convert.FromBase64String(pValue); String myString = TrippleDESCSPCoder.DecryptTextFromMemory(mEncryptedData, coder.mEncryptKey, coder.mEncryptVector); return(myString); }
public Boolean GetDataForUser(Int32 pUser) { MySqlConnection connMySQL; string myConnectionString; // Create a new TripleDESCryptoServiceProvider object // to generate a key and initialization vector (IV). TrippleDESCSPCoder coder = new TrippleDESCSPCoder(); byte[] mEncryptedData = System.Convert.FromBase64String(Properties.Settings.Default.MySQL); myConnectionString = TrippleDESCSPCoder.DecryptTextFromMemory(mEncryptedData, coder.mEncryptKey, coder.mEncryptVector); try { connMySQL = new MySqlConnection(); connMySQL.ConnectionString = myConnectionString; connMySQL.Open(); } catch (MySql.Data.MySqlClient.MySqlException ex) { MessageBox.Show(ex.Message); return(false); } // SQL Statement to retrieve the Order Header String strSQL = "SELECT "; strSQL += "MAX(CASE WHEN meta_key = 'goes_username' THEN meta_value ELSE NULL END) AS goes_username, "; strSQL += "MAX(CASE WHEN meta_key = 'goes_password' THEN meta_value ELSE NULL END) AS goes_password, "; strSQL += "MAX(CASE WHEN meta_key = 'goes_location' THEN meta_value ELSE NULL END) AS goes_location, "; strSQL += "user_email "; strSQL += "from wp_xleb_usermeta m "; strSQL += "join wp_xleb_users u on m.user_id = u.ID "; strSQL += "where user_id = " + pUser; strSQL += " and meta_key in ('goes_username', 'goes_password', 'goes_location'); "; // Execute the SQL MySqlCommand cmd = connMySQL.CreateCommand(); cmd.CommandText = strSQL; MySqlDataReader dr; try { dr = cmd.ExecuteReader(); } catch (MySqlException ex) { MessageBox.Show(ex.Message); return(false); } if (dr.HasRows) { dr.Read(); mUsername = dr.GetString(0); mUser_id = pUser; try { mPassword = dr.GetString(1); mLocation_id = dr.GetString(2); mEmail = dr.GetString(3); } catch (Exception ex) { return(false); } } dr.Close(); strSQL = "SELECT goes_location FROM goes_location WHERE location_id = " + mLocation_id; cmd.CommandText = strSQL; try { dr = cmd.ExecuteReader(); } catch (MySqlException ex) { MessageBox.Show(ex.Message); return(false); } if (dr.HasRows) { dr.Read(); mLocation_Name = dr.GetString(0); } dr.Close(); return(true); }