예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (!String.IsNullOrEmpty(Profile.AnonUserId))
            {
                unCCed.AnonUser au = new unCCed.AnonUser(Profile.AnonUserId);
                if (!String.IsNullOrEmpty(au.ID))
                    tb_email.Text = au.Email;
            }

            DataTable dt = unCCed.DAL.DbCommon.executeSql("SELECT p.UrlId, p.Title FROM dbo.Page p ORDER BY PageKey DESC");
            string html = String.Empty;
            foreach (DataRow dr in dt.Rows)
            {
                html += "<a href=\"" + dr["UrlId"].ToString() + "\">" + dr["Title"].ToString() + "</a><br/>";
            }
            lit_open.Text = html;

        }
        lbl_debug.Text = "AnonUserId: " + Profile.AnonUserId;
    }
예제 #2
0
        public List<AnonUser> GetUnccers()
        {
            List<AnonUser> list = new List<AnonUser>();

            if (_id > 0)
            {
                DataTable dt = DAL.AnonUserDb.GetAllForPage(_id);
                foreach (DataRow dr in dt.Rows)
                {
                    AnonUser au = new AnonUser();
                    au.Name = dr["Name"].ToString();
                    au.Email = dr["Email"].ToString();
                    au.ID = dr["AnonUserId"].ToString();
                    if (!dr.IsNull("DateLastComment"))
                        au.LastComment = Convert.ToDateTime(dr["DateLastComment"].ToString());
                    if (!dr.IsNull("DateLastViewed"))
                        au.LastViewed = Convert.ToDateTime(dr["DateLastViewed"].ToString());

                    list.Add(au);
                }
            }
            return list;
        }
예제 #3
0
    protected void btn_create_Click(object sender, EventArgs e)
    {
        string title = tb_title.Text.Trim();
        string pw = tb_pw.Text.Trim();
        string userId = Guid.Empty.ToString();
        string email = tb_email.Text.Trim();

        string urlId = unCCed.Utilities.GenerateRandomString(10);

        string eUserId = unCCed.AnonUser.getUserIdFromEmail(email);

        if (!String.IsNullOrEmpty(Profile.AnonUserId))
        {
            if (eUserId == Profile.AnonUserId)
            {
                unCCed.AnonUser au = new unCCed.AnonUser(Profile.AnonUserId);
                if (!String.IsNullOrEmpty(au.ID))
                {
                    if (au.Email.ToLower() != email.ToLower())
                    {
                        // update profile's email
                        au.Email = email;
                        au.Update();
                    }
                }
            }
            else
            {
                Profile.AnonUserId = eUserId;
            }
        }
        else
        {
            unCCed.AnonUser au = new unCCed.AnonUser();
            au.Email = email;
            if (au.Add())
            {
                Profile.AnonUserId = au.ID;
            }
        }

        int pageKey = unCCed.DAL.PageDb.AddViaEmail(title, urlId, email, pw);

        if (pageKey > 0)
        {
            string link = unCCed.Common.SiteRootUrl + urlId;
            string linkname = "unCCed.com/" + urlId;
            string pwtr = String.Empty;
            if (pw.Length > 0)
            {
                pwtr = "<tr><td>Password:</td><td>" + pw + "</td></tr>";
            }

            MailMessage m = new MailMessage("*****@*****.**", email);
            m.Subject = "Your new unCCed page link for " + title;
            m.Body = String.Format("<p>Thanks for using unCCed.com!</p>Here is the information about your new page.<table><tr><td>Link:</td><td><a href=\"{0}\">{1}</a></td></tr><tr><td>Title:</td><td>{2}</td></tr>{3}</table>", link, linkname, title, pwtr);
            m.IsBodyHtml = true;

            SmtpClient s = new SmtpClient();
            try
            {
                s.Send(m);
            }
            catch
            {
                //todo error handle
            }

            Response.Redirect("~/PageCofirm.aspx?u=" + urlId);
        }
    }