Ejemplo n.º 1
0
        private void SelectManager()
        {
            var managerId = GetParamGuid("g");

            if (!CheckParam(managerId))
            {
                return;
            }
            var info = reader.SelectManager(UserAccount.Account, managerId, GetIp(),
                                            UAFactory.Instance.IsTx);
            var sessionId = ShareUtil.GenerateComb().ToString();

            if (info.Code == (int)MessageCode.Success)
            {
                if (CheckLockState(info.Data.Manager.Idx))
                {
                    OutputHelper.Output(MessageCode.LoginOnlineLock);
                    return;
                }

                //写入登录信息
                var cookie = UAHelper.SetFormsAuthentication(UserAccount.Account, info.Data.Manager.Idx,
                                                             info.Data.Manager.Name, 1, sessionId);
                OnlineMgr.LoginSession(info.Data.Manager.Idx, sessionId);
                onlineClient.RiseOnlineTime(info.Data.Manager.Idx);
                info.Data.Cookie = cookie;
            }
            OutputHelper.Output(info);
        }
Ejemplo n.º 2
0
        private void ManagerInfo()
        {
            if (UserAccount.ManagerId == Guid.Empty) //登录
            {
                var info = reader.GetManagerInfoByAccount(UserAccount.Account, GetIp(),
                                                          UAFactory.Instance.IsTx);

                var sessionId = ShareUtil.GenerateComb().ToString();
                if (info.Code == (int)MessageCode.Success)
                {
                    if (info.Data.NeedSelect == false)
                    {
                        if (info.Data.ManagerInfo == null)
                        {
                            string playerName = "";
                            string logo       = "1";
                            int    templateId = 1;
                            var    createData = reader.CreateManager(UserAccount.Account, playerName, logo, templateId,
                                                                     UAHelper.GetRealIP());
                            if (createData.Code != (int)MessageCode.Success)
                            {
                                info.Code = createData.Code;
                                OutputHelper.Output(info);
                                return;
                            }
                            info = reader.GetManagerInfoByAccount(UserAccount.Account, GetIp(),
                                                                  UAFactory.Instance.IsTx);
                        }

                        if (CheckLockState(info.Data.ManagerInfo.Manager.Idx))
                        {
                            OutputHelper.Output(MessageCode.LoginOnlineLock);
                            return;
                        }

                        //写入登录信息
                        string cookie = UAHelper.SetFormsAuthentication(UserAccount.Account,
                                                                        info.Data.ManagerInfo.Manager.Idx,
                                                                        info.Data.ManagerInfo.Manager.Name, 1, sessionId);
                        OnlineMgr.LoginSession(info.Data.ManagerInfo.Manager.Idx, sessionId);
                        onlineClient.RiseOnlineTime(info.Data.ManagerInfo.Manager.Idx);
                        info.Data.Cookie = cookie;
                    }
                }
                OutputHelper.Output(info);
            }
            else
            {
                if (CheckLockState(UserAccount.ManagerId))
                {
                    OutputHelper.Output(MessageCode.LoginOnlineLock);
                    return;
                }
                var info = reader.GetManagerInfo(UserAccount.ManagerId, UAFactory.Instance.IsTx);
                info.Data.Cookie = "";
                OutputHelper.Output(info);
            }
        }
Ejemplo n.º 3
0
        private void Register()
        {
            string playerName = GetParam("name");
            string logo       = GetParam("logo");
            int    templateId = 1; // GetParamInt("ti");

            if (string.IsNullOrEmpty(playerName))
            {
                OutputHelper.Output(MessageCode.RegisterNameIsEmpty);
                return;
            }

            var createData = reader.CreateManager(UserAccount.Account, playerName, logo, templateId,
                                                  UAHelper.GetRealIP());

            if (createData.Code == (int)MessageCode.Success)
            {
                var sessionId = ShareUtil.GenerateComb().ToString();
                var cookie    = UAHelper.SetFormsAuthentication(UserAccount.Account, createData.Data, playerName, 1, sessionId);
                OnlineMgr.LoginSession(createData.Data, sessionId);
                onlineClient.RiseOnlineTime(createData.Data);
            }
            OutputHelper.Output(createData);
        }
Ejemplo n.º 4
0
        private bool doLoginNew(ref string cookie)
        {
            try
            {
                TxLogininfoEntity tLoginInfo = null;
                var platformId = GetParam("platform");
                var userName   = GetParam("openid");
                if (ShareUtil.IsQunHei)
                {
                    userName = GetParam("username");
                }
                //if (userName.Length>0 && userName.Contains("h5_zhiqu"))
                //    return false;
                var user = NbUserMgr.GetByAccount(userName, GetIp(), DateTime.Today.AddDays(-1),
                                                  DateTime.Today, 0);
                var sessionId = ShareUtil.GenerateComb().ToString();
                if (user != null)
                {
                    UserAccountEntity userAccountEntity = new UserAccountEntity(user.Account, Guid.Empty, "", 1,
                                                                                platformId, sessionId);
                    userAccountEntity.ExtraData = "d|pengyou|f";


                    var info = reader.GetManagerInfoByAccount(userAccountEntity.Account, GetIp(),
                                                              UAFactory.Instance.IsTx);
                    if (info.Code == (int)MessageCode.Success)
                    {
                        if (info.Data.NeedSelect == false)
                        {
                            if (ShareUtil.IsTx)
                            {
                                string openKey = GetParam("openkey");
                                string pf      = GetParam("pf");
                                if (string.IsNullOrEmpty(pf))
                                {
                                    pf = "wanba_ts";
                                }
                                string platform = GetParam("platform");
                                //userip
                                //sig
                                int    appId  = UAFactory.Instance.TxAppId;
                                string appKey = UAFactory.Instance.TxAppKey;
                                var    result = WbUserInfo(userName, openKey, pf, platform, appId, appKey);
                                if (result != 0)
                                {
                                    OutputHelper.Output(result);
                                }
                                tLoginInfo = new TxLogininfoEntity(userName, openKey, pf, platform, "",
                                                                   "", DateTime.Now, DateTime.Now);
                            }
                            if (info.Data.ManagerInfo == null)
                            {
                                string playerName = "";
                                string logo       = "1";
                                int    templateId = 1;
                                var    createData = reader.CreateManager(UserAccount.Account, playerName, logo, templateId,
                                                                         UAHelper.GetRealIP());
                                if (createData.Code != (int)MessageCode.Success)
                                {
                                    info.Code = createData.Code;
                                    OutputHelper.Output(info);
                                }
                                info = reader.GetManagerInfoByAccount(UserAccount.Account, GetIp(),
                                                                      UAFactory.Instance.IsTx);;
                            }
                            try
                            {
                                if (ShareUtil.IsH5A8)
                                {
                                    UA_A8.UserAction("entergame", info.Data.ManagerInfo.Manager.Account, "", "",
                                                     info.Data.ManagerInfo.Manager);
                                }
                            }
                            catch (Exception)
                            {
                            }
                            if (CheckLockState(info.Data.ManagerInfo.Manager.Idx))
                            {
                                OutputHelper.Output(MessageCode.LoginOnlineLock);
                            }
                            //写入登录信息
                            cookie = UAHelper.SetFormsAuthentication(userAccountEntity.Account,
                                                                     info.Data.ManagerInfo.Manager.Idx,
                                                                     info.Data.ManagerInfo.Manager.Name, 1, sessionId);
                            OnlineMgr.LoginSession(info.Data.ManagerInfo.Manager.Idx, sessionId);
                            onlineClient.RiseOnlineTime(info.Data.ManagerInfo.Manager.Idx);
                            info.Data.Cookie = cookie;
                            Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, cookie));
                            var isSubscribe = GetParamBool("isSubscribe");
                            if (isSubscribe)//关注
                            {
                                activityClient.DoShare(info.Data.ManagerInfo.Manager.Idx, 4);
                            }
                            if (ShareUtil.IsTx)
                            {
                                TxLogininfoMgr.InsertUpdate(tLoginInfo);
                            }
                            return(true);
                        }
                        return(true);
                    }
                    else
                    {
                        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.Account,
                                                                                         DateTime.Now,
                                                                                         DateTime.Now.AddDays(10),
                                                                                         false, userAccountEntity.ToString(),
                                                                                         FormsAuthentication
                                                                                         .FormsCookiePath);
                        cookie = FormsAuthentication.Encrypt(ticket);
                        Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, cookie));
                        return(false);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                cookie = ex.ToString();
                return(true);
            }
        }
Ejemplo n.º 5
0
        private bool doLogin(ref string cookie)
        {
            try
            {
                var platformId = GetParam("platform");
                var userName   = GetParamNOUrlDecode("username");
                //if (userName.Length > 0 && userName.Contains("h5_zhiqu"))
                //    return false;
                var user = NbUserMgr.GetByAccount(userName, GetIp(), DateTime.Today.AddDays(-1),
                                                  DateTime.Today, 0);
                var sessionId = ShareUtil.GenerateComb().ToString();
                if (user != null)
                {
                    UserAccountEntity userAccountEntity = new UserAccountEntity(user.Account, Guid.Empty, "", 1,
                                                                                platformId, sessionId);
                    userAccountEntity.ExtraData = "d|pengyou|f";


                    var info = reader.GetManagerInfoByAccount(userAccountEntity.Account, GetIp(),
                                                              UAFactory.Instance.IsTx);
                    if (info.Code == (int)MessageCode.Success)
                    {
                        if (info.Data.NeedSelect == false)
                        {
                            if (info.Data.ManagerInfo == null)
                            {
                                string playerName = "";
                                string logo       = "1";
                                int    templateId = 1;
                                var    createData = reader.CreateManager(UserAccount.Account, playerName, logo, templateId,
                                                                         UAHelper.GetRealIP());
                                if (createData.Code != (int)MessageCode.Success)
                                {
                                    info.Code = createData.Code;
                                    OutputHelper.Output(info);
                                }
                                info = reader.GetManagerInfoByAccount(UserAccount.Account, GetIp(),
                                                                      UAFactory.Instance.IsTx);;
                            }

                            if (CheckLockState(info.Data.ManagerInfo.Manager.Idx))
                            {
                                OutputHelper.Output(MessageCode.LoginOnlineLock);
                            }
                            //写入登录信息
                            cookie = UAHelper.SetFormsAuthentication(userAccountEntity.Account,
                                                                     info.Data.ManagerInfo.Manager.Idx,
                                                                     info.Data.ManagerInfo.Manager.Name, 1, sessionId);
                            OnlineMgr.LoginSession(info.Data.ManagerInfo.Manager.Idx, sessionId);
                            onlineClient.RiseOnlineTime(info.Data.ManagerInfo.Manager.Idx);
                            info.Data.Cookie = cookie;
                            Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, cookie));

                            return(true);
                        }
                        return(true);
                    }
                    else
                    {
                        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.Account,
                                                                                         DateTime.Now,
                                                                                         DateTime.Now.AddDays(10),
                                                                                         false, userAccountEntity.ToString(),
                                                                                         FormsAuthentication
                                                                                         .FormsCookiePath);
                        cookie = FormsAuthentication.Encrypt(ticket);
                        Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, cookie));
                        return(false);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                cookie = ex.ToString();
                return(true);
            }
        }