コード例 #1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (!cbxDelete.Checked)
        {
            if (bNew)
            {
                dtDate = DateTime.Now;
                int iBlogNum = DataLayer.GetBlogCountDeleted();
                DataLayer.AddBlog(tbxTitle.Text, rteBody.Text.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&amp;", "&"), dtDate);

                try
                {
                    Yedda.Twitter t = new Yedda.Twitter();
                    WebRequest    wrGETURL;
                    wrGETURL = WebRequest.Create("http://tinyurl.com/api-create.php?url=http://www.fordscleaning.com/Blog.aspx?blog=" + iBlogNum.ToString());
                    Stream objStream;
                    objStream = wrGETURL.GetResponse().GetResponseStream();
                    StreamReader objReader = new StreamReader(objStream);
                    string       sURL      = objReader.ReadToEnd();

                    t.Update("WALTatRNX", "robinwalt98", "New Blog Post: " + tbxTitle.Text + " " + sURL, Yedda.Twitter.OutputFormatType.XML);
                }
                catch
                {
                }
                Response.Redirect("http://www.fordscleaning.com/Blog.aspx?blog=" + Convert.ToString(DataLayer.GetBlogCountDeleted() - 1));
            }
            else
            {
                DataLayer.UpdateBlog(iBlogID, tbxTitle.Text, rteBody.Text.Replace("&lt;", "<").Replace("&gt;", ">").Replace("&amp;", "&"));
                Response.Redirect("http://www.fordscleaning.com/Blog.aspx?blog=" + iBlogID.ToString());
            }
        }
        else
        {
            DataLayer.DeleteBlog(iBlogID);
            Response.Redirect("http://www.fordscleaning.com/FordsBlog.aspx");
        }
    }
コード例 #2
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (lbxBlogs.SelectedIndex == -1)
        {
            DataLayer dl         = new DataLayer();
            DateTime  dtPostTime = DateTime.Now;
            dl.AddBlog(User.Identity.Name, dtPostTime, tbxTitle.Text, rteBody.Value, ddlAccessLevel.SelectedValue);
            SqlCommand sc = new SqlCommand("SELECT BlogID FROM rnxBlogs WHERE Title=@Title AND Date=@Date");
            sc.Parameters.Add(new SqlParameter("Title", tbxTitle.Text));
            sc.Parameters.Add(new SqlParameter("Date", dtPostTime));
            DataSet ds = dl.CustomQuery(sc);

            try
            {
                WebRequest wrGETURL;
                wrGETURL = WebRequest.Create("http://tinyurl.com/api-create.php?url=http://www.ReferralNetworX.com/Blog.aspx?bid=" + ds.Tables[0].Rows[0].ItemArray[0].ToString());
                Stream objStream;
                objStream = wrGETURL.GetResponse().GetResponseStream();
                StreamReader objReader = new StreamReader(objStream);
                string       sURL      = objReader.ReadToEnd();

                Yedda.Twitter t = new Yedda.Twitter();
                t.Update("ReferralNetworX", "1million!", "New RNX Blog: " + tbxTitle.Text + " " + sURL, Yedda.Twitter.OutputFormatType.XML);
                t.Update("Chevex", "Ch3vyF0rd!", "New RNX Blog: " + tbxTitle.Text + " " + sURL, Yedda.Twitter.OutputFormatType.XML);
                t.Update("WALTatRNX", "robinwalt98", "New RNX Blog: " + tbxTitle.Text + " " + sURL, Yedda.Twitter.OutputFormatType.XML);
            }
            catch
            {
            }

            SmtpClient  smtp = new SmtpClient("localhost");
            MailMessage mm;
            mm            = new MailMessage();
            mm.IsBodyHtml = true;
            mm.To.Add("*****@*****.**");
            mm.To.Add("*****@*****.**");
            mm.From    = new MailAddress("*****@*****.**");
            mm.Subject = "Someone posted a blog.";
            mm.Body    = dl.GetFullMemberNameBy_Email(User.Identity.Name) + " posted a blog titled: " + tbxTitle.Text;
            mm.Body   += "<br /><a href=\"http://www.referralnetworx.com/Blog.aspx?bid=" + ds.Tables[0].Rows[0].ItemArray[0].ToString() + "\">Click to view</a>";
            mm.Body   += "<br /><br />The blog is below:<br /><br />" + rteBody.Value;
            smtp.Send(mm);

            Session["resultColor"]     = "#007700";
            Session["resultTitle"]     = "Blog Added";
            Session["resultMessage"]   = "Blog Added Successfuly";
            Session["resultReturnURL"] = "Blog.aspx?bid=" + ds.Tables[0].Rows[0].ItemArray[0].ToString();
            Response.Redirect("Result.aspx");
        }
        else
        {
            if (cbxDeleteBlog.Checked)
            {
                DataLayer dl = new DataLayer();
                dl.DeleteBlog(Convert.ToInt32(lbxBlogs.SelectedValue));
                Session["resultColor"]     = "#007700";
                Session["resultTitle"]     = "Blog Deleted";
                Session["resultMessage"]   = "Blog Deleted Successfuly";
                Session["resultReturnURL"] = "ManageBlogs.aspx";
                Response.Redirect("Result.aspx");
            }
            else
            {
                DataLayer dl = new DataLayer();
                dl.UpdateBlog(Convert.ToInt32(lbxBlogs.SelectedValue), tbxTitle.Text, rteBody.Value, ddlAccessLevel.SelectedValue);
                Session["resultColor"]     = "#007700";
                Session["resultTitle"]     = "Blog Updated";
                Session["resultMessage"]   = "Blog Updated Successfuly";
                Session["resultReturnURL"] = "ManageBlogs.aspx";
                Response.Redirect("Result.aspx");
            }
        }
    }
コード例 #3
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (lbxBlogs.SelectedIndex == -1)
        {
            DataLayer dl = new DataLayer();
            DateTime dtPostTime = DateTime.Now;
            dl.AddBlog(User.Identity.Name, dtPostTime, tbxTitle.Text, rteBody.Value, ddlAccessLevel.SelectedValue);
            SqlCommand sc = new SqlCommand("SELECT BlogID FROM rnxBlogs WHERE Title=@Title AND Date=@Date");
            sc.Parameters.Add(new SqlParameter("Title", tbxTitle.Text));
            sc.Parameters.Add(new SqlParameter("Date", dtPostTime));
            DataSet ds = dl.CustomQuery(sc);

            try
            {
                WebRequest wrGETURL;
                wrGETURL = WebRequest.Create("http://tinyurl.com/api-create.php?url=http://www.ReferralNetworX.com/Blog.aspx?bid=" + ds.Tables[0].Rows[0].ItemArray[0].ToString());
                Stream objStream;
                objStream = wrGETURL.GetResponse().GetResponseStream();
                StreamReader objReader = new StreamReader(objStream);
                string sURL = objReader.ReadToEnd();

                Yedda.Twitter t = new Yedda.Twitter();
                t.Update("ReferralNetworX", "1million!", "New RNX Blog: " + tbxTitle.Text + " " + sURL, Yedda.Twitter.OutputFormatType.XML);
                t.Update("Chevex", "Ch3vyF0rd!", "New RNX Blog: " + tbxTitle.Text + " " + sURL, Yedda.Twitter.OutputFormatType.XML);
                t.Update("WALTatRNX", "robinwalt98", "New RNX Blog: " + tbxTitle.Text + " " + sURL, Yedda.Twitter.OutputFormatType.XML);
            }
            catch
            {

            }

            SmtpClient smtp = new SmtpClient("localhost");
            MailMessage mm;
            mm = new MailMessage();
            mm.IsBodyHtml = true;
            mm.To.Add("*****@*****.**");
            mm.To.Add("*****@*****.**");
            mm.From = new MailAddress("*****@*****.**");
            mm.Subject = "Someone posted a blog.";
            mm.Body = dl.GetFullMemberNameBy_Email(User.Identity.Name) + " posted a blog titled: " + tbxTitle.Text;
            mm.Body += "<br /><a href=\"http://www.referralnetworx.com/Blog.aspx?bid=" + ds.Tables[0].Rows[0].ItemArray[0].ToString() + "\">Click to view</a>";
            mm.Body += "<br /><br />The blog is below:<br /><br />" + rteBody.Value;
            smtp.Send(mm);

            Session["resultColor"] = "#007700";
            Session["resultTitle"] = "Blog Added";
            Session["resultMessage"] = "Blog Added Successfuly";
            Session["resultReturnURL"] = "Blog.aspx?bid=" + ds.Tables[0].Rows[0].ItemArray[0].ToString();
            Response.Redirect("Result.aspx");
        }
        else
        {
            if (cbxDeleteBlog.Checked)
            {
                DataLayer dl = new DataLayer();
                dl.DeleteBlog(Convert.ToInt32(lbxBlogs.SelectedValue));
                Session["resultColor"] = "#007700";
                Session["resultTitle"] = "Blog Deleted";
                Session["resultMessage"] = "Blog Deleted Successfuly";
                Session["resultReturnURL"] = "ManageBlogs.aspx";
                Response.Redirect("Result.aspx");
            }
            else
            {
                DataLayer dl = new DataLayer();
                dl.UpdateBlog(Convert.ToInt32(lbxBlogs.SelectedValue), tbxTitle.Text, rteBody.Value, ddlAccessLevel.SelectedValue);
                Session["resultColor"] = "#007700";
                Session["resultTitle"] = "Blog Updated";
                Session["resultMessage"] = "Blog Updated Successfuly";
                Session["resultReturnURL"] = "ManageBlogs.aspx";
                Response.Redirect("Result.aspx");
            }
        }
    }