Beispiel #1
0
        public ApplyCommand(
            SqlServerDataStoreConfiguration sqlServerDataStoreConfiguration,
            BaseSchemaRunner baseSchemaRunner,
            ISchemaManagerDataStore schemaManagerDataStore,
            ISchemaClient schemaClient)
            : base(CommandNames.Apply, Resources.ApplyCommandDescription)
        {
            AddOption(CommandOptions.ConnectionStringOption());
            AddOption(CommandOptions.ServerOption());
            AddOption(CommandOptions.VersionOption());
            AddOption(CommandOptions.NextOption());
            AddOption(CommandOptions.LatestOption());
            AddOption(CommandOptions.ForceOption());

            Handler = CommandHandler.Create(
                (string connectionString, Uri server, MutuallyExclusiveType type, bool force, CancellationToken token)
                => HandlerAsync(connectionString, server, type, force, token));

            Argument.AddValidator(symbol => Validators.RequiredOptionValidator.Validate(symbol, CommandOptions.ConnectionStringOption(), Resources.ConnectionStringRequiredValidation));
            Argument.AddValidator(symbol => Validators.RequiredOptionValidator.Validate(symbol, CommandOptions.ServerOption(), Resources.ServerRequiredValidation));
            Argument.AddValidator(symbol => Validators.MutuallyExclusiveOptionValidator.Validate(symbol, new List <Option> {
                CommandOptions.VersionOption(), CommandOptions.NextOption(), CommandOptions.LatestOption()
            }, Resources.MutuallyExclusiveValidation));

            EnsureArg.IsNotNull(sqlServerDataStoreConfiguration);
            EnsureArg.IsNotNull(baseSchemaRunner);
            EnsureArg.IsNotNull(schemaManagerDataStore);
            EnsureArg.IsNotNull(schemaClient);

            _sqlServerDataStoreConfiguration = sqlServerDataStoreConfiguration;
            _baseSchemaRunner       = baseSchemaRunner;
            _schemaManagerDataStore = schemaManagerDataStore;
            _schemaClient           = schemaClient;
        }
 public SchemaBatchOperationResult(
     ISchemaClient schemaClient,
     string businessProcessId,
     BusinessProcessLifeCycle?lifeCycle,
     IBusinessProcessClient businessProcessClient)
     : base(businessProcessId, lifeCycle, businessProcessClient)
 {
     _schemaClient = schemaClient;
 }
        private static async Task ValidateVersionCompatibility(ISchemaClient schemaClient, int maxAvailableVersion, CancellationToken cancellationToken)
        {
            CompatibleVersion compatibleVersion = await schemaClient.GetCompatibilityAsync(cancellationToken);

            if (maxAvailableVersion > compatibleVersion.Max)
            {
                throw new SchemaManagerException(string.Format(Resources.VersionIncompatibilityMessage, maxAvailableVersion));
            }
        }
        private static async Task <string> GetScriptAsync(ISchemaClient schemaClient, int version, string scriptUri, CancellationToken cancellationToken, string diffUri = null)
        {
            if (version == 1)
            {
                return(await schemaClient.GetScriptAsync(new Uri(scriptUri, UriKind.Relative), cancellationToken));
            }

            return(await schemaClient.GetDiffScriptAsync(new Uri(diffUri, UriKind.Relative), cancellationToken));
        }
        private static async Task ValidateInstancesVersionAsync(ISchemaClient schemaClient, int version, CancellationToken cancellationToken)
        {
            List <CurrentVersion> currentVersions = await schemaClient.GetCurrentVersionInformationAsync(cancellationToken);

            // check if any instance is not running on the previous version
            if (currentVersions.Any(currentVersion => currentVersion.Id != (version - 1) && currentVersion.Servers.Count > 0))
            {
                throw new SchemaManagerException(string.Format(Resources.InvalidVersionMessage, version));
            }
        }
        private static async Task FetchUpdatedAvailableVersionsAsync(ISchemaClient schemaClient, string connectionString, CancellationToken cancellationToken)
        {
            availableVersions = await schemaClient.GetAvailabilityAsync(cancellationToken);

            availableVersions.Sort((x, y) => x.Id.CompareTo(y.Id));

            if (availableVersions.First().Id != await SchemaDataStore.GetCurrentSchemaVersionAsync(connectionString, cancellationToken))
            {
                throw new SchemaManagerException(Resources.AvailableVersionsErrorMessage);
            }
        }
Beispiel #7
0
 public SqlSchemaManager(
     SqlServerDataStoreConfiguration sqlServerDataStoreConfiguration,
     IBaseSchemaRunner baseSchemaRunner,
     ISchemaManagerDataStore schemaManagerDataStore,
     ISchemaClient schemaClient,
     ILogger<SqlSchemaManager> logger)
 {
     _sqlServerDataStoreConfiguration = EnsureArg.IsNotNull(sqlServerDataStoreConfiguration, nameof(sqlServerDataStoreConfiguration));
     _baseSchemaRunner = EnsureArg.IsNotNull(baseSchemaRunner, nameof(baseSchemaRunner));
     _schemaManagerDataStore = EnsureArg.IsNotNull(schemaManagerDataStore, nameof(schemaManagerDataStore));
     _schemaClient = EnsureArg.IsNotNull(schemaClient, nameof(schemaClient));
     _logger = EnsureArg.IsNotNull(logger, nameof(logger));
 }
Beispiel #8
0
        public AvailableCommand(ISchemaClient schemaClient)
            : base(CommandNames.Available, Resources.AvailableCommandDescription)
        {
            AddOption(CommandOptions.ServerOption());

            Handler = CommandHandler.Create(
                (InvocationContext context, Uri server, CancellationToken token)
                => HandlerAsync(context, server, token));

            Argument.AddValidator(symbol => Validators.RequiredOptionValidator.Validate(symbol, CommandOptions.ServerOption(), Resources.ServerRequiredValidation));

            EnsureArg.IsNotNull(schemaClient);

            _schemaClient = schemaClient;
        }
Beispiel #9
0
        public CurrentCommand(
            BaseSchemaRunner baseSchemaRunner,
            SqlServerDataStoreConfiguration sqlServerDataStore,
            ISchemaClient schemaClient)
            : base(CommandNames.Current, Resources.CurrentCommandDescription)
        {
            AddOption(CommandOptions.ServerOption());
            AddOption(CommandOptions.ConnectionStringOption());

            Handler = CommandHandler.Create(
                (InvocationContext context, Uri server, string connectionString, CancellationToken token)
                => HandlerAsync(context, server, connectionString, token));

            Argument.AddValidator(symbol => Validators.RequiredOptionValidator.Validate(symbol, CommandOptions.ConnectionStringOption(), Resources.ConnectionStringRequiredValidation));
            Argument.AddValidator(symbol => Validators.RequiredOptionValidator.Validate(symbol, CommandOptions.ServerOption(), Resources.ServerRequiredValidation));

            EnsureArg.IsNotNull(baseSchemaRunner);
            EnsureArg.IsNotNull(sqlServerDataStore);
            EnsureArg.IsNotNull(schemaClient);

            _baseSchemaRunner   = baseSchemaRunner;
            _sqlServerDataStore = sqlServerDataStore;
            _schemaClient       = schemaClient;
        }