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); } }
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; } }
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); } } } }
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; } } }
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; } } }
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); } } } }
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(); } } }
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; } } }
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); } } } }