public static VersionLock Create() { VersionLock version = new VersionLock(Guid.NewGuid(), 0, Session.Name, DateTime.Now, Session.Name, DateTime.Now); version.isNew = true; return version; }
public void LoadVersion(Guid versionId) { _versionLock = VersionLock.Find(versionId); }
private static VersionLock Load(Guid id) { VersionLock versionLock = null; try { using (var selectCommand = new SqlCommand(LOAD_SQL, Connection)) { selectCommand.Parameters.AddWithValue("@Id", id); var reader = selectCommand.ExecuteReader(); if (reader.HasRows) { reader.Read(); var value = reader.GetInt64(1); var createdBy = reader.GetString(2); var created = reader.GetDateTime(3); var modifiedBy = reader.GetString(4); var modified = reader.GetDateTime(5); versionLock = new VersionLock(id, value, createdBy, created, modifiedBy, modified); Versions.Add(versionLock, Session.Name); } else { throw new SystemException(string.Format("Version {0} not found.", id)); } reader.Close(); } } catch (SqlException sqlEx) { throw new SystemException("unexpected sql error loading version", sqlEx); } return versionLock; }
public VersionLock GetVersion() { if (_versionLock == null) _versionLock = VersionLock.Create(); return _versionLock; }