/// <summary>
        /// Returns false if the supplied Imgur Comment has already been processed.
        /// This is determined by checking the direct Replies to the Comment,
        /// and seeing if any of them were made by the application,
        /// specifically if <see cref="ImgurInterfacer.isCommentByThisApplication"/> returns true.
        /// This method may call the Imgur API.
        /// </summary>
        protected async Task <bool> ShouldProcess(IComment ToProcess)
        {
            IEnumerable <IComment> Replies;

            //??? Imgur seems inconsistent in whether or not Comment Replies are included
            if (ToProcess.Children.Count() > 0)
            {
                Replies = ToProcess.Children;
            }
            else
            {
                Log.Imgur_.LogVerbose("No sub-Comments found in model of Comment #{0:D}; lazily loading sub-Comments", ToProcess.Id);
                try{
                    Replies = await Imgur.ReadCommentReplies(ToProcess);
                }catch (ImgurException Error) {
                    Log.Imgur_.LogError(
                        "Unable to retrieve replies for Comment with ID {0:D} (by '{1}' on {2:u}) to determine if it has been processed; skipping Comment. Details: {3}",
                        ToProcess.Id, ToProcess.Author, ToProcess.DateTime, Error.Message
                        );
                    return(false);
                }
            }
            if (Replies.Any(
                    C => Imgur.isCommentByThisApplication(C)
                    ))
            {
                return(false);
            }
            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Gets the message template unique identifier for the specified <see cref="ICommentEvent"/> event.
        /// </summary>
        /// <param name="event">The event.</param>
        protected override Guid GetMessageTemplateId(ICommentEvent @event)
        {
            IComment comment = @event.Item;

            ICommentService cs     = SystemManager.GetCommentsService();
            IThread         thread = cs.GetThread(comment.ThreadKey);

            var  ns = SystemManager.GetNotificationService();
            Guid messageTemplateId;

            if (this.IsReviewThread(thread))
            {
                messageTemplateId = ns.GetMessageTemplates(this.ServiceContext, null)
                                    .Where(mt => mt.Subject == "A new review was posted")
                                    .Select(m => m.Id).FirstOrDefault();
            }
            else
            {
                messageTemplateId = ns.GetMessageTemplates(this.ServiceContext, null)
                                    .Where(mt => mt.Subject == "A new comment was posted")
                                    .Select(m => m.Id).FirstOrDefault();
            }

            if (messageTemplateId == Guid.Empty)
            {
                messageTemplateId = base.GetMessageTemplateId(@event);
            }

            return(messageTemplateId);
        }
Exemple #3
0
        public void ThenACommentIsAddedToTheIssue()
        {
            IEnumerable <IComment> comments = StepHelper.GetComments(GetSavedIssue());
            IComment comment = comments.Single();

            Assert.That(comment.Text, Is.EqualTo(CommentText));
        }
Exemple #4
0
 public HomeController(UserManager <ApplicationUser> userManager, IPost postService, IComment commentService, IForum forumService)
 {
     _userManager    = userManager;
     _postService    = postService;
     _commentService = commentService;
     _forumService   = forumService;
 }
Exemple #5
0
        public override void Execute(GrapeCity.Documents.Excel.Workbook workbook)
        {
            IWorksheet worksheet = workbook.Worksheets[0];
            IComment   commentC3 = worksheet.Range["C3"].AddComment("This is a rich text comment:\r\n");

            //config the paragraph's style.
            commentC3.Shape.TextFrame.TextRange.Paragraphs[0].Font.Bold = true;

            //add runs for the paragraph.
            commentC3.Shape.TextFrame.TextRange.Paragraphs[0].Runs.Add("Run1 font size is 15.", 1);
            commentC3.Shape.TextFrame.TextRange.Paragraphs[0].Runs.Add("Run2 font strikethrough.", 2);
            commentC3.Shape.TextFrame.TextRange.Paragraphs[0].Runs.Add("Run3 font italic, green color.");

            //config the first run of the paragraph's style.
            commentC3.Shape.TextFrame.TextRange.Paragraphs[0].Runs[1].Font.Size = 15;
            //config the second run of the paragraph's style.
            commentC3.Shape.TextFrame.TextRange.Paragraphs[0].Runs[2].Font.Strikethrough = true;

            //config the third run of the paragraph's style.
            commentC3.Shape.TextFrame.TextRange.Paragraphs[0].Runs[3].Font.Italic    = true;
            commentC3.Shape.TextFrame.TextRange.Paragraphs[0].Runs[3].Font.Color.RGB = Color.Green;

            //show comment.
            commentC3.Visible = true;

            commentC3.Shape.WidthInPixel  = 300;
            commentC3.Shape.HeightInPixel = 100;
        }
Exemple #6
0
        public ActionResult MarkAsOffended(string storyId, string commentId)
        {
            JsonViewData viewData = Validate <JsonViewData>(
                new Validation(() => string.IsNullOrEmpty(storyId), "Identyfikator artyku³u nie mo¿e byæ pusty."),
                new Validation(() => storyId.ToGuid().IsEmpty(), "Niepoprawny identyfikator artyku³u."),
                new Validation(() => string.IsNullOrEmpty(commentId), "Identyfikator komentarza nie mo¿e byæ pusty."),
                new Validation(() => commentId.ToGuid().IsEmpty(), "Niepoprawny identyfikator komentarza."),
                new Validation(() => !IsCurrentUserAuthenticated, "Nie jesteœ zalogowany."),
                new Validation(() => !CurrentUser.CanModerate(), "Nie masz praw do wo³ania tej metody.")
                );

            if (viewData == null)
            {
                try
                {
                    using (IUnitOfWork unitOfWork = UnitOfWork.Get())
                    {
                        IStory story = _storyRepository.FindById(storyId.ToGuid());

                        if (story == null)
                        {
                            viewData = new JsonViewData {
                                errorMessage = "Podany artyku³ nie istnieje."
                            };
                        }
                        else
                        {
                            IComment comment = story.FindComment(commentId.ToGuid());

                            if (comment == null)
                            {
                                viewData = new JsonViewData {
                                    errorMessage = "Podany komentarz nie istnieje."
                                };
                            }
                            else
                            {
                                _storyService.MarkAsOffended(comment, string.Concat(Settings.RootUrl, Url.RouteUrl("Detail", new { name = story.UniqueName })), CurrentUser);

                                unitOfWork.Commit();

                                viewData = new JsonViewData {
                                    isSuccessful = true
                                };
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    Log.Exception(e);

                    viewData = new JsonViewData {
                        errorMessage = FormatStrings.UnknownError.FormatWith("zaznaczania komentarza jako obraŸliwy")
                    };
                }
            }

            return(Json(viewData));
        }
Exemple #7
0
 public void RemoveComment(IComment commentToRemove, IVehicle vehicleToRemoveComment)
 {
     if (commentToRemove.Author == this.Username && vehicleToRemoveComment.Comments.Contains(commentToRemove))
     {
         vehicleToRemoveComment.Comments.Remove(commentToRemove);
     }
 }
        public IComment GetCommentById(int id)
        {
            var      allComments = GetAll();
            IComment comment     = allComments.Find(c => c.Id == id);

            return(comment);
        }
Exemple #9
0
        private int getOldParentId(int id, CommentLevel level)
        {
            Object p = ndb.findById(commentType, id);

            if (p == null)
            {
                return(0);
            }

            IComment comment = p as IComment;

            if (comment == null)
            {
                return(0);
            }

            if (comment.ParentId == 0)
            {
                return(id);
            }
            if (comment.ParentId == id)
            {
                return(id);
            }

            level.Count = level.Count + 1;

            if (level.Count > 5)
            {
                return(0);
            }

            return(getOldParentId(comment.ParentId, level));
        }
Exemple #10
0
        protected override string Handle(ICommand command)
        {
            if (this.dataProvider.LoggedUser == null)
            {
                return(UserNotLogged);
            }

            string content      = command.Parameters[0];
            string author       = command.Parameters[1];
            int    vehicleIndex = int.Parse(command.Parameters[2]) - 1;

            IComment comment = this.dealershipFactory.CreateComment(content);

            comment.Author = this.dataProvider.LoggedUser.Username;

            IUser user = this.dataProvider.RegisteredUsers.ToList()
                         .FirstOrDefault(u => u.Username == author);

            if (user == null)
            {
                return(string.Format(NoSuchUser, author));
            }

            ValidateRange(vehicleIndex, 0, user.Vehicles.Count, VehicleDoesNotExist);

            IVehicle vehicle = user.Vehicles[vehicleIndex];

            this.dataProvider.LoggedUser.AddComment(comment, vehicle);

            return(string.Format(CommentAddedSuccessfully, this.dataProvider.LoggedUser.Username));
        }
Exemple #11
0
            /// <summary>
            /// Removes the given item from the collection
            /// </summary>
            /// <returns>True, if the item was removed, otherwise False</returns>
            /// <param name="item">The item that should be removed</param>
            public override bool Remove(IModelElement item)
            {
                ISubmission submissionItem = item.As <ISubmission>();

                if (((submissionItem != null) &&
                     this._parent.Submissions.Remove(submissionItem)))
                {
                    return(true);
                }
                IComment commentItem = item.As <IComment>();

                if (((commentItem != null) &&
                     this._parent.Likes.Remove(commentItem)))
                {
                    return(true);
                }
                IUser userItem = item.As <IUser>();

                if (((userItem != null) &&
                     this._parent.Friends.Remove(userItem)))
                {
                    return(true);
                }
                return(false);
            }
Exemple #12
0
        private OpenComment getOpenComment(IComment x)
        {
            OpenComment comment = new OpenComment();

            comment.AppId = x.AppId;

            comment.Title   = x.Title;
            comment.Content = x.Content;

            comment.Author  = x.Author;
            comment.Member  = x.Member;
            comment.Ip      = x.Ip;
            comment.Created = x.Created;

            comment.ParentId = getParentId(x);

            IEntity p = ndb.findById(targetType, x.RootId);

            if (p == null)
            {
                comment.TargetDataId   = 0;
                comment.TargetDataType = targetType.FullName;
                comment.TargetTitle    = "--null-";
                comment.TargetUserId   = 0;
            }
            else
            {
                comment.TargetDataId   = p.Id;
                comment.TargetDataType = targetType.FullName;
                comment.TargetTitle    = getTitle(p);
                comment.TargetUserId   = getCreatorId(p);
            }

            return(comment);
        }
Exemple #13
0
        private int getOldParentId(int id)
        {
            TComment p = db.findById <TComment>(id);

            if (p == null)
            {
                return(0);
            }

            IComment comment = p as IComment;

            if (comment == null)
            {
                return(0);
            }

            if (comment.ParentId == 0)
            {
                return(id);
            }
            if (comment.ParentId == id)
            {
                return(id);
            }

            return(getOldParentId(comment.ParentId));
        }
Exemple #14
0
        /// <summary>
        /// Constructs a parser that consumes a whitespace and all comments
        /// parsed by the commentParser.AnyComment parser, but parses only one trailing
        /// comment that starts exactly on the last line of the parsed value.
        /// </summary>
        /// <typeparam name="T">The result type of the given parser.</typeparam>
        /// <param name="parser">The parser to wrap.</param>
        /// <param name="commentParser">The comment parser.</param>
        /// <returns>An extended Token() version of the given parser.</returns>
        public static Parser <ICommented <T> > Commented <T>(this Parser <T> parser, IComment commentParser = null)
        {
            if (parser == null)
            {
                throw new ArgumentNullException(nameof(parser));
            }

            // consume any comment supported by the comment parser
            var comment = (commentParser ?? DefaultCommentParser).AnyComment;

            // parses any whitespace except for the new lines
            var whiteSpaceExceptForNewLine = WhiteSpace.Except(Chars("\r\n")).Many().Text();

            // returns true if the second span starts on the first span's last line
            bool IsSameLine(ITextSpan <T> first, ITextSpan <string> second) =>
            first.End.Line == second.Start.Line;

            // single comment span followed by a whitespace
            var commentSpan =
                from cs in comment.Span()
                from ws in whiteSpaceExceptForNewLine
                select cs;

            // add leading and trailing comments to the parser
            return
                (from leadingWhiteSpace in WhiteSpace.Many()
                 from leadingComments in comment.Token().Many()
                 from valueSpan in parser.Span()
                 from trailingWhiteSpace in whiteSpaceExceptForNewLine
                 from trailingPreview in commentSpan.Many().Preview()
                 let trailingCount = trailingPreview.GetOrElse(Enumerable.Empty <ITextSpan <string> >())
                                     .Where(c => IsSameLine(valueSpan, c)).Count()
                                     from trailingComments in commentSpan.Repeat(trailingCount)
                                     select new CommentedValue <T>(leadingComments, valueSpan.Value, trailingComments.Select(c => c.Value)));
        }
        //--------------------------------------------------------------------------------------------------------------

        private void initService()
        {
            String   commentTypeName = ctx.Get("type");
            IComment comment         = Entity.New(commentTypeName) as IComment;

            commentService.setComment(comment);
        }
Exemple #16
0
        public void TestQuickGuide()
        {
            IWorkbook wb = _testDataProvider.CreateWorkbook();

            ICreationHelper factory = wb.GetCreationHelper();

            ISheet sheet = wb.CreateSheet();

            ICell cell = sheet.CreateRow(3).CreateCell(5);

            cell.SetCellValue("F4");

            IDrawing drawing = sheet.CreateDrawingPatriarch();

            IClientAnchor   anchor  = factory.CreateClientAnchor();
            IComment        comment = drawing.CreateCellComment(anchor);
            IRichTextString str     = factory.CreateRichTextString("Hello, World!");

            comment.String = (str);
            comment.Author = ("Apache POI");
            //assign the comment to the cell
            cell.CellComment = (comment);

            wb      = _testDataProvider.WriteOutAndReadBack(wb);
            sheet   = wb.GetSheetAt(0);
            cell    = sheet.GetRow(3).GetCell(5);
            comment = cell.CellComment;
            Assert.IsNotNull(comment);
            Assert.AreEqual("Hello, World!", comment.String.String);
            Assert.AreEqual("Apache POI", comment.Author);
            Assert.AreEqual(3, comment.Row);
            Assert.AreEqual(5, comment.Column);
        }
Exemple #17
0
        public void TestExisting()
        {
            IWorkbook workbook = XSSFTestDataSamples.OpenSampleWorkbook("WithVariousData.xlsx");
            ISheet    sheet1   = workbook.GetSheetAt(0);
            ISheet    sheet2   = workbook.GetSheetAt(1);

            Assert.IsTrue(((XSSFSheet)sheet1).HasComments);
            Assert.IsFalse(((XSSFSheet)sheet2).HasComments);

            // Comments should be in C5 and C7
            IRow r5 = sheet1.GetRow(4);
            IRow r7 = sheet1.GetRow(6);

            Assert.IsNotNull(r5.GetCell(2).CellComment);
            Assert.IsNotNull(r7.GetCell(2).CellComment);

            // Check they have what we expect
            // TODO: Rich text formatting
            IComment cc5 = r5.GetCell(2).CellComment;
            IComment cc7 = r7.GetCell(2).CellComment;

            Assert.AreEqual("Nick Burch", cc5.Author);
            Assert.AreEqual("Nick Burch:\nThis is a comment", cc5.String.String);
            Assert.AreEqual(4, cc5.Row);
            Assert.AreEqual(2, cc5.Column);

            Assert.AreEqual("Nick Burch", cc7.Author);
            Assert.AreEqual("Nick Burch:\nComment #1\n", cc7.String.String);
            Assert.AreEqual(6, cc7.Row);
            Assert.AreEqual(2, cc7.Column);
        }
Exemple #18
0
 public void EditComment(object param)
 {
     _editableComment = (Comment)param;
     CommentContent   = _editableComment.Content;
     CommentHeader    = _editableComment.Header;
     ShowAddNotePanel();
 }
Exemple #19
0
        public void AddComment()
        {
            if (!ValidateUserInput.IsNullOrWhiteSpace(CommentContent))
            {
                return;
            }


            if (_editableComment != null)
            {
                var index = Notes.IndexOf(_editableComment);
                _editableComment.Content = CommentContent;
                _editableComment.Header  = CommentHeader;
                Notes.Insert(index, _editableComment);
                Notes.RemoveAt(index + 1);
                DataBase.UpdateComment(_editableComment);
                _editableComment = null;
            }
            else
            {
                var comment = new Comment
                {
                    SubmitionDate = DateTime.Now,
                    Content       = CommentContent,
                    Header        = CommentHeader
                };
                DataBase.InsertComment(comment, _project.ID);
                Notes.Add(comment);
            }
            CommentContent = string.Empty;
            ShowAddNotePanel();
        }
Exemple #20
0
 public PostsModel(UserManager <User> userManager, IPost post, IConfiguration config, IComment comment) : base(userManager)
 {
     _comment     = comment;
     _userManager = userManager;
     _config      = config;
     _post        = post;
 }
Exemple #21
0
        private IComment insertComment(IDrawing Drawing, ICell cell, String message)
        {
            ICreationHelper factory = cell.Sheet.Workbook.GetCreationHelper();

            IClientAnchor anchor = factory.CreateClientAnchor();

            anchor.Col1 = (/*setter*/ cell.ColumnIndex);
            anchor.Col2 = (/*setter*/ cell.ColumnIndex + 1);
            anchor.Row1 = (/*setter*/ cell.RowIndex);
            anchor.Row2 = (/*setter*/ cell.RowIndex + 1);
            anchor.Dx1  = (/*setter*/ 100);
            anchor.Dx2  = (/*setter*/ 100);
            anchor.Dy1  = (/*setter*/ 100);
            anchor.Dy2  = (/*setter*/ 100);

            IComment comment = Drawing.CreateCellComment(anchor);

            IRichTextString str = factory.CreateRichTextString(message);

            comment.String   = (/*setter*/ str);
            comment.Author   = (/*setter*/ "fanfy");
            cell.CellComment = (/*setter*/ comment);

            return(comment);
        }
 String IMarkupFormatter.Comment(IComment comment)
 {
     return String.Concat(
         IntendBefore(comment.PreviousSibling),
         HtmlMarkupFormatter.Instance.Comment(comment),
         NewLineAfter(comment.NextSibling));
 }
        internal static void SlideWithComments1(IPresentation presentation)
        {
            #region Slide 1
            ISlide slide1 = presentation.Slides[0];
            IShape shape1 = (IShape)slide1.Shapes[0];
            shape1.Left   = 1.27 * 72;
            shape1.Top    = 0.85 * 72;
            shape1.Width  = 10.86 * 72;
            shape1.Height = 3.74 * 72;

            ITextBody   textFrame  = shape1.TextBody;
            IParagraphs paragraphs = textFrame.Paragraphs;
            paragraphs.Add();
            IParagraph paragraph = paragraphs[0];
            paragraph.HorizontalAlignment = HorizontalAlignmentType.Left;
            ITextParts textParts = paragraph.TextParts;
            textParts.Add();
            ITextPart textPart = textParts[0];
            textPart.Text          = "Essential Presentation ";
            textPart.Font.CapsType = TextCapsType.All;
            textPart.Font.FontName = "Calibri Light (Headings)";
            textPart.Font.FontSize = 80;
            textPart.Font.Color    = ColorObject.Black;

            IComment comment = slide1.Comments.Add(0.35, 0.04, "Author1", "A1", "Essential Presentation is available from 13.1 versions of Essential Studio", DateTime.Now);
            #endregion
        }
        private void bindCommentOne(IBlock block, IComment c, String controllerString, Boolean canAdmin)
        {
            String userFace = "<img src='" + sys.Path.AvatarGuest + "' style='width:48px;'/></a>";
            String userName = c.Author;

            if (c.Member != null && c.Member.Id > 0)
            {
                userFace = string.Format("<a href='{0}'><img src='{1}' style='width:48px;'/></a>", Link.ToMember(c.Member), c.Member.PicSmall);
                userName = string.Format("<a href='{0}'>{1}</a>", Link.ToMember(c.Member), c.Member.Name);
            }
            block.Set("c.UserName", userName);
            block.Set("c.UserFace", userFace);
            block.Set("c.Created", c.Created);
            block.Set("c.Content", getContent(c));
            block.Set("c.Id", c.Id);

            logger.Info("controllerString=" + controllerString);

            //String lnk = Link.To( ctx.owner.obj, controllerString, "SaveReply", c.Id );
            String lnk = getActionUrl("SaveReply", c.Id);

            logger.Info("lnk=" + lnk);

            block.Set("c.ReplyLink", lnk);

            if (canAdmin)
            {
                IBlock adminBlock = block.GetBlock("admin");
                //String deleteLink = Link.To( ctx.owner.obj, controllerString, "Delete", c.Id );
                String deleteLink = getActionUrl("Delete", c.Id);
                adminBlock.Set("c.DeleteLink", deleteLink);
                adminBlock.Next();
            }
        }
        // 5) Update Comment (int id,int postId,string username,string email,string body)
        public void Update(IComment commentParam)
        {
            var comment = _context.Comments.Find(commentParam.Id);

            if (comment == null)
            {
                throw new AppException("Post not found");
            }

            // update user properties
            // comment.Name = commentParam.Name; //update should not allow change name

            comment = new Comment {
                Email = commentParam.Email,
                Body  = commentParam.Body,
                Time  = commentParam.Time
            };

            // comment.Email = commentParam.Email;
            // comment.Body = commentParam.Body;
            // comment.Time = commentParam.Time;

            _context.Comments.Update(comment);
            _context.SaveChanges();
        }
Exemple #26
0
        private int getParentId(IComment x)
        {
            if (x.ParentId <= 0)
            {
                return(0);
            }

            // 旧版数据
            if (x.ParentId == x.RootId)
            {
                return(0);
            }

            CommentLevel level = new CommentLevel {
                Count = 1
            };
            int parentId = getOldParentId(x.ParentId, level);

            OpenCommentTrans trans = OpenCommentTrans.find("CommentId=:cid and CommentType=:ctype")
                                     .set("cid", parentId)
                                     .set("ctype", x.GetType().FullName)
                                     .first();

            if (trans == null)
            {
                return(0);
            }

            if (trans.OpenCommentId <= 0)
            {
                return(0);
            }

            return(trans.OpenCommentId);
        }
Exemple #27
0
        public void TestBug57828_OnlyOneCommentShiftedInRow()
        {
            XSSFWorkbook wb    = XSSFTestDataSamples.OpenSampleWorkbook("57828.xlsx");
            XSSFSheet    sheet = wb.GetSheetAt(0) as XSSFSheet;

            IComment comment1 = sheet.GetCellComment(new CellAddress(2, 1));

            Assert.IsNotNull(comment1);

            IComment comment2 = sheet.GetCellComment(new CellAddress(2, 2));

            Assert.IsNotNull(comment2);

            IComment comment3 = sheet.GetCellComment(new CellAddress(1, 1));

            Assert.IsNull(comment3, "NO comment in (1,1) and it should be null");

            sheet.ShiftRows(2, 2, -1);

            comment3 = sheet.GetCellComment(new CellAddress(1, 1));
            Assert.IsNotNull(comment3, "Comment in (2,1) Moved to (1,1) so its not null now.");

            comment1 = sheet.GetCellComment(new CellAddress(2, 1));
            Assert.IsNull(comment1, "No comment currently in (2,1) and hence it is null");

            comment2 = sheet.GetCellComment(new CellAddress(1, 2));
            Assert.IsNotNull(comment2, "Comment in (2,2) should have Moved as well because of shift rows. But its not");

            wb.Close();
        }
Exemple #28
0
        protected override string Handle(ICommand command)
        {
            if (this.dataProvider.LoggedUser == null)
            {
                return(UserNotLogged);
            }

            int    vehicleIndex = int.Parse(command.Parameters[0]) - 1;
            int    commentIndex = int.Parse(command.Parameters[1]) - 1;
            string username     = command.Parameters[2];

            IUser user = this.dataProvider.RegisteredUsers.ToList()
                         .FirstOrDefault(u => u.Username == username);

            if (user == null)
            {
                return(string.Format(NoSuchUser, username));
            }

            ValidateRange(vehicleIndex, 0, user.Vehicles.Count, RemovedVehicleDoesNotExist);
            ValidateRange(commentIndex, 0, user.Vehicles[vehicleIndex].Comments.Count, RemovedCommentDoesNotExist);

            IVehicle vehicle = user.Vehicles[vehicleIndex];
            IComment comment = user.Vehicles[vehicleIndex].Comments[commentIndex];

            this.dataProvider.LoggedUser.RemoveComment(comment, vehicle);
            return(string.Format(CommentRemovedSuccessfully, this.dataProvider.LoggedUser.Username));
        }
        public virtual void SaveReply(int id)
        {
            if (config.Instance.Site.CloseComment)
            {
                return;
            }


            if (blacklistService.IsBlack(ctx.owner.Id, ctx.viewer.Id))
            {
                echoError(lang("backComment"));
                return;
            }

            IComment parent = commentService.GetById(id, ctx.app.Id);

            IComment comment = Validate(parent.RootId);

            if (ctx.HasErrors)
            {
                echoError();
                return;
            }

            comment.ParentId = parent.Id; // 重新设置parentId

            String lnkTarget = getTargetLink((T)comment);

            commentService.Reply(parent, comment, lnkTarget);

            String url = ctx.web.PathReferrer.ToString();

            echoRedirect(lang("opok"), addRefreshInfo(url) + "#commentFormStart");
        }
        public void AddComment(IComment commentToAdd, IVehicle vehicleToAddComment)
        {
            Validator.ValidateNull(commentToAdd, Constants.CommentCannotBeNull);
            Validator.ValidateNull(vehicleToAddComment, Constants.CommentCannotBeNull);

            vehicleToAddComment.Comments.Add(commentToAdd);
        }
Exemple #31
0
        private int getParentId(TComment obj)
        {
            IComment x = obj as IComment;

            if (x.ParentId <= 0)
            {
                return(0);
            }

            int parentId = getOldParentId(x.ParentId);

            OpenCommentTrans trans = OpenCommentTrans.find("CommentId=:cid and CommentType=:ctype")
                                     .set("cid", parentId)
                                     .set("ctype", x.GetType().FullName)
                                     .first();

            if (trans == null)
            {
                return(0);
            }

            if (trans.OpenCommentId <= 0)
            {
                return(0);
            }

            return(trans.OpenCommentId);
        }
Exemple #32
0
        public static void ParseComments(IComment message, List<string> comments, TokenReader tr)
        {
            message.Comments = "";
            foreach (string s in comments)
            {
                if (s.StartsWith(":"))
                {
                    try
                    {
                        string line = s.Substring(1);

                        //Remove comments after "//"
                        int cpos = line.IndexOf("//");
                        if (cpos >= 0)
                            line = line.Substring(0, cpos);

                        string[] parts = line.Split('=');
                        if (parts.Length > 2)
                            throw new ProtoFormatException("Bad option format, at most one '=', " + s, tr);
                        string key = parts[0].Trim().ToLowerInvariant();
                        if (parts.Length == 1)
                        {
                            //Parse flag
                            if (message is ProtoMessage)
                                ParseMessageFlags((ProtoMessage)message, key);
                            else if (message is Field)
                                ParseFieldFlags((Field)message, key);
                            else
                                throw new NotImplementedException();

                            continue;
                        }
                        else
                        {
                            string value = (parts.Length == 2) ? parts[1].Trim() : null;

                            if (message is ProtoMessage)
                                ParseMessageOption((ProtoMessage)message, key, value);
                            else if (message is Field)
                                ParseFieldOption((Field)message, key, value);
                            else
                                throw new NotImplementedException();

                            continue;
                        }
                    }
                    catch (Exception e)
                    {
                        throw new ProtoFormatException(e.Message, e, tr);
                    }
                }
                else
                {
                    message.Comments += s + "\n";
                }
            }
            message.Comments = message.Comments.Trim(new char[] { '\n' }).Replace("\n", "\r\n");
            comments.Clear();
        }
        /// <summary>
        /// Gets the comment response.
        /// </summary>
        /// <param name="comment">The comment.</param>
        /// <param name="includeSensitiveInformation">if set to <c>true</c> [include sensitive information].</param>
        /// <returns></returns>
        public static CommentResponse GetCommentResponse(IComment comment, bool includeSensitiveInformation = false)
        {
            var commentResponseObject = CommentsUtilitiesReflector.Reflect("GetCommentResponse", comment, includeSensitiveInformation);

            var commentResponse = commentResponseObject as CommentResponse;

            return commentResponse;
        }
Exemple #34
0
 public Post(IUser userRepository, ICategory categoryRepository, ITag tagRepository, IComment commentRepository)
 {
     _postsTable = context.GetTable<PostEntity>();
     _commentRepository = commentRepository;
     _tagRepository = tagRepository;
     _categoryRepository = categoryRepository;
     _userRepository = userRepository;
 }
 public AdminController(std s, Postings p, Filings f, Contactus c, Commenting com)
 {
     studnt = s;
     post = p;
     comment = com;
     file = f;
     cont = c;
 }
Exemple #36
0
 public MockPost()
 {
     _postsTable = GetMockPosts();
     _commentRepository = new MockComment();
     _tagRepository = new MockTag();
     _categoryRepository = new MockCategory();
     _userRepository = new MockUser();
 }
 public static string Render(IComment comment)
 {
     using (var writer = new StringWriter())
     {
         Render(comment, writer);
         return writer.ToString();
     }
 }
Exemple #38
0
 public CommentController(IPost postRepository, IComment commentsRepository, ISettings settingsRepository, ICacheService cacheService, IError errorLogger)
     : base(settingsRepository)
 {
     _postRepository = postRepository;
     _cacheService = cacheService;
     _commentsRepository = commentsRepository;
     _errorLogger = errorLogger;
 }
 //
 // GET: /Account/
 public AccountController(IUnitOfWork uow, IAccount accountService, ICountry countryService, IProvince provinceService, ICity cityService, IComment commentService)
 {
     _accountService = accountService;
     _countryService = countryService;
     _provinceService = provinceService;
     _cityService = cityService;
     _commentService = commentService;
     _uow = uow;
 }
Exemple #40
0
 public CommentProcessorPipeline(IComment commentRepository, ISettings settingsRepository, IAkismetService akismetService, IError error, CommentEntity commentEntity, RequestData requestData)
 {
     _commentRepository = commentRepository;
     _settingsRepository = settingsRepository;
     _akismetService = akismetService;
     _error = error;
     _commentEntity = commentEntity;
     _requestData = requestData;
 }
        private void CheckForSingleComments(string lineCheck, IComment comment)
        {
            var result = whiteSpaceHelper.CheckWhiteSpaceAroundCharacter(lineCheck, "'");
            // var result = this.whiteSpaceHelper.NeedWarningForSingleWhiteSpaceAfterKeyword(lineCheck, "//");

            if(result == true)
            {
                comment.AddCodeMarker(WarningId, this, AddSpaceAfterSingleComment, comment);
            }
        }
Exemple #42
0
 public static IHtmlString Comment(this ApiServices context, IComment comment)
 {
     if (comment != null)
     {
         var writer = new HtmlTextWriter(new StringWriter());
         CommentRenderer.Render(comment, new CommentRendererContext(writer, context));
         return MvcHtmlString.Create(writer.InnerWriter.ToString());
     }
     return MvcHtmlString.Create(string.Empty);
 }
Exemple #43
0
 public static Comment FromComment(IComment comment)
 {
     Comment t = new Comment
      {
     UserName = comment.UserName,
     Text = comment.Text,
     CreatedOn = comment.CreatedOn,
      };
      return t;
 }
Exemple #44
0
        public string Format(IComment comment)
        {
            foreach (var step in Formatters)
            {
                if (step.Criteria(comment) == true)
                    return step.Action(comment);
            }

            return null;
        }
Exemple #45
0
        public CommentAdminController(IPost postRepository, IComment commentRepository, ISettings settingsRepository)
            : base(settingsRepository)
        {
            _postRepository = postRepository;
            _commentRepository = commentRepository;
            ExpectedMasterName = string.Empty;

            _itemsPerPage = settingsRepository.ManageItemsPerPage;

            IsAdminController = true;
        }
Exemple #46
0
 public static CommentEntity CommentEntity(IComment comment)
 {
     return new CommentEntity()
     {
         Id = comment.Id,
         Description = comment.Description,
         CreatedOn = comment.CreatedOn,
         Reminder = comment.Reminder,
         Author = UserEntity(comment.Author),
         Task = TaskEntity(comment.Task)
     };
 }
Exemple #47
0
        public AdminController(IPost postRepository, IComment commentRepository, ICategory categoryRepository, ITag tagRepository, ISettings settingsRepository, IPathMapper pathMapper, IUser userRepository)
            : base(settingsRepository)
        {
            _postRepository = postRepository;
            _commentRepository = commentRepository;
            _categoryRepository = categoryRepository;
            _tagRepository = tagRepository;
            _pathMapper = pathMapper;
            _userRepository = userRepository;
            ExpectedMasterName = string.Empty;

            IsAdminController = true;
        }
Exemple #48
0
        public UserAdminController(IPost postRepository, IComment commentRepository, ICategory categoryRepository, ITag tagRepository, IUser userRepository, ISettings settingsRepository)
            : base(settingsRepository)
        {
            _postRepository = postRepository;
            _commentRepository = commentRepository;
            _categoryRepository = categoryRepository;
            _tagRepository = tagRepository;
            _userRepository = userRepository;
            ExpectedMasterName = string.Empty;

            _itemsPerPage = settingsRepository.ManageItemsPerPage;

            IsAdminController = true;
        }
        public static WorkLogItem ExtractWorkLogItem(IComment comment)
        {
            var hours = int.Parse(HoursRegEx.Match(comment.Body).Value);
            var minutes = int.Parse(MinutesRegEx.Match(comment.Body).Value);
            var day = int.Parse(DayRegEx.Match(comment.Body).Value);
            var month = int.Parse(MonthRegEx.Match(comment.Body).Value);
            var year = int.Parse(YearRegEx.Match(comment.Body).Value);

            return new WorkLogItem
            {
                Date = new DateTime(year, month, day),
                Time = new TimeSpan(0, hours, minutes, 0),
                Creator = comment.Author
            };
        }
 private static void Render(IComment node, TextWriter writer)
 {
     if (node is Summary)
     {
         RenderSummary((Summary)node, writer);
     }
     else if (node is InlineText)
     {
         RenderText((InlineText)node, writer);
     }
     else if (node is ParameterReference)
     {
         RenderParameterReference((ParameterReference)node, writer);
     }
     else
     {
         throw new NotSupportedException();
     }
 }
Exemple #51
0
        public long AddComment(IComment comment)
        {
            if (!string.IsNullOrEmpty(comment.CommentText))
            {
                var review = new comments
                {
                    text = comment.CommentText,
                    entity_id = comment.MaterialId,
                    parent_id = comment.ParentId,
                    proto_name = comment.ProtoName,
                    account_id = comment.AuthorId,
                    create_date = DateTime.Now
                };

                Insert(review);

                UpdateNestedSets(review.entity_id, review.proto_name, review.parent_id, review.level, review.left_key);

                return review.id;
            }

            return 0;
        }
 public void Add(IComment item)
 {
     _comment.Add(item);
     OnCommentAdded(new CommentEventArgs(item));
 }
Exemple #53
0
 private string FormatGeneralContainer(IComment comment)
 {
     return FormatChildren(comment.Children);
 }
Exemple #54
0
 /// <summary>
 /// Submits a comment to Akismet that should have been 
 ///   flagged as SPAM, but was not flagged by Akismet.
 /// </summary>
 /// <param name="comment">
 /// </param>
 public void SubmitSpam(IComment comment)
 {
   this.SubmitComment(comment, this.submitSpamUrl);
 }
 public void AddComment(IComment comment)
 {
     this.Comments.Add(comment);
 }
Exemple #56
0
    /// <summary>
    /// Checks the comment and returns true if it is spam, otherwise false.
    /// </summary>
    /// <param name="comment">
    /// </param>
    /// <returns>
    /// The check comment for spam.
    /// </returns>
    /// <exception cref="InvalidResponseException">
    /// Akismet returned an empty response
    /// </exception>
    public bool CheckCommentForSpam(IComment comment)
    {
      CodeContracts.ArgumentNotNull(comment, "comment");

      string result = this.SubmitComment(comment, this.submitCheckUrl);

      if (result.IsNotSet())
      {
        throw new InvalidResponseException("Akismet returned an empty response");
      }

      if (result != "true" && result != "false")
      {
        throw new InvalidResponseException(
          string.Format(
            CultureInfo.InvariantCulture, "Received the response '{0}' from Akismet. Probably a bad API key.", result));
      }

      return bool.Parse(result);
    }
Exemple #57
0
        /// <summary>
        /// Cell comment Finder.
        /// Returns cell comment for the specified sheet, row and column.
        /// </summary>
        /// <param name="sheet">The sheet.</param>
        /// <param name="row">The row.</param>
        /// <param name="column">The column.</param>
        /// <returns>cell comment or 
        /// <c>null</c>
        ///  if not found</returns>
        public static HSSFComment FindCellComment(InternalSheet sheet, int row, int column)
        {
            HSSFComment comment = null;
            Dictionary<int, TextObjectRecord> noteTxo = new Dictionary<int, TextObjectRecord>(); //map shapeId and TextObjectRecord
            int i = 0;
            for (IEnumerator it = sheet.Records.GetEnumerator(); it.MoveNext(); )
            {
                RecordBase rec = (RecordBase)it.Current;
                if (rec is NoteRecord)
                {
                    NoteRecord note = (NoteRecord)rec;
                    if (note.Row == row && note.Column == column)
                    {
                        if (i < noteTxo.Count)
                        {
                            TextObjectRecord txo = (TextObjectRecord)noteTxo[note.ShapeId];
                            comment = new HSSFComment(note, txo);
                            comment.Row = note.Row;
                            comment.Column = note.Column;
                            comment.Author = note.Author;
                            comment.Visible = (note.Flags == NoteRecord.NOTE_VISIBLE);
                            comment.String = txo.Str;
                            break;
                        }
                    }
                }
                else if (rec is ObjRecord)
                {
                    ObjRecord obj = (ObjRecord)rec;
                    SubRecord sub = obj.SubRecords[0];
                    if (sub is CommonObjectDataSubRecord)
                    {
                        CommonObjectDataSubRecord cmo = (CommonObjectDataSubRecord)sub;
                        if (cmo.ObjectType == CommonObjectType.COMMENT)
                        {
                            //Find the nearest TextObjectRecord which holds comment's text and map it to its shapeId
                            while (it.MoveNext())
                            {
                                rec = (Record)it.Current;
                                if (rec is TextObjectRecord)
                                {
                                    noteTxo.Add(cmo.ObjectId, (TextObjectRecord)rec);
                                    break;
                                }
                            }

                        }
                    }
                }
            }
            return comment;
        }
Exemple #58
0
        /// <summary>
        /// Removes the comment for this cell, if
        /// there is one.
        /// </summary>
        /// <remarks>WARNING - some versions of excel will loose
        /// all comments after performing this action!</remarks>
        public void RemoveCellComment()
        {
            HSSFComment comment = FindCellComment(sheet.Sheet, record.Row, record.Column);
            this.comment = null;

            if (comment == null)
            {
                // Nothing to do
                return;
            }

            // Zap the underlying NoteRecord
            IList sheetRecords = sheet.Sheet.Records;
            sheetRecords.Remove(comment.NoteRecord);

            // If we have a TextObjectRecord, is should
            //  be proceeed by:
            // MSODRAWING with container
            // OBJ
            // MSODRAWING with EscherTextboxRecord
            if (comment.TextObjectRecord != null)
            {
                TextObjectRecord txo = comment.TextObjectRecord;
                int txoAt = sheetRecords.IndexOf(txo);

                if (sheetRecords[txoAt - 3] is DrawingRecord &&
                    sheetRecords[txoAt - 2] is ObjRecord &&
                    sheetRecords[txoAt - 1] is DrawingRecord)
                {
                    // Zap these, in reverse order
                    sheetRecords.RemoveAt(txoAt - 1);
                    sheetRecords.RemoveAt(txoAt - 2);
                    sheetRecords.RemoveAt(txoAt - 3);
                }
                else
                {
                    throw new InvalidOperationException("Found the wrong records before the TextObjectRecord, can't Remove comment");
                }

                // Now Remove the text record
                sheetRecords.Remove(txo);
            }
        }
Exemple #59
0
 /// <summary>
 /// Returns the comments in a format suitable for display
 /// </summary>
 /// <param name="comment"></param>
 /// <returns></returns>
 public string Format(IComment comment)
 {
     return Formatter.Format(comment);
 }
 public bool Remove(IComment item)
 {
     var suc = _comment.Remove(item);
     OnCommentRemoved(new CommentEventArgs(item));
     return suc;
 }