Exemple #1
0
        public void CreateProject(Project p)
        {
            p.ApplicationId = application.Id;
            db.InsertObject(p);
            UserProject up = new UserProject();

            up.UserId      = user.Id;
            up.ProjectId   = p.Id;
            up.Permissions = ProjectPermission.Administer;
            db.InsertObject(up);

            string        subject = "Project created: " + p.Name;
            StringBuilder msg     = new StringBuilder();

            msg.AppendLine("A new project has been created.");
            msg.AppendLine();
            msg.AppendLine("Name: " + p.Name);
            msg.AppendLine("Created by: " + user.Name + " <" + user.Email + ">");
            msg.AppendLine();
            msg.AppendFormat("[Go to {0} Project Page]({1}).\n", p.Name, GetProjectUrl(p.Id));
            msg.AppendLine();
            msg.AppendLine("---");
            msg.AppendLine();
            msg.AppendLine(p.Description);

            SendMail(subject, msg.ToString(), ApplicationNotification.NewProject);
        }
Exemple #2
0
        public List <NotificationInfo> GetProjectNotifications(int projectId)
        {
            ProjectNotification notifs = (ProjectNotification)0;
            UserProject         up     = db.SelectObjectWhere <UserProject> ("UserId={0} AND ProjectId={1}", User.Id, projectId);

            if (up != null)
            {
                notifs = up.Notifications;
            }

            List <NotificationInfo> list = new List <NotificationInfo> ();

            list.Add(new NotificationInfo("New Add-in Release", ProjectNotification.NewRelease, notifs));

            if (CanManageProject(projectId))
            {
                list.Add(new NotificationInfo("Build Success", ProjectNotification.BuildSuccess, notifs));
                list.Add(new NotificationInfo("Build Error", ProjectNotification.BuildError, notifs));
            }

            if (IsAdmin)
            {
                list.Add(new NotificationInfo("Description Changed", ProjectNotification.DescriptionChage, notifs));
                list.Add(new NotificationInfo("Release Publish Request", ProjectNotification.PublishReleaseRequest, notifs));
            }
            return(list);
        }
Exemple #3
0
        public void RemoveProjectOwner(int projectId, int userId)
        {
            UserProject up = db.SelectObjectWhere <UserProject> ("UserId={0} AND ProjectId={1}", userId, projectId);

            if (up != null)
            {
                up.Permissions &= ~ProjectPermission.Administer;
                db.UpdateObject(up);
            }
        }
Exemple #4
0
        public void AddProjectOwner(int projectId, int userId)
        {
            UserProject up = db.SelectObjectWhere <UserProject> ("UserId={0} AND ProjectId={1}", userId, projectId);

            if (up == null)
            {
                up = new UserProject()
                {
                    UserId = userId, ProjectId = projectId, Permissions = ProjectPermission.Administer
                };
                db.InsertObject <UserProject> (up);
            }
            else
            {
                up.Permissions |= ProjectPermission.Administer;
                db.UpdateObject(up);
            }
        }
Exemple #5
0
        public void SetProjectNotification(ProjectNotification notif, int projectId, bool enable)
        {
            if ((notif & ProjectNotification.OwnerNotificationMask) != 0)
            {
                ValidateProject(projectId);
            }

            if ((notif & ProjectNotification.AdminNotificationMask) != 0)
            {
                CheckIsAdmin();
            }

            UserProject up = db.SelectObject <UserProject> ("SELECT * FROM UserProject WHERE UserId={0} AND ProjectId={1}", user.Id, projectId);

            if (enable)
            {
                if (up == null)
                {
                    up = new UserProject()
                    {
                        UserId = user.Id, ProjectId = projectId, Notifications = notif
                    };
                    db.InsertObject <UserProject> (up);
                }
                else
                {
                    up.Notifications |= notif;
                    db.UpdateObject(up);
                }
            }
            else if (up != null)
            {
                up.Notifications &= ~notif;
                db.UpdateObject(up);
            }
        }
Exemple #6
0
        public void SetProjectNotification(ProjectNotification notif, int projectId, bool enable)
        {
            if ((notif & ProjectNotification.OwnerNotificationMask) != 0)
                ValidateProject (projectId);

            if ((notif & ProjectNotification.AdminNotificationMask) != 0)
                CheckIsAdmin ();

            UserProject up = db.SelectObject<UserProject> ("SELECT * FROM UserProject WHERE UserId={0} AND ProjectId={1}", user.Id, projectId);
            if (enable) {
                if (up == null) {
                    up = new UserProject () { UserId = user.Id, ProjectId = projectId, Notifications = notif };
                    db.InsertObject<UserProject> (up);
                }
                else {
                    up.Notifications |= notif;
                    db.UpdateObject (up);
                }
            } else if (up != null) {
                up.Notifications &= ~notif;
                db.UpdateObject (up);
            }
        }
Exemple #7
0
        public void CreateProject(Project p)
        {
            p.ApplicationId = application.Id;
            db.InsertObject (p);
            UserProject up = new UserProject ();
            up.UserId = user.Id;
            up.ProjectId = p.Id;
            up.Permissions = ProjectPermission.Administer;
            db.InsertObject (up);

            string subject = "Project created: " + p.Name;
            StringBuilder msg = new StringBuilder ();
            msg.AppendLine ("A new project has been created.");
            msg.AppendLine ();
            msg.AppendLine ("Name: " + p.Name);
            msg.AppendLine ("Created by: " + user.Name + " <" + user.Email + ">");
            msg.AppendLine ();
            msg.AppendFormat ("[Go to {0} Project Page]({1}).\n", p.Name, GetProjectUrl (p.Id));
            msg.AppendLine ();
            msg.AppendLine ("---");
            msg.AppendLine ();
            msg.AppendLine (p.Description);

            SendMail (subject, msg.ToString (), ApplicationNotification.NewProject);
        }
Exemple #8
0
 public void AddProjectOwner(int projectId, int userId)
 {
     UserProject up = db.SelectObjectWhere<UserProject> ("UserId={0} AND ProjectId={1}", userId, projectId);
     if (up == null) {
         up = new UserProject () { UserId = userId, ProjectId = projectId, Permissions = ProjectPermission.Administer };
         db.InsertObject<UserProject> (up);
     }
     else {
         up.Permissions |= ProjectPermission.Administer;
         db.UpdateObject (up);
     }
 }