コード例 #1
0
        internal void BeginInstallVersion(DatabaseVersion version, SqlConnection connection, SqlTransaction transaction)
        {
            // Verify that this version really should be installed
            var installedVersion = GetCurrentInstalledVersionAndValidatePreInstallationState(version, connection, transaction);

            // Update information that this installation is beginning to install now, make sure that no one is in between, throw is someone is
            int result = _versionStorage.StartInstallation(installedVersion, connection, transaction);

            if (result != 1)
            {
                throw new InvalidOperationException(string.Format("Starting installation for version {0} for {1} failed with count {2}", version.Version, version.InstallationName, result));
            }
        }
コード例 #2
0
        internal void SetVersionInstalled(DatabaseVersion version, SqlConnection connection, SqlTransaction transaction)
        {
            InstallationNameAndVersion installedVersion = GetCurrentInstalledVersionAndValidatePostInstallationState(version, connection, transaction);

            // Update information that this installation is ended now, make sure that no one is in between, throw is someone is
            int result = _versionStorage.EndInstallation(installedVersion, connection, transaction);

            if (result != 1)
            {
                throw new InvalidOperationException(string.Format("Starting installation for version {0} for {1} failed with count {2}", version.Version, version.InstallationName, result));
            }
        }
コード例 #3
0
        private InstallationNameAndVersion GetCurrentInstalledVersionAndValidatePreInstallationState(DatabaseVersion version, SqlConnection connection, SqlTransaction transaction)
        {
            // Get installation row from database
            var installedVersion = GetInstalledVersion(version.InstallationName, connection, transaction);

            if (installedVersion.InstalledVersion >= version.Version)
            {
                throw new InvalidOperationException(string.Format("Version ({0}) is already installed for {1}", version.Version, version.InstallationName));
            }
            if (installedVersion.StartedInstallingVersion >= version.Version)
            {
                throw new InvalidOperationException(string.Format("Version ({0}) installation is already in progress for {1}", version.Version, version.InstallationName));
            }
            if (installedVersion.StartedInstallingVersion != version.Version - 1)
            {
                throw new InvalidOperationException(string.Format("Unknown version missmatch in version ({0}) for {1}", version.Version, version.InstallationName));
            }

            return installedVersion;
        }
コード例 #4
0
        private InstallationNameAndVersion GetCurrentInstalledVersionAndValidatePostInstallationState(DatabaseVersion version, SqlConnection connection, SqlTransaction transaction)
        {
            // Get installation row from database
            var installedVersion = GetInstalledVersion(version.InstallationName, connection, transaction);

            // Verify that this version really should have been installed now
            if (installedVersion.InstalledVersion >= version.Version)
            {
                throw new InvalidOperationException(string.Format("Version ({0}) is already installed for {1}", version.Version, version.InstallationName));
            }
            if (installedVersion.StartedInstallingVersion != version.Version)
            {
                throw new InvalidOperationException(string.Format("Version ({0}) is not in progress for {1} as it should be", version.Version, version.InstallationName));
            }

            return installedVersion;
        }