예제 #1
0
        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;
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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;
            }
        }
예제 #5
0
 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;
 }
예제 #6
0
 public async Task <IEnumerable <PurgeWorkerData> > GetAll(ISqlSettings settings)
 {
     return(await _genericDataFactory.GetData(
                settings,
                _providerFactory,
                "[bll].[GetAllPurgeWorker]",
                () => new PurgeWorkerData(),
                DataUtil.AssignDataStateManager
                ));
 }
예제 #7
0
        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);
        }
예제 #8
0
 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();
         }
     }
 }
예제 #9
0
        public DbConnectionProvider(ILogger logger, ISqlSettings settings)
        {
            _logger         = logger;
            _lazyConnection = new Lazy <IDbConnection>(() =>
            {
                if (_connection != null)
                {
                    return(_connection);
                }

                _connection = CreateConnection(settings);
                return(_connection);
            });
        }
예제 #10
0
        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());
        }
예제 #11
0
        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
                       ));
        }
예제 #12
0
 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
                ));
 }
예제 #13
0
        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());
        }
예제 #14
0
        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
            }
                       ));
        }
예제 #15
0
 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());
 }
예제 #16
0
        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
            }
                       ));
        }
예제 #17
0
        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
            }
                       ));
        }
예제 #18
0
        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());
        }
예제 #19
0
        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());
        }
예제 #20
0
 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
                ));
 }
예제 #21
0
        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();
                }
            }
        }
예제 #22
0
        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());
        }
예제 #23
0
 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
                ));
 }
예제 #24
0
        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());
        }
예제 #25
0
        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();
                }
            }
        }
예제 #26
0
        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);
        }
예제 #27
0
        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;
            }
        }
예제 #28
0
        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);
        }
예제 #29
0
        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;
        }
예제 #30
0
        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);
        }
예제 #31
0
 public SettingsForm(ISqlSettings settings, Assembly pluginAssembly, string aboutDescription)
     : this(settings, pluginAssembly, aboutDescription, null)
 {
 }
예제 #32
0
 public SettingsForm(ISqlSettings settings, Assembly pluginAssembly, string aboutDescription) : this(settings, pluginAssembly, aboutDescription, null)
 {
 }
예제 #33
0
 public SqlRepo(ISqlSettings settings, IRepoX repoX)
 {
     _settings = settings;
     _repoX    = repoX;
 }
예제 #34
0
 public OracleRepo(ISqlSettings settings, IRepoX repoX)
 {
     _settings = settings;
     _repoX    = repoX;
 }