Exemple #1
0
        public List <GraphicMessageExt> GetMyMessageList(string openId)
        {
            var dao      = new GraphicMessageDao(ConfigurationManager.AppSettings["mysqlConnStr"]);
            var messages = dao.GetListExt(filter: $" and g.openid='{openId}'", count: int.MaxValue, endId: int.MaxValue);

            messages.ForEach(msg => {
                msg.itemType = "graphic";
            });

            //messages.ForEach(msg =>
            //{
            //    if (!string.IsNullOrEmpty(msg.poster))
            //    {
            //        Bitmap bitmap = new Bitmap(ConfigurationManager.AppSettings["UploadFolderPath"] + msg.poster);
            //        msg.poster = Utils.ConvertBitmap2Base64(bitmap);
            //    }
            //});

            return(messages);
        }
Exemple #2
0
        public List <ClubItem> GetClubList(string openId, int count = 10, int endId = int.MaxValue, string filter = "")
        {
            List <ClubItem> results = new List <ClubItem>();

            var dao = new GraphicMessageDao(ConfigurationManager.AppSettings["mysqlConnStr"]);

            string nameFilter = "";

            if (!string.IsNullOrEmpty(filter))
            {
                nameFilter = $" and name like '%{filter}%' ";
            }

            var messages = dao.GetListExt(filter: $" and isTop=0 {nameFilter} ", count: count, endId: endId);

            if (messages.Count < count) //如果取出的数量不够,就从头再取,补足不够的数量
            {
                //简单起见,每次到头部的时候,就把置顶文章给带上
                var topMsgs = dao.GetTopExt(nameFilter);

                var compensateMsgs = dao.GetListExt(filter: $" and isTop=0 {nameFilter} ", count: count - messages.Count, endId: int.MaxValue);

                messages.AddRange(topMsgs);
                messages.AddRange(compensateMsgs);
            }

            if (messages != null)
            {
                messages.ForEach(msg =>
                {
                    List <string> pics = new List <string>();
                    if (!string.IsNullOrEmpty(msg.pic01))
                    {
                        pics.Add(msg.pic01);
                    }
                    if (!string.IsNullOrEmpty(msg.pic02))
                    {
                        pics.Add(msg.pic02);
                    }
                    if (!string.IsNullOrEmpty(msg.pic03))
                    {
                        pics.Add(msg.pic03);
                    }
                    if (!string.IsNullOrEmpty(msg.pic04))
                    {
                        pics.Add(msg.pic04);
                    }
                    if (!string.IsNullOrEmpty(msg.pic05))
                    {
                        pics.Add(msg.pic05);
                    }
                    if (!string.IsNullOrEmpty(msg.pic06))
                    {
                        pics.Add(msg.pic06);
                    }

                    List <string> audioes = new List <string>();
                    if (!string.IsNullOrEmpty(msg.audio01))
                    {
                        audioes.Add(msg.audio01);
                    }
                    if (!string.IsNullOrEmpty(msg.audio02))
                    {
                        audioes.Add(msg.audio02);
                    }
                    if (!string.IsNullOrEmpty(msg.audio03))
                    {
                        audioes.Add(msg.audio03);
                    }

                    results.Add(new ClubItem()
                    {
                        postId        = msg.id,
                        openId        = msg.openId,
                        author        = msg.author,
                        wechatUrl     = msg.wechatUrl,
                        authorHeadPic = msg.authorHeadPic,
                        name          = msg.name,
                        poster        = !string.IsNullOrEmpty(msg.poster)? msg.poster : msg.pic01,
                        pics          = pics,
                        audioes       = audioes,
                        itemType      = ClubItemType.Graphic,
                        text          = msg.text,
                        likeCount     = msg.likeCount,
                        commentCount  = msg.commentCount,
                        createdAt     = msg.createdAt
                    });
                });
            }

            //SQL里面已经有order by g.id desc,所以这里不用排序了
            //results = results.OrderByDescending(r => r.createdAt).ToList();


            int id = 0;

            results.ForEach(r => { r.id = ++id; });

            //如果传入了Follower的openId
            if (!string.IsNullOrEmpty(openId))
            {
                results.ForEach(r => {
                    var dao2        = new FollowDao(ConfigurationManager.AppSettings["mysqlConnStr"]);
                    bool isFollowed = dao2.GetFollowed(r.openId, openId);

                    r.followed = isFollowed;
                });
            }

            return(results);
        }
        public List <ClubItem> GetClubList()
        {
            List <ClubItem> results = new List <ClubItem>();

            var dao = new GraphicMessageDao(ConfigurationManager.AppSettings["mysqlConnStr"]);

            var messages = dao.GetListExt(count: 4, endId: int.MaxValue);

            messages.ForEach(msg =>
            {
                List <string> pics = new List <string>();
                if (!string.IsNullOrEmpty(msg.pic01))
                {
                    pics.Add(msg.pic01);
                }
                if (!string.IsNullOrEmpty(msg.pic02))
                {
                    pics.Add(msg.pic02);
                }
                if (!string.IsNullOrEmpty(msg.pic03))
                {
                    pics.Add(msg.pic03);
                }
                if (!string.IsNullOrEmpty(msg.pic04))
                {
                    pics.Add(msg.pic04);
                }
                if (!string.IsNullOrEmpty(msg.pic05))
                {
                    pics.Add(msg.pic05);
                }
                if (!string.IsNullOrEmpty(msg.pic06))
                {
                    pics.Add(msg.pic06);
                }

                List <string> audioes = new List <string>();
                if (!string.IsNullOrEmpty(msg.audio01))
                {
                    audioes.Add(msg.audio01);
                }
                if (!string.IsNullOrEmpty(msg.audio02))
                {
                    audioes.Add(msg.audio02);
                }
                if (!string.IsNullOrEmpty(msg.audio03))
                {
                    audioes.Add(msg.audio03);
                }

                results.Add(new ClubItem()
                {
                    postId        = msg.id,
                    openId        = msg.openId,
                    author        = msg.author,
                    authorHeadPic = msg.authorHeadPic,
                    name          = msg.name,
                    poster        = !string.IsNullOrEmpty(msg.poster) ? msg.poster : msg.pic01,
                    pics          = pics,
                    audioes       = audioes,
                    itemType      = ClubItemType.Graphic,
                    text          = msg.text,
                    likeCount     = msg.likeCount,
                    commentCount  = msg.commentCount,
                    createdAt     = msg.createdAt
                });
            });

            //SQL里面已经有order by g.id desc,所以这里不用排序了
            //results = results.OrderByDescending(r => r.createdAt).ToList();


            int id = 0;

            results.ForEach(r => { r.id = ++id; });

            return(results);
        }
        public List <ClubItem> GetFolloweePost(string followerOpenId)
        {
            logger.Info($"GetFolloweePost -> followerOpenId:{followerOpenId}");
            List <ClubItem> results = new List <ClubItem>();

            var followDao = new FollowDao(ConfigurationManager.AppSettings["mysqlConnStr"]);
            var followees = followDao.GetFolloweesList(followerOpenId);

            var           dao = new GraphicMessageDao(ConfigurationManager.AppSettings["mysqlConnStr"]);
            StringBuilder sb  = new StringBuilder();

            sb.Append(" and g.openid in (''");
            followees.ForEach(followeeOpenId =>
            {
                sb.Append($",'{followeeOpenId}'");
            });
            sb.Append(")");
            var messages = dao.GetListExt(sb.ToString(), count: int.MaxValue, endId: int.MaxValue);

            if (messages != null)
            {
                messages.ForEach(msg =>
                {
                    List <string> pics = new List <string>();
                    if (!string.IsNullOrEmpty(msg.pic01))
                    {
                        pics.Add(msg.pic01);
                    }
                    if (!string.IsNullOrEmpty(msg.pic02))
                    {
                        pics.Add(msg.pic02);
                    }
                    if (!string.IsNullOrEmpty(msg.pic03))
                    {
                        pics.Add(msg.pic03);
                    }
                    if (!string.IsNullOrEmpty(msg.pic04))
                    {
                        pics.Add(msg.pic04);
                    }
                    if (!string.IsNullOrEmpty(msg.pic05))
                    {
                        pics.Add(msg.pic05);
                    }
                    if (!string.IsNullOrEmpty(msg.pic06))
                    {
                        pics.Add(msg.pic06);
                    }

                    List <string> audioes = new List <string>();
                    if (!string.IsNullOrEmpty(msg.audio01))
                    {
                        audioes.Add(msg.audio01);
                    }
                    if (!string.IsNullOrEmpty(msg.audio02))
                    {
                        audioes.Add(msg.audio02);
                    }
                    if (!string.IsNullOrEmpty(msg.audio03))
                    {
                        audioes.Add(msg.audio03);
                    }

                    results.Add(new ClubItem()
                    {
                        postId        = msg.id,
                        openId        = msg.openId,
                        author        = msg.author,
                        authorHeadPic = msg.authorHeadPic,
                        name          = msg.name,
                        poster        = msg.poster,
                        pics          = pics,
                        audioes       = audioes,
                        itemType      = ClubItemType.Graphic,
                        text          = msg.text,
                        likeCount     = msg.likeCount,
                        commentCount  = msg.commentCount,
                        createdAt     = msg.createdAt
                    });
                });
            }

            results = results.OrderByDescending(r => r.createdAt).ToList();

            logger.Info($"GetFolloweePost -> return:{results.Count} items");
            return(results);
        }
        public List <PostsByDoctor> GetFolloweePostV2(string followerOpenId)
        {
            List <PostsByDoctor> result = new List <PostsByDoctor>();

            var followDao = new FollowDao(ConfigurationManager.AppSettings["mysqlConnStr"]);
            var userDao   = new UserDao(ConfigurationManager.AppSettings["mysqlConnStr"]);
            var dao       = new GraphicMessageDao(ConfigurationManager.AppSettings["mysqlConnStr"]);

            var followees = followDao.GetFolloweesList(followerOpenId);

            followees.ForEach(followeeOpenId =>
            {
                PostsByDoctor post = new PostsByDoctor();
                var author         = userDao.GetUser(followeeOpenId);
                post.author        = author;

                StringBuilder sb = new StringBuilder();
                sb.Append($" and g.openid='{followeeOpenId}' ");
                var messages = dao.GetListExt(sb.ToString(), count: 2, endId: int.MaxValue); //每个作者只取前两个作品

                var clubItems = new List <ClubItem>();
                if (messages != null)
                {
                    messages.ForEach(msg =>
                    {
                        List <string> pics = new List <string>();
                        if (!string.IsNullOrEmpty(msg.pic01))
                        {
                            pics.Add(msg.pic01);
                        }
                        if (!string.IsNullOrEmpty(msg.pic02))
                        {
                            pics.Add(msg.pic02);
                        }
                        if (!string.IsNullOrEmpty(msg.pic03))
                        {
                            pics.Add(msg.pic03);
                        }
                        if (!string.IsNullOrEmpty(msg.pic04))
                        {
                            pics.Add(msg.pic04);
                        }
                        if (!string.IsNullOrEmpty(msg.pic05))
                        {
                            pics.Add(msg.pic05);
                        }
                        if (!string.IsNullOrEmpty(msg.pic06))
                        {
                            pics.Add(msg.pic06);
                        }

                        List <string> audioes = new List <string>();
                        if (!string.IsNullOrEmpty(msg.audio01))
                        {
                            audioes.Add(msg.audio01);
                        }
                        if (!string.IsNullOrEmpty(msg.audio02))
                        {
                            audioes.Add(msg.audio02);
                        }
                        if (!string.IsNullOrEmpty(msg.audio03))
                        {
                            audioes.Add(msg.audio03);
                        }

                        clubItems.Add(new ClubItem()
                        {
                            postId        = msg.id,
                            openId        = msg.openId,
                            author        = msg.author,
                            authorHeadPic = msg.authorHeadPic,
                            name          = msg.name,
                            poster        = msg.poster,
                            pics          = pics,
                            audioes       = audioes,
                            itemType      = ClubItemType.Graphic,
                            text          = msg.text,
                            likeCount     = msg.likeCount,
                            commentCount  = msg.commentCount,
                            createdAt     = msg.createdAt
                        });
                    });
                }

                post.posts = clubItems;

                result.Add(post);
            });

            return(result);
        }