Esempio n. 1
0
        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.DemandCreateProject();

                projectDao.Save(project);
            }
            else
            {
                var oldProject = projectDao.GetById(new[] { project.ID }).FirstOrDefault();
                ProjectSecurity.DemandEdit(oldProject);

                projectDao.Save(project);

                if (!project.Private)
                {
                    ResetTeamSecurity(oldProject);
                }
            }

            if (notifyManager && !factory.DisableNotifications && !project.Responsible.Equals(SecurityContext.CurrentAccount.ID))
            {
                NotifyClient.Instance.SendAboutResponsibleByProject(project.Responsible, project);
            }

            return(project);
        }
Esempio n. 2
0
        public virtual Project SaveOrUpdate(Project project, bool notifyManager, bool isImport)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            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.DemandCreateProject();
                projectDao.Save(project);

                TimeLinePublisher.Project(project, isImport ? EngineResource.ActionText_Imported: EngineResource.ActionText_Create, UserActivityConstants.ContentActionType, UserActivityConstants.Max);
            }
            else
            {
                ProjectSecurity.DemandEdit(project);
                projectDao.Save(project);

                if (!project.Private)
                {
                    ResetTeamSecurity(project);
                }

                TimeLinePublisher.Project(project, EngineResource.ActionText_Update, UserActivityConstants.ActivityActionType, UserActivityConstants.Max);
            }

            if (notifyManager && !_factory.DisableNotifications && !project.Responsible.Equals(SecurityContext.CurrentAccount.ID))
            {
                NotifyClient.Instance.SendAboutResponsibleByProject(project.Responsible, project);
            }

            return(project);
        }