Exemplo n.º 1
0
        public string Cmd()
        {
            var mongo   = new MongoDBTool().GetMongoCollection <TestTTL>();
            var options = new CreateIndexOptions <TestTTL>();
            var be      = new BsonElement("expireAfterSeconds", 20);

            //options.StorageEngine = new BsonDocument { { "fsdfdsfd", 20 } };
            //options.Weights = new BsonDocument { { "expireAfterSeconds", 20 } };
            options.Name    = "testIndex";
            options.Version = 1;
            //mongo.Indexes.CreateOne(new BsonDocument() { { "CreateTime", 1 } } ,options);
            var bd = new BsonDocument()
            {
                { "CreateTime", 1 }
            };
            var idk = Builders <TestTTL> .IndexKeys;

            //idk.Combine();
            idk.Ascending(x => x.CreateTime);
            var iod = new IndexOptionDefaults();

            options.ExpireAfter = new TimeSpan(0, 0, 20);
            mongo.Indexes.CreateOne(new BsonDocument()
            {
                { "CreateTime", 1 }
            }, options);
            mongo.InsertOne(new TestTTL()
            {
                CreateTime = DateTime.Now, Code = "fsdfsdf"
            });
            return("sss");
        }
Exemplo n.º 2
0
        public string RequestLogin(string code, string iv, string encryptedData)
        {
            BaseResponseModel <AccountModel> responseModel = new BaseResponseModel <AccountModel>();

            AccountModel accountCard = null;

            WXSmallAppCommon.Models.WXAccountInfo wXAccount = WXSmallAppCommon.WXInteractions.WXLoginAction.ProcessRequest(code, iv, encryptedData);
            if (wXAccount.OpenId != null)
            {
                var filter = Builders <AccountModel> .Filter.And(Builders <AccountModel> .Filter.Eq(x => x.OpenID, wXAccount.OpenId));

                var collection = new MongoDBTool().GetMongoCollection <AccountModel>();
                var update     = Builders <AccountModel> .Update.Set(x => x.LastChangeTime, DateTime.Now);

                accountCard = collection.FindOneAndUpdate <AccountModel>(filter, update);

                if (accountCard == null)
                {
                    int gender = wXAccount.Gender == 1 ? 1 : wXAccount.Gender == 2 ? 2 : 3;
                    //string avatarUrl = DownloadAvatar(wXAccount.AvatarUrl, wXAccount.OpenId);
                    string avatarUrl = wXAccount.AvatarUrl;
                    accountCard = new AccountModel()
                    {
                        OpenID = wXAccount.OpenId, HasRedPocket = false, AccountName = wXAccount.NickName, Gender = gender, AccountAvatar = avatarUrl, CreateTime = DateTime.Now, LastChangeTime = DateTime.Now
                    };
                    collection.InsertOne(accountCard);
                }
            }
            int stautsCode = (int)(ActionParams.code_error);

            if (accountCard != null)
            {
                responseModel.JsonData = accountCard;
                stautsCode             = (int)(ActionParams.code_ok);
            }
            responseModel.StatusCode = stautsCode;
            JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings();

            string[] param = new string[] { "StatusCode", "JsonData", "AccountID", "HasRedPocket" };


            jsonSerializerSettings.ContractResolver = new LimitPropsContractResolver(param);
            string jsonString = JsonConvert.SerializeObject(responseModel, jsonSerializerSettings);

            Console.WriteLine("json#####UserInfo:" + jsonString);
            return(jsonString);
        }
Exemplo n.º 3
0
 public IActionResult ReceiveWe7Data()
 {
     try
     {
         string json    = new StreamReader(Request.Body).ReadToEnd();
         var    db      = new MongoDBTool().GetMongoCollection <We7Temp>();
         var    we7Temp = new We7Temp()
         {
             Data = json
         };
         db.InsertOne(we7Temp);
         return(new JsonResponse1 <string>()
         {
             JsonData = we7Temp.We7TempID.ToString()
         }.ToJsonResult(this));
     }
     catch (Exception)
     {
         return(this.JsonErrorStatus());
     }
 }
Exemplo n.º 4
0
        public string ReceiveWe7Data()
        {
            try
            {
                string json    = new StreamReader(Request.Body).ReadToEnd();
                var    db      = new MongoDBTool().GetMongoCollection <We7Temp>();
                var    we7Temp = new We7Temp()
                {
                    Data = json
                };
                db.InsertOne(we7Temp);
                return(new BaseResponseModel <string>()
                {
                    StatusCode = Tools.ActionParams.code_ok, JsonData = we7Temp.We7TempID.ToString()
                }.ToJson());
            }
            catch (Exception)
            {
                return(JsonResponseModel.ErrorJson);

                throw;
            }
        }
        public string RequestLogin(string code, string iv, string encryptedData)
        {
            AccountCard accountCard = null;

            WXSmallAppCommon.Models.WXAccountInfo wXAccount = WXSmallAppCommon.WXInteractions.WXLoginAction.ProcessRequest(code, iv, encryptedData);
            if (wXAccount.openId != null)
            {
                var filter = Builders <AccountCard> .Filter.And(Builders <AccountCard> .Filter.Eq(x => x.OpenId, wXAccount.openId));

                var collection = new MongoDBTool().GetMongoCollection <AccountCard>("AccountCard");
                var update     = Builders <AccountCard> .Update.Set(x => x.LastLoginTime, DateTime.Now);

                accountCard = collection.FindOneAndUpdate <AccountCard>(filter, update);

                if (accountCard == null)
                {
                    accountCard = new AccountCard()
                    {
                        OpenId = wXAccount.openId, AccountName = wXAccount.nickName, Gender = wXAccount.gender, AvatarUrl = wXAccount.avatarUrl, City = wXAccount.city, Province = wXAccount.province, CreateTime = DateTime.Now, LastLoginTime = DateTime.Now
                    };
                    collection.InsertOne(accountCard);
                }
            }
            BaseResponseModel <AccountCard> responseModel = new BaseResponseModel <AccountCard>();
            int stautsCode = (int)(ActionParams.code_error);

            if (accountCard != null)
            {
                responseModel.JsonData = accountCard;
                stautsCode             = (int)(ActionParams.code_ok);
            }
            responseModel.StatusCode = stautsCode;
            string jsonString = JsonConvert.SerializeObject(responseModel);

            Console.WriteLine("json**3:" + jsonString);
            return(jsonString);
        }