Ejemplo n.º 1
0
 private int SendComments()
 {
     if (txtcomment.Text.Trim() != "")
     {
         newcomment = new KLNewsComment();
         try
         {
             newcomment.Comment    = txtcomment.Text;
             newcomment.CreateDate = DateTime.Now;
             newcomment.Email      = txtEmail.Text;
             newcomment.Name       = txtFullName.Text;
             newcomment.UserID     = currentUser.UserId;
             newcomment.NewsID     = newsID;
             newcomment.Save();
             KLNotify notify = new KLNotify(); KLAuthor author = new KLAuthor(news.AuthorID);
             notify.AuthorID        = author.UserID;
             notify.UserName_Action = txtFullName.Text;
             notify.DateCreate      = DateTime.Now;
             notify.NotifyType      = "Comment";
             notify.Viewed          = false;
             News newsKL = new News(siteSettings.SiteId, news.NewsID);
             notify.Notify     = ResourceFile.GetResourceString("CustomResources", "NotifyComment") + newsKL.Title;
             notify.NotifyLink = SiteRoot + "/news-detail?newsID=" + news.NewsID;
             notify.Save();
         }
         catch (Exception ex)
         {
             log.Error(ex.Message);
         }
         return(newcomment.CommentID);
     }
     return(-1);
 }
Ejemplo n.º 2
0
        private void insertnotify(int userid, int newsid, string title)
        {
            KLNotify notify = new KLNotify();

            notify.AuthorID        = userid;
            notify.UserName_Action = currentUser.Name;
            notify.DateCreate      = DateTime.Now;
            notify.NotifyType      = "Comment";
            notify.Viewed          = false;
            notify.Notify          = ResourceFile.GetResourceString("NewsResources", "NotifyApproval") + title;
            notify.NotifyLink      = SiteRoot + "/news-detail?newsID=" + newsid;
            notify.Save();
        }
Ejemplo n.º 3
0
        protected void rptComments_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            TextBox       txtsubname    = (TextBox)e.Item.FindControl("txtsubname");
            TextBox       txtsubemail   = (TextBox)e.Item.FindControl("txtsubemail");
            TextBox       txtsubcomment = (TextBox)e.Item.FindControl("txtsubcomment");
            HiddenField   commentid     = (HiddenField)e.Item.FindControl("hdcommentid");
            KLNewsComment subcomment    = null;

            if (txtsubcomment.Text.Trim() != "")
            {
                subcomment = new KLNewsComment();
                try
                {
                    subcomment.Comment         = txtsubcomment.Text;
                    subcomment.CreateDate      = DateTime.Now;
                    subcomment.Email           = txtsubemail.Text;
                    subcomment.Name            = txtsubname.Text;
                    subcomment.UserID          = currentUser.UserId;
                    subcomment.NewsID          = newsID;
                    subcomment.CommentParentID = int.Parse(commentid.Value);
                    subcomment.Save();
                    KLNotify notify = new KLNotify();
                    KLAuthor author = new KLAuthor(news.AuthorID);
                    notify.AuthorID        = author.UserID;
                    notify.UserName_Action = txtsubname.Text;
                    notify.DateCreate      = DateTime.Now;
                    notify.NotifyType      = "Comment";
                    notify.Viewed          = false;
                    News newsKL = new News(siteSettings.SiteId, news.NewsID);
                    notify.Notify     = ResourceFile.GetResourceString("CustomResources", "NotifyComment") + newsKL.Title;
                    notify.NotifyLink = SiteRoot + "/news-detail?newsID=" + news.NewsID;
                    notify.Save();
                    divmessagecomment.InnerHtml = AlertSuccess();
                }
                catch (Exception ex)
                {
                    log.Error(ex.Message);
                }
            }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentType = "text/json";
            Encoding encoding = new UTF8Encoding();

            Response.ContentEncoding = encoding;
            try
            {
                LoadParams();
                if (method == "GetBooks")
                {
                    Response.Write(GetBooks());
                    return;
                }
                else if (method == "ComfirmPass")
                {
                    int      userid = Convert.ToInt32(postParams.Get("userid"));
                    string   pass   = postParams.Get("pass");
                    SiteUser user   = new SiteUser(siteSettings, userid);
                    bool     bol    = false;
                    if (pass == user.Password)
                    {
                        bol = true;
                    }
                    Response.Write(StringHelper.ToJsonString(new
                    {
                        success = bol,
                    })
                                   );
                    return;
                }
                else if (method == "GetNotify")
                {
                    int             userid = Convert.ToInt32(postParams.Get("userid"));
                    int             total  = 1;
                    List <KLNotify> lst    = KLNotify.GetPageByAuthorID(1, 8, out total, userid);
                    Response.Write(StringHelper.ToJsonString(new
                    {
                        success = true,
                        data    = lst.OrderByDescending(org => org.DateCreate)
                    }));
                    return;
                }
                else if (method == "ViewNotify")
                {
                    int      notifyid = Convert.ToInt32(postParams.Get("notifyid"));
                    KLNotify notify   = new KLNotify(notifyid);
                    notify.Viewed = true;
                    notify.Save();
                    Response.Write(StringHelper.ToJsonString(new
                    {
                        success = true,
                    }));
                    return;
                }
                else if (method != "GetBooks" &&
                         method != "ComfirmPass" &&
                         method != "GetNotify" &&
                         method != "ViewNotify")
                {
                    Response.Write(StringHelper.ToJsonString(new
                    {
                        success = false,
                        message = "No method found with the " + method
                    }));
                    return;
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                Response.Write(StringHelper.ToJsonString(new
                {
                    success = false,
                    message = "Failed to process from the server. Please refresh the page and try one more time."
                }));
            }
        }