public BackupPortalTask(DbFactory dbFactory, DbContextManager <BackupsContext> dbContextManager, IOptionsMonitor <ILog> options, TenantManager tenantManager, CoreBaseSettings coreBaseSettings, StorageFactory storageFactory, StorageFactoryConfig storageFactoryConfig, ModuleProvider moduleProvider) : base(dbFactory, options, storageFactory, storageFactoryConfig, moduleProvider) { Dump = coreBaseSettings.Standalone; TenantManager = tenantManager; BackupRecordContext = dbContextManager.Get(DbFactory.ConnectionStringSettings.ConnectionString); }
public EfInMemoryContext() { options = new DbContextOptionsBuilder <BackupsContext>() .UseInMemoryDatabase() .Options; // Create the schema in the database using (var context = new BackupsContext(options)) { context.Database.EnsureCreated(); } // Insert seed data into the database using one instance of the context using (var context = new BackupsContext(options)) { int id = 1; context.Add(new BackupLog { ClientIP = "192.168.1.100", Description = $"Playing with some test data {Guid.NewGuid()}", Status = "OK", ID = id++ }); context.Add(new BackupLog { ClientIP = "192.168.1.100", Description = $"Playing with some test data {Guid.NewGuid()}", Status = "OK", ID = id++ }); context.Add(new BackupLog { ClientIP = "192.168.1.101", Description = $"Playing with some test data {Guid.NewGuid()}", Status = "OK", ID = id++ }); context.Add(new BackupLog { ClientIP = "192.168.1.102", Description = $"Playing with some test data {Guid.NewGuid()}", Status = "OK", ID = id++ }); context.Add(new BackupLog { ClientIP = "192.168.1.103", Description = $"Playing with some test data {Guid.NewGuid()}", Status = "OK", ID = id++ }); context.SaveChanges(); } _context = new BackupsContext(options); }
public MssqlTests() { var serviceProvider = new ServiceCollection() .AddEntityFrameworkSqlServer() .BuildServiceProvider(); var builder = new DbContextOptionsBuilder <BackupsContext>(); builder.UseSqlServer($"Server=(localdb)\\mssqllocaldb;Database=lanbackup_db_{Guid.NewGuid()};Trusted_Connection=True;MultipleActiveResultSets=true") .UseInternalServiceProvider(serviceProvider); _context = new BackupsContext(builder.Options); _context.Database.EnsureCreated(); //_context.Database.Migrate(); }
public DbHelper(IOptionsMonitor <ILog> options, ConnectionStringSettings connectionString, BackupsContext backupsContext) { log = options.CurrentValue; this.backupsContext = backupsContext; var file = connectionString.ElementInformation.Source; if ("web.connections.config".Equals(Path.GetFileName(file), StringComparison.InvariantCultureIgnoreCase)) { file = Path.Combine(Path.GetDirectoryName(file), "Web.config"); } var xconfig = XDocument.Load(file); var provider = xconfig.XPathSelectElement("/configuration/system.data/DbProviderFactories/add[@invariant='" + connectionString.ProviderName + "']"); factory = (DbProviderFactory)Activator.CreateInstance(Type.GetType(provider.Attribute("type").Value, true)); builder = factory.CreateCommandBuilder(); connect = factory.CreateConnection(); connect.ConnectionString = connectionString.ConnectionString; connect.Open(); mysql = connectionString.ProviderName.ToLower().Contains("mysql"); if (mysql) { CreateCommand("set @@session.sql_mode = concat(@@session.sql_mode, ',NO_AUTO_VALUE_ON_ZERO')").ExecuteNonQuery(); } columns = connect.GetSchema("Columns"); whereExceptions["calendar_calendar_item"] = " where calendar_id in (select id from calendar_calendars where tenant = {0}) "; whereExceptions["calendar_calendar_user"] = "******"; whereExceptions["calendar_event_item"] = " inner join calendar_events on calendar_event_item.event_id = calendar_events.id where calendar_events.tenant = {0} "; whereExceptions["calendar_event_user"] = "******"; whereExceptions["crm_entity_contact"] = " inner join crm_contact on crm_entity_contact.contact_id = crm_contact.id where crm_contact.tenant_id = {0} "; whereExceptions["crm_entity_tag"] = " inner join crm_tag on crm_entity_tag.tag_id = crm_tag.id where crm_tag.tenant_id = {0} "; whereExceptions["files_folder_tree"] = " inner join files_folder on folder_id = id where tenant_id = {0} "; whereExceptions["forum_answer_variant"] = " where answer_id in (select id from forum_answer where tenantid = {0})"; whereExceptions["forum_topic_tag"] = " where topic_id in (select id from forum_topic where tenantid = {0})"; whereExceptions["forum_variant"] = " where question_id in (select id from forum_question where tenantid = {0})"; whereExceptions["projects_project_participant"] = " inner join projects_projects on projects_project_participant.project_id = projects_projects.id where projects_projects.tenant_id = {0} "; whereExceptions["projects_following_project_participant"] = " inner join projects_projects on projects_following_project_participant.project_id = projects_projects.id where projects_projects.tenant_id = {0} "; whereExceptions["projects_project_tag"] = " inner join projects_projects on projects_project_tag.project_id = projects_projects.id where projects_projects.tenant_id = {0} "; whereExceptions["tenants_tenants"] = " where id = {0}"; whereExceptions["core_acl"] = " where tenant = {0} or tenant = -1"; whereExceptions["core_subscription"] = " where tenant = {0} or tenant = -1"; whereExceptions["core_subscriptionmethod"] = " where tenant = {0} or tenant = -1"; }
public BackupRepository(DbContextManager <BackupsContext> backupContext) { BackupContext = backupContext.Value; }
public BackupConfigController(IMapper mapper, BackupsContext context, ITelemetryLogger telemetry) { this.mapper = mapper; this._context = context; this.telemetry = telemetry; }