public SettingsForm(ISqlSettings settings, Assembly pluginAssembly, string aboutDescription, FixHotkeyDefault hotkeyDefaultFixMethod) { _settings = settings; _pluginAssembly = pluginAssembly; _aboutDescription = aboutDescription; _hotkeyDefaultFixMethod = hotkeyDefaultFixMethod; InitializeComponent(); if (_hotkeyDefaultFixMethod != null) { foreach (System.Configuration.SettingsProperty prop in _settings.Properties) { if (prop.Name.Equals("Hotkey")) { _supportsHotkey = true; } } } if (!_supportsHotkey) { txt_Hotkey.Visible = false; lbl_Hotkey.Visible = false; lbl_HotkeyHint.Visible = false; } }
public async Task <IEnumerable <Guid> > GetAccountIdsByUserId(ISqlSettings settings, Guid userId) { List <Guid> result = new List <Guid>(); IDataParameter parameter = DataUtil.CreateParameter(_providerFactory, "userGuid", DbType.Guid, userId); using (DbConnection connection = await _providerFactory.OpenConnection(settings)) { using (DbCommand command = connection.CreateCommand()) { command.CommandText = "[bla].[GetAccountGuidByUserGuid]"; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(parameter); using (DbDataReader reader = await command.ExecuteReaderAsync()) { while (await reader.ReadAsync()) { result.Add(await reader.GetFieldValueAsync <Guid>(0)); } reader.Close(); } } connection.Close(); } return(result); }
public async Task <IEnumerable <string> > GetCodes(ISqlSettings settings, Guid domainId) { List <string> result = new List <string>(); using (DbConnection connection = await _providerFactory.OpenConnection(settings)) { using (DbCommand command = connection.CreateCommand()) { command.CommandText = "[blc].[GetLookupCodes]"; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add( DataUtil.CreateParameter(_providerFactory, "domainId", DbType.Guid, domainId) ); using (DbDataReader reader = await command.ExecuteReaderAsync()) { while (await reader.ReadAsync()) { result.Add(await reader.GetFieldValueAsync <string>(0)); } } } connection.Close(); } return(result); }
public SettingsForm(ISqlSettings settings, Assembly pluginAssembly, string aboutDescription, GetTextEditorKeyBindingScopeName keyBindingScopeNameMethod) { _settings = settings; _pluginAssembly = pluginAssembly; _aboutDescription = aboutDescription; _keyBindingScopeNameMethod = keyBindingScopeNameMethod; foreach (System.Configuration.SettingsProperty prop in _settings.Properties) { if (prop.Name.Equals("Hotkey")) { _supportsHotkey = true; } } InitializeComponent(); if (!_supportsHotkey) { txt_Hotkey.Visible = false; lbl_Hotkey.Visible = false; lbl_HotkeyHint.Visible = false; } }
public static PoorMansTSqlFormatterLib.SqlFormattingManager GetFormattingManager(ISqlSettings settings) { var formatter = new PoorMansTSqlFormatterLib.Formatters.TSqlStandardFormatter(settings.Options); ResourceManager _generalResourceManager = new ResourceManager("PoorMansTSqlFormatterPluginShared.GeneralLanguageContent", Assembly.GetExecutingAssembly()); formatter.ErrorOutputPrefix = _generalResourceManager.GetString("ParseErrorWarningPrefix") + System.Environment.NewLine; var formattingManager = new PoorMansTSqlFormatterLib.SqlFormattingManager(formatter); return formattingManager; }
public async Task <IEnumerable <PurgeWorkerData> > GetAll(ISqlSettings settings) { return(await _genericDataFactory.GetData( settings, _providerFactory, "[bll].[GetAllPurgeWorker]", () => new PurgeWorkerData(), DataUtil.AssignDataStateManager )); }
public async Task <IEnumerable <T> > GetData(ISqlSettings settings, ISqlDbProviderFactory providerFactory, string commandText, Func <T> createModelObject, Action <IEnumerable <T> > assignDataStateManager, IEnumerable <IDataParameter> parameters, CommandType commandType) { IEnumerable <T> data = await GetData(settings, providerFactory, commandText, createModelObject, parameters, commandType); if (assignDataStateManager != null) { assignDataStateManager(data); } return(data); }
public async Task InitializePurgeWorker(ISqlSettings settings) { using (DbConnection connection = await _providerFactory.OpenConnection(settings)) { using (DbCommand command = connection.CreateCommand()) { command.CommandText = "[bll].[InitializePurgeWorker]"; command.CommandType = CommandType.StoredProcedure; await command.ExecuteNonQueryAsync(); } } }
public DbConnectionProvider(ILogger logger, ISqlSettings settings) { _logger = logger; _lazyConnection = new Lazy <IDbConnection>(() => { if (_connection != null) { return(_connection); } _connection = CreateConnection(settings); return(_connection); }); }
public async Task <ExceptionData> GetInnerException(ISqlSettings settings, long id) { IDataParameter parameter = DataUtil.CreateParameter(_providerFactory, "id", DbType.Int64, id); return((await _genericDataFactory.GetData( settings, _providerFactory, "[bll].[GetInnerException]", () => new ExceptionData(), DataUtil.AssignDataStateManager, new List <IDataParameter> { parameter } )).FirstOrDefault()); }
public async Task <IEnumerable <ItemHistoryData> > GetByItemId(ISqlSettings settings, Guid itemId) { List <IDataParameter> parameters = new List <IDataParameter> { DataUtil.CreateParameter(_providerFactory, "itemId", DbType.Guid, itemId) }; return(await _genericDataFactory.GetData( settings, _providerFactory, "[blc].[GetItemHistoryByItemId]", () => new ItemHistoryData(), parameters )); }
public async Task <IEnumerable <UserInvitationData> > GetByAccountId(ISqlSettings settings, Guid accountId) { IDataParameter[] parameters = { DataUtil.CreateParameter(_providerFactory, "accountGuid", DbType.Guid, accountId) }; return(await _genericDataFactory.GetData( settings, _providerFactory, "[bla].[GetUserInvitationByAccountGuid]", () => new UserInvitationData(), DataUtil.AssignDataStateManager, parameters )); }
public async Task <UserData> GetByReferenceId(ISqlSettings settings, string referenceId) { IDataParameter parameter = DataUtil.CreateParameter(_providerFactory, "referenceId", DbType.AnsiString, referenceId); return((await _genericDataFactory.GetData( settings, _providerFactory, "[bla].[GetUserByReferenceId]", () => new UserData(), DataUtil.AssignDataStateManager, new List <IDataParameter> { parameter } )).FirstOrDefault()); }
public async Task <IEnumerable <ClientCredentialData> > GetByClientId(ISqlSettings settings, Guid clientId) { IDataParameter parameter = DataUtil.CreateParameter(_providerFactory, "clientId", DbType.Guid, clientId); return(await _genericDataFactory.GetData( settings, _providerFactory, "[bla].[GetClientCredential_by_ClientId]", () => new ClientCredentialData(), DataUtil.AssignDataStateManager, new List <IDataParameter> { parameter } )); }
public async Task <UserInvitationData> Get(ISqlSettings settings, Guid id) { IDataParameter[] parameters = { DataUtil.CreateParameter(_providerFactory, "id", DbType.Guid, id) }; return((await _genericDataFactory.GetData( settings, _providerFactory, "[bla].[GetUserInvitation]", () => new UserInvitationData(), DataUtil.AssignDataStateManager, parameters )).FirstOrDefault()); }
public async Task <IEnumerable <UserData> > GetByEmailAddress(ISqlSettings settings, string emailAddress) { IDataParameter parameter = DataUtil.CreateParameter(_providerFactory, "address", DbType.String, emailAddress); return(await _genericDataFactory.GetData( settings, _providerFactory, "[bla].[GetUserByEmailAddress]", () => new UserData(), DataUtil.AssignDataStateManager, new List <IDataParameter> { parameter } )); }
public async Task <IEnumerable <UserData> > GetByAccountId(ISqlSettings settings, Guid accountId) { IDataParameter parameter = DataUtil.CreateParameter(_providerFactory, "accountId", DbType.Guid, accountId); return(await _genericDataFactory.GetData( settings, _providerFactory, "[bla].[GetUserByAccountId]", () => new UserData(), DataUtil.AssignDataStateManager, new List <IDataParameter> { parameter } )); }
public async Task <UserData> Get(ISqlSettings settings, Guid id) { IDataParameter parameter = DataUtil.CreateParameter(_providerFactory, "guid", DbType.Guid, id); return((await _genericDataFactory.GetData( settings, _providerFactory, "[bla].[GetUser]", () => new UserData(), DataUtil.AssignDataStateManager, new List <IDataParameter> { parameter } )).FirstOrDefault()); }
public async Task <EmailAddressData> GetByAddress(ISqlSettings settings, string address) { IDataParameter parameter = DataUtil.CreateParameter(_providerFactory, "address", DbType.String, address); return((await _genericDataFactory.GetData( settings, _providerFactory, "[bla].[GetEmailAddressByAddress]", () => new EmailAddressData(), DataUtil.AssignDataStateManager, new List <IDataParameter> { parameter } )).FirstOrDefault()); }
public async Task <IEnumerable <ExceptionData> > GetTopBeforeTimestamp(ISqlSettings settings, Guid domainId, DateTime maxTimestamp) { IDataParameter[] parameters = new IDataParameter[] { DataUtil.CreateParameter(_providerFactory, "domainId", DbType.Guid, domainId), DataUtil.CreateParameter(_providerFactory, "maxTimestamp", DbType.DateTime2, maxTimestamp) }; return(await _genericDataFactory.GetData( settings, _providerFactory, "[bll].[GetTopExceptionBeforeTimestamp]", () => new ExceptionData(), DataUtil.AssignDataStateManager, parameters )); }
private async Task DeleteByMinTimestamp(ISqlSettings settings, DateTime timestamp, string procedureName) { IDataParameter parameter = DataUtil.CreateParameter(_providerFactory, "minTimestamp", DbType.DateTime2, timestamp); using (DbConnection connection = await _providerFactory.OpenConnection(settings)) { using (DbCommand command = connection.CreateCommand()) { command.CommandText = procedureName; command.CommandType = CommandType.StoredProcedure; command.CommandTimeout = 150; command.Parameters.Add(parameter); await command.ExecuteNonQueryAsync(); } } }
public async Task <PurgeWorkerData> Get(ISqlSettings settings, Guid id) { IDataParameter[] parameters = new IDataParameter[] { DataUtil.CreateParameter(_providerFactory, "purgeWorkerId", DbType.Guid, id), }; return((await _genericDataFactory.GetData( settings, _providerFactory, "[bll].[GetPurgeWorker]", () => new PurgeWorkerData(), DataUtil.AssignDataStateManager, parameters )).FirstOrDefault()); }
public Task <IEnumerable <T> > GetData( ISqlSettings settings, ISqlDbProviderFactory providerFactory, string commandText, Func <T> createModelObject, IEnumerable <IDataParameter> parameters, CommandType commandType) { return(GetData( () => providerFactory.OpenConnection(settings), commandText, createModelObject, parameters, commandType )); }
public async Task <LookupData> GetByCode(ISqlSettings settings, Guid domainId, string code) { List <IDataParameter> parameters = new List <IDataParameter> { DataUtil.CreateParameter(_providerFactory, "domainId", DbType.Guid, domainId), DataUtil.CreateParameter(_providerFactory, "code", DbType.AnsiString, code) }; return((await _genericDataFactory.GetData( settings, _providerFactory, "[blc].[GetLookupByCode]", () => new LookupData(), DataUtil.AssignDataStateManager, parameters )).FirstOrDefault()); }
private async Task Purge(ISqlSettings settings, Guid domainId, DateTime maxExpirationTimestamp, string procedureName) { IDataParameter parameterDomainId = DataUtil.CreateParameter(_providerFactory, "domainId", DbType.Guid, domainId); IDataParameter parameterMaxExpirationTimestamp = DataUtil.CreateParameter(_providerFactory, "maxExpirationTimestamp", DbType.DateTime2, maxExpirationTimestamp); using (DbConnection connection = await _providerFactory.OpenConnection(settings)) { using (DbCommand command = connection.CreateCommand()) { command.CommandText = procedureName; command.CommandType = CommandType.StoredProcedure; command.CommandTimeout = 150; command.Parameters.Add(parameterDomainId); command.Parameters.Add(parameterMaxExpirationTimestamp); await command.ExecuteNonQueryAsync(); } } }
private IDbConnection CreateConnection(ISqlSettings settings) { Dapper.DefaultTypeMap.MatchNamesWithUnderscores = true; var pgSql = new NpgsqlConnection(settings.EphemeralConnectionString); pgSql.Notice += (sender, args) => _logger.Information("psql NOTICE: {Notice} at {Where}", args.Notice.MessageText, args.Notice.Where); try { pgSql.Open(); } catch (Exception ex) { throw new Exception("Error opening connection to database (" + settings.EphemeralConnectionString + "): " + ex.Message, ex); } return(pgSql); }
public SettingsForm(ISqlSettings settings, Assembly pluginAssembly, string aboutDescription, GetTextEditorKeyBindingScopeName keyBindingScopeNameMethod) { _settings = settings; _pluginAssembly = pluginAssembly; _aboutDescription = aboutDescription; _keyBindingScopeNameMethod = keyBindingScopeNameMethod; foreach (System.Configuration.SettingsProperty prop in _settings.Properties) if (prop.Name.Equals("Hotkey")) _supportsHotkey = true; InitializeComponent(); if (!_supportsHotkey) { txt_Hotkey.Visible = false; lbl_Hotkey.Visible = false; lbl_HotkeyHint.Visible = false; } }
private IDbConnection CreateConnection(ISqlSettings settings) { Dapper.DefaultTypeMap.MatchNamesWithUnderscores = true; var pgSql = new NpgsqlConnection(settings.EphemeralConnectionString); pgSql.Notice += (sender, args) => _logger.Information("psql NOTICE: {Notice} at {Where}", args.Notice.MessageText, args.Notice.Where); try { _logger.Information("Opening SQL Connection"); pgSql.Open(); _logger.Information("SQL Connection ({ProcessId}/{ServerVersion}) state: {State}", pgSql.ProcessID, pgSql.PostgreSqlVersion, pgSql.FullState); } catch (Exception ex) { throw new Exception("Error opening SQL Connection to database (" + settings.EphemeralConnectionString + "): " + ex.Message, ex); } return(pgSql); }
public static PoorMansTSqlFormatterLib.SqlFormattingManager GetFormattingManager(ISqlSettings settings) { var formatter = new PoorMansTSqlFormatterLib.Formatters.TSqlStandardFormatter( settings.IndentString.Replace("\\t", "\t").Replace("\\s", " "), settings.SpacesPerTab, settings.MaxLineWidth, settings.ExpandCommaLists, settings.TrailingCommas, settings.SpaceAfterExpandedComma, settings.ExpandBooleanExpressions, settings.ExpandCaseStatements, settings.ExpandBetweenConditions, settings.BreakJoinOnSections, settings.UppercaseKeywords, false, settings.KeywordStandardization ); ResourceManager _generalResourceManager = new ResourceManager("PoorMansTSqlFormatterPluginShared.GeneralLanguageContent", Assembly.GetExecutingAssembly()); formatter.ErrorOutputPrefix = _generalResourceManager.GetString("ParseErrorWarningPrefix") + System.Environment.NewLine; var formattingManager = new PoorMansTSqlFormatterLib.SqlFormattingManager(formatter); return formattingManager; }
public async Task <Guid?> ClaimPurgeWorker(ISqlSettings settings) { Guid? result = null; IDataParameter parameter = DataUtil.CreateParameter(_providerFactory, "id", DbType.Guid); parameter.Direction = ParameterDirection.Output; using (DbConnection connection = await _providerFactory.OpenConnection(settings)) { using (DbCommand command = connection.CreateCommand()) { command.CommandText = "[bll].[ClaimPurgeWorker]"; command.CommandType = CommandType.StoredProcedure; command.Parameters.Add(parameter); await command.ExecuteNonQueryAsync(); if (parameter.Value != null && parameter.Value != DBNull.Value) { result = (Guid)parameter.Value; } } } return(result); }
public SettingsForm(ISqlSettings settings, Assembly pluginAssembly, string aboutDescription) : this(settings, pluginAssembly, aboutDescription, null) { }
public SqlRepo(ISqlSettings settings, IRepoX repoX) { _settings = settings; _repoX = repoX; }
public OracleRepo(ISqlSettings settings, IRepoX repoX) { _settings = settings; _repoX = repoX; }