public ProcessDAL() { // Create a Settings object with all Defaults DALSettingsSection dss = new DALSettingsSection(); Settings = new DALSettings(dss); }
private void MenuItem_Click(object sender, RoutedEventArgs e) { lblStatus.Text = "Specify new config"; // Create OpenFileDialog Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); // Set filter for file extension and default file extension dlg.DefaultExt = ".config"; dlg.Filter = "Config files (*.config)|*.config"; // Display OpenFileDialog by calling ShowDialog method Nullable <bool> result = dlg.ShowDialog(); // Get the selected file name and display in a TextBox if (result == true) { // Open document string filename = dlg.FileName; ExeConfigurationFileMap fm = new ExeConfigurationFileMap(); fm.ExeConfigFilename = filename; var conf = ConfigurationManager.OpenMappedExeConfiguration(fm, ConfigurationUserLevel.None); DALSettingsSection dss = (DALSettingsSection)conf.Sections["dalSettings"]; DALSettings settings = new DALSettings(dss); this.DataContext = settings; lblStatus.Text = "New Config Loaded"; return; } lblStatus.Text = "Ready"; }
static void Main(string[] args) { Console.WriteLine("Simple test of constructing the objects..."); DALSettingsSection dss = null; var config = ConfigurationManager.OpenExeConfiguration(null); dss = (DALSettingsSection)config.Sections["dalSettings"]; Console.WriteLine("Looking for templates in this folder: " + dss.BaseTemplateFolder); DALSettings settings = new DALSettings(dss); ProcessDAL pd = new ProcessDAL(settings); if (pd.GenerateAllFiles()) { Console.WriteLine("Files generated successfully."); Console.WriteLine("Please check the " + dss.BaseOutputFolder + " folder for results."); } else { Console.WriteLine("There was some sort of processing error."); Console.WriteLine("Check the log files."); } Console.Write("End of test. Press Enter..."); Console.ReadLine(); }
/// <summary> /// Save the data /// </summary> private void _SaveData() { if (this.rbSQL.Checked) { this._cfg.Server = this.txtServer.Text.Trim(); this._cfg.Database = this.txtDatabase.Text.Trim(); this._cfg.User = this.txtUsername.Text.Trim(); this._cfg.Password = this.txtPassword.Text.Trim(); this._cfg.IntegratedSecurity = false; } else { this._cfg = null; this._cfg = new DALSettings( ProviderType.MSSql2005, this.txtServer.Text.Trim(), this.txtDatabase.Text.Trim() ); } try { Configuration.SaveConnectionString(this._cfg.ConnectionString); } catch (Exception) { } }
// ------------------------------------------------------- // PRIVATE MEMBERS // ------------------------------------------------------- /// <summary> /// Load the data /// </summary> private void _LoadData() { this._cfg = UdlParser.ParseConnectionString( Configuration.ConnectionString ); if (this._cfg.IsWindowsAuthentication) { this.rbWindows.Checked = true; this.rbSQL.Checked = false; this.txtServer.Enabled = true; this.txtDatabase.Enabled = true; this.txtUsername.Enabled = false; this.txtPassword.Enabled = false; this.txtServer.Text = this._cfg.Server; this.txtDatabase.Text = this._cfg.Database; } else { this.rbWindows.Checked = false; this.rbSQL.Checked = true; this.txtServer.Enabled = true; this.txtDatabase.Enabled = true; this.txtUsername.Enabled = true; this.txtPassword.Enabled = true; this.txtServer.Text = this._cfg.Server; this.txtDatabase.Text = this._cfg.Database; this.txtUsername.Text = this._cfg.User; this.txtPassword.Text = this._cfg.Password; } }
void worker_DoWork(object sender, DoWorkEventArgs e) { DALSettingsSection sect = e.Argument as DALSettingsSection; DALSettings settings = new DALSettings(sect); ProcessDAL pd = new ProcessDAL(settings); e.Result = pd.GenerateAllFiles(); }
public void SetupObjects() { // Read the settings from the config file. // Assume "App" file exists in the output folder var config = ConfigurationManager.OpenExeConfiguration(".\\App"); _dssConfigured = (DALSettingsSection)config.Sections["dalSettings"]; _settingsConfigured = new DALSettings(_dssConfigured); _dssDefault = new DALSettingsSection(); _settingsDefault = new DALSettings(_dssDefault); }
/// <summary> /// Initializes a new instance of the <see cref="WikipediaParser"/> class. /// </summary> /// <param name="connectionString">The connection string.</param> public WikipediaParser(string connectionString) { if(connectionString == null || connectionString.Trim() == "") { throw new ArgumentNullException( "connectionString", "The connectionString parameter cannot be null." ); } this._cfg = UdlParser.ParseConnectionString(connectionString); this._db = new DAL(this._cfg); this._dh = new DataHandler(connectionString); this._sh = new StaticHandler(connectionString); }
private void LoadSettingsSection() { DALSettingsSection dss = null; var config = ConfigurationManager.OpenExeConfiguration(null); dss = (DALSettingsSection)config.Sections["dalSettings"]; Console.WriteLine("Looking for templates in this folder: " + dss.BaseTemplateFolder); DALSettings settings = new DALSettings(dss); this.DataContext = settings; ConfigureWorkerThread(); lblStatus.Text = "Ready"; }
/// <summary> /// Initializes a new instance of the <see cref="WikipediaParser"/> class. /// </summary> /// <param name="connectionString">The connection string.</param> public WikipediaParser(string connectionString) { if (connectionString == null || connectionString.Trim() == "") { throw new ArgumentNullException( "connectionString", "The connectionString parameter cannot be null." ); } this._cfg = UdlParser.ParseConnectionString(connectionString); this._db = new DAL(this._cfg); this._dh = new DataHandler(connectionString); this._sh = new StaticHandler(connectionString); }
/// <summary> /// Load the file /// </summary> /// <exception cref="FileNotFoundException">If the file was not found or is not a file with the Excel2003 format.</exception> /// <returns></returns> public bool LoadFile() { if (!File.Exists(this._filename)) { throw new FileNotFoundException( "The file [" + this._filename + "] does not exist or is not a file with the Microsoft Excel 2003 format.", this._filename ); } this._cfg = new DALSettings( ProviderType.OleDb, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + this._filename + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\";" ); this._db = new DAL(this._cfg); return(true); }
// --------------------------------------------------- // CONSTRUCTORS // --------------------------------------------------- /// <summary> /// Default Ctor /// </summary> /// <param name="connectionString"></param> /// <param name="filename">The filename including the path of the spreadsheet file.</param> /// <exception cref="ArgumentNullException">If the connectionString or filename parameter is null or empty.</exception> public OpenDocumentImporter(string connectionString, string filename) { if(connectionString == null || connectionString.Trim() == "") { throw new ArgumentNullException( "connectionString", "The connectionString parameter canot be null." ); } if(filename == null || filename.Trim() == "") { throw new ArgumentNullException( "filename", "The filename parameter canot be null." ); } this._filename = filename; this._cfg = UdlParser.ParseConnectionString(connectionString); this._db = new DAL(this._cfg); this._dh = new DataHandler(connectionString); }
// ------------------------------------------------------- // PRIVATE MEMBERS // ------------------------------------------------------- /// <summary> /// Load the data /// </summary> private void _LoadData() { this._cfg = UdlParser.ParseConnectionString( Configuration.ConnectionString ); if(this._cfg.IsWindowsAuthentication) { this.rbWindows.Checked = true; this.rbSQL.Checked = false; this.txtServer.Enabled = true; this.txtDatabase.Enabled = true; this.txtUsername.Enabled = false; this.txtPassword.Enabled = false; this.txtServer.Text = this._cfg.Server; this.txtDatabase.Text = this._cfg.Database; } else { this.rbWindows.Checked = false; this.rbSQL.Checked = true; this.txtServer.Enabled = true; this.txtDatabase.Enabled = true; this.txtUsername.Enabled = true; this.txtPassword.Enabled = true; this.txtServer.Text = this._cfg.Server; this.txtDatabase.Text = this._cfg.Database; this.txtUsername.Text = this._cfg.User; this.txtPassword.Text = this._cfg.Password; } }
/// <summary> /// Load the file /// </summary> /// <exception cref="FileNotFoundException">If the file was not found or is not a file with the Excel2003 format.</exception> /// <returns></returns> public bool LoadFile() { if(!File.Exists(this._filename)) { throw new FileNotFoundException( "The file [" + this._filename + "] does not exist or is not a file with the Microsoft Excel 2003 format.", this._filename ); } this._cfg = new DALSettings( ProviderType.OleDb, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + this._filename + ";Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\";" ); this._db = new DAL(this._cfg); return true; }
// ------------------------------------------------------- // CONSTRUCTORS // ------------------------------------------------------- /// <summary> /// Default constructor /// </summary> /// <param name="connectionString"></param> public StaticHandler(string connectionString) { this._cfg = UdlParser.ParseConnectionString(connectionString); this._db = new DAL(this._cfg); }
public ProcessDAL(DALSettings settings) { this.Settings = settings; }
private IdentityEFPersistenceBuilder(IConfiguration configuration) { _setting = DALSettings.GetSection(configuration ?? throw new DataAccessTierException(nameof(configuration))); }
/// <summary> /// Save the data /// </summary> private void _SaveData() { if(this.rbSQL.Checked) { this._cfg.Server = this.txtServer.Text.Trim(); this._cfg.Database = this.txtDatabase.Text.Trim(); this._cfg.User = this.txtUsername.Text.Trim(); this._cfg.Password = this.txtPassword.Text.Trim(); this._cfg.IntegratedSecurity = false; } else { this._cfg = null; this._cfg = new DALSettings( ProviderType.MSSql2005, this.txtServer.Text.Trim(), this.txtDatabase.Text.Trim() ); } try { Configuration.SaveConnectionString(this._cfg.ConnectionString); } catch(Exception) { } }