public void UpdateDalConfig(DalConfig config) { var validationResult = ValidateInput(); if (!string.IsNullOrWhiteSpace(validationResult)) { throw new Exception(validationResult); } config.DesignerConnection = new DesignerConnection() { Authentication = Authentication.SelectedIndex == 0 ? new Authentication {AuthenticationType = AuthenticationType.WindowsAuthentication} : (Authentication) new Authentication { AuthenticationType = AuthenticationType.SqlAuthentication, UserName = UserName.Text, Password = Password.Text, SavePassword = SavePassword.Checked }, ServerName = ServerName.Text, DatabaseName = (string) DatabaseName.SelectedItem }; config.Namespace = Namespace.Text; config.RuntimeConnectionStringName = ConnectionString.Text; }
public TableValuedParameter(DalConfig config, ISqlRepository sqlRepository) { _config = config; if (sqlRepository == null) throw new ArgumentNullException(nameof(sqlRepository)); _sqlRepository = sqlRepository; }
public void InitializeFromDalConfig(DalConfig config) { ServerName.Text = config?.DesignerConnection?.ServerName; if (config?.DesignerConnection?.Authentication?.AuthenticationType == AuthenticationType.SqlAuthentication) { _sqlPassword = config?.DesignerConnection?.Authentication?.Password; _sqlUserName = config?.DesignerConnection?.Authentication?.UserName; var savePasswordNullable = config?.DesignerConnection?.Authentication?.SavePassword; _sqlSavePassword = savePasswordNullable.HasValue && savePasswordNullable.Value; } Authentication.SelectedIndex = config?.DesignerConnection?.Authentication?.AuthenticationType == AuthenticationType.SqlAuthentication ? 1 : 0; ServerName.Text = config?.DesignerConnection?.ServerName; if (!string.IsNullOrWhiteSpace(config?.DesignerConnection?.DatabaseName)) { DatabaseName.Items.Add(config?.DesignerConnection?.DatabaseName); DatabaseName.SelectedIndex = 0; } Namespace.Text = config?.Namespace; ConnectionString.Text = config?.RuntimeConnectionStringName; }
public Enum(DalConfig config, ISqlRepository sqlRepository) { _config = config; if (sqlRepository == null) throw new ArgumentNullException(nameof(sqlRepository)); _sqlRepository = sqlRepository; }
public Procedure(DalConfig config, ISqlRepository sqlRepository, bool supportsAsync) { _config = config; if (sqlRepository == null) throw new ArgumentNullException(nameof(sqlRepository)); _sqlRepository = sqlRepository; _supportsAsync = supportsAsync; }
private void Edit_Click(object sender, EventArgs e) { var tempConfig = _config.Clone(); if (new ModelWizard(tempConfig).ShowDialog(this) == DialogResult.OK) { _config = tempConfig.Clone(); RefreshEditor(); } }
public ModelWizard(DalConfig config) { _config = config; InitializeComponent(); VisibleTab_Changed(null, null); foreach (TabPage tabPage in tabContainer.TabPages) { tabPage.Controls.OfType<IUseDalConfig>().FirstOrDefault()?.InitializeFromDalConfig(_config); } }
public void InitializeFromDalConfig(DalConfig config) { _config = config; if (_config?.Enums == null) return; foreach (var _enum in _config.Enums) { _configEnumsCollection.Add(Utilities.QuoteName(_enum.Schema) + "." + Utilities.QuoteName(_enum.TableName), _enum); } }
public void UpdateDalConfig(DalConfig config) { config.Procedures = (from DataGridViewRow row in proceduresGrid.Rows where (bool)row.Cells["GenerateInterface"].Value select new Procedure() { Schema = (string)row.Cells["Schema"].Value, ProcedureName = (string)row.Cells["ProcedureName"].Value, Alias = (string)row.Cells["Alias"].Value }).ToList(); }
public void InitializeFromDalConfig(DalConfig config) { _config = config; if (_config?.Procedures == null) return; foreach (var procedure in _config.Procedures) { _configProceduresCollection.Add(Utilities.QuoteName(procedure.Schema) + "." + Utilities.QuoteName(procedure.ProcedureName), procedure); } }
public void UpdateDalConfig(DalConfig config) { config.Enums = (from DataGridViewRow row in enumsGrid.Rows where (bool)row.Cells["GenerateInterface"].Value select new Enum() { Schema = (string)row.Cells["Schema"].Value, TableName = (string)row.Cells["TableName"].Value, KeyColumn = (string)row.Cells["KeyColumn"].Value, ValueColumn = (string)row.Cells["ValueColumn"].Value, Alias = (string)row.Cells["Alias"].Value }).ToList(); }
internal static string BuildConnectionString(DalConfig config) { var csb = new SqlConnectionStringBuilder { DataSource = config.DesignerConnection.ServerName, InitialCatalog = config.DesignerConnection.DatabaseName }; if (config.DesignerConnection.Authentication.AuthenticationType == AuthenticationType.SqlAuthentication) { csb.UserID = config.DesignerConnection.Authentication.UserName; csb.Password = config.DesignerConnection.Authentication.Password; } else { csb.IntegratedSecurity = true; } return csb.ConnectionString; }
public void Init(string configSerialized) { try { _config = JsonConvert.DeserializeObject<DalConfig>(configSerialized, new StringEnumConverter()); } catch (Exception je) { try { // if the json deserialization did not work try xml _config = SimpleDataAccessLayer.Common.utilities.DalConfigXmlConverter.ParseDalConfigXml(configSerialized); } catch (Exception xe) { MessageBox.Show( $"Failed to deserealize config file.\r\nJSON error: \"{je.Message}\"\r\nXML error: \"{xe.Message}\"\r\nBlank config will be used.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); _config = new DalConfig(); } } RefreshEditor(); }
public DalConfig Clone() { var clone = new DalConfig() { DesignerConnection = new DesignerConnection() { Authentication = new Authentication() { AuthenticationType = (DesignerConnection?.Authentication?.AuthenticationType) ?? AuthenticationType.WindowsAuthentication, Password = DesignerConnection?.Authentication?.Password == null ? null : string.Copy(DesignerConnection?.Authentication?.Password), UserName = DesignerConnection?.Authentication?.UserName == null ? null : string.Copy(DesignerConnection?.Authentication?.UserName), SavePassword = (DesignerConnection?.Authentication?.SavePassword) ?? false }, DatabaseName = DesignerConnection?.DatabaseName == null ? null : string.Copy(DesignerConnection?.DatabaseName), ServerName = DesignerConnection?.ServerName == null ? null : string.Copy(DesignerConnection?.ServerName) }, Namespace = Namespace == null ? null : string.Copy(Namespace), RuntimeConnectionStringName = RuntimeConnectionStringName == null ? null : string.Copy(RuntimeConnectionStringName), Enums = new List<Enum>(Enums.Select(e => new Enum { Alias = e.Alias == null ? null : string.Copy(e.Alias), Schema = e.Schema == null ? null : string.Copy(e.Schema), ValueColumn = e.ValueColumn == null ? null : string.Copy(e.ValueColumn), KeyColumn = e.KeyColumn == null ? null : string.Copy(e.KeyColumn), TableName = e.TableName == null ? null : string.Copy(e.TableName) })), Procedures = new List<Procedure>(Procedures.Select(p => new Procedure { Schema = p.Schema == null ? null : string.Copy(p.Schema), Alias = p.Alias == null ? null : string.Copy(p.Alias), ProcedureName = p.ProcedureName == null ? null : string.Copy(p.ProcedureName) })) }; return clone; }
public Common(DalConfig config) { _config = config; }
public Main(DalConfig dalConfig, bool supportsAsync) { _config = dalConfig; _supportsAsync = supportsAsync; }