예제 #1
0
 public ActionResult Create(Project project)
 {
     try
     {
         CurrentUserModel.CreateProject (project);
         return RedirectToAction ("CreateInitial", "Source", new { projectId = project.Id });
     }
     catch (Exception ex)
     {
         return Content (ex.ToString ());
     }
 }
예제 #2
0
        public void UpdateProject(Project p)
        {
            ValidateProject (p.Id);
            db.UpdateObject (p);

            string subject = "Project modified: " + p.Name;
            StringBuilder msg = new StringBuilder ();
            msg.AppendLine ("A project has been modified.");
            msg.AppendLine ();
            msg.AppendLine ("Name: " + p.Name);
            msg.AppendLine ("Modified 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 (), p.Id, ProjectNotification.DescriptionChage, ApplicationNotification.ProjectDescriptionChage);
        }
예제 #3
0
 public IEnumerable<User> GetProjectOwners(Project p)
 {
     return db.SelectObjects<User> ("SELECT User.* FROM User, UserProject, Project WHERE Project.Id = UserProject.ProjectId AND User.Id = UserProject.UserId AND UserProject.ProjectId = {0} AND UserProject.Permissions & {1} != 0 AND Project.ApplicationId={2}", p.Id, (int)ProjectPermission.Administer, application.Id);
 }
예제 #4
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);
        }
예제 #5
0
 public bool CanManageProject(Project pr)
 {
     return CanManageProject (pr.Id);
 }
예제 #6
0
 public SourceInfo(Project p, VcsSource s, SourceTagInfo[] stags)
 {
     Id = s.Id;
     ProjectName = p.Name;
     ProjectId = p.Id;
     Type = s.Type;
     Url = s.Url;
     Tags = s.Tags;
     Branches = s.Branches;
     LastFetchTime = s.LastFetchTime;
     AutoPublish = s.AutoPublish;
     Directory = s.Directory;
     SourceTags = stags;
     ProjectFlags = p.Flags;
 }
예제 #7
0
 public ActionResult Edit(Project project)
 {
     try
     {
         Project p = CurrentUserModel.GetProject (project.Id);
         p.Name = project.Name;
         p.Description = project.Description;
         CurrentUserModel.UpdateProject (p);
         return RedirectToAction ("Index", new { id = project.Id });
     }
     catch (Exception ex)
     {
         return Content (ex.ToString ());
     }
 }
예제 #8
0
        public string GetDownloadSummary(Project p)
        {
            int total = 0;
            Dictionary<string,int> platforms = new Dictionary<string, int> ();

            foreach (Release rel in userModel.GetProjectReleases (p.Id)) {
                foreach (string plat in rel.PlatformsList) {
                    using (DbDataReader r = db.ExecuteSelect ("SELECT SUM(Downloads) Total FROM ReleasePackage WHERE ReleaseId={0} AND Platform={1}", rel.Id, plat)) {
                        if (r.Read ()) {
                            int ptotal = r.IsDBNull (0) ? 0 : r.GetInt32 (0);
                            if (ptotal > 0) {
                                int c = 0;
                                platforms.TryGetValue (plat, out c);
                                c += ptotal;
                                platforms [plat] = c;
                                total += ptotal;
                            }
                        }
                    }
                }
            }
            StringBuilder sb = new StringBuilder ();
            sb.Append (total);
            if (platforms.Count > 0) {
                sb.Append (" (");
                List<KeyValuePair<string,int>> list = platforms.ToList ();
                list.Sort (delegate (KeyValuePair<string,int> a, KeyValuePair<string,int> b) {
                    return a.Key.CompareTo (b.Key);
                });
                for (int n=0; n<list.Count; n++) {
                    if (n > 0)
                        sb.Append (", ");
                    sb.Append (list [n].Value).Append (" ").Append (list[n].Key);
                }
                sb.Append (")");
            }
            return sb.ToString ();
        }
예제 #9
0
파일: UserModel.cs 프로젝트: garuma/cydin
        public string GetDownloadSummary(Project p)
        {
            int total = 0;
            Dictionary<string,int> platforms = new Dictionary<string, int> ();

            foreach (Release rel in GetProjectReleases (p.Id)) {
                foreach (ReleasePackage rp in db.SelectObjectsWhere<ReleasePackage> ("ReleaseId={0}", rel.Id)) {
                    if (rp.Downloads > 0) {
                        int c = 0;
                        platforms.TryGetValue (rp.Platform, out c);
                        c += rp.Downloads;
                        platforms [rp.Platform] = c;
                        total += rp.Downloads;
                    }
                }
            }
            StringBuilder sb = new StringBuilder ();
            sb.Append (total);
            if (platforms.Count > 0) {
                sb.Append (" (");
                List<KeyValuePair<string,int>> list = platforms.ToList ();
                list.Sort (delegate (KeyValuePair<string,int> a, KeyValuePair<string,int> b) {
                    return a.Key.CompareTo (b.Key);
                });
                for (int n=0; n<list.Count; n++) {
                    if (n > 0)
                        sb.Append (", ");
                    sb.Append (list [n].Key).Append (" ").Append (list[n].Value);
                }
                sb.Append (")");
            }
            return sb.ToString ();
        }