Exemplo n.º 1
0
        /// <summary>Envia um mail</summary>
        public static bool Send(MailMessage message)
        {
            try {
                if (message.From == null || message.From == "")
                {
                    message.From = Mailer.From;
                }

#if DEBUG_MAIL
                Log.log("----- SEND MAIL DEBUG ----------");
                Log.log("To: {0}", message.To);
                Log.log("From: {0}", message.From);
                Log.log("Bcc: {0}", message.Bcc);
                Log.log("Title: {0}", message.Subject);
                Log.log("Message: {0}", message.Body);
                Log.log("-------------------------------");
#endif

                Log.log("Sending mail message '{0}'...", message.Subject);
                SmtpMail.Send(message);
                Log.log("... Done!");
                return(true);
            } catch (System.Exception e) {
                ExceptionLog.log(e, false);
                return(false);
            }
        }
Exemplo n.º 2
0
        private void BindData()
        {
            m_bDataBound = true;

            Pager.PageSize = BoardSettings.PostsPerPage;

            if (topic == null)
            {
                Forum.Redirect(Pages.topics, "f={0}", PageForumID);
            }

            PagedDataSource pds = new PagedDataSource();

            pds.AllowPaging = true;
            pds.PageSize    = Pager.PageSize;

            using (DataTable dt0 = DB.post_list(PageTopicID, IsPostBack ? 0 : 1))
            {
                if (dt0 == null)
                {
                    ExceptionLog.log("dt0 é null", "NULL");
                }

                DataView dt = dt0.DefaultView;

                if (dt == null)
                {
                    ExceptionLog.log("dt é null", "NULL");
                }


                if (IsThreaded)
                {
                    dt.Sort = "Position";
                }
                else
                {
                    dt.Sort = "Posted";
                }

                Pager.Count    = dt.Count;
                pds.DataSource = dt;
                int nFindMessage = 0;

                try
                {
                    if (m_bIgnoreQueryString)
                    {
                    }
                    else if (Request.QueryString["p"] != null)
                    {
                        // show specific page (p is 1 based)
                        int tPage = Convert.ToInt32(Request.QueryString["p"]);
                        if (pds.PageCount >= tPage)
                        {
                            pds.CurrentPageIndex   = tPage - 1;
                            Pager.CurrentPageIndex = pds.CurrentPageIndex;
                        }
                    }
                    else if (Request.QueryString["m"] != null)
                    {
                        // Show this message
                        nFindMessage = int.Parse(Request.QueryString["m"]);
                    }
                    else if (Request.QueryString["find"] != null && Request.QueryString["find"].ToLower() == "unread")
                    {
                        // Find next unread
                        using (DataTable dtUnread = DB.message_findunread(PageTopicID, Mession.LastVisit))
                        {
                            foreach (DataRow row in dtUnread.Rows)
                            {
                                nFindMessage = (int)row["MessageID"];
                                break;
                            }
                        }
                    }
                }
                catch (Exception)
                {
                }

                if (nFindMessage > 0)
                {
                    CurrentMessage = nFindMessage;
                    // Find correct page for message
                    for (int foundRow = 0; foundRow < dt.Count; foundRow++)
                    {
                        if ((int)dt[foundRow]["MessageID"] == nFindMessage)
                        {
                            pds.CurrentPageIndex   = foundRow / pds.PageSize;
                            Pager.CurrentPageIndex = pds.CurrentPageIndex;
                            break;
                        }
                    }
                }
                else
                {
                    foreach (DataRow row in dt0.Rows)
                    {
                        CurrentMessage = (int)row["MessageID"];
                        break;
                    }
                }
            }

            pds.CurrentPageIndex = Pager.CurrentPageIndex;

            if (pds.CurrentPageIndex >= pds.PageCount)
            {
                pds.CurrentPageIndex = pds.PageCount - 1;
            }

            MessageList.DataSource = pds;

            if (topic["PollID"] != DBNull.Value)
            {
                Poll.Visible    = true;
                dtPoll          = DB.poll_stats(topic["PollID"]);
                Poll.DataSource = dtPoll;
            }

            DataBind();
        }