コード例 #1
0
ファイル: MongoHelper.cs プロジェクト: war-man/nhabe
        public void checkAndCreateAutHistory(string user, string token, string device, string os, string imei)
        {
            var collection = db.GetCollection <MongoAPIAuthHistory>("APIAuthHistory");
            var builder    = Builders <MongoAPIAuthHistory> .Filter;
            //  var filter = builder.Eq("UserLogin", user) & builder.Eq("IsExpired", 0);
            var data = collection.Find <MongoAPIAuthHistory>(builder.Eq("UserLogin", user) & builder.Eq("IsExpired", 0)).ToList();

            foreach (var item in data)
            {
                var update = Builders <MongoAPIAuthHistory> .Update.Set("IsExpired", 1);

                var result = collection.UpdateOneAsync(Builders <MongoAPIAuthHistory> .Filter.Eq("Id", item.Id), update);
            }

            var authHistory = new MongoAPIAuthHistory()
            {
                Device    = device,
                Imei      = imei,
                OS        = os,
                Token     = token,
                UserLogin = user,
                IsExpired = 0,
                LoginTime = DateTime.Now
            };

            collection.InsertOneAsync(authHistory);
        }
コード例 #2
0
ファイル: MongoHelper.cs プロジェクト: war-man/nhabe
        // auth history
        public void createAuthHistory(MongoAPIAuthHistory data)
        {
            var collection = db.GetCollection <MongoAPIAuthHistory>("APIAuthHistory");

            collection.InsertOneAsync(data);
        }