/// <summary>
        /// 带事务的Update
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="trans">The trans.</param>
        /// <returns></returns>
        /// <remarks>2016/12/19 16:54:28</remarks>
        public bool Update(TxLogininfoEntity entity, DbTransaction trans = null)
        {
            var       database       = new SqlDatabase(this.ConnectionString);
            DbCommand commandWrapper = database.GetStoredProcCommand("dbo.P_TxLogininfo_Update");

            database.AddInParameter(commandWrapper, "@OpenId", DbType.AnsiString, entity.OpenId);
            database.AddInParameter(commandWrapper, "@OpenKey", DbType.AnsiString, entity.OpenKey);
            database.AddInParameter(commandWrapper, "@Pf", DbType.AnsiString, entity.Pf);
            database.AddInParameter(commandWrapper, "@Format", DbType.AnsiString, entity.Format);
            database.AddInParameter(commandWrapper, "@Ext", DbType.AnsiString, entity.Ext);
            database.AddInParameter(commandWrapper, "@Ext1", DbType.AnsiString, entity.Ext1);
            database.AddInParameter(commandWrapper, "@UpdateTime", DbType.DateTime, entity.UpdateTime);
            database.AddInParameter(commandWrapper, "@RowTime", DbType.DateTime, entity.RowTime);


            int results = 0;

            if (trans != null)
            {
                results = database.ExecuteNonQuery(commandWrapper, trans);
            }
            else
            {
                results = database.ExecuteNonQuery(commandWrapper);
            }


            return(Convert.ToBoolean(results));
        }
        /// <summary>
        /// 将IDataReader的当前记录读取到TxLogininfoEntity 对象
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public TxLogininfoEntity LoadSingleRow(IDataReader reader)
        {
            var obj = new TxLogininfoEntity();

            obj.OpenId     = (System.String)reader["OpenId"];
            obj.OpenKey    = (System.String)reader["OpenKey"];
            obj.Pf         = (System.String)reader["Pf"];
            obj.Format     = (System.String)reader["Format"];
            obj.Ext        = (System.String)reader["Ext"];
            obj.Ext1       = (System.String)reader["Ext1"];
            obj.UpdateTime = (System.DateTime)reader["UpdateTime"];
            obj.RowTime    = (System.DateTime)reader["RowTime"];

            return(obj);
        }
        /// <summary>
        /// GetById
        /// </summary>
        /// <param name="openId">openId</param>
        /// <returns>TxLogininfoEntity</returns>
        /// <remarks>2016/12/19 16:54:28</remarks>
        public TxLogininfoEntity GetById(System.String openId)
        {
            var database = new SqlDatabase(this.ConnectionString);

            DbCommand commandWrapper = database.GetStoredProcCommand("P_TxLogininfo_GetById");

            database.AddInParameter(commandWrapper, "@OpenId", DbType.AnsiString, openId);


            TxLogininfoEntity obj = null;

            using (IDataReader reader = database.ExecuteReader(commandWrapper))
            {
                if (reader.Read())
                {
                    obj = LoadSingleRow(reader);
                }
            }
            return(obj);
        }
示例#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);
            }
        }
示例#5
0
        public static bool InsertUpdate(TxLogininfoEntity txLogininfoEntity, DbTransaction trans = null, string zoneId = "")
        {
            TxLogininfoProvider provider = new TxLogininfoProvider(zoneId);

            return(provider.InsertUpdate(txLogininfoEntity, trans));
        }