Ejemplo n.º 1
0
        public ViewResult UserList(int?page, string type = "User", int groupId = 0, string viewName = "UserLists", string ajaxViewName = "_UserList")
        {
            YSWL.MALL.ViewModel.SNS.GroupInfo groupInfo = new MALL.ViewModel.SNS.GroupInfo();
            groupId = groupId > 0 ? groupId : GroupId;
            //重置页面索引
            page = page.HasValue && page.Value > 1 ? page.Value : 1;
            //页大小
            int pagesize = 10;
            //计算分页起始索引
            int startIndex = page.Value > 1 ? (page.Value - 1) * pagesize + 1 : 1;
            //计算分页结束索引
            int endIndex = page.Value * pagesize;
            //总记录数
            int toalcount = 0;

            //小组成员总数 非管理员用户
            toalcount = bllGroupUser.GetRecordCount("GroupId=" + groupId + " AND Role = 0");
            //小组成员分页加载  非管理员用户
            groupInfo.UserList = new PagedList <Model.SNS.GroupUsers>(
                bllGroupUser.GetUserList(groupId, startIndex, endIndex)
                , page ?? 1, pagesize, toalcount);
            if (Request.IsAjaxRequest())
            {
                return(View(ajaxViewName, groupInfo.UserList));
            }
            return(View(viewName, groupInfo.UserList));
        }
Ejemplo n.º 2
0
        public ActionResult Index(int?page, string type, string q, int groupId = 0)
        {
            YSWL.MALL.ViewModel.SNS.GroupInfo groupInfo = new MALL.ViewModel.SNS.GroupInfo();
            groupId         = groupId > 0 ? groupId : GroupId;
            groupInfo.Group = bllGroups.GetModel(groupId);
            ViewBag.GroupId = groupId;
            ViewBag.GetType = type;
            if (null != groupInfo.Group)
            {
                ViewBag.IsCreator = (CurrentUser != null && groupInfo.Group.CreatedUserId == CurrentUser.UserID);
                //小组帖子数
                ViewBag.toalcount = groupInfo.Group.TopicCount;
            }
            //重置页面索引
            page = page.HasValue && page.Value > 1 ? page.Value : 1;
            //页大小
            int pagesize = 10;
            //计算分页起始索引
            int startIndex = page.Value > 1 ? (page.Value - 1) * pagesize + 1 : 1;
            //计算分页结束索引
            int endIndex = page.Value * pagesize;
            //总记录数
            int toalcount = 0;

            switch (type)
            {
            case "Search":
                //小组帖子搜索
                //推荐帖子
                q                   = Common.InjectionFilter.Filter(q);
                toalcount           = bllTopic.GetCountByKeyWord(q, groupId);
                ViewBag.q           = q;
                ViewBag.toalcount   = toalcount;
                groupInfo.TopicList = new PagedList <YSWL.MALL.Model.SNS.GroupTopics>(
                    bllTopic.SearchTopicByKeyWord(startIndex, endIndex, q, groupId, "")
                    , page ?? 1, pagesize, toalcount);
                if (Request.IsAjaxRequest())
                {
                    return(PartialView(CurrentThemeViewPath + "/Group/TopicList.cshtml", groupInfo.TopicList));
                }
                break;

            case "User":
                //小组管理员
                groupInfo.AdminUserList = bllGroupUser.GetAdminUserList(groupId);
                if (groupInfo.AdminUserList.Count > 0 && groupInfo.AdminUserList[0].Role == 2)
                {
                    BLL.Members.UsersExp bllUser = new BLL.Members.UsersExp();
                    groupInfo.AdminUserList[0].User = bllUser.GetUsersExpModelByCache(groupInfo.AdminUserList[0].UserID);
                }
                //小组成员总数 非管理员用户
                toalcount = bllGroupUser.GetRecordCount("GroupId=" + groupId + " AND Role = 0");
                //小组成员分页加载  非管理员用户
                groupInfo.UserList = new PagedList <Model.SNS.GroupUsers>(
                    bllGroupUser.GetUserList(groupId, startIndex, endIndex)
                    , page ?? 1, pagesize, toalcount);
                if (Request.IsAjaxRequest())
                {
                    return(PartialView(CurrentThemeViewPath + "/Group/UserList.cshtml", groupInfo));
                }
                break;

            case "Recommand":
                //推荐帖子
                toalcount           = bllTopic.GetRecommandCount(groupId);
                groupInfo.TopicList = new PagedList <YSWL.MALL.Model.SNS.GroupTopics>(
                    bllTopic.GetTopicListPageByGroup(groupId, startIndex, endIndex, true)
                    , page ?? 1, pagesize, toalcount);
                if (Request.IsAjaxRequest())
                {
                    return(PartialView(CurrentThemeViewPath + "/Group/TopicList.cshtml", groupInfo.TopicList));
                }
                break;

            default:
                //帖子
                toalcount           = bllTopic.GetRecordCount("  Status=1 and GroupID=" + groupId);
                groupInfo.TopicList = new PagedList <YSWL.MALL.Model.SNS.GroupTopics>(
                    bllTopic.GetTopicListPageByGroup(groupId, startIndex, endIndex, false)
                    , page ?? 1, pagesize, toalcount);
                ViewBag.page = (toalcount + pagesize - 1) / pagesize;
                if (Request.IsAjaxRequest())
                {
                    return(PartialView("_ReplyList", groupInfo));
                }
                break;
            }
            groupInfo.NewTopicList = bllTopic.GetNewTopListByGroup(groupId, 10);
            groupInfo.NewUserList  = bllGroupUser.GetNewUserListByGroup(groupId, 9);
            ViewBag.joined         = (currentUser != null && bllGroupUser.Exists(groupId, currentUser.UserID)) ? "ok" : "error";

            #region SEO 优化设置
            IPageSetting pageSetting = PageSetting.GetPageSetting("GroupList", ApplicationKeyType.SNS);
            pageSetting.Replace(
                new[] { PageSetting.RKEY_CNAME, null != groupInfo.Group?groupInfo.Group.GroupName:"" },        //小组名称
                new[] { PageSetting.RKEY_CTAG, null != groupInfo.Group?groupInfo.Group.Tags:"" },              //小组标签
                new[] { PageSetting.RKEY_CDES, null != groupInfo.Group?groupInfo.Group.GroupDescription:"" }); //小组描述
            ViewBag.Title       = pageSetting.Title;
            ViewBag.Keywords    = pageSetting.Keywords;
            ViewBag.Description = pageSetting.Description;
            #endregion

            return(View(groupInfo));
        }
Ejemplo n.º 3
0
        public JsonResult GetPageData(int page = 1)
        {
            JsonObject json = new JsonObject();

            YSWL.MALL.ViewModel.SNS.GroupInfo groupInfo      = new MALL.ViewModel.SNS.GroupInfo();
            YSWL.MALL.BLL.SNS.GroupTopics     groupTopicsBll = new GroupTopics();
            int pagesize = 10;
            //计算分页起始索引
            int startIndex = page > 1 ? (page - 1) * pagesize + 1 : 1;
            //计算分页结束索引
            int endIndex = page * pagesize;
            //总记录数
            int toalcount = 0;

            toalcount           = bllTopic.GetRecordCount("  Status=1 and GroupID=" + GroupId);
            groupInfo.TopicList = new PagedList <YSWL.MALL.Model.SNS.GroupTopics>(
                bllTopic.GetTopicListPageByGroup(GroupId, startIndex, endIndex, false)
                , page, pagesize, toalcount);
            if (groupInfo.TopicList != null && groupInfo.TopicList.Count > 0)//有话题
            {
                YSWL.MALL.Model.SNS.GroupTopics groupTopics;
                JsonObject        jsonObject;
                JsonObject        reply;
                HttpCookie        cookie;
                List <JsonObject> replyList  = new List <JsonObject>();
                List <JsonObject> resultList = new List <JsonObject>();
                foreach (YSWL.MALL.Model.SNS.GroupTopics item in groupInfo.TopicList)//遍历话题列表
                {
                    groupTopics = groupTopicsBll.GetModelByCache(item.TopicID);
                    jsonObject  = new JsonObject();
                    if (null != groupTopics)
                    {
                        if (null != CurrentUser)
                        {
                            cookie = Request.Cookies["topicFav_" + groupTopics.TopicID + CurrentUser.UserID];
                            if (null != cookie) //取消赞
                            {
                                jsonObject.Put("support", "support");
                            }
                            else
                            {
                                jsonObject.Put("support", "nosupport");
                            }
                        }
                        jsonObject.Put("uid", groupTopics.CreatedUserID);
                        jsonObject.Put("topicId", groupTopics.TopicID);
                        jsonObject.Put("nickName", groupTopics.CreatedNickName);
                        jsonObject.Put("createdDate", YSWL.MALL.Web.Components.DateTimeHelper.ConvertDateToTime(groupTopics.CreatedDate));
                        jsonObject.Put("description", Server.HtmlDecode(YSWL.MALL.ViewModel.ViewModelBase.ReplaceFace(groupTopics.Description)));
                        jsonObject.Put("imageUrl", YSWL.MALL.Web.Components.FileHelper.GeThumbImage(groupTopics.ImageUrl, "T180X120_"));
                        jsonObject.Put("ref", groupTopics.ImageUrl);
                        jsonObject.Put("favCount", groupTopics.FavCount);
                        List <YSWL.MALL.Model.SNS.GroupTopicReply> list = bllReply.GetTopicReplyByTopic(groupTopics.TopicID, startIndex, endIndex);
                        if (null != list && list.Count > 0)
                        {
                            foreach (YSWL.MALL.Model.SNS.GroupTopicReply topicReply in list)
                            {
                                reply = new JsonObject();
                                reply.Put("replynickName", topicReply.ReplyNickName);
                                reply.Put("replyContent", Server.HtmlDecode(YSWL.MALL.ViewModel.ViewModelBase.ReplaceFace(topicReply.Description)));
                                reply.Put("replyCount", list.Count);
                                replyList.Add(reply);
                            }
                            jsonObject.Put("replyList", replyList);
                        }
                    }
                    resultList.Add(jsonObject);
                }
                // return new Result(ResultStatus.Success,resultList);
                json.Put("status", "success");
                json.Put("result", resultList);
                return(Json(json));
            }
            return(null);
        }