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);
        }
Esempio n. 2
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)
            });
        }
Esempio n. 3
0
 private void ChechDocBuilder()
 {
     ProjectSecurity.DemandAuthentication();
     if (string.IsNullOrEmpty(FilesLinkUtility.DocServiceDocbuilderUrl))
     {
         throw ProjectSecurity.CreateSecurityException();
     }
 }
Esempio n. 4
0
        public IEnumerable <MessageWrapper> GetProjectMessages(int projectid)
        {
            var project = EngineFactory.ProjectEngine.GetByID(projectid).NotFoundIfNull();

            if (!ProjectSecurity.CanReadMessages(project))
            {
                throw ProjectSecurity.CreateSecurityException();
            }

            return(EngineFactory.MessageEngine.GetByProject(projectid).Select(x => new MessageWrapper(x)));
        }
        public ProjectsCommonSettings UpdateSettings(bool?everebodyCanCreate,
                                                     bool?hideEntitiesInPausedProjects,
                                                     StartModuleType?startModule,
                                                     object folderId)
        {
            if (everebodyCanCreate.HasValue || hideEntitiesInPausedProjects.HasValue)
            {
                if (!ProjectSecurity.CurrentUserAdministrator)
                {
                    ProjectSecurity.CreateSecurityException();
                }

                var settings = ProjectsCommonSettings.Load();

                if (everebodyCanCreate.HasValue)
                {
                    settings.EverebodyCanCreate = everebodyCanCreate.Value;
                }

                if (hideEntitiesInPausedProjects.HasValue)
                {
                    settings.HideEntitiesInPausedProjects = hideEntitiesInPausedProjects.Value;
                }

                settings.Save();
                return(settings);
            }

            if (startModule.HasValue || folderId != null)
            {
                if (!ProjectSecurity.IsProjectsEnabled(CurrentUserId))
                {
                    ProjectSecurity.CreateSecurityException();
                }
                var settings = ProjectsCommonSettings.LoadForCurrentUser();
                if (startModule.HasValue)
                {
                    settings.StartModuleType = startModule.Value;
                }

                if (folderId != null)
                {
                    settings.FolderId = folderId;
                }

                settings.SaveForCurrentUser();
                return(settings);
            }

            return(null);
        }
Esempio n. 6
0
        public TaskWrapper DeleteTask(int taskid)
        {
            var taskEngine = EngineFactory.GetTaskEngine();
            var task       = taskEngine.GetByID(taskid).NotFoundIfNull();

            if (!ProjectSecurity.CanDelete(task))
            {
                throw ProjectSecurity.CreateSecurityException();
            }

            taskEngine.Delete(task);

            return(new TaskWrapper(task));
        }