Ejemplo n.º 1
0
        public static async Task<List<string>> GetMessage(long toEK, int sectionNo)
        {
            var config = BK.Configuration.BK_ConfigurationManager.GetConfig<UserBehaviorConfig>();
            int pageSize = Convert.ToInt32(config.GetMessageCount);
            int fromIndex = pageSize * sectionNo;

            if (sectionNo == 0)
            {
                return await GetContentFromRedis(toEK);
            }

            using (MessageRepository r = new MessageRepository())
            {
                var list = await r.GetEKCommentAsync(toEK,fromIndex, pageSize);
                if (list == null || list.Count == 0)
                    return null;
                List<string> ret = new List<string>();
                foreach (var l in list)
                {
                    double time = CommonLib.Util.CommonHelper.ToUnixTime(l.timestamp);
                    string from = l.from.ToString();
                    string message = from + ":" + time.ToString() + ":" + l.content;
                    ret.Add(message);
                }
                return ret;
            }
        }