internal virtual async Task <bool> InternalUpgradeAsync(SyncContext context, SyncSet schema, ScopeInfo scopeInfo, DbScopeBuilder builder, DbConnection connection, DbTransaction transaction,
                                                                CancellationToken cancellationToken, IProgress <ProgressArgs> progress)
        {
            var version    = SyncVersion.EnsureVersion(scopeInfo.Version);
            var oldVersion = version.Clone() as Version;

            // beta version
            if (version.Major == 0)
            {
                // Migrate from 0.5.x to 0.6.0
                if (version.Minor <= 5)
                {
                    version = await UpgdrateTo600Async(context, schema, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                // Migrate from 0.6.0 to 0.6.1
                if (version.Minor <= 6 && version.Build <= 0)
                {
                    version = await UpgdrateTo601Async(context, schema, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }
            }

            if (oldVersion != version)
            {
                scopeInfo.Version = version.ToString();
                await this.InternalSaveScopeAsync(context, DbScopeType.Client, scopeInfo, builder, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
            }
            return(version == SyncVersion.Current);
        }
Esempio n. 2
0
        internal virtual async Task <ScopeInfo> InternalUpgradeAsync(SyncContext context, SyncSet schema, SyncSetup setup, ScopeInfo scopeInfo, DbScopeBuilder builder, DbConnection connection, DbTransaction transaction,
                                                                     CancellationToken cancellationToken, IProgress <ProgressArgs> progress)
        {
            var version    = SyncVersion.EnsureVersion(scopeInfo.Version);
            var oldVersion = version.Clone() as Version;

            // beta version
            if (version.Major == 0)
            {
                if (version.Minor <= 5)
                {
                    version = await AutoUpgdrateToNewVersionAsync(context, new Version(0, 6, 0), connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                if (version.Minor == 6 && version.Build == 0)
                {
                    version = await UpgdrateTo601Async(context, schema, setup, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                if (version.Minor == 6 && version.Build == 1)
                {
                    version = await UpgdrateTo602Async(context, schema, setup, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                if (version.Minor == 6 && version.Build >= 2)
                {
                    version = await UpgdrateTo700Async(context, schema, setup, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                if (version.Minor == 7 && version.Build == 0)
                {
                    version = await AutoUpgdrateToNewVersionAsync(context, new Version(0, 7, 1), connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                if (version.Minor == 7 && version.Build == 1)
                {
                    version = await AutoUpgdrateToNewVersionAsync(context, new Version(0, 7, 2), connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                if (version.Minor == 7 && version.Build == 2)
                {
                    version = await AutoUpgdrateToNewVersionAsync(context, new Version(0, 7, 3), connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                if (version.Minor == 7 && version.Build >= 3)
                {
                    version = await AutoUpgdrateToNewVersionAsync(context, new Version(0, 8, 0), connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }
            }

            if (oldVersion != version)
            {
                scopeInfo.Version = version.ToString();
                scopeInfo         = await this.InternalSaveScopeAsync(context, DbScopeType.Client, scopeInfo, builder, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
            }
            return(scopeInfo);
        }
Esempio n. 3
0
        internal virtual async Task <ScopeInfo> InternalUpgradeAsync(SyncContext context, SyncSet schema, SyncSetup setup, ScopeInfo scopeInfo, DbScopeBuilder builder, DbConnection connection, DbTransaction transaction,
                                                                     CancellationToken cancellationToken, IProgress <ProgressArgs> progress)
        {
            var version    = SyncVersion.EnsureVersion(scopeInfo.Version);
            var oldVersion = version.Clone() as Version;

            // beta version
            if (version.Major == 0)
            {
                if (version.Minor <= 5)
                {
                    version = await UpgdrateTo600Async(context, schema, setup, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                if (version.Minor == 6 && version.Build == 0)
                {
                    version = await UpgdrateTo601Async(context, schema, setup, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                if (version.Minor == 6 && version.Build == 1)
                {
                    version = await UpgdrateTo602Async(context, schema, setup, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                // last version of 0.6 Can be 0.6.2 or beta version 0.6.3 (that will never be released but still in the nuget packages available)
                if (version.Minor == 6 && version.Build >= 2)
                {
                    version = await UpgdrateTo700Async(context, schema, setup, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                if (version.Minor == 7 && version.Build == 0)
                {
                    version = await UpgdrateTo701Async(context, schema, setup, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                if (version.Minor == 7 && version.Build == 1)
                {
                    version = await UpgdrateTo702Async(context, schema, setup, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                if (version.Minor == 7 && version.Build == 2)
                {
                    version = await UpgdrateTo703Async(context, schema, setup, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }
            }

            if (oldVersion != version)
            {
                scopeInfo.Version = version.ToString();
                scopeInfo         = await this.InternalSaveScopeAsync(context, DbScopeType.Client, scopeInfo, builder, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
            }
            return(scopeInfo);
        }
        internal virtual bool InternalNeedsToUpgrade(SyncContext context, List <ServerScopeInfo> serverScopeInfos)
        {
            var version = SyncVersion.Current;

            // get the smallest version of all scope in the scope info server tables
            foreach (var serverScopeInfo in serverScopeInfos)
            {
                var tmpVersion = SyncVersion.EnsureVersion(serverScopeInfo.Version);

                if (tmpVersion < version)
                {
                    version = tmpVersion;
                }
            }

            return(version < SyncVersion.Current);
        }
        internal virtual bool InternalNeedsToUpgrade(List <ClientScopeInfo> clientScopeInfos)
        {
            var version = SyncVersion.Current;

            // get the smallest version of all scope in the scope info server tables
            foreach (var clientScopeInfo in clientScopeInfos)
            {
                var tmpVersion = SyncVersion.EnsureVersion(clientScopeInfo.Version);

                if (tmpVersion < version)
                {
                    version = tmpVersion;
                }
            }

            return(version < SyncVersion.Current);
        }
        internal virtual async Task <bool> InternalUpgradeAsync(SyncContext context, SyncSet schema, List <ServerScopeInfo> serverScopeInfos, DbScopeBuilder builder, DbConnection connection, DbTransaction transaction,
                                                                CancellationToken cancellationToken, IProgress <ProgressArgs> progress)
        {
            var version = SyncVersion.Current;

            // get the smallest version of all scope in the scope info server tables
            foreach (var serverScopeInfo in serverScopeInfos)
            {
                var tmpVersion = SyncVersion.EnsureVersion(serverScopeInfo.Version);

                if (tmpVersion < version)
                {
                    version = tmpVersion;
                }
            }

            // beta version
            if (version.Major == 0)
            {
                // Migrate from 0.5.x to 0.6.0
                if (version.Minor <= 5)
                {
                    version = await UpgdrateTo600Async(context, schema, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                // Migrate from 0.6.0 to 0.6.1
                if (version.Minor <= 6 && version.Build <= 0)
                {
                    version = await UpgdrateTo601Async(context, schema, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }
            }

            foreach (var serverScopeInfo in serverScopeInfos)
            {
                var oldVersion = SyncVersion.EnsureVersion(serverScopeInfo.Version);
                if (oldVersion != version)
                {
                    serverScopeInfo.Version = version.ToString();
                    await this.InternalSaveScopeAsync(context, DbScopeType.Server, serverScopeInfo, builder, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }
            }

            return(version == SyncVersion.Current);
        }
        internal virtual bool InternalNeedsToUpgrade(SyncContext context, ScopeInfo scopeInfo)
        {
            var version = SyncVersion.EnsureVersion(scopeInfo.Version);

            return(version < SyncVersion.Current);
        }
        internal virtual async Task <(SyncContext context, bool upgraded)> InternalUpgradeAsync(List <ClientScopeInfo> clientScopeInfos,
                                                                                                SyncContext context, DbConnection connection, DbTransaction transaction,
                                                                                                CancellationToken cancellationToken, IProgress <ProgressArgs> progress)
        {
            await using var runner = await this.GetConnectionAsync(context, SyncMode.Writing, SyncStage.Migrating, connection, transaction, cancellationToken, progress).ConfigureAwait(false);

            try
            {
                foreach (var clientScopeInfo in clientScopeInfos)
                {
                    var version    = SyncVersion.EnsureVersion(clientScopeInfo.Version);
                    var oldVersion = version.Clone() as Version;
                    // beta version
                    if (version.Major == 0)
                    {
                        if (version.Minor <= 5)
                        {
                            version = await AutoUpgdrateToNewVersionAsync(clientScopeInfo, context, new Version(0, 6, 0), runner.Connection, runner.Transaction, runner.CancellationToken, runner.Progress).ConfigureAwait(false);
                        }

                        if (version.Minor == 6 && version.Build == 0)
                        {
                            version = await UpgdrateTo601Async(clientScopeInfo, context, runner.Connection, runner.Transaction, runner.CancellationToken, runner.Progress).ConfigureAwait(false);
                        }

                        if (version.Minor == 6 && version.Build == 1)
                        {
                            version = await UpgdrateTo602Async(clientScopeInfo, context, runner.Connection, runner.Transaction, runner.CancellationToken, runner.Progress).ConfigureAwait(false);
                        }

                        if (version.Minor == 6 && version.Build >= 2)
                        {
                            version = await UpgdrateTo700Async(clientScopeInfo, context, runner.Connection, runner.Transaction, runner.CancellationToken, runner.Progress).ConfigureAwait(false);
                        }

                        if (version.Minor == 7 && version.Build == 0)
                        {
                            version = await AutoUpgdrateToNewVersionAsync(clientScopeInfo, context, new Version(0, 7, 1), runner.Connection, runner.Transaction, runner.CancellationToken, runner.Progress).ConfigureAwait(false);
                        }

                        if (version.Minor == 7 && version.Build == 1)
                        {
                            version = await AutoUpgdrateToNewVersionAsync(clientScopeInfo, context, new Version(0, 7, 2), runner.Connection, runner.Transaction, runner.CancellationToken, runner.Progress).ConfigureAwait(false);
                        }

                        if (version.Minor == 7 && version.Build == 2)
                        {
                            version = await AutoUpgdrateToNewVersionAsync(clientScopeInfo, context, new Version(0, 7, 3), runner.Connection, runner.Transaction, runner.CancellationToken, runner.Progress).ConfigureAwait(false);
                        }

                        if (version.Minor == 7 && version.Build >= 3)
                        {
                            version = await AutoUpgdrateToNewVersionAsync(clientScopeInfo, context, new Version(0, 8, 0), runner.Connection, runner.Transaction, runner.CancellationToken, runner.Progress).ConfigureAwait(false);
                        }

                        if (version.Minor == 8 && version.Build == 0)
                        {
                            version = await UpgdrateTo801Async(clientScopeInfo, context, runner.Connection, runner.Transaction, runner.CancellationToken, runner.Progress).ConfigureAwait(false);
                        }

                        if (version.Minor == 8 && version.Build == 1)
                        {
                            version = await AutoUpgdrateToNewVersionAsync(clientScopeInfo, context, new Version(0, 9, 0), runner.Connection, runner.Transaction, runner.CancellationToken, runner.Progress).ConfigureAwait(false);
                        }

                        if (version.Minor == 9 && version.Build == 0)
                        {
                            version = await AutoUpgdrateToNewVersionAsync(clientScopeInfo, context, new Version(0, 9, 1), runner.Connection, runner.Transaction, runner.CancellationToken, runner.Progress).ConfigureAwait(false);
                        }

                        if (version.Minor == 9 && version.Build == 1)
                        {
                            version = await UpgdrateTo093Async(clientScopeInfo, context, runner.Connection, runner.Transaction, runner.CancellationToken, runner.Progress).ConfigureAwait(false);
                        }

                        if (version.Minor == 9 && version.Build == 2)
                        {
                            version = await UpgdrateTo093Async(clientScopeInfo, context, runner.Connection, runner.Transaction, runner.CancellationToken, runner.Progress).ConfigureAwait(false);
                        }

                        if (version.Minor == 9 && version.Build == 3)
                        {
                            version = await UpgdrateTo094Async(clientScopeInfo, context, runner.Connection, runner.Transaction, runner.CancellationToken, runner.Progress).ConfigureAwait(false);
                        }

                        if (version.Minor == 9 && version.Build == 4)
                        {
                            version = await UpgdrateTo095Async(clientScopeInfo, context, runner.Connection, runner.Transaction, runner.CancellationToken, runner.Progress).ConfigureAwait(false);
                        }
                    }

                    if (oldVersion != version)
                    {
                        clientScopeInfo.Version = version.ToString();
                        (context, _)            = await this.InternalSaveClientScopeInfoAsync(clientScopeInfo, context, runner.Connection, runner.Transaction, runner.CancellationToken, runner.Progress).ConfigureAwait(false);
                    }
                }

                await runner.CommitAsync().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                throw GetSyncError(context, ex);
            }
            return(context, true);
        }
Esempio n. 9
0
        internal virtual async Task <(SyncContext context, bool upgraded)> InternalUpgradeAsync(List <ServerScopeInfo> serverScopeInfos, SyncContext context, DbConnection connection, DbTransaction transaction,
                                                                                                CancellationToken cancellationToken, IProgress <ProgressArgs> progress)
        {
            // get the smallest version of all scope in the scope info server tables
            foreach (var serverScopeInfo in serverScopeInfos)
            {
                var version = SyncVersion.EnsureVersion(serverScopeInfo.Version);

                // beta version
                if (version.Major == 0)
                {
                    if (version.Minor <= 5)
                    {
                        version = await AutoUpgdrateToNewVersionAsync(serverScopeInfo, context, new Version(0, 6, 0), connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                    }

                    if (version.Minor == 6 && version.Build == 0)
                    {
                        version = await UpgdrateTo601Async(serverScopeInfo, context, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                    }

                    if (version.Minor == 6 && version.Build == 1)
                    {
                        version = await UpgdrateTo602Async(serverScopeInfo, context, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                    }

                    if (version.Minor == 6 && version.Build >= 2)
                    {
                        version = await UpgdrateTo700Async(serverScopeInfo, context, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                    }

                    if (version.Minor == 7 && version.Build == 0)
                    {
                        version = await AutoUpgdrateToNewVersionAsync(serverScopeInfo, context, new Version(0, 7, 1), connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                    }

                    if (version.Minor == 7 && version.Build == 1)
                    {
                        version = await AutoUpgdrateToNewVersionAsync(serverScopeInfo, context, new Version(0, 7, 2), connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                    }

                    if (version.Minor == 7 && version.Build == 2)
                    {
                        version = await AutoUpgdrateToNewVersionAsync(serverScopeInfo, context, new Version(0, 7, 3), connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                    }

                    if (version.Minor == 7 && version.Build >= 3)
                    {
                        version = await AutoUpgdrateToNewVersionAsync(serverScopeInfo, context, new Version(0, 8, 0), connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                    }

                    if (version.Minor == 8 && version.Build == 0)
                    {
                        version = await UpgdrateTo801Async(serverScopeInfo, context, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                    }

                    if (version.Minor == 8 && version.Build >= 1)
                    {
                        version = await AutoUpgdrateToNewVersionAsync(serverScopeInfo, context, new Version(0, 9, 0), connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                    }

                    if (version.Minor == 9 && version.Build == 0)
                    {
                        version = await AutoUpgdrateToNewVersionAsync(serverScopeInfo, context, new Version(0, 9, 1), connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                    }

                    if (version.Minor == 9 && version.Build == 1)
                    {
                        version = await UpgdrateTo093Async(serverScopeInfo, context, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                    }

                    if (version.Minor == 9 && version.Build == 2)
                    {
                        version = await UpgdrateTo093Async(serverScopeInfo, context, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                    }

                    if (version.Minor == 9 && version.Build == 3)
                    {
                        version = await UpgdrateTo094Async(serverScopeInfo, context, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                    }

                    if (version.Minor == 9 && version.Build == 4)
                    {
                        version = await UpgdrateTo095Async(serverScopeInfo, context, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                    }
                }

                serverScopeInfo.Version = version.ToString();
                (context, _)            = await this.InternalSaveServerScopeInfoAsync(serverScopeInfo, context, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
            }

            return(context, true);
        }
Esempio n. 10
0
        internal virtual async Task <bool> InternalUpgradeAsync(SyncContext context, SyncSet schema, List <ServerScopeInfo> serverScopeInfos, DbScopeBuilder builder, DbConnection connection, DbTransaction transaction,
                                                                CancellationToken cancellationToken, IProgress <ProgressArgs> progress)
        {
            var version = SyncVersion.Current;

            // get the smallest version of all scope in the scope info server tables
            foreach (var serverScopeInfo in serverScopeInfos)
            {
                var tmpVersion = SyncVersion.EnsureVersion(serverScopeInfo.Version);

                if (tmpVersion < version)
                {
                    version = tmpVersion;
                }
            }

            // beta version
            if (version.Major == 0)
            {
                if (version.Minor <= 5)
                {
                    version = await UpgdrateTo600Async(context, schema, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                if (version.Minor == 6 && version.Build == 0)
                {
                    version = await UpgdrateTo601Async(context, schema, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                if (version.Minor == 6 && version.Build == 1)
                {
                    version = await UpgdrateTo602Async(context, schema, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                // last version of 0.6 Can be 0.6.2 or beta version 0.6.3 (that will never be released but still in the nuget packages available)
                if (version.Minor == 6 && version.Build >= 2)
                {
                    version = await UpgdrateTo700Async(context, schema, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                if (version.Minor == 7 && version.Build == 0)
                {
                    version = await UpgdrateTo701Async(context, schema, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                if (version.Minor == 7 && version.Build == 1)
                {
                    version = await UpgdrateTo702Async(context, schema, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }

                if (version.Minor == 7 && version.Build == 2)
                {
                    version = await UpgdrateTo703Async(context, schema, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }
            }

            foreach (var serverScopeInfo in serverScopeInfos)
            {
                var oldVersion = SyncVersion.EnsureVersion(serverScopeInfo.Version);
                if (oldVersion != version)
                {
                    serverScopeInfo.Version = version.ToString();
                    await this.InternalSaveScopeAsync(context, DbScopeType.Server, serverScopeInfo, builder, connection, transaction, cancellationToken, progress).ConfigureAwait(false);
                }
            }

            return(version == SyncVersion.Current);
        }