public CommentWrapper AddTaskComments(int taskid, string content, Guid parentid)
        {
            if (string.IsNullOrEmpty(content))
            {
                throw new ArgumentException(@"Comment text is empty", content);
            }
            if (parentid != Guid.Empty && EngineFactory.CommentEngine.GetByID(parentid) == null)
            {
                throw new ItemNotFoundException("parent comment not found");
            }

            var comment = new Comment
            {
                Content      = content,
                TargetUniqID = ProjectEntity.BuildUniqId <Task>(taskid),
                CreateBy     = CurrentUserId,
                CreateOn     = Core.Tenants.TenantUtil.DateTimeNow()
            };

            if (parentid != Guid.Empty)
            {
                comment.Parent = parentid;
            }

            var task = EngineFactory.CommentEngine.GetEntityByTargetUniqId(comment).NotFoundIfNull();

            EngineFactory.CommentEngine.SaveOrUpdateComment(task, comment);

            MessageService.Send(Request, MessageAction.TaskCommentCreated, MessageTarget.Create(comment.ID), task.Project.Title, task.Title);

            return(new CommentWrapper(this, comment, task));
        }
Пример #2
0
        public AjaxResponse AddComment(string parrentCommentID, string messageID, string text, string pid)
        {
            ProjectSecurity.DemandCreateComment();

            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);
            }

            var messageEngine = Global.EngineFactory.GetMessageEngine();

            Discussion = messageEngine.GetByID(Convert.ToInt32(messageID));

            if (Discussion == null)
            {
                return new AjaxResponse {
                           status = "error", message = "Access denied."
                }
            }
            ;

            messageEngine.SaveOrUpdateComment(Discussion, comment);
            resp.rs2 = GetHTMLComment(comment);
            return(resp);
        }
Пример #3
0
        public CommentWrapper AddProjectMessagesComment(int messageid, string content, Guid parentId)
        {
            if (string.IsNullOrEmpty(content))
            {
                throw new ArgumentException(@"Comment text is empty", content);
            }
            if (parentId != Guid.Empty && EngineFactory.CommentEngine.GetByID(parentId) == null)
            {
                throw new ItemNotFoundException("parent comment not found");
            }

            var comment = new Comment
            {
                Content      = content,
                TargetUniqID = ProjectEntity.BuildUniqId <Message>(messageid),
                CreateBy     = CurrentUserId,
                CreateOn     = Core.Tenants.TenantUtil.DateTimeNow()
            };

            if (parentId != Guid.Empty)
            {
                comment.Parent = parentId;
            }

            var message = EngineFactory.CommentEngine.GetEntityByTargetUniqId(comment).NotFoundIfNull();

            EngineFactory.CommentEngine.SaveOrUpdateComment(message, comment);

            MessageService.Send(Request, MessageAction.DiscussionCommentCreated, message.Project.Title, message.Title);

            return(new CommentWrapper(comment, message));
        }
        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);
        }
Пример #5
0
        public CommentWrapper AddTaskComments(int taskid, string content, Guid parentid)
        {
            if (string.IsNullOrEmpty(content))
            {
                throw new ArgumentException(@"Comment text is empty", content);
            }
            if (parentid != Guid.Empty && EngineFactory.GetCommentEngine().GetByID(parentid) == null)
            {
                throw new ItemNotFoundException("parent comment not found");
            }

            var comment = new Comment
            {
                Content      = content,
                TargetUniqID = ProjectEntity.BuildUniqId <Task>(taskid),
                CreateBy     = CurrentUserId,
                CreateOn     = Core.Tenants.TenantUtil.DateTimeNow()
            };

            if (parentid != Guid.Empty)
            {
                comment.Parent = parentid;
            }

            EngineFactory.GetTaskEngine().SaveOrUpdateTaskComment(EngineFactory.GetTaskEngine().GetByID(taskid).NotFoundIfNull(), comment);
            return(new CommentWrapper(comment));
        }
Пример #6
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)
            });
        }
Пример #7
0
        public AjaxResponse AddComment(string parrentCommentID, int taskID, string text, string pid)
        {
            var taskEngine = Global.EngineFactory.GetTaskEngine();

            ProjectSecurity.DemandCreateComment();

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

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

            Task = taskEngine.GetByID(taskID);

            if (Task == null)
            {
                return new AjaxResponse {
                           status = "error", message = "Access denied."
                }
            }
            ;

            taskEngine.SaveOrUpdateComment(Task, comment);

            return(new AjaxResponse {
                rs1 = parrentCommentID, rs2 = GetHTMLComment(comment)
            });
        }
Пример #8
0
        public AjaxResponse AddComment(string parrentCommentID, int taskID, string text, string pid)
        {
            text = HtmlUtility.GetFull(text);
            var taskEngine = Global.EngineFactory.GetTaskEngine();

            ProjectSecurity.DemandCreateComment();

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

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

            Task = taskEngine.GetByID(taskID);

            if (Task == null)
            {
                return new AjaxResponse {
                           status = "error", message = "Access denied."
                }
            }
            ;

            comment = taskEngine.SaveOrUpdateComment(Task, comment);
            MessageService.Send(HttpContext.Current.Request, MessageAction.TaskCommentCreated, Task.Project.Title, Task.Title);

            return(new AjaxResponse {
                rs1 = parrentCommentID, rs2 = GetHTMLComment(comment)
            });
        }
        public CommentWrapper AddMilestoneComment(int id, string content, Guid parentId)
        {
            var milestone = EngineFactory.GetMilestoneEngine().GetByID(id).NotFoundIfNull();

            if (string.IsNullOrEmpty(content))
            {
                throw new ArgumentException(@"Comment text is empty", "content");
            }
            if (parentId != Guid.Empty && EngineFactory.GetCommentEngine().GetByID(parentId) == null)
            {
                throw new ItemNotFoundException("parent comment not found");
            }

            var comment = new Comment
            {
                Content      = content,
                TargetUniqID = ProjectEntity.BuildUniqId <Milestone>(id),
                CreateBy     = CurrentUserId,
                CreateOn     = Core.Tenants.TenantUtil.DateTimeNow()
            };

            if (parentId != Guid.Empty)
            {
                comment.Parent = parentId;
            }

            EngineFactory.GetMilestoneEngine().SaveMilestoneComment(milestone, comment);
            return(new CommentWrapper(comment));
        }
Пример #10
0
        public CommentWrapper AddProjectMessagesComment(int messageid, string content, Guid parentId)
        {
            var messageEngine = EngineFactory.GetMessageEngine();
            var commentEngine = EngineFactory.GetCommentEngine();

            if (!messageEngine.IsExists(messageid))
            {
                throw new ItemNotFoundException();
            }
            if (string.IsNullOrEmpty(content))
            {
                throw new ArgumentException(@"Comment text is empty", content);
            }
            if (parentId != Guid.Empty && commentEngine.GetByID(parentId) == null)
            {
                throw new ItemNotFoundException("parent comment not found");
            }

            var comment = new Comment
            {
                Content      = content,
                TargetUniqID = ProjectEntity.BuildUniqId <Message>(messageid),
                CreateBy     = CurrentUserId,
                CreateOn     = Core.Tenants.TenantUtil.DateTimeNow()
            };

            if (parentId != Guid.Empty)
            {
                comment.Parent = parentId;
            }

            messageEngine.SaveOrUpdateComment(messageEngine.GetByID(messageid).NotFoundIfNull(), comment);
            return(new CommentWrapper(comment));
        }
        public CommentInfo AddProjectComment(string parentcommentid, int entityid, string content, string type)
        {
            if (string.IsNullOrEmpty(type) || !(new List <string> {
                "message", "task"
            }).Contains(type.ToLower()))
            {
                throw new ArgumentException();
            }

            var isMessageComment = type.ToLower().Equals("message");
            var comment          = isMessageComment
                ? new Comment {
                Content = content, TargetUniqID = ProjectEntity.BuildUniqId <Message>(entityid)
            }
                : new Comment {
                Content = content, TargetUniqID = ProjectEntity.BuildUniqId <Task>(entityid)
            };


            if (!string.IsNullOrEmpty(parentcommentid))
            {
                comment.Parent = new Guid(parentcommentid);
            }

            var commentEngine = EngineFactory.CommentEngine;
            var entity        = commentEngine.GetEntityByTargetUniqId(comment).NotFoundIfNull();

            comment = commentEngine.SaveOrUpdateComment(entity, comment);

            MessageService.Send(Request, isMessageComment ? MessageAction.DiscussionCommentCreated : MessageAction.TaskCommentCreated, MessageTarget.Create(comment.ID), entity.Project.Title, entity.Title);

            return(GetCommentInfo(null, comment, entity));
        }
Пример #12
0
        public virtual void Delete(int id)
        {
            using (var tx = Db.BeginTransaction())
            {
                Db.ExecuteNonQuery(Delete(CommentsTable).Where("target_uniq_id", ProjectEntity.BuildUniqId <Message>(id)));
                Db.ExecuteNonQuery(Delete(MessagesTable).Where("id", id));

                tx.Commit();
            }
        }
Пример #13
0
        public virtual void Delete(int id)
        {
            using (var tx = Db.BeginTransaction())
            {
                Db.ExecuteNonQuery(Delete(CommentsTable).Where("target_uniq_id", ProjectEntity.BuildUniqId <Milestone>(id)));
                Db.ExecuteNonQuery(Update(TasksTable).Set("milestone_id", 0).Where("milestone_id", id));
                Db.ExecuteNonQuery(Delete(MilestonesTable).Where("id", id));

                tx.Commit();
            }
        }
Пример #14
0
        public virtual void Delete(int id)
        {
            using (var db = new DbManager(DatabaseId))
                using (var tx = db.BeginTransaction())
                {
                    db.ExecuteNonQuery(Delete(CommentsTable).Where("target_uniq_id", ProjectEntity.BuildUniqId <Task>(id)));
                    db.ExecuteNonQuery(Delete(TasksResponsibleTable).Where("task_id", id));
                    db.ExecuteNonQuery(Delete(TasksTable).Where("id", id));
                    db.ExecuteNonQuery(Delete(SubtasksTable).Where("task_id", id));

                    tx.Commit();
                }
        }
Пример #15
0
        public AjaxResponse AddComment(string parrentCommentID, string messageID, string text, string pid)
        {
            text = HtmlUtility.GetFull(text);
            ProjectSecurity.DemandCreateComment();

            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);
            }

            var messageEngine = Global.EngineFactory.GetMessageEngine();

            Discussion = messageEngine.GetByID(Convert.ToInt32(messageID));

            if (Discussion == null)
            {
                return new AjaxResponse {
                           status = "error", message = "Access denied."
                }
            }
            ;

            comment = messageEngine.SaveOrUpdateComment(Discussion, comment);
            MessageService.Send(HttpContext.Current.Request, MessageAction.DiscussionCommentCreated, Discussion.Project.Title, Discussion.Title);

            resp.rs2 = GetHTMLComment(comment);
            return(resp);
        }
Пример #16
0
        public CommentInfo AddProjectComment(string parentcommentid, int entityid, string content, string type)
        {
            if (string.IsNullOrEmpty(type) || !(new List <string> {
                "message", "task"
            }).Contains(type.ToLower()))
            {
                throw new ArgumentException();
            }

            var comment = type.ToLower().Equals("message")
                ? new Comment {
                Content = content, TargetUniqID = ProjectEntity.BuildUniqId <Message>(entityid)
            }
                : new Comment {
                Content = content, TargetUniqID = ProjectEntity.BuildUniqId <Task>(entityid)
            };


            if (!string.IsNullOrEmpty(parentcommentid))
            {
                comment.Parent = new Guid(parentcommentid);
            }

            var commentEngine = EngineFactory.CommentEngine;
            var entity        = commentEngine.GetEntityByTargetUniqId(comment);

            if (entity == null)
            {
                throw new Exception("Access denied.");
            }
            ProjectSecurity.DemandCreateComment(entity);

            comment = commentEngine.SaveOrUpdateComment(entity, comment);
            MessageService.Send(Request, MessageAction.TaskCommentCreated, entity.Project.Title, entity.Title);

            return(GetCommentInfo(comment, entity));
        }
Пример #17
0
        private void SaveTaskComments(IEnumerable <IComment> comments, int taskid)
        {
            var commentEngine = _engineFactory.CommentEngine;

            foreach (var comment in comments)
            {
                try
                {
                    var newComment = new Comment
                    {
                        CreateBy     = FindUser(comment.AuthorID),
                        Content      = comment.Body,
                        CreateOn     = comment.CreatedAt.ToUniversalTime(),
                        TargetUniqID = ProjectEntity.BuildUniqId <Task>(FindTask(taskid))
                    };
                    commentEngine.SaveOrUpdate(newComment);
                }
                catch (Exception e)
                {
                    StatusState.StatusLogError(string.Format(ImportResource.FailedToSaveComment, comment.ID), e);
                    LogError(string.Format("comment '{0}' failed", comment.ID), e);
                }
            }
        }
Пример #18
0
        private void SaveMessageComments(IComment[] comments, int messageid)
        {
            var commentEngine = _engineFactory.GetCommentEngine();

            foreach (var comment in comments)
            {
                try
                {
                    Comment newComment = new Comment()
                    {
                        CreateBy     = FindUser(comment.AuthorID),
                        Content      = comment.Body,
                        CreateOn     = comment.CreatedAt.ToUniversalTime(),
                        TargetUniqID = ProjectEntity.BuildUniqId <Message>(FindMessage(messageid))
                    };
                    commentEngine.SaveOrUpdate(newComment);
                }
                catch (Exception e)
                {
                    Status.LogError(string.Format(SettingsResource.FailedToSaveComment, comment.ID), e);
                    LogError(string.Format("comment '{0}' failed", comment.ID), e);
                }
            }
        }
Пример #19
0
        public virtual void Delete(int id)
        {
            using (var tx = DbManager.BeginTransaction())
            {
                DbManager.ExecuteNonQuery(Delete("projects_comments").Where("target_uniq_id", ProjectEntity.BuildUniqId <Milestone>(id)));
                DbManager.ExecuteNonQuery(Delete("projects_review_entity_info").Where("entity_uniqID", "Milestone_" + id));
                DbManager.ExecuteNonQuery(Update("projects_tasks").Set("milestone_id", 0).Where("milestone_id", id));
                DbManager.ExecuteNonQuery(Delete(table).Where("id", id));

                tx.Commit();
            }
        }
Пример #20
0
        public virtual void Delete(int id)
        {
            using (var tx = DbManager.BeginTransaction())
            {
                DbManager.ExecuteNonQuery(Delete("projects_comments").Where("target_uniq_id", ProjectEntity.BuildUniqId <Task>(id)));
                DbManager.ExecuteNonQuery(Delete("projects_review_entity_info").Where("entity_uniqID", "Task_" + id));
                DbManager.ExecuteNonQuery(Delete("projects_tasks_trace").Where("task_id", id));
                DbManager.ExecuteNonQuery(Delete(responsibleTable).Where("task_id", id));
                DbManager.ExecuteNonQuery(Delete(table).Where("id", id));

                tx.Commit();
            }
        }