コード例 #1
0
        public static string FormatTopicInfo(object messageId, object topicId, object userId, object topicSubject, object creationDate, int?msgCount, object msgBody)
        {
            StringBuilder retval = new StringBuilder();

            string messageUrl  = Various.GetTopicURL(topicId, topicSubject);
            string queryString = (messageUrl.IndexOf("?") > -1) ? "&" : "?";

            //claculate link to last page
            if (!msgCount.HasValue)
            {
                msgCount = 0;
            }
            int pageCount = (int)Math.Ceiling(Convert.ToDouble(msgCount) / Settings.PageSize);

            if (pageCount > 1)
            {
                messageUrl += queryString + "page=" + (pageCount - 1);
            }

            messageUrl += "#post" + messageId;

            retval.Append("<a href=\"");
            retval.Append(messageUrl);
            retval.Append("\" title=\"");
            retval.Append(Formatting.StripBBCode(msgBody.ToString().Replace("\"", "")));
            retval.Append("\">");

            retval.Append(topicSubject.ToString().Left(20));

            retval.Append("...</a>");

            //retval.Append(creationDate.ToString("ddd, d MMM, yy, "));
            if (creationDate != null && !(creationDate is DBNull))
            {
                DateTime dtCreationDate = Convert.ToDateTime(creationDate);
                retval.Append("<div>" + ForumPage.ToAgoString(dtCreationDate) + "</div>");
            }

            return(retval.ToString());
        }
コード例 #2
0
        public static string FormatMessageInfo(object messageId, object topicId, object userId, object userName, object firstName, object lastName, object topicSubject, object creationDate, int?msgCount, object msgBody)
        {
            if (msgBody == null || msgBody is DBNull)             //msgbody is null - probably cause messageId is wrong, probably cause LastMsgID is wrong
            {
                int?maxmsgid = RecalculateLastMessageID(Convert.ToInt32(topicId));
                if (maxmsgid.HasValue)
                {
                    return(GetMsgInfoByID(maxmsgid.Value, Utils.DB.CreateCommand()));
                }
            }

            StringBuilder retval = new StringBuilder();

            string uname;

            if (userId != null && !(userId is DBNull) && Convert.ToInt32(userId) != 0)
            {
                uname = User.GetUserDisplayName(userName, firstName, lastName);
            }
            else
            {
                uname = Resources.various.Guest;
            }

            string messageUrl  = Various.GetTopicURL(topicId, topicSubject);
            string queryString = (messageUrl.IndexOf("?") > -1) ? "&amp;" : "?";

            //claculate link to last page
            if (!msgCount.HasValue)
            {
                msgCount = 0;
            }
            int pageCount = (int)Math.Ceiling(Convert.ToDouble(msgCount) / Settings.PageSize);

            if (pageCount > 1)
            {
                messageUrl += queryString + "page=" + (pageCount - 1);
            }

            messageUrl += "#post" + messageId;

            retval.Append("<div class='gray2'>");
            //retval.Append(creationDate.ToString("ddd, d MMM, yy, "));
            if (creationDate != null && !(creationDate is DBNull))
            {
                DateTime dtCreationDate = Convert.ToDateTime(creationDate);
                retval.Append(ForumPage.ToAgoString(dtCreationDate));
            }
            retval.Append("<br>");

            retval.Append(Resources.various.From);
            retval.Append(" <a href=\"");
            retval.Append(messageUrl);
            retval.Append("\" title=\"");
            retval.Append(Formatting.StripBBCode(msgBody.ToString().Replace("\"", "")));
            retval.Append("\">");
            retval.Append(uname);
            retval.Append("</a>");

            retval.Append("</div>");

            return(retval.ToString());
        }