Beispiel #1
0
 public EmailSender(string host, string username, string password, int port)
 {
     _client = new SmtpClient
     {
         Port                  = port,
         DeliveryMethod        = SmtpDeliveryMethod.Network,
         EnableSsl             = true,
         UseDefaultCredentials = false,
         Host                  = host,
         Credentials           = new System.Net.NetworkCredential(username, EncryptionUtils.Unprotect(password))
     };
 }
Beispiel #2
0
        private static void SetMySqlConnectionString(string stringName, string dbName)
        {
            Configuration            config      = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            ConnectionStringSettings conSettings = config.ConnectionStrings.ConnectionStrings[stringName];

            //this is an extremely dirty hack that allows us to change the connection string at runtime
            var fi = typeof(ConfigurationElement).GetField("_bReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);

            fi.SetValue(conSettings, false);

            conSettings.ConnectionString = string.Format("User Id={0};Password={1};Host={2};Database={3};Persist Security Info=True;UseCompression=True;SslMode=none",
                                                         Settings.Default.mySqlUsername,
                                                         EncryptionUtils.Unprotect(Settings.Default.mySqlPassword),
                                                         Settings.Default.mySqlHost,
                                                         dbName);
            conSettings.ProviderName = "MySql.Data.MySqlClient";

            config.Save();
        }
Beispiel #3
0
        private static void SetSqlServerConnectionString(string stringName, string dbName)
        {
            Configuration            config      = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            ConnectionStringSettings conSettings = config.ConnectionStrings.ConnectionStrings[stringName];

            //this is an extremely dirty hack that allows us to change the connection string at runtime
            var fi = typeof(ConfigurationElement).GetField("_bReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);

            fi.SetValue(conSettings, false);

            conSettings.ConnectionString = GetSqlServerConnectionString(
                dbName,
                Settings.Default.sqlServerHost,
                Settings.Default.sqlServerUsername,
                EncryptionUtils.Unprotect(Settings.Default.sqlServerPassword),
                useWindowsAuthentication: Settings.Default.sqlServerUseWindowsAuthentication);
            conSettings.ProviderName = "System.Data.SqlClient";

            config.Save();
        }
Beispiel #4
0
        private static NameValueCollection GetQuartzSettingsSqlServer()
        {
            NameValueCollection properties = new NameValueCollection();

            properties["quartz.scheduler.instanceName"]      = "QdmsScheduler";
            properties["quartz.scheduler.instanceId"]        = "instance_one";
            properties["quartz.jobStore.type"]               = "Quartz.Impl.AdoJobStore.JobStoreTX, Quartz";
            properties["quartz.jobStore.driverDelegateType"] = "Quartz.Impl.AdoJobStore.SqlServerDelegate, Quartz";
            properties["quartz.jobStore.useProperties"]      = "true";
            properties["quartz.jobStore.dataSource"]         = "default";
            properties["quartz.jobStore.tablePrefix"]        = "QRTZ_";

            //properties["quartz.jobStore.lockHandler.type"] = "Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz";

            properties["quartz.dataSource.default.connectionString"] = DBUtils.GetSqlServerConnectionString(
                "qdmsQuartz",
                Settings.Default.sqlServerHost,
                Settings.Default.sqlServerUsername,
                EncryptionUtils.Unprotect(Settings.Default.sqlServerPassword),
                useWindowsAuthentication: Settings.Default.sqlServerUseWindowsAuthentication);
            properties["quartz.dataSource.default.provider"] = "SqlServer-20";

            return(properties);
        }
Beispiel #5
0
        public SettingsWindow()
        {
            InitializeComponent();

            //Economic Releases
            EconomicReleaseDataSources.Add("FXStreet");
            SelectedDefaultEconomicReleaseDatasource = Properties.Settings.Default.EconomicReleaseDefaultDatasource;

            //ports for the servers
            RTDPubPortTextBox.Text = Properties.Settings.Default.rtDBPubPort.ToString();
            RTDReqPortTextBox.Text = Properties.Settings.Default.rtDBReqPort.ToString();
            HDPortTextBox.Text     = Properties.Settings.Default.hDBPort.ToString();
            HttpPort.Text          = Properties.Settings.Default.httpPort.ToString();

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

            //logs
            LogFolderTextBox.Text = Properties.Settings.Default.logDirectory;

            //IB Settings
            IBHostTextBox.Text                   = Properties.Settings.Default.ibClientHost;
            IBPortTextBox.Text                   = Properties.Settings.Default.ibClientPort.ToString();
            IBHistClientIDTextBox.Text           = Properties.Settings.Default.histClientIBID.ToString();
            IBRTDClientIDTextBox.Text            = Properties.Settings.Default.rtdClientIBID.ToString();
            IBUseNewRealtimeDataSystem.IsChecked = Properties.Settings.Default.ibUseNewRealTimeDataSystem;

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

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

            //Database
            if (Properties.Settings.Default.databaseType == "MySql")
            {
                DbTypeMySql.IsChecked     = true;
                DbTypeSqlServer.IsChecked = false;
            }
            else
            {
                DbTypeMySql.IsChecked     = false;
                DbTypeSqlServer.IsChecked = true;
            }

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

            SqlServerAuthenticationWindowsRadioBtn.IsChecked = Properties.Settings.Default.sqlServerUseWindowsAuthentication;
            SqlServerAuthenticationServerRadioBtn.IsChecked  = !Properties.Settings.Default.sqlServerUseWindowsAuthentication;
            SqlServerHost.Text         = Properties.Settings.Default.sqlServerHost;
            SqlServerUsername.Text     = Properties.Settings.Default.sqlServerUsername;
            SqlServerPassword.Password = EncryptionUtils.Unprotect(Properties.Settings.Default.sqlServerPassword);

            //Data jobs
            UpdateJobEmailHost.Text         = Properties.Settings.Default.updateJobEmailHost;
            UpdateJobEmailPort.Text         = Properties.Settings.Default.updateJobEmailPort.ToString();
            UpdateJobEmailUsername.Text     = Properties.Settings.Default.updateJobEmailUsername;
            UpdateJobEmailSender.Text       = Properties.Settings.Default.updateJobEmailSender;
            UpdateJobEmail.Text             = Properties.Settings.Default.updateJobEmail;
            UpdateJobEmailPassword.Password = EncryptionUtils.Unprotect(Properties.Settings.Default.updateJobEmailPassword);
            UpdateJobTimeout.Text           = Properties.Settings.Default.updateJobTimeout.ToString();

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

            DataContext = this;
        }
Beispiel #6
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;
            }

            Properties.Settings.Default.ibUseNewRealTimeDataSystem = IBUseNewRealtimeDataSystem.IsChecked.Value;

            //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();
        }