public void Init(string connectionString, DatabaseProvider databaseType)
        {
            DatabaseProvider = databaseType;

            conn = DatabaseProvider.GetAndConfigureConnection(connectionString, (dbConnection, dbtype) =>
            {
                switch (dbtype)
                {
                case DatabaseProvider.MySqlData:
                    MySqlInsightDbProvider.RegisterProvider();
                    break;

                case DatabaseProvider.Npgsql:
                    PostgreSQLInsightDbProvider.RegisterProvider();
                    break;

                case DatabaseProvider.SystemData:
                case DatabaseProvider.MicrosoftData:
                    SqlInsightDbProvider.RegisterProvider();
                    break;

                case DatabaseProvider.MySqlConnector:
                    MySqlConnectorInsightDbProvider.RegisterProvider();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                return(dbConnection);
            });
        }
Пример #2
0
        /// <summary>
        /// Initializes the database connection
        /// </summary>
        static LogicAndDataAccess()
        {
            SqlInsightDbProvider.RegisterProvider();
            DbConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["AbsenceSoft"].ConnectionString);

            Database = connection.As <IDataAccess>();
        }
Пример #3
0
        public static void Initialize(TestContext context)
        {
            var dataDirectory = Path.Combine(new DirectoryInfo(Environment.CurrentDirectory).Parent.Parent.Parent.FullName, "Take Home\\App_Data");

            AppDomain.CurrentDomain.SetData("DataDirectory", dataDirectory);
            SqlInsightDbProvider.RegisterProvider();
        }
Пример #4
0
        protected override void Load(ContainerBuilder builder)
        {
            SqlInsightDbProvider.RegisterProvider();

            if (this._lifeTime == "InstancePerLifetimeScope")
            {
                builder
                .Register(b => this._sqlConnection.AsParallel <IAuthenticationRepository>())
                .InstancePerLifetimeScope().EnableInterfaceInterceptors();
                builder
                .Register(b => this._sqlConnection.AsParallel <IUserManagementRepository>())
                .InstancePerLifetimeScope().EnableInterfaceInterceptors();
                builder.Register(b => this._sqlConnection.AsParallel <IFileCryptRepository>())
                .InstancePerLifetimeScope()
                .EnableInterfaceInterceptors();
            }
            else
            {
                builder.Register(b => this._sqlConnection.AsParallel <IAuthenticationRepository>())
                .EnableInterfaceInterceptors();
                builder.Register(b => this._sqlConnection.AsParallel <IUserManagementRepository>())
                .EnableInterfaceInterceptors();
                builder.Register(b => this._sqlConnection.AsParallel <IFileCryptRepository>())
                .EnableInterfaceInterceptors();
            }

            base.Load(builder);
        }
        public void DbSetup()
        {
            connection = new SqlConnection(connectionString);
            SqlInsightDbProvider.RegisterProvider();
            connection.Open();

            var cmd = connection.CreateCommand();

            cmd.CommandText = $@"
                    SET NOCOUNT ON;
                    IF (OBJECT_ID('PostXml') IS NULL)
                    BEGIN
                        CREATE TABLE PostXml
                        (
                            Id INT IDENTITY(1,1) PRIMARY KEY NOT NULL,
                            [Child] XML NOT NULL,
                            CreationDate DATETIME NOT NULL,
                            LastChangeDate DATETIME NOT NULL
                        );

                    END;

                    DELETE FROM dbo.PostXml;

                    DECLARE @i INT = 0;
                    WHILE (@i <= {iterations})
                    BEGIN
                        INSERT INTO	PostXml([Child], CreationDate, LastChangeDate)
                        SELECT CONCAT(N'{NamespaceHeader}', REPLICATE('x', 2000), '{NamespaceFooter}'), SYSDATETIME(), SYSDATETIME();
                                SET @i = @i + 1;
                    END;";

            cmd.Connection = connection;
            cmd.ExecuteNonQuery();
        }
Пример #6
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     SqlInsightDbProvider.RegisterProvider();
 }
        public UserAccountService()
        {
            SqlInsightDbProvider.RegisterProvider();
            string       sqlConnection = ConfigurationManager.ConnectionStrings["SQLConnection"].ConnectionString;
            DbConnection c             = new SqlConnection(sqlConnection);

            _IUserAccountRepository = c.As <IUserAccountRepository>();
        }
Пример #8
0
        public IDbConnection GetConnection()
        {
            SqlInsightDbProvider.RegisterProvider();
            string       sqlConnection = ConfigurationManager.ConnectionStrings["SQLConnection"].ConnectionString;
            DbConnection connection    = new SqlConnection(sqlConnection);

            return(connection);
        }
        public async Task <List <EmployeeModel> > LoadEmployeeData()
        {
            //List<EmployeeModel> employeeDetails = new List<EmployeeModel>();

            var employeeDetails = Builder <EmployeeModel> .CreateListOfSize(1000)
                                  .All()
                                  .With(c => c.FullName  = Faker.Name.FullName())
                                  .With(c => c.FirstName = Faker.Name.FirstName())
                                  .With(c => c.LastName  = Faker.Name.LastName())
                                  .With(c => c.Email     = Faker.User.Email())
                                  .With(c => c.Initial   = Faker.Name.Gender())

                                  .With(c => c.DateOfBirth   = Faker.Date.Birthday())
                                  .With(c => c.DateOfJoining = Faker.Date.Recent(5))
                                  .With(c => c.TIN           = Faker.Number.RandomNumber(56123488).ToString())
                                  .With(c => c.PASSPORT      = Faker.Number.RandomNumber(86123488).ToString())
                                  .With(c => c.UserId        = 1)

                                  .Build();

            Parallel.ForEach(employeeDetails, new ParallelOptions {
                MaxDegreeOfParallelism = 30
            }, item =>
            {
                EmployeeAddressModel employeeAddressModelP = new EmployeeAddressModel();
                employeeAddressModelP.Address1             = Faker.Address.SecondaryAddress();
                employeeAddressModelP.Address2             = Faker.Address.SecondaryAddress();
                employeeAddressModelP.Address3             = Faker.Address.SecondaryAddress();
                employeeAddressModelP.City  = Faker.Address.USCity();
                employeeAddressModelP.State = Faker.Address.State();

                EmployeeAddressModel employeeAddressModelC = new EmployeeAddressModel();
                employeeAddressModelC.Address1             = Faker.Address.SecondaryAddress();
                employeeAddressModelC.Address2             = Faker.Address.SecondaryAddress();
                employeeAddressModelC.Address3             = Faker.Address.SecondaryAddress();
                employeeAddressModelC.City  = Faker.Address.USCity();
                employeeAddressModelC.State = Faker.Address.State();

                List <EmployeeAddressModel> employeeAddresses = new List <EmployeeAddressModel>();
                employeeAddresses.Add(employeeAddressModelP);
                employeeAddresses.Add(employeeAddressModelC);

                IEmployeeManageRepository _IEmployeeManageRepository1;

                SqlInsightDbProvider.RegisterProvider();
                //  string sqlConnection = "Data Source=.;Initial Catalog=EmployeeManage;Integrated Security=True";
                string sqlConnection1 = Caching.Instance.GetApplicationConfigs("DBConnection")
                ;
                DbConnection c1 = new SqlConnection(sqlConnection1);

                _IEmployeeManageRepository1 = c1.As <IEmployeeManageRepository>();

                var returnValue = _IEmployeeManageRepository1.LoadEmployeeData(item, employeeAddresses);
                //var returnValue = this._IEmployeeManageRepository.LoadEmployeeData(item);
            });
            return(employeeDetails.ToList());
        }
Пример #10
0
        public AppAnalyticsService(DbConnection Parameter, IIPRequestDetails iIPRequestDetails)
        {
            SqlInsightDbProvider.RegisterProvider();
            string       sqlConnection = Caching.Instance.GetApplicationConfigs("DBConnection");
            DbConnection c             = new SqlConnection(sqlConnection);

            _IAppAnalyticsRepository = c.As <IAppAnalyticsRepository>();
            _IIPRequestDetails       = iIPRequestDetails;
        }
        public StoreServerService()
        {
            SqlInsightDbProvider.RegisterProvider();
            //string sqlConnection = ConfigurationManager.ConnectionStrings["SQLConnection"].ConnectionString;
            string       sqlConnection = "Data Source=.;Initial Catalog=HRAMDashBoard;Integrated Security=True";
            DbConnection c             = new SqlConnection(sqlConnection);

            _IStoreServerRepository = c.As <IStoreServerRepository>();
        }
Пример #12
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940

        public void ConfigureServices(IServiceCollection services)
        {
            //// configure jwt authentication
            //var appSettings = appSettingsSection.Get<AppSettings>();
            //var key = Encoding.ASCII.GetBytes(appSettings.Secret);
            var key = Encoding.ASCII.GetBytes(ClsGlobal.Secret);// default authentication initialization


            services.AddAuthentication(x =>
            {
                x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                x.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })

            .AddJwtBearer(x =>
            {
                x.RequireHttpsMetadata      = false;
                x.SaveToken                 = true;
                x.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(key),
                    ValidateIssuer           = false,
                    ValidateAudience         = false
                };
            });

            services.AddMvc().AddNewtonsoftJson();
            services.AddResponseCompression(opts =>
            {
                opts.EnableForHttps = true;
                opts.MimeTypes      = ResponseCompressionDefaults.MimeTypes.Concat(
                    new[] { "application/octet-stream" });
            });

            // configure DI for application services
            //***Inject Repository to DataAcess Binders();
            services.AddTransient <ICustomerRepository, CustomerDataAccess>();
            services.AddTransient <IPolicyRepository, PolicyDataAccess>();
            services.AddTransient <IUserRepository, UserDataAccess>();
            services.AddTransient <IExcelRepository, ExcelDataAccess>();



            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);

            //CORS services
            //PM: Install-Package Microsoft.AspNetCore.Cors -Version 2.2.0
            //https://docs.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-3.0
            services.AddCors();


            //***PM: Install-Package Insight.Database
            SqlInsightDbProvider.RegisterProvider();
            JsonNetObjectSerializer.Initialize();
        }
        public EmployeeManageService(DbConnection Parameter)
        {
            SqlInsightDbProvider.RegisterProvider();
            //  string sqlConnection = "Data Source=.;Initial Catalog=EmployeeManage;Integrated Security=True";
            string sqlConnection = Caching.Instance.GetApplicationConfigs("DBConnection")
            ;
            DbConnection c = new SqlConnection(sqlConnection);

            _IEmployeeManageRepository = c.AsParallel <IEmployeeManageRepository>();
        }
Пример #14
0
        public ApiRepository(DbConnection connection)
        {
            this.connection = connection;
            SqlInsightDbProvider.RegisterProvider();

            if (this.connection.State == System.Data.ConnectionState.Closed)
            {
                this.connection.Open();
            }
        }
        public UserAccountService(DbConnection Parameter, ISercurityService iSercurityService)
        {
            SqlInsightDbProvider.RegisterProvider();
            string       sqlConnection = Caching.Instance.GetApplicationConfigs("DBConnection");
            DbConnection c             = new SqlConnection(sqlConnection);

            _IUserAccountRepository = c.As <IUserAccountRepository>();

            _ISercurityService = iSercurityService;
        }
Пример #16
0
 internal static void EnsureInsightIsInitialized()
 {
     if (!_hasInsightBeenInitialized)
     {
         // Ensure we register the SqlInsightDbProvider
         // TODO: Consider moving this call closer to where the Insight.Database dependency is actually used
         SqlInsightDbProvider.RegisterProvider();
         ColumnMapping.Parameters.AddMapper(new SsisParameterMapper());
         _hasInsightBeenInitialized = true;
     }
 }
Пример #17
0
        public SercurityService(IIPRequestDetails iIPRequestDetails)
        {
            SqlInsightDbProvider.RegisterProvider();
            //  string sqlConnection = "Data Source=.;Initial Catalog=EmployeeManage;Integrated Security=True";
            string       sqlConnection = Caching.Instance.GetApplicationConfigs("DBConnection");
            DbConnection c             = new SqlConnection(sqlConnection);

            _IUserAccountRepository  = c.As <IUserAccountRepository>();
            _IAppAnalyticsRepository = c.As <IAppAnalyticsRepository>();
            _IIPRequestDetails       = iIPRequestDetails;
        }
Пример #18
0
        public Startup(IHostingEnvironment env)
        {
            SqlInsightDbProvider.RegisterProvider();
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", true, true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", true)
                          .AddEnvironmentVariables();

            Configuration = builder.Build();
        }
        public void ConfigureContainer(ContainerBuilder builder)
        {
            SqlInsightDbProvider.RegisterProvider();
            DbConnection sqlConnection = new SqlConnection("Data Source=.;Initial Catalog=BlazorAppWinWin;Integrated Security=True;Persist Security Info=true;");

            builder
            .Register(b => sqlConnection.AsParallel <IEmployeeManageRepository>())
            .InstancePerLifetimeScope();
            builder
            .Register(b => sqlConnection.AsParallel <IEmployeeApprovalRepository>())
            .InstancePerLifetimeScope();
        }
        public void ConfigureContainer(ContainerBuilder builder)
        {
            SqlInsightDbProvider.RegisterProvider();
            DbConnection sqlConnection = new SqlConnection("Data Source=.;Initial Catalog=BlazorAppWinWin;Integrated Security=True;Persist Security Info=true;");

            builder
            .Register(b => sqlConnection.AsParallel <IAuthenticationRepository>())
            .InstancePerLifetimeScope()
            .EnableInterfaceInterceptors()
            .InterceptedBy(typeof(RepositoryInterfaceLogger));;
            builder.Register(c => new RepositoryInterfaceLogger(Console.Out));
        }
Пример #21
0
        protected override void Load(ContainerBuilder builder)
        {
            SqlInsightDbProvider.RegisterProvider();

            builder.Register(b => this._sqlConnection.AsParallel <IEmployeeQueryRepository>());
            builder.Register(b => this._sqlConnection.AsParallel <IEmployeeCommandRepository>());
            builder.Register(b => this._sqlConnection.AsParallel <IUserCommandRepository>());
            builder.Register(b => this._sqlConnection.AsParallel <IUserQueryRepository>());
            builder.Register(b => this._sqlConnection.AsParallel <IAuthrizationQueryRepository>());

            base.Load(builder);
        }
Пример #22
0
        protected override void Load(ContainerBuilder builder)
        {
            base.Load(builder);

            SqlInsightDbProvider.RegisterProvider();
            //GlimpseInsightDbProvider.RegisterProvider();

            IDbConnection connection = this.GetSqlConnection();

            //builder.RegisterInstance(connection.AsParallel<IRevenueLossRepository>());
            builder.Register(c => connection.AsParallel <RevenueLossRepository>()).As <IRevenueLossRepository>();
            builder.Register(c => connection.AsParallel <LayoutRepository>()).As <ILayoutRepository>();
            //builder.RegisterAssemblyTypes(Assembly.GetAssembly(typeof(RepositoryBase))).Where(t => t.IsClass && t.GetInterfaces().Where(i => i.IsAssignableFrom(typeof(IRepository))).Count() > 0).AsImplementedInterfaces();
        }
Пример #23
0
//				"Server=localhost; Database=BetAppDb; Trusted_Connection=True; User ID=sa; Password=Pa$$w0rd123;";

        public DbInsight()
        {
            SqlInsightDbProvider.RegisterProvider();

            Connection = new SqlConnection(connStr);

            CountryRepository   = Connection.AsParallel <ICountryRepository>();
            LeagueRepository    = Connection.AsParallel <ILeagueRepository>();
            SeasonRepository    = Connection.AsParallel <ISeasonRepository>();
            GameRepository      = Connection.AsParallel <IGameRepository>();
            StageRepository     = Connection.AsParallel <IStageRepository>();
            TeamRepository      = Connection.AsParallel <ITeamRepository>();
            ResultRepository    = Connection.AsParallel <IResultRepository>();
            SpanStatsRepository = Connection.AsParallel <ISpanStatsRepository>();
        }
Пример #24
0
        public static IServiceCollection AddCustomPersistence(this IServiceCollection serviceCollection)
        {
            SqlInsightDbProvider.RegisterProvider();

            serviceCollection.AddSingleton <IExampleDbRepository>(context =>
            {
                var connectionString = context.GetRequiredService <DatabaseConnectionStringSetting>().Value;

                var innerConnection = new SqlConnection(connectionString);

                return(new ReliableConnection(innerConnection).AsParallel <IExampleDbRepository>());
            });

            return(serviceCollection);
        }
        public DashBoardService(DbConnection Parameter, IWeatherForecast iWeatherForecast,
                                IIPRequestDetails iIPRequestDetails, IEmailService iEmailService)
        {
            SqlInsightDbProvider.RegisterProvider();
            //  string sqlConnection = "Data Source=.;Initial Catalog=EmployeeManage;Integrated Security=True";
            string sqlConnection = Caching.Instance.GetApplicationConfigs("DBConnection")
            ;
            DbConnection c = new SqlConnection(sqlConnection);

            _IUserAccountRepository = c.As <IUserAccountRepository>();
            _IIPRequestDetails      = iIPRequestDetails;

            _IWeatherForecast = iWeatherForecast;
            _IEmailService    = iEmailService;
        }
Пример #26
0
        static void Main(string[] args)
        {
            SqlInsightDbProvider.RegisterProvider();

            using (var c = Database.Open())
            {
                try
                {
                    c.ExecuteSql("DROP PROCEDURE HelloWorld", null);
                }
                catch
                {
                }
                try
                {
                    c.ExecuteSql("CREATE PROCEDURE HelloWorld AS SELECT 'Hello, World.'", null);
                    Console.WriteLine(c.ExecuteScalar <String>("HelloWorld", null));
                }
                finally
                {
                    c.ExecuteSql("DROP PROCEDURE HelloWorld", null);
                }
            }
        }
        public void DbSetup()
        {
            connection = new SqlConnection(connectionString);
            SqlInsightDbProvider.RegisterProvider();
            connection.Open();

            var cmd = connection.CreateCommand();

            cmd.CommandText = $@"
                    SET NOCOUNT ON;
                    IF (OBJECT_ID('PostJson') IS NULL)
                    BEGIN
                        CREATE TABLE PostJson
                        (
                            Id INT IDENTITY(1,1) PRIMARY KEY NOT NULL,
                            [Child] NVARCHAR(MAX) NOT NULL,
                            CreationDate DATETIME NOT NULL,
                            LastChangeDate DATETIME NOT NULL
                        );

                        ALTER TABLE [dbo].PostJson ADD CONSTRAINT [Text must be formatted as JSON object] CHECK  (IsJson([Child]) > 0)
                    END;

                    DELETE FROM dbo.PostJson;

                    DECLARE @i INT = 0;
                    WHILE (@i <= {iterations})
                    BEGIN
                        INSERT INTO	PostJson([Child], CreationDate, LastChangeDate)
                        SELECT (SELECT TOP 1 REPLICATE('x', 2000) [Text] FOR JSON PATH, WITHOUT_ARRAY_WRAPPER), SYSDATETIME(), SYSDATETIME();
                        SET @i = @i + 1;
                    END;";

            cmd.Connection = connection;
            cmd.ExecuteNonQuery();
        }
Пример #28
0
        static void Main(string[] args)
        {
            SqlInsightDbProvider.RegisterProvider();

            #region Performance Tests
            if (args.Length > 0 && args[0] == "perf")
            {
                PerfTest();
                return;
            }
            #endregion

            #region Opening Connections
            IDBConnection_OpenConnection();
            ConnectionStringSettings_Connection();
            ConnectionStringSettings_Open();
            SqlConnectionStringBuilder_Connection();
            SqlConnectionStringBuilder_Open();
            #endregion

            #region Executing Database Commands
            Execute();
            ExecuteSql();
            #endregion

            #region Querying for Objects
            Query_Query();
            Query_QuerySql();
            Query_ToList();
            Query_AsEnumerable();
            #endregion

            #region Insert
            Insert_Sql();
            #endregion

            #region Dynamic Objects
            Dynamic_Query();
            Dynamic_ForEach();
            #endregion

            #region Dynamic Database Calls
            DynamicCall_Named();
            DynamicCall_Transaction();
            #endregion

            #region Lists of Objects
            List_ValueTypeSql();
            List_ValueTypeStoredProcedure();
            List_ClassStoredProcedure();
            List_ClassSql();
            #endregion

            #region Async Queries
            Async_Execute();
            Async_Query();
            #endregion

            #region Bulk Copy
            BulkCopy();
            #endregion

            #region Multiple Result Sets
            MultipleResultSets();
            #endregion

            #region Object Hierarchies
            ObjectHierarchy();
            #endregion

            #region Creating Commands
            IDbConnection_CreateCommand();
            IDbConnection_CreateCommandSql();
            #endregion

            #region Common Parameters
            CommonParameter_Transaction();
            #endregion

            #region Manual Transformation
            ManualTransform();
            ManualTransform_Sum();
            ManualTransform_GetReader();
            #endregion

            #region Expando Expansion
            Expando_Expand();
            #endregion

            #region Expando Mutation
            Expando_Mutate();
            Expando_Transform();
            Expando_TransformList();
            #endregion

            #region ForEach
            ForEach();
            AsEnumerable();
            #endregion

            #region Repository Pattern
            Repository();
            #endregion

            #region Auto Interface Implementation
            AutoInterfaceImplementation();
            #endregion
        }
Пример #29
0
        static void Main(string[] args)
        {
            SqlInsightDbProvider.RegisterProvider();

            #region Opening Connections
            IDBConnection_OpenConnection();
            SqlConnectionStringBuilder_Connection();
            SqlConnectionStringBuilder_Open();
            #endregion

            #region Executing Database Commands
            Execute();
            ExecuteSql();
            #endregion

            #region Querying for Objects
            Query_Query();
            Query_QuerySql();
            Query_ToList();
            Query_AsEnumerable();
            #endregion

            #region Insert
            Insert_Sql();
            #endregion

            #region Dynamic Objects
            Dynamic_Query();
            Dynamic_ForEach();
            #endregion

            #region Dynamic Database Calls
            DynamicCall_Named();
            DynamicCall_Transaction();
            #endregion

            #region Lists of Objects
            List_ValueTypeSql();
            List_ClassSql();
            #endregion

            #region Async Queries
            Async_Execute();
            Async_Query();
            #endregion

            #region Bulk Copy
            BulkCopy();
            #endregion

            #region Creating Commands
            IDbConnection_CreateCommand();
            IDbConnection_CreateCommandSql();
            #endregion

            #region Common Parameters
            CommonParameter_Transaction();
            #endregion

            #region Manual Transformation
            ManualTransform();
            ManualTransform_Sum();
            ManualTransform_GetReader();
            #endregion

            #region Expando Expansion
            Expando_Expand();
            #endregion

            #region Expando Mutation
            Expando_Mutate();
            Expando_Transform();
            Expando_TransformList();
            #endregion

            #region ForEach
            ForEach();
            AsEnumerable();
            #endregion
        }
 public void Init(string connectionStrong)
 {
     conn = new SqlConnection(connectionStrong);
     SqlInsightDbProvider.RegisterProvider();
 }