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

            try
            {
                rs = TMPStore.OpenRecordStore(resName, true);
                if (rs.GetNumRecords() == 0)
                {
                    rs.AddRecord(data, 0, data.Length);
                }
                else
                {
                    rs.SetRecord(recordId, data, 0, data.Length);
                }
            }
            catch (Exception ex)
            {
                Loon.Utils.Debugging.Log.Exception(ex);
            }
            finally
            {
                CloseRecordStore(rs);
            }
        }
Beispiel #2
0
 public static void CloseRecordStore(TMPStore rs)
 {
     if (rs != null)
     {
         rs.CloseRecordStore();
         rs = null;
     }
 }
Beispiel #3
0
        public void Save()
        {
            string result = Encode();

            if (result != null && !"".Equals(result))
            {
                TMPStore.SetBytes(name, result);
            }
        }
Beispiel #4
0
 public static TMPStore OpenRecordStore(string recordStoreName, bool createIfNecessary)
 {
     lock (stores)
     {
         TMPStore store = (TMPStore)CollectionUtils.Get(stores, recordStoreName);
         if (store == null)
         {
             store = new TMPStore(recordStoreName);
             stores.Add(recordStoreName, store);
         }
         store.OpenRecordStore(createIfNecessary);
         return(store);
     }
 }
Beispiel #5
0
        public static void RemoveRecord(string resName, int recordId)
        {
            TMPStore rs = null;

            try
            {
                rs = TMPStore.OpenRecordStore(resName, false);
                rs.DeleteRecord(recordId);
            }
            finally
            {
                CloseRecordStore(rs);
            }
        }
Beispiel #6
0
 public static bool ExistRecordStoreAll(string resName)
 {
     string[] recordStores = TMPStore.ListRecordStores();
     if (recordStores == null)
     {
         return(false);
     }
     for (int i = 0; i < recordStores.Length; i++)
     {
         if (recordStores[i].Equals(resName))
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #7
0
        public static bool ExistRecordStore(string resName)
        {
            TMPStore rs = null;

            try
            {
                rs = TMPStore.OpenRecordStore(resName, false);
                return(rs != null);
            }
            catch
            {
                return(false);
            }
            finally
            {
                CloseRecordStore(rs);
            }
        }
Beispiel #8
0
 public void Dispose()
 {
     try
     {
         if (records != null)
         {
             records.Clear();
         }
         if (recordsList != null)
         {
             recordsList.Clear();
         }
         TMPStore.RemoveRecord(name);
     }
     catch (Exception ex)
     {
         Loon.Utils.Debugging.Log.Exception(ex);
     }
 }
Beispiel #9
0
        public static int AddBytes(string resName, byte[] data)
        {
            TMPStore rs     = null;
            bool     opened = false;

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

            try
            {
                rs = TMPStore.OpenRecordStore(resName, true);
                if (rs.Count >= recordId)
                {
                    result = rs.GetRecord(recordId);
                }
            }
            catch (Exception ex)
            {
                Loon.Utils.Debugging.Log.Exception(ex.Message);
            }
            finally
            {
                CloseRecordStore(rs);
            }
            return(result);
        }
Beispiel #11
0
 public int Load()
 {
     return(LoadEncodeSession(TMPStore.GetString(name)));
 }
Beispiel #12
0
 public static TMPStore OpenRecordStore(string recordStoreName, bool createIfNecessary)
 {
     lock (stores)
     {
         TMPStore store = (TMPStore)CollectionUtils.Get(stores, recordStoreName);
         if (store == null)
         {
             store = new TMPStore(recordStoreName);
             stores.Add(recordStoreName, store);
         }
         store.OpenRecordStore(createIfNecessary);
         return store;
     }
 }
Beispiel #13
0
 public static void CloseRecordStore(TMPStore rs)
 {
     if (rs != null)
     {
         rs.CloseRecordStore();
         rs = null;
     }
 }