コード例 #1
0
 public PluginConfigurationSource(
     string connectionString,
     IPluginConfigurationSeedData pluginConfigurationSeedData,
     IDesignTimeDbContextFactory <TDbContext> dbContextFactory)
 {
     _connectionString            = connectionString;
     _pluginConfigurationSeedData = pluginConfigurationSeedData;
     _dbContextFactory            = dbContextFactory;
 }
コード例 #2
0
 public PluginConfigurationProvider(
     string connectionString,
     IPluginConfigurationSeedData pluginConfigurationSeedData,
     IDesignTimeDbContextFactory <TDbContext> dbContextFactory)
 {
     _connectionString            = connectionString;
     _pluginConfigurationSeedData = pluginConfigurationSeedData;
     _dbContextFactory            = dbContextFactory;
     ReloadDbConfigurationDelegates.ReloadDbConfigurationDelegate += ReloadPluginConfiguration;
 }
コード例 #3
0
 public static IConfigurationBuilder AddPluginConfiguration <TDbContext>(
     this IConfigurationBuilder builder,
     string connectionString,
     IPluginConfigurationSeedData pluginConfigurationSeedData,
     IDesignTimeDbContextFactory <TDbContext> dbContextFactory) where TDbContext : DbContext, IPluginDbContext
 {
     return(builder.Add(new PluginConfigurationSource <TDbContext>(
                            connectionString,
                            pluginConfigurationSeedData,
                            dbContextFactory)));
 }
コード例 #4
0
        public static void SeedData(IPluginDbContext dbContext, IPluginConfigurationSeedData data)
        {
            foreach (var configurationItem in data.Data)
            {
                if (!dbContext.PluginConfigurationValues.Any(x => x.Name == configurationItem.Name))
                {
                    var newConfigValue = new PluginConfigurationValue()
                    {
                        Name            = configurationItem.Name,
                        Value           = configurationItem.Value,
                        CreatedAt       = DateTime.UtcNow,
                        Version         = 1,
                        WorkflowState   = Constants.WorkflowStates.Created,
                        CreatedByUserId = 1
                    };
                    dbContext.PluginConfigurationValues.Add(newConfigValue);
                    dbContext.SaveChanges();
                }
            }

            //// Seed plugin permissions
            //var newPermissions = CustomersPermissionsSeedData.Data
            //    .Where(p => dbContext.PluginPermissions.All(x => x.ClaimName != p.ClaimName))
            //    .Select(p => new PluginPermission
            //    {
            //        PermissionName = p.PermissionName,
            //        ClaimName = p.ClaimName,
            //        CreatedAt = DateTime.UtcNow,
            //        Version = 1,
            //        WorkflowState = Constants.WorkflowStates.Created,
            //        CreatedByUserId = 1
            //    }
            //    );
            //dbContext.PluginPermissions.AddRange(newPermissions);

            dbContext.SaveChanges();
        }