コード例 #1
0
        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);
            }
        }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        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);
            }
        }