Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BCW.Mobile.Model.UserPlatform model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_UserPlatform set ");
            strSql.Append("userId=@userId");
            strSql.Append(" where platformId=@platformId and platformType=@platformType ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@userId",       SqlDbType.Int,       4),
                new SqlParameter("@platformId",   SqlDbType.NVarChar, 50),
                new SqlParameter("@platformType", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.userId;
            parameters[1].Value = model.platformId;
            parameters[2].Value = model.platformType;

            int rows = SqlHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(BCW.Mobile.Model.UserPlatform model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_UserPlatform(");
            strSql.Append("platformId,platformType,userId)");
            strSql.Append(" values (");
            strSql.Append("@platformId,@platformType,@userId)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@platformId",   SqlDbType.NVarChar, 50),
                new SqlParameter("@platformType", SqlDbType.Int,       4),
                new SqlParameter("@userId",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.platformId;
            parameters[1].Value = model.platformType;
            parameters[2].Value = model.userId;

            int rows = SqlHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BCW.Mobile.Model.UserPlatform GetModel(string platformId, int platformType)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 platformId,platformType,userId from tb_UserPlatform ");
            strSql.Append(" where platformId=@platformId and platformType=@platformType ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@platformId",   SqlDbType.NVarChar, 50),
                new SqlParameter("@platformType", SqlDbType.Int, 4)
            };
            parameters[0].Value = platformId;
            parameters[1].Value = platformType;

            BCW.Mobile.Model.UserPlatform model = new BCW.Mobile.Model.UserPlatform();
            DataSet ds = SqlHelper.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #4
0
        /// <summary>
        /// 登录同时绑定第三方登录平台信息
        /// </summary>
        /// <param name="_account">登录用户名</param>
        /// <param name="_pwd">登录密码</param>
        /// <param name="_type">绑定的第三方平台类型(1:微信  2:QQ  3:新浪微博)</param>
        /// <param name="_assessToken"></param>
        public void Login(string _account, string _pwd, EMobileLoginType _type, string _assessToken)
        {
            //绑定第三方登录
            Model.UserPlatform _userPlatform = new BLL.UserPlatform().GetModel(_assessToken, ( int )this.loginType);
            if (_userPlatform == null)
            {
                //检查用户密码是否正确
                int            _userRow = 0;
                string         _md5Pwd  = Utils.MD5Str(_pwd);
                BCW.Model.User _user    = new BCW.Model.User();
                _user.UsPwd = _md5Pwd;
                if (_account.ToString().Length == 11)
                {
                    _user.Mobile = _account;
                    _userRow     = new BCW.BLL.User().GetRowByMobile(_user);
                }
                else
                {
                    _user.ID = int.Parse(_account);
                    _userRow = new BCW.BLL.User().GetRowByID(_user);
                }

                if (_userRow <= 0)
                {
                    rspLoginData.header.status     = ERequestResult.faild;
                    rspLoginData.header.statusCode = MOBILE_ERROR_CODE.LOGIN_USER_PWD_ERROR;
                    return;
                }

                _user = new BCW.BLL.User().GetKey(_userRow);

                Model.UserPlatform _newUserPlatform = new BCW.Mobile.Model.UserPlatform();
                try
                {
                    _newUserPlatform.platformId   = _assessToken;
                    _newUserPlatform.platformType = ( int )_type;
                    _newUserPlatform.userId       = _user.ID;
                    rspLoginData.user.platformId  = _assessToken;
                    new BLL.UserPlatform().Add(_newUserPlatform);
                }
                catch (Exception e)
                {
                    ;
                }
            }


            base.Login(_account, _pwd);
        }
Example #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public BCW.Mobile.Model.UserPlatform DataRowToModel(DataRow row)
 {
     BCW.Mobile.Model.UserPlatform model = new BCW.Mobile.Model.UserPlatform();
     if (row != null)
     {
         if (row["platformId"] != null)
         {
             model.platformId = row["platformId"].ToString();
         }
         if (row["platformType"] != null && row["platformType"].ToString() != "")
         {
             model.platformType = int.Parse(row["platformType"].ToString());
         }
         if (row["userId"] != null && row["userId"].ToString() != "")
         {
             model.userId = int.Parse(row["userId"].ToString());
         }
     }
     return(model);
 }