Exemplo n.º 1
0
        static void TouristsLogin(KcpUser user, Login login)
        {
            var query = SqlCmd.Query("userinfo", "deviceId", login.key, true);

            SqlClient.Instance.ExecuteReader(query, (o) => {
                if (o.Read())
                {
                    UserInfo info = new UserInfo();
                    SqlTable.ReadToObject(info, o);
                    o.Close();
                    info.LastLogin = DateTime.Now.Ticks;
                    user.userInfo  = info;
                    user.Login();
                }
                else
                {
                    UserInfo info  = new UserInfo();
                    info.coins     = 1000;
                    info.deviceId  = login.key;
                    info.LastLogin = DateTime.Now.Ticks;
                    var cmd        = SqlCmd.InsertNewRow(info, "userinfo");
                    user.userInfo  = info;
                    o.Close();
                    SqlClient.Instance.ExecuteCmd(cmd, () => {
                        var qid = SqlCmd.Query("userinfo", "deviceId", login.key, true, "id");
                        SqlClient.Instance.ExecuteReader(qid, (e) => {
                            e.Read();
                            try
                            {
                                long uid         = e.GetInt64(0);
                                user.userInfo.id = uid;
                                user.Login();
                            }
                            catch
                            {
                            }
                        });
                    });
                }
            });
        }