public static void OnUpshelf(this ProductItem product, LiteCollection<ProductItem> productItems) { product.正在上架 = product.正在上架 = false; product.Where = "出售中"; productItems.Update(product); }
public UsersDL() { if (dataColl == null) { dataColl = db.GetCollection<DTO.UsersDTO>("Users"); } dataColl.EnsureIndex("User"); }
public DbRepo(string dp, ILogger logger, IJsonSerializer json = null) { DataPath = dp; //LitePlatform.Initialize(new LitePlatformFullDotNet()); var data = Path.Combine(DataPath, dataName); _logger = logger; _json = json; if (File.Exists(Path.Combine(DataPath, "Emby.Kodi.SyncQueue.ldb"))) { File.Delete(Path.Combine(DataPath, "Emby.Kodi.SyncQueue.ldb")); } if (File.Exists(Path.Combine(DataPath, "Emby.Kodi.SyncQueue.1.2.ldb"))) { File.Delete(Path.Combine(DataPath, "Emby.Kodi.SyncQueue.1.2.ldb")); } if (File.Exists(Path.Combine(DataPath, "Emby.Kodi.SyncQueue.1.3.ldb"))) { File.Delete(Path.Combine(DataPath, "Emby.Kodi.SyncQueue.1.3.ldb")); } if (File.Exists(Path.Combine(DataPath, "Emby.Kodi.SyncQueue.1.31.ldb"))) { File.Delete(Path.Combine(DataPath, "Emby.Kodi.SyncQueue.1.31.ldb")); } if (!Directory.Exists(DataPath)) { Directory.CreateDirectory(DataPath); } if (!File.Exists(data)) { } if (DB == null) { DB = new LiteDatabase(data); } folders = DB.GetCollection<FolderRec>("Folders"); items = DB.GetCollection<ItemRec>("Items"); userinfos = DB.GetCollection<UserInfoRec>("UserInfos"); folders.EnsureIndex(x => x.ItemId); folders.EnsureIndex(x => x.UserId); folders.EnsureIndex(x => x.LastModified); folders.EnsureIndex(x => x.Status); folders.EnsureIndex(x => x.MediaType); items.EnsureIndex(x => x.ItemId); items.EnsureIndex(x => x.LastModified); items.EnsureIndex(x => x.Status); items.EnsureIndex(x => x.MediaType); userinfos.EnsureIndex(x => x.ItemId); userinfos.EnsureIndex(x => x.UserId); userinfos.EnsureIndex(x => x.LastModified); userinfos.EnsureIndex(x => x.MediaType); }
public async Task Integrate6_DeleteEmployeeByIdTest() { HttpResponseMessage response = await _httpClient.DeleteAsync(_newEmployee1.EmployeeID.ToString()); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); using (LiteDatabase db = new LiteDatabase(_dbFileName)) { LiteCollection <Employee> col = db.GetCollection <Employee>("Employee"); Employee dbEmpl = col.FindById(_newEmployee1.EmployeeID); Assert.IsNull(dbEmpl); } }
public void AddCourier(ExpressMail e) { try { using (var db = new LiteDatabase(@"Courier.db")) { LiteCollection <ExpressMail> collection = db.GetCollection <ExpressMail>("Express"); collection.Insert(e); } } catch (Exception) { throw; } }
public override Guid?GetCanonicalChainId() { LiteCollection <BsonDocument> collection = _db.GetCollection <BsonDocument>("canon"); var docId = new BsonValue("canon"); BsonDocument doc = collection.FindById(docId); if (doc is null) { return(null); } return(doc.TryGetValue("chainId", out BsonValue ns) ? new Guid(ns.AsBinary) : (Guid?)null); }
internal static void Insert(Other obj) { try { using (LiteDatabase db = new LiteDatabase(@"Data.db")) { LiteCollection <Other> collection = db.GetCollection <Other>("data"); collection.Insert(obj); } } catch (Exception ex) { Debug.Log(ex); } }
public static List <ParameterControlTemplate> GetListFromDb() { List <ParameterControlTemplate> list = new List <ParameterControlTemplate>(); using (LiteDatabase db = new LiteDatabase(Program.settings.DatabasePath)) { LiteCollection <ParameterControlTemplate> collection = db.GetCollection <ParameterControlTemplate>(Program.settings.ParameterControlDatabase); IEnumerable <ParameterControlTemplate> d = collection.FindAll(); list = d.ToList(); } return(list); }
public bool WriteMessage(string carsN, string message) { try { using (LiteDatabase db = _config.Database) { LiteCollection <Message> collection = db.GetCollection <Message>("Message"); Message newMessage = new Message(message, carsN, Status.Saved); collection.Insert(newMessage); return(true); } } catch (Exception e) { Console.WriteLine(e); return(false); } }
public LiteDbContext(IOptions <MyConfig> configs) { try { if (_context == null) { _context = new LiteDatabase(configs.Value.PathToDB); collection = _context.GetCollection <Customer>(nameOfCollection); } } catch (Exception ex) { throw new Exception("Can find or create LiteDb database.", ex); } }
private static async void UpdateIcons(DiscordClient discord) { // Run forever Random random = new Random(); while (true) { using (LiteDatabase db = new LiteDatabase("data.db")) { // Check all server configs LiteCollection <ServerConfig> servers = db.GetCollection <ServerConfig>("servers"); ServerConfig[] configs = servers.FindAll().ToArray(); for (Int32 i = 0; i < configs.Length; i++) { ServerConfig server = configs[i]; if (server.Thumbnails.Count == 0) { servers.Delete(s => s.Id == server.Id); continue; } if (DateTime.Now > server.NextSet) { // Get the server DiscordGuild guild = await discord.GetGuildAsync(server.Server); // Select a new image String newIcon = server.Thumbnails[random.Next(0, server.Thumbnails.Count)]; WebClient client = new WebClient(); Byte[] data = await client.DownloadDataTaskAsync(newIcon); MemoryStream stream = new MemoryStream(data); // Apply the modification await guild.ModifyAsync(icon : stream); // Update the next update time Double days = server.IntervalMin + random.NextDouble() * (server.IntervalMax - server.IntervalMin); server.NextSet = server.NextSet.AddDays(days); servers.Update(server); } } } // Wait one minute Thread.Sleep(60000); } }
/// <summary> /// A default constructor of Wallet service. (Need to initialized from a ContractService object.) /// </summary> /// <param name="contract">A wallet contract object</param> /// <param name="contractService">A wallet contract service object</param> /// <param name="db">LiteDB database object</param> /// <param name="userPrivateKey">User's private key</param> /// <param name="api">Insight-based compatible API (>0.4)</param> /// <param name="TransferFee">Fee for token transfer</param> /// <returns>A wallet service is used to obtain all the ledger from the wallet. Private key is used to create the ledger on the user's behalf.</returns> internal WalletService(WalletContract contract, ContractService contractService, LiteDatabase db, BitcoinSecret userPrivateKey, IInsightAPI api, decimal TransferFee) { this.TransferFee = TransferFee; this.userPrivateKey = userPrivateKey; this.contractService = contractService; this.contract = contract; this.api = api; this.db = db; byte[] myByte = Encoding.ASCII.GetBytes(contract.ID); var encrypted = NBitcoin.Crypto.Hashes.RIPEMD160(myByte, myByte.Length); var hashID = encrypted.ByteArrayToString(); ledger = db.GetCollection <Ledger>($"Ledger-{hashID}"); account = db.GetCollection <Account>($"Account-{hashID}"); ownerAddress = new BitcoinPubKeyAddress(contract.OwnerPublicAddress, contractService.MainNetwork); }
public static UpsertType Upsert <T>(this LiteCollection <T> col, T item, BsonValue itemId) where T : new() { var x = col.FindById(itemId); if (x == null) { col.Insert(item); return(UpsertType.Insert); } else { col.Update(item); return(UpsertType.Update); } }
public static void BlockUser(int UserId) { try { using (var db = new LiteDatabase(@"EgovMedDB.db")) { LiteCollection <User> users = db.GetCollection <User>("User"); User newUser = users.FindOne(f => f.UserId == UserId); newUser.IsBlock = true; users.Update(newUser); } } catch (Exception ex) { } }
//+ private void ClientEditor_Load(object sender, EventArgs e) { #if !DEBUG dataGridView1.Columns[0].Visible = false; #endif ctx = new ContextMenu(); ctx.MenuItems.Add("Delete", OnClient_Delete); colClients = Prefs.DB.GetCollection <Client>(Prefs.ColClients); clients = new List <Client>(); foreach (Client c in colClients.FindAll()) { clients.Add(c); dataGridView1.Rows.Add(c.ClientId, c.ClientName, c.ClientDiscount); } }
public override void ForkTxNonces(Guid sourceChainId, Guid destinationChainId) { LiteCollection <BsonDocument> srcColl = TxNonceCollection(sourceChainId); if (!srcColl.Exists(_ => true)) { throw new ChainIdNotFoundException( sourceChainId, $"No such chain ID: {sourceChainId}." ); } LiteCollection <BsonDocument> destColl = TxNonceCollection(destinationChainId); destColl.InsertBulk(srcColl.FindAll()); }
public static bool UserIsExist(string login) { using (var db = new LiteDatabase(@"EgovMedDB.db")) //using для безопасного использования БД, не надо следить за открытием и закрытием { LiteCollection <User> users = db.GetCollection <User>("User"); User user = users.FindOne(f => f.login == login); if (user != null) { return(true); } else { return(false); } } }
public LPServer(string dbPath, string auth) { db = new LiteDatabase(dbPath); db.Checkpoint(); posts = db.GetCollection <LitePost>("posts"); LoadIndexTemplate(); LoadPostTemplate(); options = new JsonSerializerOptions { PropertyNamingPolicy = new CamelBack(), PropertyNameCaseInsensitive = true, }; this.auth = auth; }
private void createCollections() { nodes = db.GetCollection <dbNode>("nodes"); namespaces = db.GetCollection <dbNamespace>("namespaces"); latestValues = db.GetCollection <dbVariableValue>("latestValues"); bufferValues = db.GetCollection <dbVariableValue>("bufferValues"); // Creating indexes nodes.EnsureIndex("name"); namespaces.EnsureIndex("URI"); namespaces.EnsureIndex("internalIndex"); namespaces.EnsureIndex("currentServerIndex"); latestValues.EnsureIndex("name"); bufferValues.EnsureIndex("name"); bufferValues.EnsureIndex("timestamp"); }
public static bool UserIsExist(string login) { using (var db = new LiteDatabase(@"EgovMedDB.db")) { LiteCollection <User> users = db.GetCollection <User>("User"); User newUser = users.FindOne(f => f.Login == login); if (newUser != null) { return(true); } else { return(false); } } }
public static bool DeleteCountry(int id) { try { using (var db = new LiteDatabase(@"MyData.db")) { LiteCollection <Country> col = db.GetCollection <Country>("Countries"); col.Delete(id); return(true); } } catch { return(false); } }
public async Task <int> Initialize() { return(await Task.Run(() => { using (var db = new LiteDatabase(configuration.ConnectionString)) { LiteCollection <SiteItem> collection = db.GetCollection <SiteItem>(); IEnumerable <SiteItem> result = collection.FindAll(); if (!result.Any()) { return collection.InsertBulk(GetItems()); } return 0; } })); }
public async void InitDB() { try { db = new LiteDatabase("filename=" + ApplicationData.Current.LocalFolder.Path + @"\albums.db;journal=false;"); albumCollection = db.GetCollection <Album>("albums"); albumCollection.EnsureIndex(t => t.AlbumName); albumCollection.EnsureIndex(t => t.Artist); } catch { await(await StorageFile.GetFileFromPathAsync(ApplicationData.Current.LocalFolder.Path + @"\albums.db")).DeleteAsync(); InitDB(); } }
public async Task <List <Candle> > GetBacktestCandlesBetweenTime(BacktestOptions backtestOptions) { try { LiteCollection <CandleAdapter> candleCollection = DataStoreBacktest.GetInstance(GetDatabase(backtestOptions)).GetTable <CandleAdapter>("Candle_" + backtestOptions.CandlePeriod); candleCollection.EnsureIndex("Timestamp"); List <CandleAdapter> candles = candleCollection.Find(Query.Between("Timestamp", backtestOptions.StartDate, backtestOptions.EndDate), Query.Ascending).ToList(); var items = Mapping.Mapper.Map <List <Candle> >(candles); return(items); } catch (Exception ex) { Global.Logger.Error(ex.ToString()); throw; } }
public LiteCollection <T> GetCollection <T>(string collectionName) { LiteCollection <T> collection = null; try { using (var db = new LiteDatabase(this.ConnectionString)) { collection = db.GetCollection <T>(collectionName); } } catch (Exception) { } return(collection); }
/// <summary> /// 构建DbLite实例对象设置集合实体 /// </summary> public DbCollection() { var path = $"{Directory.GetCurrentDirectory()}\\data\\"; if (!File.Exists(path)) //如果不存在就创建file文件夹 { if (!Directory.Exists(path)) //如果不存在就创建file文件夹 { Directory.CreateDirectory(path); //创建该文件夹 } File.Create(path); //创建该文件夹 } DataBase = DbContext.Context($"{path}YeaJur.db").DataBase; Collection = DataBase.GetCollection <T>(typeof(T).Name); }
public async Task SaveBacktestTradeSignalsBulk(List <TradeSignal> signals, BacktestOptions backtestOptions) { var items = Mapping.Mapper.Map <List <TradeSignalAdapter> >(signals); LiteCollection <TradeSignalAdapter> itemCollection = DataStoreBacktest.GetInstance(GetDatabase(backtestOptions)).GetTable <TradeSignalAdapter>("Signals_" + backtestOptions.CandlePeriod); foreach (var item in items) { itemCollection.Delete(i => i.StrategyName == item.StrategyName); } // TradeSignalAdapter lastCandle = itemCollection.Find(Query.All("Timestamp", Query.Descending), limit: 1).FirstOrDefault(); itemCollection.EnsureIndex("Timestamp"); itemCollection.InsertBulk(items); }
public void SetUpdateUser() { try { using (LiteDatabase db = new LiteDatabase(ConfigManager.DBPath)) { LiteCollection <User> users = db.GetCollection <User>("users"); users.Update(this.User); Utils.WriteLine($"Updating User LastPlayed: {this.User.LastPlayed}"); } } catch (Exception ex) { Utils.Throw(ex); } }
public bool OpenIfPossible() { try { db = new LiteDatabase($"Filename={dbPath};"); data = db.GetCollection <T>(collectionName); return(true); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"Failed to open {dbPath}"); System.Diagnostics.Debug.WriteLine(ex.ToString()); System.Diagnostics.Debug.WriteLine("*****"); return(false); } }
private static void CreateAdminUser(LiteCollection <User> collection, User user, bool update) { if (!collection.Exists(u => u.Username == user.Username)) { collection.Insert(user); } else { if (update) { var oldUser = collection.FindOne(u => u.Username == user.Username); user.Id = oldUser.Id; collection.Update(user); } } }
/// <summary> /// Gets the task whose last completed date is oldest. /// </summary> /// <returns>The task whose last completed date is oldest.</returns> private Task GetOldestCompletedDateTask() { using (LiteDatabase db = new LiteDatabase(Settings.DatabaseFilePath)) { LiteCollection <Task> tasks = db.GetCollection <Task>(Settings.TaskCollectionName); Task oldestCompletedDateTask = null; foreach (Task task in tasks.FindAll()) { if (oldestCompletedDateTask is null || oldestCompletedDateTask.LastCompleted > task.LastCompleted) { oldestCompletedDateTask = task; } } return(oldestCompletedDateTask); } }
//Return a list of mobiles for a user public ArrayList MobileList(int UserID) { ArrayList arrayList = new ArrayList(); LiteCollection <Mobileunit> aDBValues = m_db.GetCollection <Mobileunit>("mobile"); var results = aDBValues.Find(x => x.UserID == UserID); foreach (Mobileunit item in results) { if (item != null) { arrayList.Add(item.Id); arrayList.Add(item.Displayname); } } return(arrayList); }
protected static Character SelectDBCharacter([FromSource] Player _player, User _user, int _charID) { try { using (LiteDatabase db = new LiteDatabase(@"./resources/[local]/laced/data/laced.db")) { LiteCollection <Character> characters = (LiteCollection <Character>)db.GetCollection <Character>("characters"); return(characters.FindOne(charc => charc.Id == _charID)); } } catch (Exception _ex) { Utils.Throw(_ex); return(null); } }
public PlayerFollowerDB() { db = new LiteDatabase(@"playerfollower.db"); col = db.GetCollection<PlayerFollowerInfo>("playerfollower"); }
public CustomerInfoDB() { db = new LiteDatabase(@"customer.db"); col = db.GetCollection<CustomerInfo>("customer"); }
public FollowerDB() { db = new LiteDatabase(@"follower.db"); col = db.GetCollection<FollowerInfo>("follower"); }
public UserDb() { db = new LiteDatabase(@"user.db"); col = db.GetCollection<User>("user"); }
public void Init(Region tregion) { TheRegion = tregion; string dir = "/saves/" + TheRegion.TheWorld.Name + "/"; TheRegion.TheServer.Files.CreateDirectory(dir); dir = TheRegion.TheServer.Files.BaseDirectory + dir; Database = new LiteDatabase("filename=" + dir + "chunks.ldb"); DBChunks = Database.GetCollection<BsonDocument>("chunks"); LODsDatabase = new LiteDatabase("filename=" + dir + "lod_chunks.ldb"); DBLODs = LODsDatabase.GetCollection<BsonDocument>("lodchunks"); EntsDatabase = new LiteDatabase("filename=" + dir + "ents.ldb"); DBEnts = EntsDatabase.GetCollection<BsonDocument>("ents"); ImageDatabase = new LiteDatabase("filename=" + dir + "images.ldb"); DBImages = ImageDatabase.GetCollection<BsonDocument>("images"); DBMaxes = ImageDatabase.GetCollection<BsonDocument>("maxes"); DBImages2 = ImageDatabase.GetCollection<BsonDocument>("images_angle"); }
public static void OnUpshelfing(this ProductItem product, LiteCollection<ProductItem> productItems) { product.正在上架 = true; productItems.Update(product); }
public NoteDb() { db = new LiteDatabase(@"note.db"); col = db.GetCollection<Note>("note"); }
public static void ClassInit(TestContext context) { db = new LiteDatabase(new MemoryStream()); col = db.GetCollection<TestPocoClass>("col1"); col.EnsureIndex(o => o.Key); }
public NotebookDb() { db = new LiteDatabase(@"notebook.db"); col = db.GetCollection<Notebook>("notebook"); }
/// <summary> /// Initializes a new instance of the <see cref="Library"/> class. /// </summary> /// <param name="database">The database.</param> public Library(LiteDatabase database) { this.database = database; Tracks = this.database.GetCollection<LibraryTrack>("Tracks"); }
public ClipboardDB() { db = new LiteDatabase(@"clipboard.db"); col = db.GetCollection<ClipboardRecord>("clipboard"); }