Example #1
0
        private void PrepareTest()
        {
            AuthCommand auth = new AuthCommand();
            ReqAuth     req  = new ReqAuth();

            req.accountKey = "test";
            req.authType   = AuthType.Guest;
            var reqAuth = auth.Auth(req) as ResAuth;

            ReqItemGet reqItemGet = new ReqItemGet();

            reqItemGet.sessionKey = reqAuth.sessionKey;
            auth.ItemGet(reqItemGet);
        }
Example #2
0
        public CommonResponse Auth(ReqAuth req)
        {
            List <DataInventory> invertoryList = new List <DataInventory>();
            int idxAccount = 0;

            //using (var db = ORMContext.Open())
            //{  // 속성으로 만든 클래스가 있어야함
            //    var data = db.Single<AccountData>(w => w.accountKey == req.accountKey);
            //    idxAccount = data.idx;
            //}

            using (var db = ORMContext.Open())
            {
                using (var tran = db.OpenTransaction()) //Commit을 하기 전에는 RollBack 저리가 된다. //트랜젝션을 OPen하는 순간 Commit을 안하면 무조건 RollBack이다.
                {
                    var data = db.Single <t_account>(w => w.accountKey == req.accountKey);
                    if (data == null)
                    {
                        return(Response(ResultCode.Error));
                    }
                    idxAccount = data.idx;

                    var rows = db.Select <t_inventory>(w => w.idx == idxAccount);

                    db.UpdateOnly(() => new t_account {
                        loginTime = DateTime.UtcNow
                    }, w => w.idx == idxAccount);                                                                  //CTRL +R 두번 누르면 다 바뀜 , 세계 서비스 제공시 UtcNow로 하는게 좋음
                    var format = $"UPDATE new_table set loginTime = '{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}' Where idx = {idxAccount}";
                    //tran.Rollback();
                    tran.Commit();
                }


                //db.ExecuteNonQuery(format);
            }
            var res = new ResAuth();

            res.accessKey  = "werwerwerwerwerwer";
            res.sessionKey = RedisProvider.CreateSession(idxAccount);
            res.success    = true;
            res.inventory  = invertoryList;
            return(Response(res));
        }