public frmMain() { InitializeComponent(); CheckForIllegalCrossThreadCalls = true; mySqlDB = new MySqlDB(Properties.Default.MySqlServerUsername, Properties.Default.MySqlServerPassword, Properties.Default.MySqlServerAddress, Properties.Default.MySqlServerPort, Properties.Default.MySqlServerDatabase); }
public RuslanParser2(string user, string pass, string pathToProxy, MySqlDB _mySqlDB, string _ftpUsername, string _ftpPassword, ImageParsedCountHelper imageParsed) { mySqlDB = _mySqlDB; ftpUsername = _ftpUsername; ftpPassword = _ftpPassword; imageParsedCountHelper = imageParsed; }
private void btnSave_Click(object sender, EventArgs e) { if (edtFtpFolder.Text.Length > 0 && edtSaveImagePath.Text.Length > 0) { MessageBox.Show("You need to fill only one path: 'Path to save images' or 'FTP folder'", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.None; return; } if (edtSaveImagePath.Text.Length > 0) Properties.Default.PathToImg = edtSaveImagePath.Text; else if (edtFtpFolder.Text.Length > 0) { if (edtFtpUsername.Text.Length == 0 || edtFtpPassword.Text.Length == 0) { MessageBox.Show("Incomplete FTP settings", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.None; return; } else Properties.Default.PathToImg = edtFtpFolder.Text; } if (cbRunSMSSpamer.Checked && edtSMSSPamerPath.Text.Length == 0) { MessageBox.Show("SMSSPamer path is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.None; return; } else { Properties.Default.SMSSpamerPath = edtSMSSPamerPath.Text; Properties.Default.RunSMSSpamer = cbRunSMSSpamer.Checked; } Properties.Default.PathToProxy = edtPathToProxyFile.Text; Properties.Default.SleepAfterParseSec = Convert.ToInt32(edtSleepAfterParse.Text); Properties.Default.SleepSecAfterPublicationSec = Convert.ToInt32(edtSleepSecAfterPublication.Text); Properties.Default.User = edtUsername.Text; Properties.Default.Password = edtPassword.Text; if (edtMySqlServerAddress.Text.Length == 0 || edtMySqlServerDatabase.Text.Length == 0 || edtMySqlServerPort.Text.Length == 0 || edtMySqlServerUsername.Text.Length == 0 || edtMySqlServerPassword.Text.Length == 0) { MessageBox.Show("Incomplete MySql settings", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.None; return; } var bNeedRestart = false; if (Properties.Default.MySqlServerAddress != edtMySqlServerAddress.Text || Properties.Default.MySqlServerPort != Convert.ToInt32(edtMySqlServerPort.Text) || Properties.Default.MySqlServerDatabase != edtMySqlServerDatabase.Text || Properties.Default.MySqlServerUsername != edtMySqlServerUsername.Text || Properties.Default.MySqlServerPassword != edtMySqlServerPassword.Text) { bNeedRestart = true; } Properties.Default.MySqlServerAddress = edtMySqlServerAddress.Text; Properties.Default.MySqlServerPort = Convert.ToInt32(edtMySqlServerPort.Text); Properties.Default.MySqlServerDatabase = edtMySqlServerDatabase.Text; Properties.Default.MySqlServerUsername = edtMySqlServerUsername.Text; Properties.Default.MySqlServerPassword = edtMySqlServerPassword.Text; Properties.Default.FtpUsername = edtFtpUsername.Text; Properties.Default.FtpPassword = edtFtpPassword.Text; Properties.Default.PublishParsedData = cbPublishParsedData.Checked; Properties.Default.InfiniteParsing = cbInfiniteParsing.Checked; Properties.Default.Save(); // Test MySql connection var db = new MySqlDB(Properties.Default.MySqlServerUsername, Properties.Default.MySqlServerPassword, Properties.Default.MySqlServerAddress, Properties.Default.MySqlServerPort, Properties.Default.MySqlServerDatabase); try { var r = db.mySqlConnection; } catch (Exception) { MessageBox.Show("Невозможно установить соединение с базой данных", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); DialogResult = DialogResult.Abort; bNeedRestart = false; ForceRestart = false; } db.Close(); if (bNeedRestart || ForceRestart) { MessageBox.Show("Для внесения изменения программа будет перезапущена", "Перезапуск", MessageBoxButtons.OK, MessageBoxIcon.Information); Application.Restart(); } }
public RuslanParser(string user, string pass, string pathToProxy, MySqlDB _mySqlDB) { ProxyCollectionSingl.ProxyPass = pathToProxy; mySqlDB = _mySqlDB; }