public virtual Project SaveOrUpdate(Project project, bool notifyManager, bool isImport) { if (project == null) { throw new ArgumentNullException("project"); } // check guest responsible if (ProjectSecurity.IsVisitor(project.Responsible)) { ProjectSecurity.CreateGuestSecurityException(); } project.LastModifiedBy = SecurityContext.CurrentAccount.ID; project.LastModifiedOn = TenantUtil.DateTimeNow(); if (project.ID == 0) { if (project.CreateBy == default(Guid)) { project.CreateBy = SecurityContext.CurrentAccount.ID; } if (project.CreateOn == default(DateTime)) { project.CreateOn = TenantUtil.DateTimeNow(); } ProjectSecurity.DemandCreate <Project>(null); DaoFactory.ProjectDao.Create(project); FactoryIndexer <ProjectsWrapper> .IndexAsync(project); } else { var oldProject = DaoFactory.ProjectDao.GetById(new List <int> { project.ID }).FirstOrDefault(); ProjectSecurity.DemandEdit(oldProject); DaoFactory.ProjectDao.Update(project); if (!project.Private) { ResetTeamSecurity(oldProject); } FactoryIndexer <ProjectsWrapper> .UpdateAsync(project); } if (notifyManager && !DisableNotifications && !project.Responsible.Equals(SecurityContext.CurrentAccount.ID)) { NotifyClient.Instance.SendAboutResponsibleByProject(project.Responsible, project); } return(project); }
public List <ReportTemplate> GetAutoTemplates() { if (ProjectSecurity.IsVisitor(SecurityContext.CurrentAccount.ID)) { throw new SecurityException("Access denied."); } return(DaoFactory.ReportDao.GetAutoTemplates()); }
public ReportTemplate SaveTemplate(ReportTemplate template) { if (ProjectSecurity.IsVisitor(SecurityContext.CurrentAccount.ID)) { throw new SecurityException("Access denied."); } return(DaoFactory.ReportDao.SaveTemplate(template)); }
public ReportFile GetByFileId(int fileid) { if (ProjectSecurity.IsVisitor(SecurityContext.CurrentAccount.ID)) { throw new SecurityException("Access denied."); } return(DaoFactory.ReportDao.GetByFileId(fileid)); }
public IEnumerable <ReportFile> Get() { if (ProjectSecurity.IsVisitor(SecurityContext.CurrentAccount.ID)) { throw new SecurityException("Access denied."); } return(DaoFactory.ReportDao.Get()); }
public void DeleteTemplate(int id) { if (ProjectSecurity.IsVisitor(SecurityContext.CurrentAccount.ID)) { throw new SecurityException("Access denied."); } DaoFactory.ReportDao.DeleteTemplate(id); }
public ReportTemplate GetTemplate(int id) { if (ProjectSecurity.IsVisitor(SecurityContext.CurrentAccount.ID)) { throw new SecurityException("Access denied."); } return(reportDao.GetTemplate(id)); }
public List <ReportTemplate> GetTemplates(Guid userId) { if (ProjectSecurity.IsVisitor(SecurityContext.CurrentAccount.ID)) { throw new SecurityException("Access denied."); } return(reportDao.GetTemplates(userId)); }
public void Remove(ReportFile report) { if (ProjectSecurity.IsVisitor(SecurityContext.CurrentAccount.ID)) { throw new SecurityException("Access denied."); } DaoFactory.ReportDao.Remove(report); FileEngine.MoveToTrash(report.FileId); }
public TimeSpend SaveOrUpdate(TimeSpend timeSpend) { ProjectSecurity.DemandEdit(timeSpend); // check guest responsible if (ProjectSecurity.IsVisitor(timeSpend.Person)) { ProjectSecurity.CreateGuestSecurityException(); } timeSpend.CreateOn = DateTime.UtcNow; return(timeSpendDao.Save(timeSpend)); }
public ReportTemplate SaveTemplate(ReportTemplate template) { if (template == null) { throw new ArgumentNullException("template"); } if (ProjectSecurity.IsVisitor(SecurityContext.CurrentAccount.ID)) { throw new SecurityException("Access denied."); } if (template.CreateOn == default(DateTime)) { template.CreateOn = TenantUtil.DateTimeNow(); } if (template.CreateBy.Equals(Guid.Empty)) { template.CreateBy = SecurityContext.CurrentAccount.ID; } return(reportDao.SaveTemplate(template)); }
public Subtask SaveOrUpdate(Subtask subtask, Task task) { if (subtask == null) { throw new Exception("subtask.Task"); } if (task == null) { throw new ArgumentNullException("task"); } if (task.Status == TaskStatus.Closed) { throw new Exception("task can't be closed"); } // check guest responsible if (ProjectSecurity.IsVisitor(subtask.Responsible)) { ProjectSecurity.CreateGuestSecurityException(); } var isNew = subtask.ID == default(int); //Task is new var oldResponsible = Guid.Empty; subtask.LastModifiedBy = SecurityContext.CurrentAccount.ID; subtask.LastModifiedOn = TenantUtil.DateTimeNow(); if (isNew) { if (subtask.CreateBy == default(Guid)) { subtask.CreateBy = SecurityContext.CurrentAccount.ID; } if (subtask.CreateOn == default(DateTime)) { subtask.CreateOn = TenantUtil.DateTimeNow(); } ProjectSecurity.DemandEdit(task); subtask = DaoFactory.SubtaskDao.Save(subtask); } else { var oldSubtask = DaoFactory.SubtaskDao.GetById(new[] { subtask.ID }).First(); if (oldSubtask == null) { throw new ArgumentNullException("subtask"); } oldResponsible = oldSubtask.Responsible; //changed task ProjectSecurity.DemandEdit(task, oldSubtask); subtask = DaoFactory.SubtaskDao.Save(subtask); } NotifySubtask(task, subtask, isNew, oldResponsible); var senders = new HashSet <Guid> { subtask.Responsible, subtask.CreateBy }; senders.Remove(Guid.Empty); foreach (var sender in senders) { Subscribe(task, sender); } return(subtask); }
public Milestone SaveOrUpdate(Milestone milestone, bool notifyResponsible, bool import) { if (milestone == null) { throw new ArgumentNullException("milestone"); } if (milestone.Project == null) { throw new Exception("milestone.project is null"); } if (milestone.Responsible.Equals(Guid.Empty)) { throw new Exception("milestone.responsible is empty"); } // check guest responsible if (ProjectSecurity.IsVisitor(milestone.Responsible)) { ProjectSecurity.CreateGuestSecurityException(); } milestone.LastModifiedBy = SecurityContext.CurrentAccount.ID; milestone.LastModifiedOn = TenantUtil.DateTimeNow(); var isNew = milestone.ID == default(int);//Task is new var oldResponsible = Guid.Empty; if (isNew) { if (milestone.CreateBy == default(Guid)) { milestone.CreateBy = SecurityContext.CurrentAccount.ID; } if (milestone.CreateOn == default(DateTime)) { milestone.CreateOn = TenantUtil.DateTimeNow(); } ProjectSecurity.DemandCreate <Milestone>(milestone.Project); milestone = DaoFactory.MilestoneDao.Save(milestone); } else { var oldMilestone = DaoFactory.MilestoneDao.GetById(new[] { milestone.ID }).FirstOrDefault(); if (oldMilestone == null) { throw new ArgumentNullException("milestone"); } oldResponsible = oldMilestone.Responsible; ProjectSecurity.DemandEdit(milestone); milestone = DaoFactory.MilestoneDao.Save(milestone); } if (!milestone.Responsible.Equals(Guid.Empty)) { NotifyMilestone(milestone, notifyResponsible, isNew, oldResponsible); } FactoryIndexer <MilestonesWrapper> .IndexAsync(milestone); return(milestone); }
public Task SaveOrUpdate(Task task, IEnumerable <int> attachedFileIds, bool notifyResponsible, bool isImport) { if (task == null) { throw new ArgumentNullException("task"); } if (task.Project == null) { throw new Exception("task.Project"); } // check guests responsibles foreach (var responsible in task.Responsibles) { if (ProjectSecurity.IsVisitor(responsible)) { ProjectSecurity.CreateGuestSecurityException(); } } var milestone = task.Milestone != 0 ? milestoneDao.GetById(task.Milestone) : null; var milestoneResponsible = milestone != null ? milestone.Responsible : Guid.Empty; var removeResponsibles = new List <Guid>(); var inviteToResponsibles = new List <Guid>(); task.LastModifiedBy = SecurityContext.CurrentAccount.ID; task.LastModifiedOn = TenantUtil.DateTimeNow(); var isNew = task.ID == default(int); //Task is new if (isNew) { if (task.CreateBy == default(Guid)) { task.CreateBy = SecurityContext.CurrentAccount.ID; } if (task.CreateOn == default(DateTime)) { task.CreateOn = TenantUtil.DateTimeNow(); } ProjectSecurity.DemandCreateTask(task.Project); task = taskDao.Save(task); inviteToResponsibles.AddRange(task.Responsibles.Distinct()); } else { var oldTask = GetByID(new[] { task.ID }).FirstOrDefault(); if (oldTask == null) { throw new ArgumentNullException("task"); } var newResponsibles = task.Responsibles.Distinct().ToList(); var oldResponsibles = oldTask.Responsibles.Distinct().ToList(); removeResponsibles.AddRange(oldResponsibles.Where(p => !newResponsibles.Contains(p))); inviteToResponsibles.AddRange(newResponsibles.Where(participant => !oldResponsibles.Contains(participant))); //changed task ProjectSecurity.DemandEdit(oldTask); task = taskDao.Save(task); } if (attachedFileIds != null && attachedFileIds.Any()) { foreach (var attachedFileId in attachedFileIds) { AttachFile(task, attachedFileId, false); } } var senders = new HashSet <Guid>(task.Responsibles) { task.Project.Responsible, milestoneResponsible, task.CreateBy }; senders.Remove(Guid.Empty); foreach (var subscriber in senders) { Subscribe(task, subscriber); } inviteToResponsibles.RemoveAll(r => r.Equals(Guid.Empty)); removeResponsibles.RemoveAll(r => r.Equals(Guid.Empty)); NotifyTask(task, inviteToResponsibles, removeResponsibles, isNew, notifyResponsible); return(task); }