Пример #1
0
        private void ApplyDeprovision(DbSynchronizerConfiguration configuration, Action <DbSyncScopeDescription> defineScope)
        {
            using (var connection = new SqlConnection(configuration.ConnectionString))
            {
                var provision = new SqlSyncScopeDeprovisioning(connection)
                {
                    ObjectPrefix = configuration.ObjectPrefix ?? string.Empty,
                    ObjectSchema = configuration.ObjectSchema ?? string.Empty,
                };
                //var scopeDescription = new DbSyncScopeDescription(configuration.ScopeName);
                //defineScope(scopeDescription);
                provision.DeprovisionScope(configuration.ScopeName);

                /*
                 * if (!provision.ScopeExists(configuration.ScopeName))
                 * {
                 *  var scopeDescription = new DbSyncScopeDescription(configuration.ScopeName);
                 *  defineScope(scopeDescription);
                 *  provision.SetCreateTableDefault(DbSyncCreationOption.Skip);
                 *  provision.PopulateFromScopeDescription(scopeDescription);
                 *  provision.Apply();
                 * }
                 */
            }
        }
Пример #2
0
 private void CheckSchema(DbSynchronizerConfiguration configuration)
 {
     if (string.IsNullOrEmpty(configuration?.ObjectSchema))
     {
         return;
     }
     using (var connection = new SqlConnection(configuration.ConnectionString))
     {
         var checkCommand = connection.CreateCommand();
         checkCommand.CommandText = $"select schema_id from sys.schemas where name='{configuration.ObjectSchema}'";
         connection.Open();
         var reader  = checkCommand.ExecuteReader();
         var hasRows = reader.HasRows;
         reader.Close();
         if (!hasRows)
         {
             var createSchemaCommand = connection.CreateCommand();
             createSchemaCommand.CommandText = $"CREATE SCHEMA {configuration.ObjectSchema}";
             createSchemaCommand.ExecuteNonQuery();
         }
     }
 }
Пример #3
0
 public I1CDbSynchronization(DbSynchronizerConfiguration localConfiguration, DbSynchronizerConfiguration remoteConfiguration, List <TableMapping> tableMapings) : base(localConfiguration, remoteConfiguration)
 {
     ApplyLocalChangesFailed += ApplyLocalChangesFailedFn;
     _tableMappings           = tableMapings;
 }
Пример #4
0
 public DbSynchronizer(DbSynchronizerConfiguration localConfiguration, DbSynchronizerConfiguration remoteConfiguration)
 {
     LocalConfiguration  = localConfiguration;
     RemoteConfiguration = remoteConfiguration;
 }