Esempio n. 1
0
        private async Task UpdateDataBaseWithCache()
        {
            foreach (var cache in ServerDataManager.GetAllServerData())
            {
                var mongoDbHandler = new MongoDBHandler(cache.Key.ToString());

                //todo: find a way to use replaceMany for generics to reduce foreach loops and load times
                foreach (var userData in cache.Value.GetUserDataModel())
                {
                    await mongoDbHandler.Upsert("UserData", Convert.ToInt64(userData.Key), userData.Value);
                }

                foreach (var shopRole in cache.Value.GetShopRoleModel())
                {
                    await mongoDbHandler.Upsert("ShopRoles", Convert.ToInt64(shopRole.Key), shopRole.Value);
                }

                foreach (var serverSettings in cache.Value.GetServerSettingsModel())
                {
                    await mongoDbHandler.Upsert("ServerSettings", serverSettings.Key, serverSettings.Value);
                }
            }
        }