示例#1
0
        private string GetHTMLComment(Comment comment)
        {
            var creator      = Global.EngineFactory.GetParticipantEngine().GetByID(comment.CreateBy).UserInfo;
            var oCommentInfo = new CommentInfo
            {
                TimeStamp             = comment.CreateOn,
                TimeStampStr          = comment.CreateOn.Ago(),
                CommentBody           = comment.Content,
                CommentID             = comment.ID.ToString(),
                UserID                = comment.CreateBy,
                UserFullName          = creator.DisplayUserName(),
                Inactive              = comment.Inactive,
                IsEditPermissions     = ProjectSecurity.CanEditComment(Task != null ? Task.Project : null, comment),
                IsResponsePermissions = ProjectSecurity.CanCreateComment(),
                IsRead                = true,
                UserAvatar            = Global.GetHTMLUserAvatar(creator),
                UserPost              = creator.Title
            };

            if (commentList == null)
            {
                commentList = new CommentsList();

                ConfigureComments(commentList, null);
            }

            return(CommentsHelper.GetOneCommentHtmlWithContainer(
                       commentList,
                       oCommentInfo,
                       comment.Parent == Guid.Empty,
                       false));
        }
示例#2
0
        private string GetHTMLComment(Comment comment, bool isPreview)
        {
            var creator = Global.EngineFactory.GetParticipantEngine().GetByID(comment.CreateBy).UserInfo;
            var info    = new CommentInfo
            {
                CommentID    = comment.ID.ToString(),
                UserID       = comment.CreateBy,
                TimeStamp    = comment.CreateOn,
                TimeStampStr = comment.CreateOn.Ago(),
                UserPost     = creator.Title,
                Inactive     = comment.Inactive,
                CommentBody  = comment.Content,
                UserFullName = DisplayUserSettings.GetFullUserName(creator),
                UserAvatar   = Global.GetHTMLUserAvatar(creator)
            };

            var defComment = new CommentsList();

            ConfigureComments(defComment, null);

            if (!isPreview)
            {
                info.IsRead                = true;
                info.IsEditPermissions     = ProjectSecurity.CanEditComment(Task.Project, comment);
                info.IsResponsePermissions = ProjectSecurity.CanCreateComment();
            }

            return(CommentsHelper.GetOneCommentHtmlWithContainer(
                       defComment,
                       info,
                       comment.Parent == Guid.Empty,
                       false));
        }
        public AjaxResponse AddComment(string parrentCommentID, string messageID, string text, string pid)
        {
            if (!ProjectSecurity.CanCreateComment())
            {
                throw ProjectSecurity.CreateSecurityException();
            }

            var resp = new AjaxResponse();

            var comment = new Comment
            {
                Content      = text,
                TargetUniqID = ProjectEntity.BuildUniqId <Message>(Convert.ToInt32(messageID))
            };

            resp.rs1 = parrentCommentID;

            if (!String.IsNullOrEmpty(parrentCommentID))
            {
                comment.Parent = new Guid(parrentCommentID);
            }

            Discussion = Global.EngineFactory.GetMessageEngine().GetByID(Convert.ToInt32(messageID));
            Global.EngineFactory.GetMessageEngine().SaveMessageComment(Discussion, comment);
            resp.rs2 = GetHTMLComment(comment);
            return(resp);
        }
示例#4
0
        private CommentInfo GetCommentInfo(IEnumerable <Comment> allComments, Comment parent)
        {
            var creator     = Global.EngineFactory.GetParticipantEngine().GetByID(parent.CreateBy).UserInfo;
            var commentInfo = new CommentInfo
            {
                TimeStampStr          = parent.CreateOn.Ago(),
                Inactive              = parent.Inactive,
                IsRead                = true,
                IsResponsePermissions = ProjectSecurity.CanCreateComment(),
                IsEditPermissions     = ProjectSecurity.CanEditComment(Task.Project, parent),
                CommentID             = parent.ID.ToString(),
                CommentBody           = parent.Content,
                UserID                = parent.CreateBy,
                UserFullName          = creator.DisplayUserName(),
                UserPost              = creator.Title,
                UserAvatar            = Global.GetHTMLUserAvatar(creator),
                CommentList           = new List <CommentInfo>(),
            };

            if (allComments != null)
            {
                foreach (var comment in allComments.Where(comment => comment.Parent == parent.ID))
                {
                    commentInfo.CommentList.Add(GetCommentInfo(allComments, comment));
                }
            }

            return(commentInfo);
        }
示例#5
0
        public AjaxResponse AddComment(string parrentCommentID, int taskID, string text, string pid)
        {
            if (!ProjectSecurity.CanCreateComment())
            {
                throw ProjectSecurity.CreateSecurityException();
            }

            var comment = new Comment
            {
                Content      = text,
                TargetUniqID = ProjectEntity.BuildUniqId <Task>(taskID)
            };

            if (!String.IsNullOrEmpty(parrentCommentID))
            {
                comment.Parent = new Guid(parrentCommentID);
            }

            Task = Global.EngineFactory.GetTaskEngine().GetByID(taskID);
            Global.EngineFactory.GetTaskEngine().SaveOrUpdateTaskComment(Task, comment);

            return(new AjaxResponse {
                rs1 = parrentCommentID, rs2 = GetHTMLComment(comment)
            });
        }
        internal CommentInfo GetCommentInfo(IEnumerable <Comment> allComments, Comment comment, ProjectEntity entity)
        {
            var creator      = EngineFactory.ParticipantEngine.GetByID(comment.CreateBy).UserInfo;
            var oCommentInfo = new CommentInfo
            {
                TimeStamp             = comment.CreateOn,
                TimeStampStr          = comment.CreateOn.Ago(),
                CommentBody           = HtmlUtility.GetFull(comment.Content),
                CommentID             = comment.OldGuidId.ToString(),
                UserID                = comment.CreateBy,
                UserFullName          = creator.DisplayUserName(),
                UserProfileLink       = creator.GetUserProfilePageURL(),
                Inactive              = comment.Inactive,
                IsEditPermissions     = ProjectSecurity.CanEditComment(entity, comment),
                IsResponsePermissions = ProjectSecurity.CanCreateComment(entity),
                IsRead                = true,
                UserAvatarPath        = creator.GetBigPhotoURL(),
                UserPost              = creator.Title,
                CommentList           = new List <CommentInfo>()
            };

            if (allComments != null)
            {
                foreach (var com in allComments.Where(com => com.Parent == comment.OldGuidId))
                {
                    oCommentInfo.CommentList.Add(GetCommentInfo(allComments, com, entity));
                }
            }

            return(oCommentInfo);
        }
示例#7
0
        public MessageWrapper(ProjectApiBase projectApiBase, Message message)
        {
            Id = message.ID;
            if (message.Project != null)
            {
                ProjectOwner = new SimpleProjectWrapper(message.Project);
            }
            Title   = message.Title;
            Text    = message.Description;
            Created = (ApiDateTime)message.CreateOn;
            Updated = (ApiDateTime)message.LastModifiedOn;

            if (projectApiBase.Context.GetRequestValue("simple") != null)
            {
                CreatedById = message.CreateBy;
                UpdatedById = message.LastModifiedBy;
            }
            else
            {
                CreatedBy = projectApiBase.GetEmployeeWraper(message.CreateBy);
                if (message.CreateBy != message.LastModifiedBy)
                {
                    UpdatedBy = projectApiBase.GetEmployeeWraper(message.LastModifiedBy);
                }
            }

            CanEdit          = ProjectSecurity.CanEdit(message);
            CommentsCount    = message.CommentsCount;
            Status           = (int)message.Status;
            CanCreateComment = ProjectSecurity.CanCreateComment(message);
        }
示例#8
0
 public TaskWrapperFull(Task task, Milestone milestone, ProjectWrapperFull project, IEnumerable <FileWrapper> files, IEnumerable <CommentInfo> comments, int commentsCount, bool isSubscribed, float timeSpend) : base(task, milestone)
 {
     Files            = files.ToList();
     CommentsCount    = commentsCount;
     IsSubscribed     = isSubscribed;
     Project          = project;
     CanEditFiles     = ProjectSecurity.CanEditFiles(task);
     CanCreateComment = ProjectSecurity.CanCreateComment(task);
     TimeSpend        = timeSpend;
     Comments         = comments.ToList();
 }
        private void ConfigureComments(CommentsList commentList, ProjectEntity taskToUpdate)
        {
            CommonControlsConfigurer.CommentsConfigure(commentList);
            var commentsCount = Page.EngineFactory.CommentEngine.Count(taskToUpdate);

            commentList.IsShowAddCommentBtn = ProjectSecurity.CanCreateComment(taskToUpdate);

            commentList.ObjectID = taskToUpdate != null?taskToUpdate.ID.ToString(CultureInfo.InvariantCulture) : "";

            commentList.BehaviorID         = "commentsObj";
            commentList.ModuleName         = "projects_" + typeof(T).Name;
            commentList.FckDomainName      = "projects_comments";
            commentList.OnRemovedCommentJS = "ASC.Projects.Common.removeComment";
            commentList.TotalCount         = commentsCount;
        }
示例#10
0
 public MessageWrapper(Message message)
 {
     Id = message.ID;
     if (message.Project != null)
     {
         ProjectOwner = new SimpleProjectWrapper(message.Project);
     }
     Title     = message.Title;
     Text      = message.Description;
     Created   = (ApiDateTime)message.CreateOn;
     CreatedBy = new EmployeeWraperFull(CoreContext.UserManager.GetUsers(message.CreateBy));
     Updated   = (ApiDateTime)message.LastModifiedOn;
     if (message.CreateBy != message.LastModifiedBy)
     {
         UpdatedBy = EmployeeWraper.Get(message.LastModifiedBy);
     }
     CanEdit          = ProjectSecurity.CanEdit(message);
     CommentsCount    = message.CommentsCount;
     Status           = message.Status;
     CanCreateComment = ProjectSecurity.CanCreateComment(message);
 }
        private static void ConfigureComments(CommentsList commentList, Message messageToUpdate)
        {
            CommonControlsConfigurer.CommentsConfigure(commentList);

            commentList.IsShowAddCommentBtn = ProjectSecurity.CanCreateComment();
            commentList.CommentsCountTitle  = messageToUpdate != null
                ? Global.EngineFactory.GetCommentEngine().Count(messageToUpdate).ToString(CultureInfo.InvariantCulture) : "";

            commentList.ObjectID = messageToUpdate != null
                ? messageToUpdate.ID.ToString(CultureInfo.InvariantCulture) : "";

            commentList.Simple     = false;
            commentList.BehaviorID = "commentsObj";
            commentList.JavaScriptAddCommentFunctionName        = "AjaxPro.DiscussionDetails.AddComment";
            commentList.JavaScriptLoadBBcodeCommentFunctionName = "AjaxPro.DiscussionDetails.LoadCommentBBCode";
            commentList.JavaScriptPreviewCommentFunctionName    = "AjaxPro.DiscussionDetails.GetPreview";
            commentList.JavaScriptRemoveCommentFunctionName     = "AjaxPro.DiscussionDetails.RemoveComment";
            commentList.JavaScriptUpdateCommentFunctionName     = "AjaxPro.DiscussionDetails.UpdateComment";
            commentList.FckDomainName = "projects_comments";
            commentList.TotalCount    = messageToUpdate != null?Global.EngineFactory.GetCommentEngine().Count(messageToUpdate) : 0;
        }
        private CommentInfo GetCommentInfo(Comment comment, ProjectEntity entity)
        {
            var creator      = EngineFactory.ParticipantEngine.GetByID(comment.CreateBy).UserInfo;
            var oCommentInfo = new CommentInfo
            {
                TimeStamp             = comment.CreateOn,
                TimeStampStr          = comment.CreateOn.Ago(),
                CommentBody           = comment.Content,
                CommentID             = comment.OldGuidId.ToString(),
                UserID                = comment.CreateBy,
                UserFullName          = creator.DisplayUserName(),
                UserProfileLink       = creator.GetUserProfilePageURL(),
                Inactive              = comment.Inactive,
                IsEditPermissions     = ProjectSecurity.CanEditComment(entity != null ? entity.Project : null, comment),
                IsResponsePermissions = ProjectSecurity.CanCreateComment(entity),
                IsRead                = true,
                UserAvatarPath        = creator.GetBigPhotoURL(),
                UserPost              = creator.Title
            };

            return(oCommentInfo);
        }
        private string GetHTMLComment(Comment comment, bool isPreview)
        {
            var creator     = Global.EngineFactory.GetParticipantEngine().GetByID(comment.CreateBy);
            var commentInfo = new CommentInfo
            {
                CommentID    = comment.ID.ToString(),
                UserID       = comment.CreateBy,
                TimeStamp    = comment.CreateOn,
                TimeStampStr = comment.CreateOn.Ago(),
                UserPost     = creator.UserInfo.Title,
                IsRead       = true,
                Inactive     = comment.Inactive,
                CommentBody  = comment.Content,
                UserFullName = DisplayUserSettings.GetFullUserName(creator.UserInfo),
                UserAvatar   = Global.GetHTMLUserAvatar(creator.UserInfo)
            };

            var defComment = new CommentsList();

            ConfigureComments(defComment, null);

            if (!isPreview)
            {
                var targetID = Convert.ToInt32(comment.TargetUniqID.Split('_')[1]);

                var target = Global.EngineFactory.GetMessageEngine().GetByID(targetID);
                Discussion = target;

                commentInfo.IsEditPermissions     = ProjectSecurity.CanEditComment(Discussion, comment);
                commentInfo.IsResponsePermissions = ProjectSecurity.CanCreateComment(Discussion);
                commentInfo.IsRead = true;
            }

            return(CommentsHelper.GetOneCommentHtmlWithContainer(
                       defComment,
                       commentInfo,
                       comment.Parent == Guid.Empty,
                       false));
        }
示例#14
0
        private static void ConfigureComments(CommentsList commentList, Task taskToUpdate)
        {
            var commentsCount = Global.EngineFactory.GetCommentEngine().Count(taskToUpdate);

            CommonControlsConfigurer.CommentsConfigure(commentList);

            commentList.IsShowAddCommentBtn = ProjectSecurity.CanCreateComment();

            commentList.CommentsCountTitle = commentsCount != 0 ? commentsCount.ToString() : "";

            commentList.ObjectID = taskToUpdate != null?taskToUpdate.ID.ToString() : "";

            commentList.Simple     = false;
            commentList.BehaviorID = "commentsObj";
            commentList.JavaScriptAddCommentFunctionName        = "AjaxPro.TaskDescriptionView.AddComment";
            commentList.JavaScriptLoadBBcodeCommentFunctionName = "AjaxPro.TaskDescriptionView.LoadCommentBBCode";
            commentList.JavaScriptPreviewCommentFunctionName    = "AjaxPro.TaskDescriptionView.GetPreview";
            commentList.JavaScriptRemoveCommentFunctionName     = "AjaxPro.TaskDescriptionView.RemoveComment";
            commentList.JavaScriptUpdateCommentFunctionName     = "AjaxPro.TaskDescriptionView.UpdateComment";
            commentList.FckDomainName = "projects_comments";

            commentList.TotalCount = commentsCount;
        }
        private string GetHTMLComment(Comment comment, bool isPreview)
        {
            var commentInfo = new CommentInfo
            {
                CommentID    = comment.ID.ToString(),
                UserID       = comment.CreateBy,
                TimeStamp    = comment.CreateOn,
                TimeStampStr = comment.CreateOn.Ago(),
                UserPost     = Global.EngineFactory.GetParticipantEngine().GetByID(comment.CreateBy).UserInfo.Title,
                IsRead       = true,
                Inactive     = comment.Inactive,
                CommentBody  = comment.Content,
                UserFullName = DisplayUserSettings.GetFullUserName(
                    Global.EngineFactory.GetParticipantEngine().GetByID(comment.CreateBy).UserInfo),
                UserAvatar = Global.GetHTMLUserAvatar(comment.CreateBy)
            };

            var defComment = new CommentsList();

            ConfigureComments(defComment, null);

            if (!isPreview)
            {
                commentInfo.IsEditPermissions     = ProjectSecurity.CanEditComment(Discussion.Project, comment);
                commentInfo.IsResponsePermissions = ProjectSecurity.CanCreateComment();

                var when = Global.EngineFactory.GetParticipantEngine().WhenReaded(Page.Participant.ID, Discussion.UniqID);
                commentInfo.IsRead = when.HasValue && when.Value > comment.CreateOn;
            }

            return(CommentsHelper.GetOneCommentHtmlWithContainer(
                       defComment,
                       commentInfo,
                       comment.Parent == Guid.Empty,
                       false));
        }