Exemplo n.º 1
0
 public static async Task Test1()
 {
     for (int i = 0; i < 100; i++)
     {
         new System.Threading.Tasks.Task(() =>
         {
             StatictisLogUtil.Login("123", "123", "ip", "channel", "123", "login");
         }).Start();
     }
 }
        private void OperatorSuccess(User user, string channelName, string ip, string versionName, JObject responseData)
        {
            responseData.Add(MyCommon.CODE, (int)Consts.Code.Code_OK);
            responseData.Add(MyCommon.UID, user.Uid);

            //更新下用户的任务
            MySqlUtil.UpdateUserTask(user.Uid);

            StatisticsHelper.StatisticsLogin(user.Uid);

            StatictisLogUtil.Login(user.Uid, user.Username, ip, channelName, versionName, MyCommon.OpType.Login);
        }
Exemplo n.º 3
0
        public override string OnResponse(string data)
        {
            StatictisLoginReq statictisLoginReq = null;

            try
            {
                statictisLoginReq = JsonConvert.DeserializeObject <StatictisLoginReq>(data);
            }
            catch (Exception e)
            {
                MySqlService.log.Warn("传入的参数有误:" + e);
                return(null);
            }

            string uid         = statictisLoginReq.uid;
            string ip          = statictisLoginReq.ip;
            string apkVersion  = statictisLoginReq.apkVersion;
            string channelname = statictisLoginReq.channelname;
            int    type        = statictisLoginReq.type;

            if (string.IsNullOrWhiteSpace(ip) || string.IsNullOrWhiteSpace(uid) ||
                string.IsNullOrWhiteSpace(apkVersion) || string.IsNullOrWhiteSpace(channelname) || type < 1)
            {
                MySqlService.log.Warn("字段有空:" + data);
                return(null);
            }

            User user = NHibernateHelper.userManager.GetByUid(uid);

            if (user == null)
            {
                MySqlService.log.Warn("uid未注册:" + data);
            }
            switch (type)
            {
            case 1:
                StatictisLogUtil.Login(uid, user.Username, ip, channelname, apkVersion, MyCommon.OpType.Login);
                break;

            case 2:
                StatictisLogUtil.Login(uid, user.Username, ip, channelname, apkVersion, MyCommon.OpType.Register);
                break;
            }
            return(null);
        }
Exemplo n.º 4
0
        private void ThirdLoginSQL(string thirdId, string nickname, string channelname, string ip, JObject responseData)
        {
            //通过第三方查询用户
            List <User> users = NHibernateHelper.userManager.GetUserByTid(thirdId);
            User        user;

            if (users?.Count == 0)
            {
                string uid = UidUtil.createUID();
                user = new User()
                {
                    //去除开头的空白
                    Username       = nickname.TrimStart(),
                    Userpassword   = "",
                    ChannelName    = channelname,
                    ThirdId        = thirdId,
                    Secondpassword = "",
                    Uid            = uid,
                    IsRobot        = 0,
                    CreateTime     = DateTime.Now,
                    MachineId      = ""
                };

                Random random = new Random();

                //注册用户数据 并 注册新手邮箱
                if (NHibernateHelper.userManager.Add(user))
                {
                    OperatorSuccess(user, responseData);
                    StatictisLogUtil.Login(uid, user.Username, ip, channelname, "1.0.43", MyCommon.OpType.Register);
                }
                else
                {
                    bool flag = false;
                    for (int i = 0; i < 10; i++)
                    {
                        int next = random.Next(1, 100);
                        if (user.Username.Length > 0)
                        {
                            user.Username.Remove(user.Username.Length - 1);
                        }

                        user.Username += next;
                        if (NHibernateHelper.userManager.Add(user))
                        {
                            flag = true;
                            break;
                        }
                    }

                    if (flag)
                    {
                        MySqlService.log.Info("第三方重复注册成功 user.Username:"******"\nuser.Uid" + user.Uid);
                        OperatorSuccess(user, responseData);

                        //第三方注册
                        StatisticsHelper.StatisticsRegister(user.Uid);
                        StatictisLogUtil.Login(uid, user.Username, ip, channelname, "1.0.43", MyCommon.OpType.Register);
                    }
                    else
                    {
                        MySqlService.log.Warn("第三方注册失败 user.Username:"******"\nuser.Uid" + user.Uid);
                        OperatorFail(responseData);
                    }
                }

                SendEmailUtil.SendEmail(uid, "新用户奖励", "欢迎来到疯狂升级,为您送上1000金币,快去对战吧!", "1:1000");
//                SendEmailUtil.SendEmail(uid, "“疯狂升级”新手指引",
//                    @"欢迎来到疯狂升级,本游戏有多种玩法供您选择,更有比赛场可以获取丰厚大奖噢!详细规则可在“关于-游戏规则”中查看,祝您游戏愉快~",
//                    "");
//                SendEmailUtil.SendEmail(uid, "“疯狂升级”游戏福利",
//                    @"每日登陆可领取签到奖励,通过游戏可获得抽奖机会,完成任务以达成成就,比赛场中获得胜利有丰厚大礼,更多精彩内容等你来玩噢~",
//                    "");
            }
            else
            {
                //第三方登陆
                user = users?[0];
                OperatorSuccess(user, responseData);
                StatisticsHelper.StatisticsLogin(user.Uid);
            }
        }