public long RegisterRemoteVolume(string name, RemoteVolumeType type, RemoteVolumeState state, TimeSpan deleteGraceTime, System.Data.IDbTransaction transaction) { using (var tr = new TemporaryTransactionWrapper(m_connection, transaction)) { m_createremotevolumeCommand.SetParameterValue(0, m_operationid); m_createremotevolumeCommand.SetParameterValue(1, name); m_createremotevolumeCommand.SetParameterValue(2, type.ToString()); m_createremotevolumeCommand.SetParameterValue(3, state.ToString()); m_createremotevolumeCommand.SetParameterValue(4, 0); if (deleteGraceTime.Ticks <= 0) { m_createremotevolumeCommand.SetParameterValue(5, 0); } else { m_createremotevolumeCommand.SetParameterValue(5, (DateTime.UtcNow + deleteGraceTime).Ticks); } m_createremotevolumeCommand.Transaction = tr.Parent; var r = m_createremotevolumeCommand.ExecuteScalarInt64(); tr.Commit(); return(r); } }
public RemoteVolumeEntry(string name, string hash, long size, RemoteVolumeType type, RemoteVolumeState state) { m_name = name; m_size = size; m_type = type; m_state = state; m_hash = hash; }
public void LogDbUpdate(string remotename, RemoteVolumeState state, long size, string hash) { lock (m_dbqueuelock) m_dbqueue.Add(new DbUpdate() { Remotename = remotename, State = state, Size = size, Hash = hash }); }
public RemoteVolumeEntry(string name, string hash, long size, RemoteVolumeType type, RemoteVolumeState state, DateTime deleteGracePeriod) { m_name = name; m_size = size; m_type = type; m_state = state; m_hash = hash; m_deleteGracePeriod = deleteGracePeriod; }
public RemoteVolumeEntry(long id, string name, string hash, long size, RemoteVolumeType type, RemoteVolumeState state, DateTime deleteGracePeriod) { ID = id; Name = name; Size = size; Type = type; State = state; Hash = hash; DeleteGracePeriod = deleteGracePeriod; }
public long RegisterRemoteVolume(string name, RemoteVolumeType type, RemoteVolumeState state, System.Data.IDbTransaction transaction = null) { using (var tr = new TemporaryTransactionWrapper(m_connection, transaction)) { m_createremotevolumeCommand.SetParameterValue(0, m_operationid); m_createremotevolumeCommand.SetParameterValue(1, name); m_createremotevolumeCommand.SetParameterValue(2, type.ToString()); m_createremotevolumeCommand.SetParameterValue(3, state.ToString()); m_createremotevolumeCommand.SetParameterValue(4, 0); m_createremotevolumeCommand.Transaction = tr.Parent; var r = Convert.ToInt64(m_createremotevolumeCommand.ExecuteScalar()); tr.Commit(); return(r); } }
public void UpdateRemoteVolume(string name, RemoteVolumeState state, long size, string hash, System.Data.IDbTransaction transaction = null) { m_updateremotevolumeCommand.Transaction = transaction; m_updateremotevolumeCommand.SetParameterValue(0, m_operationid); m_updateremotevolumeCommand.SetParameterValue(1, state.ToString()); m_updateremotevolumeCommand.SetParameterValue(2, hash); m_updateremotevolumeCommand.SetParameterValue(3, size); m_updateremotevolumeCommand.SetParameterValue(4, name); var c = m_updateremotevolumeCommand.ExecuteNonQuery(); if (c != 1) { throw new Exception("Unexpected number of remote volumes detected!"); } if (state == RemoteVolumeState.Deleted) { RemoveRemoteVolume(name, transaction); } }
public bool GetRemoteVolume(string file, out string hash, out long size, out RemoteVolumeType type, out RemoteVolumeState state) { m_selectremotevolumeCommand.SetParameterValue(0, file); using (var rd = m_selectremotevolumeCommand.ExecuteReader()) if (rd.Read()) { hash = (rd.GetValue(2) == null || rd.GetValue(2) == DBNull.Value) ? null : rd.GetValue(3).ToString(); size = (rd.GetValue(1) == null || rd.GetValue(1) == DBNull.Value) ? -1 : Convert.ToInt64(rd.GetValue(2)); type = (RemoteVolumeType)Enum.Parse(typeof(RemoteVolumeType), rd.GetValue(0).ToString()); state = (RemoteVolumeState)Enum.Parse(typeof(RemoteVolumeState), rd.GetValue(3).ToString()); return(true); } hash = null; size = -1; type = (RemoteVolumeType)(-1); state = (RemoteVolumeState)(-1); return(false); }
public Task UpdateRemoteVolumeAsync(string name, RemoteVolumeState state, long size, string hash, bool suppressCleanup = false, TimeSpan deleteGraceTime = default(TimeSpan)) { return(RunOnMain(() => m_db.UpdateRemoteVolume(name, state, size, hash, suppressCleanup, deleteGraceTime, m_transaction))); }
public Task <long> RegisterRemoteVolumeAsync(string name, RemoteVolumeType type, RemoteVolumeState state) { return(RunOnMain(() => m_db.RegisterRemoteVolume(name, type, state, m_transaction))); }
public void LogDbUpdate(string remotename, RemoteVolumeState state, long size, string hash) { lock(m_dbqueuelock) m_dbqueue.Add(new DbUpdate() { Remotename = remotename, State = state, Size = size, Hash = hash }); }
public long RegisterRemoteVolume(string name, RemoteVolumeType type, RemoteVolumeState state, System.Data.IDbTransaction transaction) { return(RegisterRemoteVolume(name, type, state, new TimeSpan(0), transaction)); }
public long RegisterRemoteVolume(string name, RemoteVolumeType type, RemoteVolumeState state) { return(RegisterRemoteVolume(name, type, state, new TimeSpan(0), null)); }