Beispiel #1
0
        public static string BuildContent(List <NewsInfo> oList)
        {
            #if !DEBUG
            var oData = CacheController.GetListTronGoi(oList[0].fk_CategoryId);
            if (oData != null)
            {
                return(oData.ToString());
            }
            #endif

            int             numColum = 2;
            int             iRow     = (oList.Count % numColum != 0) ? ((int)oList.Count / numColum) : (oList.Count / numColum) - 1;
            StringBuilder[] sb       = new StringBuilder[iRow + 1];
            int             i        = 0;
            for (i = 0; i < iRow + 1; i++)
            {
                sb[i] = new StringBuilder();
            }

            i = 1;
            foreach (NewsInfo o in oList)
            {
                int Row = (i % numColum != 0) ? ((int)i / numColum) : (i / numColum) - 1;
                sb[Row].Append("<td width=\"50%\" class=\"td\" valign=\"top\">");
                sb[Row].AppendFormat("<div class=\"idtitle\" style=\"color:#09F;\">{0}</div>", o.s_Title);
                sb[Row].AppendFormat("<p>{0}</p>", o.s_Content);
                i++;
            }

            string s = "";
            for (i = 0; i < iRow + 1; i++)
            {
                s += "<tr>" + sb[i].ToString() + "</tr>";
            }
            #if !DEBUG
            CacheController.GetListTronGoi(oList[0].fk_CategoryId, s);
            #endif
            return(s);
        }