예제 #1
0
        /// <summary>
        /// 获取信友圈消息[首页]
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public FriMessageCollection GetMsgHome(ReqGetMsgHome req)
        {
            TnetReginfo          reginfo = HttpContext.Current.GetRegInfo();
            FriMessageCollection result  = new FriMessageCollection();
            var queryMsg = from msg in db.VpxinMessageSet
                           where msg.Localnodeid == req.Nodeid && msg.Createtime > req.StartTime
                           select new MessageDto
            {
                Commentnum  = msg.Commentnum,
                Nodeid      = msg.Msgnodeid,
                Localnodeid = msg.Localnodeid,
                Content     = msg.Content,
                Createtime  = msg.Createtime,
                Down        = msg.Down,
                Infoid      = msg.Infoid,
                Ispay       = msg.Ispay,
                Picurl      = msg.Picurl,
                Price       = msg.Price,
                Reward      = msg.Reward,
                Sound       = msg.Sound,
                Up          = msg.Up,
                Video       = msg.Video,
                IsDown      = msg.IsDown,
                IsUp        = msg.IsUp,
                Hisid       = msg.Hisid
            };

            result.Messages = queryMsg.OrderByDescending(a => a.Createtime).Skip(req.PageSize * (req.PageIndex - 1)).Take(req.PageSize).ToList();
            bool isResult = IsMessage(result.Messages);

            int[] infos        = result.Messages.Select(a => a.Infoid).ToArray();
            var   queryComment = from mu in db.TpxinMessageUesrSet
                                 join comment in db.TpxinCommentHisSet on new { mu.Typeid, mu.Infoid } equals new { Typeid = 1, Infoid = comment.Hisid }
            join msg in db.TpxinMessageSet on comment.Infoid equals msg.Infoid
            where mu.Nodeid == reginfo.Nodeid && msg.Createtime > req.StartTime && infos.Contains(msg.Infoid)
            orderby comment.Createtime ascending
            select new CommentDto
            {
                Content    = comment.Content,
                Createtime = comment.Createtime,
                Hisid      = comment.Hisid,
                Infoid     = comment.Infoid,
                Nodeid     = comment.Nodeid,
                Phisid     = comment.Phisid,
                Pnodeid    = comment.Pnodeid
            };

            result.Comments = queryComment.ToList();
            return(result);
        }
예제 #2
0
        /// <summary>
        /// 获取信友圈-根据用户查询
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public FriMessageCollection GetMsg(ReqGetMsg req)
        {
            FriMessageCollection result  = new FriMessageCollection();
            TnetReginfo          regInfo = db.TnetReginfoSet.Find(req.Snodeid);

            if (regInfo == null)
            {
                Alert("用户不存在");
                return(null);
            }
            //当前用户是否是查看用户好友
            List <TchatFriend> friList = db.TchatFriendSet.Where(c => c.Friendstatus == 1 && (c.Mynodeid == req.Nodeid || c.Friendnodeid == req.Nodeid)).ToList();
            //查看用户是达人时不是好友也可以查看他的朋友圈
            var user = db.TnetReginfoSet.Where(c => c.Nodeid == req.Snodeid).FirstOrDefault();

            if ((user?.Isenterprise != 3 && user?.Isenterprise != 4))
            {
                if (!(friList.Select(a => a.Mynodeid).Contains(req.Snodeid) || friList.Select(a => a.Friendnodeid).Contains(req.Snodeid)))
                {
                    Alert("请添加好友再查看该用户信友圈");
                    return(null);
                }
            }

            var query = from msg in db.TpxinMessageSet
                        join tp in db.TpxinPayhisSet.Where(a => a.Nodeid == req.Nodeid) on msg.Infoid equals tp.Infoid into tp_join
                        from tp in tp_join.DefaultIfEmpty()
                        join tp2 in db.TpxinPraiseSet.Where(a => a.Fromnodeid == req.Nodeid) on msg.Infoid equals tp2.Infoid into tp2_join
                        from tp2 in tp2_join.DefaultIfEmpty()
                        where msg.Nodeid == req.Snodeid && msg.Status == 1
                        select new MessageDto
            {
                Commentnum  = msg.Commentnum,
                Createtime  = msg.Createtime,
                Down        = msg.Down,
                Infoid      = msg.Infoid,
                Up          = msg.Up,
                Nodeid      = msg.Nodeid,
                Localnodeid = req.Nodeid,
                Ispay       = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? 1 : 0,
                IsUp        = (tp2.Fromnodeid == req.Nodeid && tp2.Tonodeid == msg.Nodeid && tp2.Status == 1) ? 1 : 0,
                IsDown      = (tp2.Fromnodeid == req.Nodeid && tp2.Tonodeid == msg.Nodeid && tp2.Status == -1) ? 1 : 0,
                Reward      = tp2 == null ? 0 : tp2.Reward,
                Price       = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? 0 : msg.Price,
                Content     = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? msg.Content : (msg.Content.Substring(0, 5) + "..."),
                Video       = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? msg.Video : "",
                Sound       = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? msg.Sound : "",
                Picurl      = (msg.Nodeid == req.Nodeid || msg.Price == 0 || (tp != null && tp.Hisid > 0)) ? msg.Picurl : ""
            };


            result.Messages = query.OrderByDescending(a => a.Createtime).Skip(req.PageSize * (req.PageIndex - 1)).Take(req.PageSize).ToList();//进行分页
            int[] infos         = result.Messages.Select(a => a.Infoid).ToArray();
            int[] mynodeids     = friList.Select(a => a.Mynodeid).ToArray();
            int[] Friendnodeids = friList.Select(a => a.Friendnodeid).ToArray();
            var   queryComment  = from comment in db.TpxinCommentHisSet
                                  join msg in db.TpxinMessageSet on comment.Infoid equals msg.Infoid
                                  where infos.Contains(msg.Infoid) && (mynodeids.Contains(comment.Nodeid) || Friendnodeids.Contains(comment.Nodeid))
                                  orderby comment.Createtime ascending
                                  select new CommentDto
            {
                Content    = comment.Content,
                Createtime = comment.Createtime,
                Hisid      = comment.Hisid,
                Infoid     = comment.Infoid,
                Nodeid     = comment.Nodeid,
                Phisid     = comment.Phisid,
                Pnodeid    = comment.Pnodeid
            };

            result.Comments = queryComment.ToList();
            return(result);
        }