Beispiel #1
0
 public void PrefareDatabase()
 {
     using (var db = ORMContext.Open())
     {  // ¼Ó¼ºÀ¸·Î ¸¸µç Ŭ·¡½º°¡ ÀÖ¾î¾ßÇÔ
         var data = db.Single <AccountData>(w => w.accountKey == "");
     }
 }
Beispiel #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));
        }
Beispiel #3
0
        public CommonResponse AccountCreation(ReqAccountCreation req)
        {
            ResAccountCreation res = new ResAccountCreation();

            using (var db = ORMContext.Open())
            {
                if (db.Exists <t_account>(w => w.accountKey == req.accountKey))
                {
                    return(Response(ResultCode.Error));
                }

                long lastKey = 0;
                if (req.authType == AuthType.GameCenter || req.authType == AuthType.Google)
                {
                    t_account acc = new t_account();
                    acc.accountKey = req.accountKey;
                    acc.loginTime  = DateTime.UtcNow;
                    acc.authType   = req.authType;
                    //lastKey = db.Insert<t_account>(acc);
                    lastKey = db.Insert(acc);
                }
                else if (req.authType == AuthType.Guest)
                {
                    t_account acc  = new t_account();
                    var       guid = Guid.NewGuid();
                    acc.accountKey = guid.ToString();
                    acc.loginTime  = DateTime.UtcNow;
                    acc.authType   = req.authType;
                    lastKey        = db.Insert <t_account>(acc);
                }
                RedisProvider.CreateSession((int)lastKey);
            }
            //req.accountKey; //클리이언트가 Access 키를 넘겨줌
            //req.authType;

            //1. 해당키가 존재하는지 확인
            // 1-1 해당키가 존재하면 에러
            // 2 해당키를 가지고 데이터베이스에 데이터를 생성
            // 2-1 Guest 인증의 경우 키를 생성할것

            return(Response(ResultCode.OK));
        }