public static void Run(string platform, bool asyncProcessing) { Console.WriteLine($"Testing {platform}..."); var serverName = "."; DataConnection.AddConfiguration( "Test", $"Server={serverName};Database=PerformanceTest;Trusted_Connection=True;Application Name=LinqToDB Test;" + (asyncProcessing ? "Asynchronous Processing=True;" : ""), SqlServerTools.GetDataProvider(SqlServerVersion.v2012)); DataConnection.DefaultConfiguration = "Test"; var basePath = Path.GetDirectoryName(typeof(LinqTestRunner).Assembly.Location); while (!Directory.Exists(Path.Combine(basePath, "Result"))) { basePath = Path.GetDirectoryName(basePath); } var resultPath = Path.Combine(basePath, "Result"); CreateResultDatabase(false, resultPath); CreateTestDatabase(false, serverName); RunTests(platform); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // Set connection configuration DataConnection .AddConfiguration( "Default", Configuration["Data:DefaultConnection:ConnectionString"], new SqlServerDataProvider("Default", SqlServerVersion.v2012)); DataConnection.DefaultConfiguration = "Default"; services.AddIdentity <ApplicationUser, LinqToDB.Identity.IdentityRole>() .AddLinqToDBStores(new DefaultConnectionFactory()) .AddDefaultTokenProviders(); services.AddAuthentication() .AddCookie(options => { options.Cookie.Name = "Interop"; options.DataProtectionProvider = DataProtectionProvider.Create(new DirectoryInfo("C:\\Github\\Identity\\artifacts")); }); services.AddMvc(); // Add application services. services.AddTransient <IEmailSender, AuthMessageSender>(); services.AddTransient <ISmsSender, AuthMessageSender>(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { DataConnection .AddConfiguration( "DefaultConnection", _configuration["Data:DefaultConnection:ConnectionString"], new MySqlDataProvider()); DataConnection.DefaultConfiguration = "DefaultConnection"; services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddMvc().AddJsonOptions(opt => { //This AddJsonOptions method are used for make the json serializer write as is as the object from the controller //It's not serialize to camel case. For example: The object contain Foo ==> Good Day, it will become Foo: Good Day //Not become foo ==> Good Day var resolver = opt.SerializerSettings.ContractResolver; if (resolver != null) { var res = resolver as DefaultContractResolver; res.NamingStrategy = null; } }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.RegisterDataTables(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { DataConnection .AddConfiguration( "DefaultConnection", Configuration["Data:DefaultConnection:ConnectionString"], new MySqlDataProvider()); DataConnection .AddConfiguration( "ReadOnlyConnection", Configuration["Data:ReadOnlyConnection:ConnectionString"], new MySqlDataProvider()); DataConnection.DefaultConfiguration = "DefaultConnection"; //Add Session services.AddDistributedMemoryCache(); services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(10); }); //End of add session services.AddMvc(); //Dependency Injection services.AddScoped <IPupukSession, PupukSessionImplementation>(); // DataTables.AspNet registration with default options. services.RegisterDataTables(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //MySqlDataProvider DataConnectionReadOnly = new MySqlDataProvider(); //DataConnectionReadOnly.CreateConnection(Configuration["Data:DefaultConnection:ConnectionString"]); DataConnection .AddConfiguration( "DefaultConnection", _configuration["Data:DefaultConnection:ConnectionString"], new MySqlDataProvider()); DataConnection .AddConfiguration( "ReadOnlyConnection", _configuration["Data:ReadOnlyConnection:ConnectionString"], new MySqlDataProvider()); DataConnection.DefaultConfiguration = "DefaultConnection"; //Configurations services.Configure <MedicoConfig>(_configuration); services.AddTransient <IRepository <TrDynamicFormPatient>, DynamicFormPatientRepository>(); services.AddTransient <IRepository <MsDynamicFormTemplates>, DynamicFormTemplateRepository>(); services.AddRawRabbit(new RawRabbitOptions { ClientConfiguration = GetRawRabbitConfiguration(), Plugins = p => p .UseStateMachine() .UseGlobalExecutionId() .UseHttpContext() .UseMessageContext(c => { return(new Medico.Shared.EventBrooker.TodoContext { Source = c.GetHttpContext().Request.GetDisplayUrl(), ExecutionId = c.GetGlobalExecutionId(), SessionId = c.GetHttpContext().Request.Cookies["medicorabbit:sessionid"] }); }) }); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info { Title = "Medico DynamicForm API", Version = "v1" }); }); services.AddMvc(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { DataConnection .AddConfiguration( "Default", Configuration["ConnectionString"], new SqlServerDataProvider("Default", SqlServerVersion.v2012)); DataConnection.DefaultConfiguration = "Default"; services.AddIdentity <User, LinqToDB.Identity.IdentityRole>() .AddLinqToDBStores(new DefaultConnectionFactory()) .AddDefaultTokenProviders(); JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); services .AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(cfg => { cfg.RequireHttpsMetadata = false; cfg.SaveToken = true; cfg.TokenValidationParameters = new TokenValidationParameters { ValidIssuer = Configuration["JwtIssuer"], ValidAudience = Configuration["JwtIssuer"], IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["JwtKey"])), ClockSkew = TimeSpan.Zero // remove delay of token when expire }; }) .AddCookie(options => { options.Cookie.Name = "Interop"; options.DataProtectionProvider = DataProtectionProvider.Create(new DirectoryInfo("C:\\Github\\Identity\\artifacts")); }); AddManagers(services); services.AddCors(o => o.AddPolicy("MyPolicy", builder => { builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); })); services.AddRouting(options => options.LowercaseUrls = true); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddSingleton <IConfiguration>(Configuration); }
public static void Run(string[] args) { var serverName = "."; DataConnection.AddConfiguration( "Test", $"Server={serverName};Database=PerformanceTest;Trusted_Connection=True", SqlServerTools.GetDataProvider(SqlServerVersion.v2012)); DataConnection.DefaultConfiguration = "Test"; CreateDatabase(serverName); RunTests(); }
public MySqlContext() { DataConnection .AddConfiguration( "test", ConnectionString, new MySqlDataProvider()); DataConnection.DefaultConfiguration = "test"; //using (TestDB testDB = new TestDB("test")) //{ // var s = testDB.Comboboxnames.ToList(); //} LinqToDB.Common.Configuration.Linq.AllowMultipleQuery = true; context = new ApplicationDbContext(); }
/// <summary> /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// </summary> /// <param name="app"></param> /// <param name="env"></param> /// <param name="loggerFactory"></param> //============================================================ //Revision History //Date Author Description //06/28/2017 TB Created //06/30/2017 AA Updated to handle Auth0 authentication with jwt //============================================================ public virtual void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { //configure linq2db DataConnection.DefaultDataProvider = Configuration.GetSection("DBSettings").GetValue <string>("Provider"); DataConnection.AddConfiguration("default", Configuration.GetSection("DBSettings").GetValue <string>("ConnectionString"), null); loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddContext(LogLevel.Warning, Configuration.GetSection("DBSettings").GetValue <string>("ConnectionString")); if (env.IsDevelopment()) { loggerFactory.AddDebug(); } app.UseAuthentication(); app.UseMiddleware <MaintenanceMode>(); app.UseResponseCompression(); app.UseMvc(); app.UsePathBase(Configuration.GetSection("Urls").GetValue <string>("Base")); app.UseStaticFiles(); app.UseDefaultFiles(new DefaultFilesOptions() { DefaultFileNames = new[] { "index.html" } }); //override mapping to keep .net core from interferring with angular routing app.MapWhen(context => { var path = context.Request.Path.Value.ToLower(); return(path.Contains("/") && !path.Contains(".js") && !path.Contains("/api/") && !path.Contains(".ico")); }, branch => { branch.Use((context, next) => { context.Request.Path = new PathString("/index.html"); return(next()); }); branch.UseStaticFiles(); }); }
static EventController() { var rnd = new Random(DateTime.Now.Millisecond); DataConnection.AddConfiguration("default", "Data Source=:memory:", new LinqToDB.DataProvider.SQLite.SQLiteDataProvider()); DataConnection.DefaultConfiguration = "default"; _connection = new DataConnection(); _connection.CreateTable <Event>(); for (var i = 0; i < 10; i++) { _connection.Insert(new Event() { Id = Guid.NewGuid(), Date = DateTime.Now.AddDays(rnd.Next(-i, i)), Name = $"Event {i}" }); } }
public App() { DataConnection.TurnTraceSwitchOn(); DataConnection.WriteTraceLine = (s, s1) => Debug.WriteLine(s, s1); SettingValueExtension.AppSettings = new AppSettings(); var basePath = Path.GetDirectoryName(typeof(App).Assembly.Location); while (!Directory.Exists(Path.Combine(basePath, "Result"))) { basePath = Path.GetDirectoryName(basePath); } var dbPath = Path.Combine(basePath, "Result", "Result"); DataConnection.AddConfiguration("Result", $"Data Source={dbPath}.sqlite", SQLiteTools.GetDataProvider()); DataConnection.DefaultConfiguration = "Result"; }
public void Test(string context) { var connectionString = DataConnection.GetConnectionString(context); var oldProvider = DataConnection.GetDataProvider(context); try { DataConnection.AddConfiguration( context, connectionString, new FirebirdDataProvider(new Issue982FirebirdSqlOptimizer(oldProvider.SqlProviderFlags))); using (var db = GetDataContext(context)) { var query = from p in db.Parent from c in db.Child.InnerJoin(c => c.ParentID == p.ParentID) from cg in ( from cc in db.Child group cc by cc.ChildID into g select g.Key ).InnerJoin(cg => c.ChildID == cg) where p.ParentID > 1 || p.ParentID > 0 select new { p, c }; var str = query.ToString(); Assert.True(str.Contains("2147483647")); var values = query.ToArray(); } } finally { // restore DataConnection.AddConfiguration(context, connectionString, oldProvider); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { DataConnection .AddConfiguration( "Default", Configuration["ConnectionString"], new SqlServerDataProvider("Default", SqlServerVersion.v2012)); DataConnection.DefaultConfiguration = "Default"; services.AddIdentity <User, LinqToDB.Identity.IdentityRole>() .AddLinqToDBStores(new DefaultConnectionFactory()) .AddDefaultTokenProviders(); JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); services .AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(cfg => { cfg.RequireHttpsMetadata = false; cfg.SaveToken = true; cfg.TokenValidationParameters = new TokenValidationParameters { ValidIssuer = Configuration["JwtIssuer"], ValidAudience = Configuration["JwtIssuer"], IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration["JwtKey"])), ClockSkew = TimeSpan.Zero // remove delay of token when expire }; }) .AddCookie(options => { options.Cookie.Name = "Interop"; options.DataProtectionProvider = DataProtectionProvider.Create(new DirectoryInfo("C:\\Github\\Identity\\artifacts")); }); AddManagers(services); services.AddCors(o => o.AddPolicy("MyPolicy", builder => { builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader(); })); services.AddRouting(options => options.LowercaseUrls = true); services.AddMvc(opt => { opt.Filters.Add <ValidatorActionFilter>(); }).SetCompatibilityVersion(CompatibilityVersion.Version_2_1).AddJsonOptions(options => { options.SerializerSettings.Converters.Add(new Newtonsoft.Json.Converters.StringEnumConverter()); options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore; }).AddFluentValidation().AddApplicationPart(typeof(ClassOfEndpointAssembly).Assembly).AddControllersAsServices(); ValidatorConfigurator.Configure(services); services.AddOptions(); services.Configure <GlobalOptions>(Configuration.GetSection("global")); services.AddResponseCaching(); services.AddSingleton <IConfiguration>(Configuration); services.AddSingleton <ServiceProvider>(services.BuildServiceProvider()); }
public DataConnectionFactory(IOptions <ConnectionStringSettings> settings) { DataConnection.AddConfiguration("Erm", settings.Value.Erm, SqlServerTools.GetDataProvider(SqlServerVersion.v2012)); _schema = CreateSchema(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //Connection Strings DataConnection .AddConfiguration( "DefaultConnection", _configuration["Data:DefaultConnection:ConnectionString"], new MySqlDataProvider()); DataConnection .AddConfiguration( "ReadOnlyConnection", _configuration["Data:ReadOnlyConnection:ConnectionString"], new MySqlDataProvider()); DataConnection.DefaultConfiguration = "DefaultConnection"; // Authentication services.AddAuthentication(options => { options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultSignOutScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultForbidScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; }) .AddCookie(options => { options.Cookie.Name = "PasCookies"; options.LoginPath = "/Login/Index"; options.LogoutPath = "/Login/Logout"; options.SlidingExpiration = true; options.ExpireTimeSpan = TimeSpan.FromMinutes(150); }); //Add session and set session expired services.AddSession(o => { o.IdleTimeout = new TimeSpan(0, 10, 0); }); //Add Cache services.AddDistributedMemoryCache(); //DataTables services.RegisterDataTables(); //Protection services.AddDataProtection(); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddSingleton <IConfiguration>(sp => { return(_configuration); }); services.AddScoped <IPasSession, PasSessionImplementation>(); // Add MVC services to the services container. services.AddMvc() .AddJsonOptions(opt => { //This AddJsonOptions method are used for make the json serializer write as is as the object from the controller //It's not serialize to camel case. For example: The object contain Foo ==> Good Day, it will become Foo: Good Day //Not become foo ==> Good Day var resolver = opt.SerializerSettings.ContractResolver; if (resolver != null) { var res = resolver as DefaultContractResolver; res.NamingStrategy = null; } }); }