示例#1
0
        public void SetAppSetting(UserAppSettingData appSetting)
        {
            InitOnece();
            if (appSetting == null || string.IsNullOrEmpty(appSetting.LoginName))
            {
                return;
            }
            if (!_dicByLoginName.TryGetValue(appSetting.LoginName, out List <UserAppSettingData> list))
            {
                list = new List <UserAppSettingData>();
                _dicByLoginName.Add(appSetting.LoginName, list);
            }
            var exist = list.FirstOrDefault(a => a.Key == appSetting.Key);

            if (exist != null)
            {
                exist.Value = appSetting.Value;
            }
            else
            {
                list.Add(appSetting);
            }
            using (LiteDatabase db = WebApiRoot.CreateLocalDb()) {
                var col = db.GetCollection <UserAppSettingData>();
                col.Upsert(exist);
            }
        }
示例#2
0
 public void SaveCalcConfigs(List <CalcConfigData> data)
 {
     InitOnece();
     if (data == null || data.Count == 0)
     {
         return;
     }
     lock (_locker) {
         var dic = new Dictionary <string, CalcConfigData>(StringComparer.OrdinalIgnoreCase);
         foreach (var item in data)
         {
             if (dic.TryGetValue(item.CoinCode, out CalcConfigData entity))
             {
                 entity.Update(item);
             }
             else
             {
                 dic.Add(item.CoinCode, item);
             }
         }
         using (LiteDatabase db = WebApiRoot.CreateLocalDb()) {
             var col = db.GetCollection <CalcConfigData>();
             col.Delete(Query.All());
             col.Insert(dic.Values);
         }
         _dicByCode = dic;
     }
 }
示例#3
0
 public void RemoveById(Guid id)
 {
     InitOnece();
     lock (_locker) {
         if (_dicById.ContainsKey(id))
         {
             _dicById.Remove(id);
             using (LiteDatabase db = WebApiRoot.CreateLocalDb()) {
                 var col = db.GetCollection <OverClockData>();
                 col.Delete(id);
             }
         }
     }
 }
示例#4
0
 private void Init()
 {
     lock (_locker) {
         if (!_isInited)
         {
             using (LiteDatabase db = WebApiRoot.CreateLocalDb()) {
                 var col = db.GetCollection <CalcConfigData>();
                 foreach (var item in col.FindAll())
                 {
                     _dicByCode.Add(item.CoinCode, item);
                 }
             }
             _isInited = true;
         }
     }
 }
示例#5
0
 private void Init()
 {
     lock (_locker) {
         if (!_isInited)
         {
             using (LiteDatabase db = WebApiRoot.CreateLocalDb()) {
                 var col = db.GetCollection <OverClockData>();
                 foreach (var item in col.FindAll())
                 {
                     _dicById.Add(item.Id, item);
                 }
             }
             _isInited = true;
         }
     }
 }
示例#6
0
 public void AddOrUpdate(OverClockData data)
 {
     InitOnece();
     lock (_locker) {
         using (LiteDatabase db = WebApiRoot.CreateLocalDb()) {
             var col = db.GetCollection <OverClockData>();
             if (_dicById.TryGetValue(data.Id, out OverClockData entity))
             {
                 entity.Update(data);
                 col.Update(entity);
             }
             else
             {
                 _dicById.Add(data.Id, data);
                 col.Insert(data);
             }
         }
     }
 }
示例#7
0
 public void AddOrUpdate(NTMinerFileData data)
 {
     InitOnece();
     lock (_locker) {
         using (LiteDatabase db = WebApiRoot.CreateLocalDb()) {
             var col = db.GetCollection <NTMinerFileData>();
             if (_dicById.TryGetValue(data.Id, out NTMinerFileData entity))
             {
                 entity.Update(data);
                 col.Update(entity);
             }
             else
             {
                 data.CreatedOn = DateTime.Now;
                 _dicById.Add(data.Id, data);
                 col.Insert(data);
             }
             RefreshLatest();
         }
     }
 }
示例#8
0
 private void Init()
 {
     lock (_locker) {
         if (!_isInited)
         {
             using (LiteDatabase db = WebApiRoot.CreateLocalDb()) {
                 var col = db.GetCollection <UserAppSettingData>();
                 foreach (var item in col.FindAll())
                 {
                     if (!_dicByLoginName.TryGetValue(item.LoginName, out List <UserAppSettingData> list))
                     {
                         list = new List <UserAppSettingData>();
                         _dicByLoginName.Add(item.LoginName, list);
                     }
                     list.Add(item);
                 }
             }
             _isInited = true;
         }
     }
 }
示例#9
0
 public void AddOrUpdate(UserMinerGroupData data)
 {
     InitOnece();
     lock (_locker) {
         using (LiteDatabase db = WebApiRoot.CreateLocalDb()) {
             var col = db.GetCollection <UserMinerGroupData>();
             if (_dicById.TryGetValue(data.Id, out UserMinerGroupData entity))
             {
                 data.ModifiedOn = DateTime.Now;
                 entity.Update(data);
                 col.Update(entity);
             }
             else
             {
                 data.CreatedOn = DateTime.Now;
                 _dicById.Add(data.Id, data);
                 col.Insert(data);
             }
         }
     }
 }