Ejemplo n.º 1
0
        /// <summary>
        /// 获取收藏数据
        /// </summary>
        /// <param name="_reqData"></param>
        /// <returns></returns>
        public RspFavoritesList GetFavoritesList(ReqFavoritesList _reqData)
        {
            RspFavoritesList _rspData = new RspFavoritesList();

            //验证用户ID格式
            if (_reqData.userId < 0)
            {
                _rspData.header.status     = ERequestResult.faild;
                _rspData.header.statusCode = Error.MOBILE_ERROR_CODE.MOBILE_PARAMS_ERROR;
                return(_rspData);
            }

            //检查是否登录状态
            if (Common.Common.CheckLogin(_reqData.userId, _reqData.userKey) == 0)
            {
                _rspData.header.status     = ERequestResult.faild;
                _rspData.header.statusCode = Error.MOBILE_ERROR_CODE.SYS_USER_NOLOGIN;
                return(_rspData);
            }

            //获取动态列表
            string strWhere = string.Empty;
            string strOrder = " order by AddTime desc";

            strWhere += "Types=1 and UsId = " + _reqData.userId;

            if (_reqData.favoritesId > 0)
            {
                strWhere += " and ID<" + _reqData.favoritesId;    //因为是倒序显示,所以是<
            }
            _rspData.isFinish = true;

            DataSet _ds = new BCW.BLL.Favorites().GetList("TOP 10 ID,Types,NodeId,UsID,Title,PUrl,AddTime", strWhere + strOrder);

            if (_ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < _ds.Tables[0].Rows.Count; i++)
                {
                    FavoritesData _favoritesData = new FavoritesData();

                    _favoritesData.favoritesId = int.Parse(_ds.Tables[0].Rows[i]["ID"].ToString());
                    string _url = _ds.Tables[0].Rows[i]["PUrl"].ToString();
                    if (!_url.Contains("bid="))
                    {
                        continue;
                    }

                    int _threadId = 0;
                    try
                    {
                        //截取ID
                        _threadId = int.Parse(_url.Substring(_url.IndexOf("bid=") + 4));
                    }
                    catch
                    {
                        continue;
                    }


                    BCW.Model.Text _text = new BCW.BLL.Text().GetText(_threadId);
                    _favoritesData.threadItem = EssencePost.AssembleItem(_text);
                    _rspData.lstFavorites.Add(_favoritesData);


                    //检查是否到底
                    if (i == _ds.Tables[0].Rows.Count - 1)
                    {
                        if (strWhere.Contains("1=1") == false)
                        {
                            strWhere += " and 1=1";
                        }
                        DataSet _dsCheck = new BCW.BLL.Favorites().GetList(" TOP 10 ID,Types,NodeId,UsID,Title,PUrl,AddTime ", strWhere.Replace("1=1", "ID<" + _reqData.favoritesId) + strOrder);
                        _rspData.isFinish = _dsCheck.Tables[0].Rows.Count <= 0;
                    }
                }
            }

            _rspData.serverTime    = Common.Common.GetLongTime(DateTime.Now);
            _rspData.header.status = ERequestResult.success;
            return(_rspData);
        }
Ejemplo n.º 2
0
 //初始化精华贴
 public void InitEssencePost(int _threadId)
 {
     bests = new EssencePost();
     bests.InitData(0, _threadId, 1, -1);
 }