/// <summary> /// Used to get the current profile version /// </summary> /// <param name="profile"></param> /// <param name="transaction"></param> public double GetVersion(DatabaseVersionSetup.Profile profile, ITransaction transaction) { IConnection connection = profile.RepositoryProfile.GetDatabase(); var access = new DoTrackDataAccess(() => connection, TableName); IDoTrack doTrack = access.Select(profile.RepositoryProfile.DatabaseRepository, transaction); if (doTrack != null) return doTrack.Version; // // todo: Rolf remove this as some stage // Log.Info("Tracker not found on repository name. Older version used database name. Trying on database name"); doTrack = access.Select(profile.RepositoryProfile.DatabaseName, transaction); if (doTrack != null){ Log.Info("Tracker found. Renaming to DatabaseRepository name"); access.Delete(profile.RepositoryProfile.DatabaseName, transaction); doTrack.DatabaseName = profile.RepositoryProfile.DatabaseRepository; access.Insert(doTrack, transaction); return doTrack.Version; } return -1; }
public void SetUp() { var database = _controller.Profile.RepositoryProfile.GetDatabase(); _server = database as SqlServer; database.SwitchToDatabase(_controller.Profile.RepositoryProfile.DatabaseName,null); _doTrackDataAccess = new DoTrackDataAccess(() => database, "_DbTracking"); _transaction = new MysqlServer.SqlTransactionWrapper(GetConnection().BeginTransaction(IsolationLevel.ReadUncommitted)); }
/// <summary> /// Sets the version number /// </summary> /// <param name="profile"></param> /// <param name="version"></param> /// <param name="transaction"></param> public void SetVersion(DatabaseVersionSetup.Profile profile, double version, ITransaction transaction) { IConnection connection = profile.RepositoryProfile.GetDatabase(); var access = new DoTrackDataAccess(() => connection, TableName); var track = new DoTrack { DatabaseName = profile.RepositoryProfile.DatabaseRepository, Version = version }; try{ access.Insert(track, transaction); } catch (Exception){ access.Update(track, transaction); } }