Beispiel #1
0
        public void SetPublished(Release rel)
        {
            rel.Status = ReleaseStatus.Published;
            rel.LastChangeTime = DateTime.Now;
            db.UpdateObject (rel);

            Project p = GetProject (rel.ProjectId);
            bool firstRelease = !p.IsPublic;
            if (!p.IsPublic) {
                p.IsPublic = true;
                db.UpdateObject (p);
            }

            if (rel.DevStatus != DevStatus.Test) {
                string subject = "New add-in release published: " + rel.AddinId + " v" + rel.Version;
                StringBuilder msg = new StringBuilder ();
                msg.AppendLine ("The add-in " + rel.AddinId + " v" + rel.Version + " has been released.");
                msg.AppendLine ();
                msg.AppendFormat ("[Go to {0} Project Page]({1}).\n", p.Name, GetProjectUrl (p.Id));

                if (firstRelease)
                    SendMail (subject, msg.ToString (), p.Id, ProjectNotification.NewRelease, ApplicationNotification.ProjectNewRelease, ApplicationNotification.FirstProjectRelease);
                else
                    SendMail (subject, msg.ToString (), p.Id, ProjectNotification.NewRelease, ApplicationNotification.ProjectNewRelease);
            }
        }
Beispiel #2
0
        public void CreateRelease(Release rel)
        {
            Release oldRel = db.SelectObjectWhere<Release> ("ProjectId={0} AND Version={1} AND AddinId={2} AND TargetAppVersion={3} AND Status={4}", rel.ProjectId, rel.Version, rel.AddinId, rel.TargetAppVersion, ReleaseStatus.Deleted);
            if (oldRel != null) {
                rel.Id = oldRel.Id;
                db.UpdateObject (rel);
            }
            else
                db.InsertObject (rel);

            BindDownloadInfo (rel);

            Project p = GetProject (rel.ProjectId);

            if (rel.Status == ReleaseStatus.PendingReview) {
                string subject = "Add-in release review pending: " + rel.AddinId + " v" + rel.Version;
                StringBuilder msg = new StringBuilder ();
                msg.AppendLine ("The user '" + user.Name + "' has requested the publication of the release of the add-in " + rel.AddinId + " v" + rel.Version + ".");
                msg.AppendLine ();
                msg.AppendFormat ("[Go to {0} Project Page]({1}).\n", p.Name, GetProjectUrl (p.Id));
                msg.AppendFormat ("[Go to Review Page]({0}/Review).", GetBaseUrl ());
                SendMail (subject, msg.ToString (), p.Id, ProjectNotification.PublishReleaseRequest, ApplicationNotification.ProjectPublishReleaseRequest);
            }
        }
Beispiel #3
0
 public void DeleteRelease(Release rel)
 {
     ValidateProject (rel.ProjectId);
     bool requiresRebuild = rel.Status == ReleaseStatus.Published;
     if (db.SelectObjectWhere<ReleasePackage> ("ReleaseId = {0} AND Downloads != 0", rel.Id) != null) {
         // If the release has download information, don't remove it, just mark it as deleted
         rel = db.SelectObjectById<Release> (rel.Id);
         rel.Status = ReleaseStatus.Deleted;
         db.UpdateObject (rel);
     }
     else {
         // No downloads. Delete it all
         db.DeleteObject (rel);
     }
     if (requiresRebuild)
         BuildService.UpdateRepositories (false);
 }
Beispiel #4
0
 internal static void GenerateInstallerXml(TextWriter sw, UserModel m, Release rel, params string[] platforms)
 {
     XmlTextWriter tw = new XmlTextWriter (sw);
     tw.Formatting = Formatting.Indented;
     tw.WriteStartElement ("Package");
     tw.WriteStartElement ("Repositories");
     foreach (string plat in platforms) {
         tw.WriteStartElement ("Repository");
         tw.WriteAttributeString ("platform", plat);
         tw.WriteAttributeString ("appVersion", rel.TargetAppVersion);
         string url = "http://" + Settings.Default.WebSiteHost + "/" + rel.DevStatus.ToString() + "/" + plat + "/" + rel.TargetAppVersion;
         tw.WriteString (url);
         tw.WriteEndElement (); // Repository
     }
     tw.WriteEndElement (); // Repositories
     tw.WriteStartElement ("Addins");
     tw.WriteStartElement ("Addin");
     tw.WriteElementString ("Id", rel.AddinId);
     tw.WriteElementString ("Version", rel.Version);
     tw.WriteElementString ("Name", rel.AddinName);
     tw.WriteElementString ("Description", rel.AddinDescription);
     tw.WriteEndElement (); // Addin
     tw.WriteEndElement (); // Addins
     tw.WriteEndElement (); // Package
 }
Beispiel #5
0
 public void BindDownloadInfo(Release rel)
 {
     foreach (string plat in rel.PlatformsList) {
         // Make sure there is at least one ReleasePackage register for this platform
         string fid = rel.GetReleasePackageId (plat);
         ReleasePackage rp = db.SelectObjectWhere<ReleasePackage> ("FileId={0}", fid);
         if (rp == null) {
             rp = new ReleasePackage ();
             rp.ReleaseId = rel.Id;
             rp.FileId = fid;
             rp.Date = DateTime.Now;
             rp.TargetAppVersion = rel.TargetAppVersion;
             rp.Platform = plat;
             rp.Downloads = 0;
             db.InsertObject (rp);
         }
     }
 }
Beispiel #6
0
        public static Release PublishRelease(UserModel m, SourceTag source, bool activate)
        {
            Release rel = m.GetPublishedRelease (source);
            if (rel != null)
                m.DeleteRelease (rel);

            Project p = m.GetProject (source.ProjectId);
            rel = new Release ();
            rel.ProjectId = source.ProjectId;
            rel.Status = p.HasFlag (ProjectFlag.AllowDirectPublish) || activate ? ReleaseStatus.PendingPublish : ReleaseStatus.PendingReview;
            rel.DevStatus = source.DevStatus;
            rel.LastChangeTime = DateTime.Now;
            rel.Platforms = source.Platforms;
            rel.TargetAppVersion = source.TargetAppVersion;
            rel.Version = source.AddinVersion;
            rel.SourceTagId = source.Id;

            string mpack = rel.GetFilePath (rel.PlatformsList [0]);
            AddinInfo ainfo = UserModel.ReadAddinInfo (mpack);
            rel.AddinId = Mono.Addins.Addin.GetIdName (ainfo.Id);
            rel.AddinName = ainfo.Name;
            rel.AddinDescription = ainfo.Description;

            m.CreateRelease (rel);

            if (rel.Status == ReleaseStatus.PendingPublish)
                BuildService.UpdateRepositories (false);

            return rel;
        }
Beispiel #7
0
 internal static void GenerateInstallerFile(UserModel m, string packagesPath, Release rel, params string[] platforms)
 {
     string file = Path.ChangeExtension (packagesPath, m.CurrentApplication.AddinPackageExtension);
     using (StreamWriter sw = new StreamWriter (file)) {
         GenerateInstallerXml (sw, m, rel, platforms);
     }
 }
 static bool IsLatestRelease(UserModel m, List<AppRelease> allAppReleases, List<Release> releases, Release release, string platform, string targetAppVersion)
 {
     var compatReleases = GetCompatibleAppVersions (m, allAppReleases, targetAppVersion);
     return !releases.Any (r => r.ProjectId == release.ProjectId &&
         r.AddinId == release.AddinId &&
         (r.Status == ReleaseStatus.Published || r.Status == ReleaseStatus.PendingPublish) &&
         r.PlatformsList.Contains (platform) &&
         compatReleases.Contains (r.TargetAppVersion) &&
         (Mono.Addins.Addin.CompareVersions (r.Version, release.Version) < 0 || (r.Version == release.Version && r.LastChangeTime > release.LastChangeTime))
     );
 }
Beispiel #9
0
 public ReleaseInfo(Release rel)
 {
     Id = rel.Id;
     AddinId = rel.AddinId;
     Version = rel.Version;
     TargetAppVersion = rel.TargetAppVersion;
     Platforms = rel.PlatformsList;
     Status = rel.Status;
     DevStatus = rel.DevStatus;
 }
Beispiel #10
0
        public string GetDownloadSummary(Release rel)
        {
            int total = 0;
            List<string> platforms = new List<string> ();
            List<int> counts = new List<int> ();

            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) {
                            platforms.Add (plat);
                            counts.Add (ptotal);
                            total += ptotal;
                        }
                    }
                }
            }
            StringBuilder sb = new StringBuilder ();
            sb.Append (total);
            if (counts.Count > 0) {
                sb.Append (" (");
                for (int n=0; n<counts.Count; n++) {
                    if (n > 0)
                        sb.Append (", ");
                    sb.Append (counts [n]).Append (" ").Append (platforms[n]);
                }
                sb.Append (")");
            }
            return sb.ToString ();
        }
Beispiel #11
0
        public string GetDownloadSummary(Release rel)
        {
            int total = 0;
            List<string> platforms = new List<string> ();
            List<int> counts = new List<int> ();

            foreach (ReleasePackage rp in db.SelectObjectsWhere<ReleasePackage> ("ReleaseId={0}", rel.Id)) {
                if (rp.Downloads > 0) {
                    platforms.Add (rp.Platform);
                    counts.Add (rp.Downloads);
                    total += rp.Downloads;
                }
            }
            StringBuilder sb = new StringBuilder ();
            sb.Append (total);
            if (counts.Count > 0) {
                sb.Append (" (");
                for (int n=0; n<counts.Count; n++) {
                    if (n > 0)
                        sb.Append (", ");
                    sb.Append (counts [n]).Append (" ").Append (platforms[n]);
                }
                sb.Append (")");
            }
            return sb.ToString ();
        }
Beispiel #12
0
 public void DeleteRelease(Release rel)
 {
     ValidateProject (rel.ProjectId);
     bool requiresRebuild = rel.Status == ReleaseStatus.Published;
     db.DeleteObject (rel);
     if (requiresRebuild)
         BuildService.UpdateRepositories (false);
 }
Beispiel #13
0
        public void CreateRelease(Release rel)
        {
            db.InsertObject (rel);
            BindDownloadInfo (rel);
            Project p = GetProject (rel.ProjectId);

            if (rel.Status == ReleaseStatus.PendingReview) {
                string subject = "Add-in release review pending: " + rel.AddinId + " v" + rel.Version;
                StringBuilder msg = new StringBuilder ();
                msg.AppendLine ("The user '" + user.Name + "' has requested the publication of the release of the add-in " + rel.AddinId + " v" + rel.Version + ".");
                msg.AppendLine ();
                msg.AppendFormat ("[Go to {0} Project Page]({1}).\n", p.Name, GetProjectUrl (p.Id));
                msg.AppendFormat ("[Go to Review Page]({0}/Review).", GetBaseUrl ());
                SendMail (subject, msg.ToString (), p.Id, ProjectNotification.PublishReleaseRequest, ApplicationNotification.ProjectPublishReleaseRequest);
            }
        }
Beispiel #14
0
 public void BindDownloadInfo(Release rel)
 {
     foreach (string plat in rel.PlatformsList) {
         string fid = rel.GetReleasePackageId (plat);
         ReleasePackage rp = db.SelectObjectWhere<ReleasePackage> ("FileId={0}", fid);
         if (rp != null) {
             rp.ReleaseId = rel.Id;
             db.UpdateObject (rp);
         } else {
             rp = new ReleasePackage ();
             rp.ReleaseId = rel.Id;
             rp.FileId = fid;
             rp.TargetAppVersion = rel.TargetAppVersion;
             rp.Platform = plat;
             rp.Downloads = 0;
             db.InsertObject (rp);
         }
     }
 }