Beispiel #1
0
        private void SqlServerOKBtn_Click(object sender, RoutedEventArgs e)
        {
            bool          windowsAuth = WindowsAuthenticationRadioBtn.IsChecked ?? true;
            SqlConnection connection  = DBUtils.CreateSqlServerConnection(
                server: SqlServerHostTextBox.Text,
                username: SqlServerUsernameTextBox.Text,
                password: SqlServerPasswordTextBox.Password,
                useWindowsAuthentication: windowsAuth,
                noDB: true);

            try
            {
                connection.Open();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Connection failed with error: " + ex.Message);
                return;
            }

            if (WindowsAuthenticationRadioBtn.IsChecked != null)
            {
                Properties.Settings.Default.sqlServerUseWindowsAuthentication = WindowsAuthenticationRadioBtn.IsChecked.Value;
            }
            Properties.Settings.Default.sqlServerHost     = SqlServerHostTextBox.Text;
            Properties.Settings.Default.sqlServerUsername = SqlServerUsernameTextBox.Text;
            Properties.Settings.Default.sqlServerPassword = EncryptionUtils.Protect(SqlServerPasswordTextBox.Password);
            Properties.Settings.Default.databaseType      = "SqlServer";

            Properties.Settings.Default.Save();

            Close();
        }
Beispiel #2
0
        private void MySqlOKBtn_Click(object sender, RoutedEventArgs e)
        {
            MySqlConnection connection = DBUtils.CreateMySqlConnection(
                server: MySqlHostTextBox.Text,
                username: MySqlUsernameTextBox.Text,
                password: MySqlPasswordTextBox.Password,
                noDB: true);

            try
            {
                connection.Open();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Connection failed with error: " + ex.Message);
                return;
            }
            connection.Close();

            Properties.Settings.Default.mySqlHost     = MySqlHostTextBox.Text;
            Properties.Settings.Default.mySqlUsername = MySqlUsernameTextBox.Text;
            Properties.Settings.Default.mySqlPassword = EncryptionUtils.Protect(MySqlPasswordTextBox.Password);
            Properties.Settings.Default.databaseType  = "MySql";

            Properties.Settings.Default.Save();

            Close();
        }
Beispiel #3
0
        private void SaveBtn_Click(object sender, RoutedEventArgs e)
        {
            //ports settings
            int rtDBPubPort;

            if (int.TryParse(RTDPubPortTextBox.Text, out rtDBPubPort))
            {
                Properties.Settings.Default.rtDBPubPort = rtDBPubPort;
            }

            int rtDBReqPort;

            if (int.TryParse(RTDReqPortTextBox.Text, out rtDBReqPort))
            {
                Properties.Settings.Default.rtDBReqPort = rtDBReqPort;
            }

            int hDBPort;

            if (int.TryParse(HDPortTextBox.Text, out hDBPort))
            {
                Properties.Settings.Default.hDBPort = hDBPort;
            }

            int httpPort;

            if (int.TryParse(HttpPort.Text, out httpPort))
            {
                Properties.Settings.Default.httpPort = httpPort;
            }

            //REST API key
            Properties.Settings.Default.apiKey = RestApiKeyTextBox.Text;
            Properties.Settings.Default.useSsl = UseSslCheckBox.IsChecked ?? false;

            //logging settings...create folder if necessary
            try
            {
                if (!Directory.Exists(LogFolderTextBox.Text))
                {
                    Directory.CreateDirectory(LogFolderTextBox.Text);
                }
                Properties.Settings.Default.logDirectory = LogFolderTextBox.Text;
                ((FileTarget)LogManager.Configuration.FindTargetByName("default")).FileName = LogFolderTextBox.Text + "Log.log";
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error setting log directory: " + ex.Message);
            }

            //IB Settings
            Properties.Settings.Default.ibClientHost = IBHostTextBox.Text;

            int ibPort;

            if (int.TryParse(IBPortTextBox.Text, out ibPort))
            {
                Properties.Settings.Default.ibClientPort = ibPort;
            }

            int ibHistClientID;

            if (int.TryParse(IBHistClientIDTextBox.Text, out ibHistClientID))
            {
                Properties.Settings.Default.histClientIBID = ibHistClientID;
            }

            int ibRTDClientID;

            if (int.TryParse(IBRTDClientIDTextBox.Text, out ibRTDClientID))
            {
                Properties.Settings.Default.rtdClientIBID = ibRTDClientID;
            }

            //Quandl
            Properties.Settings.Default.quandlAuthCode = QuandlAPITokenTextBox.Text;

            //BarChart
            Properties.Settings.Default.barChartApiKey = BarChartAPITokenTextBox.Text;

            //Database
            if (DbTypeMySql.IsChecked.HasValue && DbTypeMySql.IsChecked.Value)
            {
                Properties.Settings.Default.databaseType = "MySql";
            }
            else
            {
                Properties.Settings.Default.databaseType = "SqlServer";
            }

            Properties.Settings.Default.mySqlHost     = MySqlHost.Text;
            Properties.Settings.Default.mySqlUsername = MySqlUsername.Text;
            Properties.Settings.Default.mySqlPassword = EncryptionUtils.Protect(MySqlPassword.Password);

            if (SqlServerAuthenticationWindowsRadioBtn.IsChecked != null)
            {
                Properties.Settings.Default.sqlServerUseWindowsAuthentication = SqlServerAuthenticationWindowsRadioBtn.IsChecked.Value;
            }

            Properties.Settings.Default.sqlServerHost     = SqlServerHost.Text;
            Properties.Settings.Default.sqlServerUsername = SqlServerUsername.Text;
            Properties.Settings.Default.sqlServerPassword = EncryptionUtils.Protect(SqlServerPassword.Password);

            //Data jobs
            Properties.Settings.Default.updateJobEmailHost = UpdateJobEmailHost.Text;
            int port;

            if (int.TryParse(UpdateJobEmailPort.Text, out port))
            {
                Properties.Settings.Default.updateJobEmailPort = port;
            }

            Properties.Settings.Default.updateJobEmailUsername = UpdateJobEmailUsername.Text;
            Properties.Settings.Default.updateJobEmailSender   = UpdateJobEmailSender.Text;
            Properties.Settings.Default.updateJobEmail         = UpdateJobEmail.Text;
            Properties.Settings.Default.updateJobEmailPassword = EncryptionUtils.Protect(UpdateJobEmailPassword.Password);

            int timeout;

            if (int.TryParse(UpdateJobTimeout.Text, out timeout) && timeout > 0)
            {
                Properties.Settings.Default.updateJobTimeout = timeout;
            }

            Properties.Settings.Default.updateJobReportOutliers = UpdateJobAbnormalities.IsChecked.Value;
            Properties.Settings.Default.updateJobTimeouts       = UpdateJobTimeouts.IsChecked.Value;
            Properties.Settings.Default.updateJobReportErrors   = UpdateJobDatasourceErrors.IsChecked.Value;
            Properties.Settings.Default.updateJobReportNoData   = UpdateJobNoData.IsChecked.Value;

            //Economic Releases
            Properties.Settings.Default.EconomicReleaseDefaultDatasource = SelectedDefaultEconomicReleaseDatasource;

            Properties.Settings.Default.Save();

            Close();
        }