Beispiel #1
0
        public static void SetBytes(string resName, int recordId, byte[] data)
        {
            RecordStore rs = null;

            try
            {
                rs = RecordStore.OpenRecordStore(resName, true);
                if (rs.GetNumRecords() == 0)
                {
                    rs.AddRecord(data, 0, data.Length);
                }
                else
                {
                    rs.SetRecord(recordId, data, 0, data.Length);
                }
            }
            catch (RecordStoreException ex)
            {
                Log.Exception(ex);
            }
            finally
            {
                CloseRecordStore(rs);
            }
        }
Beispiel #2
0
        public static void RemoveRecord(string resName, int recordId)
        {
            RecordStore rs = null;

            try
            {
                rs = RecordStore.OpenRecordStore(resName, false);
                rs.DeleteRecord(recordId);
            }
            finally
            {
                CloseRecordStore(rs);
            }
        }
Beispiel #3
0
        public static bool ExistRecordStore(string resName)
        {
            RecordStore rs = null;

            try
            {
                rs = RecordStore.OpenRecordStore(resName, false);
                return(rs != null);
            }
            catch
            {
                return(false);
            }
            finally
            {
                CloseRecordStore(rs);
            }
        }
Beispiel #4
0
        public static int AddBytes(string resName, byte[] data)
        {
            RecordStore rs     = null;
            bool        opened = false;

            try
            {
                rs     = RecordStore.OpenRecordStore(resName, true);
                opened = true;
                return(rs.AddRecord(data, 0, data.Length));
            }
            catch (RecordStoreException ex)
            {
                Log.Exception(ex);
            }
            finally
            {
                CloseRecordStore(rs);
            }
            return(opened ? COULD_NOT_SAVE : COULD_NOT_OPEN);
        }
Beispiel #5
0
        public static byte[] GetBytes(string resName, int recordId)
        {
            byte[]      result = new byte[0];
            RecordStore rs     = null;

            try
            {
                rs = RecordStore.OpenRecordStore(resName, true);
                if (rs.Count >= recordId)
                {
                    result = rs.GetRecord(recordId);
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex.Message);
            }
            finally
            {
                CloseRecordStore(rs);
            }
            return(result);
        }