예제 #1
0
        public CommentsDataSource()
        {
            this.DataLibrary = cte.lib;
            OrderBy          = "CommentId Desc";

            cMgr = new CommentsManager();
        }
예제 #2
0
        public IHttpActionResult GetComments(long Id)
        {
            CommentsManager comMngr = new CommentsManager(db);

            var comments = comMngr.FindComments(Id);

            return(Json(comments));
        }
예제 #3
0
 public ReviewPageModel(
     ReviewManager manager,
     BlobCodeFileRepository codeFileRepository,
     CommentsManager commentsManager)
 {
     _manager            = manager;
     _codeFileRepository = codeFileRepository;
     _commentsManager    = commentsManager;
 }
        public GroupCommentsDataSource()
        {
            this.DataLibrary = cte.lib;
            this.RelateTo    = "ID";
            this.TableName   = cte.CommentsTable;
            OrderBy          = "CommentId Desc";

            cMgr = new CommentsManager();

            this.Top = "120";
        }
예제 #5
0
 public ConversationModel(
     IConfiguration configuration,
     BlobCodeFileRepository codeFileRepository,
     CommentsManager commentsManager,
     ReviewManager reviewManager)
 {
     _codeFileRepository = codeFileRepository;
     _commentsManager    = commentsManager;
     _reviewManager      = reviewManager;
     Endpoint            = configuration.GetValue <string>(ENDPOINT_SETTING);
 }
예제 #6
0
        public int RemoveCommentLike(int userId, int commentId)
        {
            using (var db = _paintStoreContext)
            {
                var likeId = db.CommentLikes.First(x => x.CommentId == commentId && x.UserId == userId).Id;

                CommentsManager.CommentLikesCountMinus(db, db.CommentLikes.First(x => x.Id == likeId).CommentId);
                db.CommentLikes.Remove(db.CommentLikes.First(x => x.Id == likeId));
                db.SaveChanges();
                return(likeId);
            }
        }
        private static void ProcessDocumentationComments(SyntaxNodeAnalysisContext context, Location declarationLocation, string declarationName, int threshold)
        {
            var docummentation = CommentsManager.ExtractDocumentationComment(context.Node);

            if (docummentation != null)
            {
                var numberOfLines = RegexManager.NumberOfLines(docummentation.Content.ToFullString());
                if (numberOfLines > threshold)
                {
                    DiagnosticsManager.CreateCommentsTooLongDiagnostic(context, declarationLocation, Rule, declarationName, threshold);
                }
            }
        }
예제 #8
0
 public ReviewPageModel(
     ReviewManager manager,
     BlobCodeFileRepository codeFileRepository,
     CommentsManager commentsManager,
     NotificationManager notificationManager,
     UserPreferenceCache preferenceCache)
 {
     _manager             = manager;
     _codeFileRepository  = codeFileRepository;
     _commentsManager     = commentsManager;
     _notificationManager = notificationManager;
     _preferenceCache     = preferenceCache;
 }
예제 #9
0
        private void AnalyzedInterfaceDeclaration(SyntaxNodeAnalysisContext context)
        {
            if (context.IsGeneratedCode())
            {
                return;
            }

            var declaration = Cast <InterfaceDeclarationSyntax>(context.Node);

            if (!CommentsManager.HasValidSummaryComments(context.Node))
            {
                DiagnosticsManager.CreateCommentsDiagnostic(context, declaration.Identifier.Text, declaration.Identifier.GetLocation(), Rule);
            }
        }
예제 #10
0
 public CommentLikes AddCommentLike(CommentLikes like)
 {
     using (var db = _paintStoreContext)
     {
         if ((db.CommentLikes.Any(x => x.CommentId == like.CommentId && x.UserId == like.UserId)))
         {
             throw new NegotiatedContentResultException();
         }
         CommentsManager.CommentLikesCountPlus(db, like.CommentId);
         db.CommentLikes.Add(like);
         db.SaveChanges();
         return(like);
     }
 }
예제 #11
0
        private void AnalyzedClassDeclaration(SyntaxNodeAnalysisContext context)
        {
            if (context.IsGeneratedCode())
            {
                return;
            }

            var declaration = Cast <ClassDeclarationSyntax>(context.Node);

            if (IsExternallyVisibleComments(declaration.Modifiers) && !CommentsManager.HasValidSummaryComments(context.Node))
            {
                DiagnosticsManager.CreateCommentsDiagnostic(context, declaration.Identifier.Text, declaration.Identifier.GetLocation(), Rule);
            }
        }
예제 #12
0
    public string GetCommentsStatistics()
    {
        var manager = new CommentsManager(this);

        var query  = manager.GetComments(SubjectId, PageName).OrderByDescending(c => c.CreatedDate).ToList();
        int amount = query.Count;

        if (amount > 0)
        {
            return("Comentários (" + amount + "), último por " + query.First().UserName);
        }
        else
        {
            return("Seja o primeiro a comentar!");
        }
    }
예제 #13
0
        public void IncorrectCommentFormatURI()
        {
            // Get the recent media of the auth user
            var AuthUserMedia = UserManager.GetRecentMedia();

            Assert.IsNotNull(AuthUserMedia);

            // Post a comment to the most recent media
            IMedia recentMedia = AuthUserMedia.First();

            // Post an incorrect Comment
            CommentsManager.PostCommentToMedia(recentMedia.Id, "http://www.google.es http://www.github.com");

            // Then CommentFormatException is rised with a message saying that you cannot
            // add more than one URI to de comment
        }
예제 #14
0
        public void IncorrectCommentFormatCapitalLetters()
        {
            // Get the recent media of the auth user
            var AuthUserMedia = UserManager.GetRecentMedia();

            Assert.IsNotNull(AuthUserMedia);

            // Post a comment to the most recent media
            IMedia recentMedia = AuthUserMedia.First();

            // Post an incorrect Comment
            CommentsManager.PostCommentToMedia(recentMedia.Id, "THIS COMMENT IS NOT WELL FORMATED.");

            // Then CommentFormatException is rised with a message saying
            // that all letters can't be capital case
        }
예제 #15
0
        public void IncorrectCommentFormatHashtag()
        {
            // Get the recent media of the auth user
            var AuthUserMedia = UserManager.GetRecentMedia();

            Assert.IsNotNull(AuthUserMedia);

            // Post a comment to the most recent media
            IMedia recentMedia = AuthUserMedia.First();

            // Post an incorrect Comment
            CommentsManager.PostCommentToMedia(recentMedia.Id, "#love #sex #american #express #morehashtag");

            // Then CommentFormatException is rised with a message saying that you cannot
            // add more than four hashtags to de comment
        }
예제 #16
0
        public IHttpActionResult AddComment(AddCommentModel comment)
        {
            if (ModelState.IsValid)
            {
                CommentsManager comMngr = new CommentsManager(db);

                var userId = RequestContext.Principal.Identity.GetUserId();
                var result = comMngr.AddUserComment(comment, userId);

                var comments = comMngr.FindComments(comment.TranId);

                return(Json(comments));
            }

            return(Json(false));
        }
예제 #17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //显示文章
            Article art  = new Article();
            string  aids = Request.QueryString["aid"].ToString();
            int     aid  = Convert.ToInt32(aids);//文章id
            art          = ArticleManager.GetArticleById(aid);
            Title.Text   = art.NTitle;
            Author.Text  = "作者: " + art.Author.Name + " 发表时间: " + art.NDate;
            Content.Text = art.NContent;

            //显示评论
            cm = new List <comments>();
            cm = CommentsManager.GetCommentByAid(aid);
        }
    }
        private void AnalyzedMethodDeclaration(SyntaxNodeAnalysisContext context)
        {
            if (context.IsAutomaticallyGeneratedCode())
            {
                return;
            }

            var declaration = Cast <MethodDeclarationSyntax>(context.Node);

            // if this method is within an interface then we do not need to process with access qualifier check
            var interfaceDeclaration = Cast <InterfaceDeclarationSyntax>(declaration.Parent);

            if (((interfaceDeclaration == null && IsExternallyVisibleComments(declaration.Modifiers)) || interfaceDeclaration != null) &&
                !CommentsManager.HasValidSummaryComments(context.Node))
            {
                DiagnosticsManager.CreateCommentsDiagnostic(context, declaration.Identifier.Text, declaration.Identifier.GetLocation(), Rule);
            }
        }
예제 #19
0
 //评论
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (TextBox1.Text == "" || TextBox2.Text == "")
     {
         Response.Write("<script>alert('标题/内容不能为空,请重新输入.');</script>");
     }
     else
     {
         if (CommentsManager.SetCommentByAid(TextBox1.Text, TextBox2.Text, Convert.ToInt32(Request.QueryString["aid"])))
         {
             string Now_User_Name = Now_User.now_user == ""?"游客":Now_User.now_user;
             Response.Write("<script>alert('您好," + Now_User_Name + ",您已评论成功!');window.location.href='Article_Page.aspx?aid=" + Request.QueryString["aid"].ToString() + "'</script>");
         }
         else
         {
             Response.Write("<script>alert('评论失败.');</script>");
         }
     }
 }
예제 #20
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (sigma.Count == 0)
        {
            Response.Write("<script>alert('请去评论..');</script>");
            return;
        }
        int Cid = sigma[DropDownList1.SelectedIndex].CId;//待删除评论Cid

        if (CommentsManager.DelCommentByCid(Cid))
        {
            Response.Write("<script>alert('删除成功.');window.location.href='Comments_Control.aspx';</script>");
        }
        else
        {
            //删除失败
            Response.Write("<script>alert('删除失败..');</script>");
        }
    }
예제 #21
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     if (DropDownList1.Items.Count > 0)                    //你没有评论过干嘛点修改评论
     {
         int cid = sigma[DropDownList1.SelectedIndex].CId; //待修改评论id
         if (CommentsManager.UpdateCommentByCid(TextBox1.Text, TextBox2.Text, cid))
         {
             //修改成功
             Response.Write("<script>alert('修改成功.');window.location.href='Comments_Control.aspx';</script>");
         }
         else
         {
             //修改失败
             Response.Write("<script>alert('修改失败.');</script>");
         }
     }
     else
     {
         Response.Write("<script>alert('你还没有评论过呢,快去写几篇吧老师.');</script>");
     }
 }
예제 #22
0
        public ActionResult Guest(Comment comment)
        {
            CommentsManager commentsManager = new CommentsManager();

            ViewBag.Comments = commentsManager.GetData();

            //add new comment
            if (Request.HttpMethod == "POST")
            {
                if (ModelState.IsValid)
                {
                    comment.CommentDate = DateTime.Now;
                    commentsManager.AddItem(comment);
                    ViewBag.Comments = commentsManager.GetData();
                    return(View());
                }
                else
                {
                    return(View());
                }
            }
            return(View());
        }
예제 #23
0
        public void DeleteComment()
        {
            try
            {
                // Get the recent media of the auth user
                var AuthUserMedia = UserManager.GetRecentMedia();
                Assert.IsNotNull(AuthUserMedia);

                // Post a comment to the most recent media
                IMedia recentMedia = AuthUserMedia.First();

                // Comments from this media
                List <IComment> prevComments = CommentsManager.GetCommentsFromMedia(recentMedia.Id);

                Assert.IsNotNull(prevComments);

                // Delete the comment made in the previous test
                CommentsManager.DeleteComment(recentMedia.Id, prevComments.Single(c => c.Text.Contains("Making some tests.")).Id);

                // Get the comements again
                List <IComment> currentComments = CommentsManager.GetCommentsFromMedia(recentMedia.Id);

                // Check that 1 comment has been deleted
                Assert.AreEqual(prevComments.Count() - 1, currentComments.Count());

                // Check if new comment doesn't exist now
                Assert.IsFalse(currentComments.Any(c => c.Text.Contains("Making some tests.")));
            }
            catch (Exceptions.CommentFormatException e)
            {
                Assert.Fail("Incorrect comment error." + e.ToString());
            }
            catch (Exceptions.InstagramAPICallException e)
            {
                Assert.Fail("Instagram API call error." + e.ToString());
            }
        }
예제 #24
0
        public void PostComment()
        {
            try
            {
                // Get the recent media of the auth user
                var AuthUserMedia = UserManager.GetRecentMedia();
                Assert.IsNotNull(AuthUserMedia);

                // Post a comment to the most recent media
                IMedia recentMedia = AuthUserMedia.First();

                // Comments from this media
                List <IComment> prevComments = CommentsManager.GetCommentsFromMedia(recentMedia.Id);

                Assert.IsNotNull(prevComments);

                // Post the new comment
                CommentsManager.PostCommentToMedia(recentMedia.Id, "Making some tests.");

                // Get the comements again
                List <IComment> currentComments = CommentsManager.GetCommentsFromMedia(recentMedia.Id);

                // Check that 1 comment has been added
                Assert.AreEqual(prevComments.Count() + 1, currentComments.Count());

                // Check if new comment has been added correctly
                Assert.IsTrue(currentComments.Any(c => c.Text.Contains("Making some tests.")));
            }
            catch (Exceptions.CommentFormatException e)
            {
                Assert.Fail("Incorrect comment error." + e.ToString());
            }
            catch (Exceptions.InstagramAPICallException e)
            {
                Assert.Fail("Instagram API call error." + e.ToString());
            }
        }
예제 #25
0
        public override void DataBind()
        {
            dataSrc = this.Parent as CommentsDataSource;

            if (!_bound)
            {
                _bound = true;

                CommentsManager cMgr = new CommentsManager();

                Comments.Comments_Tables_View table = cMgr.GetTableDetails(TableName);
                if (table == null)
                {
                    CommentsSetup cs = new CommentsSetup();
                    if (MembersOnly)
                    {
                        cs.CreateCommentsTableWithMembers(TableName, RelateTo, 1);
                    }
                    else
                    {
                        cs.CreateCommentsTableNoMembers(TableName, RelateTo, 1);
                    }

                    table = cMgr.GetTableDetails(TableName);
                }

                //HtmlInputHidden RelationId = new HtmlInputHidden();
                //RelationId.ID = "RelationId";
                //RelationId.Value = "-2";
                //this.Controls.Add(RelationId);

                HtmlInputHidden ParentId = new HtmlInputHidden();
                ParentId.ID = "ParentId";
                if (this.dataSrc == null)
                {
                    ParentId.Value = "-1";
                }
                else
                {
                    ParentId.Value = dataSrc.ParentId.ToString();
                }
                this.Controls.Add(ParentId);


                if (!NoRelations)
                {
                    object relationValue = ControlUtils.GetBoundedDataField(this.NamingContainer, table.RelationField);

                    RelationId = (int)relationValue;
                }
                if (AjaxSubmit)
                {
                    AjaxResponse resp = new AjaxResponse();

                    if (this.IsPostBack)
                    {
                        resp.callBack = this.AjaxCallback;
                        this.Validate();
                        resp.valid = this.IsValid.Value;

                        if (resp.valid)
                        {
                            if (this.MembersOnly)
                            {
                                string text = WebContext.Request["CommentText"];
                                if (!String.IsNullOrWhiteSpace(text))
                                {
                                    int comment = cMgr.AddMemberComment(TableName,
                                                                        Int32.Parse(ParentId.Value), RelationId,
                                                                        WebContext.Request["CommentTitle"],
                                                                        text, WebContext.Profile.UserId, CommentType.Text);

                                    var dr = cMgr.GetTopComment(TableName, RelationId, Int32.Parse(ParentId.Value), "Order By CommentId Desc");

                                    MembersManager mMgr = new MembersManager();

                                    resp r = new resp();

                                    string mId = dr["MemberId"].ToString();

                                    if (!String.IsNullOrWhiteSpace(mId))
                                    {
                                        var member = mMgr.GetMember(Int32.Parse(mId));

                                        r.FirstName = member.FirstName;
                                        r.LastName  = member.LastName;
                                        r.Username  = member.UserName;
                                        r.Picture   = member.Picture;
                                    }

                                    r.CommentId   = dr["CommentId"].ToString();
                                    r.ParentId    = dr["ParentId"].ToString();
                                    r.RelationId  = dr["RelationId"].ToString();
                                    r.DateCreated = string.Format("{0:MMM dd, yyyy} at {0:h:mm:tt}", dr["DateCreated"]);
                                    r.Title       = dr["Title"].ToString();
                                    r.CommentText = dr["CommentText"].ToString();
                                    r.MemberId    = dr["MemberId"].ToString();
                                    r.TableName   = TableName;

                                    resp.data    = r;
                                    resp.message = "Text successfully added";
                                    resp.error   = null;
                                }
                                else
                                {
                                    resp.message = "Please write your text before submitting and try again.";
                                    resp.error   = "true";
                                }
                            }
                            else
                            {
                                NameValueCollection post = GetValues();
                                ContentManager      pMgr = new ContentManager();

                                CustomPage thisPage = this.Page as CustomPage;
                                if (thisPage == null)
                                {
                                    thisPage = new CustomPage();
                                }

                                if (String.IsNullOrEmpty(post["Name"]))
                                {
                                    Validated = false;
                                    ErrorContext.Add("validation-name", ContentManager.ErrorMsg("Name-Validation", thisPage.Language));
                                }
                                if (String.IsNullOrEmpty(post["Email"]) || !Validation.IsEmail(post["Email"]))
                                {
                                    Validated = false;
                                    ErrorContext.Add("validation-email", ContentManager.ErrorMsg("Email-Validation", thisPage.Language));
                                }
                                if (String.IsNullOrEmpty(post["Title"]))
                                {
                                    Validated = false;
                                    ErrorContext.Add("validation-comment", ContentManager.ErrorMsg("Comment-Validation", thisPage.Language));
                                }
                                if (String.IsNullOrEmpty(post["Comment"]))
                                {
                                    Validated = false;
                                    ErrorContext.Add("validation-comment", ContentManager.ErrorMsg("Comment-Validation", thisPage.Language));
                                }
                                if (Validated != null && Validated.Value)
                                {
                                    int commentId = -1;
                                    try
                                    {
                                        commentId = cMgr.AddNoMemberComment(TableName, -1,
                                                                            RelationId,
                                                                            post["Title"],
                                                                            post["Comment"], WebContext.Profile.UserGuid,
                                                                            post["Name"], post["Website"],
                                                                            post["Country"], WebContext.Request.ServerVariables["REMOTE_ADDR"],
                                                                            post["avatar"], CommentType.Text);
                                    }
                                    catch (Exception ex)
                                    {
                                        ErrorContext.Add(ex);
                                    }
                                    if (commentId > 0)
                                    {
                                        if (!String.IsNullOrEmpty(table.Email))
                                        {
                                            Config cfg  = new Config();
                                            Mail   mail = new Mail("Comments");
                                            mail.Subject = post["Name"] + " submitted a comment to " + table.TableName;

                                            NameValueCollection dic = new NameValueCollection();
                                            dic["Name"]    = post["Name"];
                                            dic["Email"]   = post["Email"];
                                            dic["Comment"] = StringUtils.PutBR(post["Comment"].ToString());

                                            if (!String.IsNullOrWhiteSpace(post["Website"]))
                                            {
                                                dic["Website"] = post["Website"];
                                            }

                                            ArrayList files = cMgr.AddFiles(TableName, commentId);

                                            StringBuilder sb = new StringBuilder();

                                            if (files.Count > 0)
                                            {
                                                sb.Append("<dl><dt>Files:</dt><dd>");
                                                foreach (string s in files)
                                                {
                                                    string temp = s;
                                                    if (temp.IndexOf("~") == 0)
                                                    {
                                                        temp = temp.Substring(1);
                                                    }

                                                    sb.Append(String.Format("<a href=\"http://{0}/{1}\">{2}</a>",
                                                                            WebTools.WebContext.ServerName,
                                                                            s.Replace("\\", "/").Substring(1),
                                                                            Path.GetFileName(temp)));
                                                    sb.Append("<br />");
                                                }
                                                sb.Append("</dd></dl>");
                                            }

                                            dic["Files"] = sb.ToString();
                                            sb.Clear();

                                            sb.Append(string.Format(@"<p>
	<a href=""http://{0}/Prv/proxies/comments/status.ashx?commentId={1}&table={2}&action=approve"">Approve</a>
	- <a href=""http://{0}/Prv/proxies/comments/status.ashx?commentId={1}&table={2}&action=edit"">Edit</a>
	- <a href=""http://{0}/Prv/proxies/comments/status.ashx?CommentId={1}&table={2}&action=delete"">Delete</a>
</p>", WebTools.WebContext.ServerName, commentId, table.TableName));

                                            dic["Permission"] = sb.ToString();

                                            mail.Data = dic;
                                            mail.To   = table.Email;

                                            /*
                                             * mail.From = cfg.GetKey("EmailsFrom");
                                             *
                                             * StringBuilder sb = new StringBuilder();
                                             *
                                             * sb.Append("<dl>");
                                             * sb.Append(String.Format("<dt>Name: </dt><dd>{0}</dd>", post["Name"]));
                                             * sb.Append(String.Format("<dt>Email: </dt><dd>{0}</dd>", post["Email"]));
                                             *
                                             * if(!String.IsNullOrWhiteSpace(post["Website"]))
                                             *      sb.Append(String.Format("<dt>Website: </dt><dd>{0}</dd>", post["Website"]));
                                             *
                                             *
                                             * ArrayList files = cMgr.AddFiles(TableName, commentId);
                                             *
                                             * if (files.Count > 0)
                                             * {
                                             *      sb.Append("<dt>Files:</dt><dd>");
                                             *      foreach (string s in files)
                                             *      {
                                             *              String.Format("<a href=\"{0}/{1}\">{2}</a>",
                                             *                      WebTools.WebContext.ServerName,
                                             *                      s.Replace("\\", "/"),
                                             *                      Path.GetFileName(s));
                                             *      }
                                             *      sb.Append("</dd>");
                                             * }
                                             *
                                             * sb.Append(String.Format("<dt>Comment: </dt><dd>{0}</dd>", StringUtils.PutBR(post["Comment"])));
                                             * sb.Append("</dl>");
                                             *
                                             * sb.Append(string.Format(@"<p>
                                             * <a href=""http://{0}/Prv/proxies/comments/status.ashx?commentId={1}&table={2}&action=approve"">Approve</a>
                                             * - <a href=""http://{0}/Prv/proxies/comments/status.ashx?commentId={1}&table={2}&action=edit"">Edit</a>
                                             * - <a href=""http://{0}/Prv/proxies/comments/status.ashx?CommentId={1}&table={2}&action=delete"">Delete</a>
                                             * </p>", WebTools.WebContext.ServerName, commentId, table.TableName));
                                             *
                                             * mail.Body = sb.ToString();
                                             * mail.Subject = post["Name"] + " submitted a comment to " + table.TableName;
                                             */
                                            mail.Send();
                                        }
                                        SuccessContext.Add("comment-submitted", ContentManager.Message("comment-submitted"));
                                        this.Visible = false;
                                    }
                                }
                            }
                        }
                        resp.WriteJson(true);
                    }
                }
                else
                {
                    if (this.MembersOnly)
                    {
                        string text = WebContext.Request["CommentText"];
                        if (!String.IsNullOrWhiteSpace(text))
                        {
                            cMgr.AddMemberComment(TableName,
                                                  Int32.Parse(ParentId.Value), RelationId,
                                                  WebContext.Request["CommentTitle"],
                                                  text, WebContext.Profile.UserId, CommentType.Text);

                            WebContext.Response.Redirect(WebContext.Request.RawUrl);
                        }
                    }
                    else
                    {
                        NameValueCollection post = GetValues();
                        ContentManager      pMgr = new ContentManager();

                        CustomPage thisPage = this.Page as CustomPage;
                        if (thisPage == null)
                        {
                            thisPage = new CustomPage();
                        }

                        if (String.IsNullOrEmpty(post["Name"]))
                        {
                            Validated = false;
                            ErrorContext.Add("validation-name", ContentManager.ErrorMsg("Name-Validation", thisPage.Language));
                        }
                        if (String.IsNullOrEmpty(post["Email"]) || !Validation.IsEmail(post["Email"]))
                        {
                            Validated = false;
                            ErrorContext.Add("validation-email", ContentManager.ErrorMsg("Email-Validation", thisPage.Language));
                        }
                        if (String.IsNullOrEmpty(post["Title"]))
                        {
                            Validated = false;
                            ErrorContext.Add("validation-comment", ContentManager.ErrorMsg("Comment-Validation", thisPage.Language));
                        }
                        if (String.IsNullOrEmpty(post["Comment"]))
                        {
                            Validated = false;
                            ErrorContext.Add("validation-comment", ContentManager.ErrorMsg("Comment-Validation", thisPage.Language));
                        }
                        if (Validated != null && Validated.Value)
                        {
                            int commentId = -1;
                            try
                            {
                                commentId = cMgr.AddNoMemberComment(TableName, -1,
                                                                    RelationId,
                                                                    post["Title"],
                                                                    post["Comment"], WebContext.Profile.UserGuid,
                                                                    post["Name"], post["Website"],
                                                                    post["Country"], WebContext.Request.ServerVariables["REMOTE_ADDR"],
                                                                    post["avatar"], CommentType.Text);
                            }
                            catch (Exception ex)
                            {
                                ErrorContext.Add(ex);
                            }
                            if (commentId > 0)
                            {
                                if (!String.IsNullOrEmpty(table.Email))
                                {
                                    Config cfg  = new Config();
                                    Mail   mail = new Mail("Comments");
                                    mail.Subject = post["Name"] + " submitted a comment to " + table.TableName;

                                    NameValueCollection dic = new NameValueCollection();
                                    dic["Name"]    = post["Name"];
                                    dic["Email"]   = post["Email"];
                                    dic["Comment"] = StringUtils.PutBR(post["Comment"].ToString());

                                    if (!String.IsNullOrWhiteSpace(post["Website"]))
                                    {
                                        dic["Website"] = post["Website"];
                                    }

                                    ArrayList files = cMgr.AddFiles(TableName, commentId);

                                    StringBuilder sb = new StringBuilder();

                                    if (files.Count > 0)
                                    {
                                        sb.Append("<dl><dt>Files:</dt><dd>");
                                        foreach (string s in files)
                                        {
                                            string temp = s;
                                            if (temp.IndexOf("~") == 0)
                                            {
                                                temp = temp.Substring(1);
                                            }

                                            sb.Append(String.Format("<a href=\"http://{0}/{1}\">{2}</a>",
                                                                    WebTools.WebContext.ServerName,
                                                                    s.Replace("\\", "/").Substring(1),
                                                                    Path.GetFileName(temp)));
                                            sb.Append("<br />");
                                        }
                                        sb.Append("</dd></dl>");
                                    }

                                    dic["Files"] = sb.ToString();
                                    sb.Clear();

                                    sb.Append(string.Format(@"<p>
								<a href=""http://{0}/Prv/proxies/comments/status.ashx?commentId={1}&table={2}&action=approve"">Approve</a>
								- <a href=""http://{0}/Prv/proxies/comments/status.ashx?commentId={1}&table={2}&action=edit"">Edit</a>
								- <a href=""http://{0}/Prv/proxies/comments/status.ashx?CommentId={1}&table={2}&action=delete"">Delete</a>
							</p>"                            , WebTools.WebContext.ServerName, commentId, table.TableName));

                                    dic["Permission"] = sb.ToString();

                                    mail.Data = dic;
                                    mail.To   = table.Email;

                                    /*
                                     * mail.From = cfg.GetKey("EmailsFrom");
                                     *
                                     * StringBuilder sb = new StringBuilder();
                                     *
                                     * sb.Append("<dl>");
                                     * sb.Append(String.Format("<dt>Name: </dt><dd>{0}</dd>", post["Name"]));
                                     * sb.Append(String.Format("<dt>Email: </dt><dd>{0}</dd>", post["Email"]));
                                     *
                                     * if(!String.IsNullOrWhiteSpace(post["Website"]))
                                     *      sb.Append(String.Format("<dt>Website: </dt><dd>{0}</dd>", post["Website"]));
                                     *
                                     *
                                     * ArrayList files = cMgr.AddFiles(TableName, commentId);
                                     *
                                     * if (files.Count > 0)
                                     * {
                                     *      sb.Append("<dt>Files:</dt><dd>");
                                     *      foreach (string s in files)
                                     *      {
                                     *              String.Format("<a href=\"{0}/{1}\">{2}</a>",
                                     *                      WebTools.WebContext.ServerName,
                                     *                      s.Replace("\\", "/"),
                                     *                      Path.GetFileName(s));
                                     *      }
                                     *      sb.Append("</dd>");
                                     * }
                                     *
                                     * sb.Append(String.Format("<dt>Comment: </dt><dd>{0}</dd>", StringUtils.PutBR(post["Comment"])));
                                     * sb.Append("</dl>");
                                     *
                                     * sb.Append(string.Format(@"<p>
                                     * <a href=""http://{0}/Prv/proxies/comments/status.ashx?commentId={1}&table={2}&action=approve"">Approve</a>
                                     * - <a href=""http://{0}/Prv/proxies/comments/status.ashx?commentId={1}&table={2}&action=edit"">Edit</a>
                                     * - <a href=""http://{0}/Prv/proxies/comments/status.ashx?CommentId={1}&table={2}&action=delete"">Delete</a>
                                     * </p>", WebTools.WebContext.ServerName, commentId, table.TableName));
                                     *
                                     * mail.Body = sb.ToString();
                                     * mail.Subject = post["Name"] + " submitted a comment to " + table.TableName;
                                     */
                                    mail.Send();
                                }
                                SuccessContext.Add("comment-submitted", ContentManager.Message("comment-submitted"));
                                this.Visible = false;
                            }
                        }
                    }
                }
            }
            base.DataBind();
        }
예제 #26
0
 public GroupCommentsForm()
 {
     _cMgr = new CommentsManager();
 }
예제 #27
0
    public string GetCommentsStatistics()
    {
        var manager = new CommentsManager(this);

        var query = manager.GetComments(SubjectId, PageName).OrderByDescending(c => c.CreatedDate).ToList();
        int amount = query.Count;

        if (amount > 0)
            return "Comentários (" + amount + "), último por " + query.First().UserName;
        else
            return "Seja o primeiro a comentar!";

    }
예제 #28
0
 public LegacyReview(CommentsManager commentsManager)
 {
     _commentsManager = commentsManager;
 }
예제 #29
0
 public CommentsController(CommentsManager commentsManager)
 {
     _commentsManager = commentsManager;
 }
예제 #30
0
 public CommentsController(CommentsManager commentsManager, ReviewManager reviewManager, NotificationManager notificationManager)
 {
     _commentsManager     = commentsManager;
     _reviewManager       = reviewManager;
     _notificationManager = notificationManager;
 }
예제 #31
0
 protected void GetAll()
 {
     sigma = CommentsManager.GetCommentByUid(Now_User.now_user_id);
 }