예제 #1
0
        public SourceTag GetSourceTag(int sourceTagId)
        {
            SourceTag s = db.SelectObjectById <SourceTag> (sourceTagId);

            ValidateProject(s.ProjectId);
            return(s);
        }
예제 #2
0
        public Release PublishRelease(int sourceId)
        {
            SourceTag source = db.SelectObjectById <SourceTag> (sourceId);

            ValidateProject(source.ProjectId);
            return(BuildService.PublishRelease(this, source, IsAdmin));
        }
예제 #3
0
        public void SetSourceTagStatus(SourceTag stag, string status)
        {
            bool statusChanged = false;

            stag.Status = status;

            if (status != SourceTagStatus.Building && status != SourceTagStatus.Fetching && status != SourceTagStatus.Waiting)
            {
                // A final status
                statusChanged   = stag.LastStatus != status;
                stag.LastStatus = status;
            }

            stag.BuildDate = DateTime.Now;
            db.UpdateObject(stag);

            Project p = GetProject(stag.ProjectId);

            if (status == SourceTagStatus.BuildError && statusChanged)
            {
                string        subject = "Project build failed: " + p.Name + " (" + stag.Name + ")";
                StringBuilder msg     = new StringBuilder();
                msg.AppendLine("The project **" + p.Name + "** failed to build.");
                msg.AppendLine();
                msg.AppendLine("Tag/Branch: " + stag.Name);
                msg.AppendLine("Revision: " + stag.LastRevision);
                msg.AppendLine();
                msg.AppendFormat("[Go to Project Page]({0}).\n", GetProjectUrl(p.Id));
                msg.AppendFormat("[View Build Log]({0}).\n", GetBuildLogUrl(stag.Id));
                SendMail(subject, msg.ToString(), p.Id, ProjectNotification.BuildError, ApplicationNotification.ProjectBuildError);
            }
            else if (status == SourceTagStatus.Built)
            {
                string        subject = "Project built: " + p.Name + " (" + stag.Name + ")";
                StringBuilder msg     = new StringBuilder();
                msg.AppendLine("The project **" + p.Name + "** has been successfuly built.");
                msg.AppendLine();
                msg.AppendLine("Tag/Branch: " + stag.Name);
                msg.AppendLine("Revision: " + stag.LastRevision);
                msg.AppendLine("Add-in version: " + stag.AddinVersion);
                msg.AppendLine("App version: " + stag.TargetAppVersion);
                msg.AppendLine();
                msg.AppendFormat("[Go to Project Page]({0}).\n", GetProjectUrl(p.Id));
                msg.AppendFormat("[View Build Log]({0}).\n", GetBuildLogUrl(stag.Id));
                SendMail(subject, msg.ToString(), p.Id, ProjectNotification.BuildSuccess, ApplicationNotification.ProjectBuildSuccess);
            }
            else if (status == SourceTagStatus.FetchError && statusChanged)
            {
                string        subject = "Project fetch failed: " + p.Name + " (" + stag.Name + ")";
                StringBuilder msg     = new StringBuilder();
                msg.AppendLine("The source code of the project **" + p.Name + "** could not be fetched.");
                msg.AppendLine();
                msg.AppendLine("Tag/Branch: " + stag.Name);
                msg.AppendLine("Revision: " + stag.LastRevision);
                msg.AppendLine();
                msg.AppendFormat("[Go to Project Page]({0}).\n", GetProjectUrl(p.Id));
                SendMail(subject, msg.ToString(), p.Id, ProjectNotification.BuildError, ApplicationNotification.ProjectBuildError);
            }
        }
예제 #4
0
        public void CleanSources(int sourceTagId)
        {
            SourceTag st = GetSourceTag(sourceTagId);

            st.CleanPackages();
            st.Status = SourceTagStatus.Waiting;
            db.UpdateObject(st);
        }
예제 #5
0
 public void CreateSourceTag(SourceTag stag)
 {
     db.InsertObject (stag);
 }
예제 #6
0
        SourceTag UploadRelease(int projectId, HttpPostedFileBase file, byte[] fileData, string appVersion, string[] platforms)
        {
            if (platforms.Length == 0)
                throw new Exception ("No platform selected");

            VcsSource uploadSource = GetSources (projectId).Where (s => s.Type == "Upload").FirstOrDefault ();
            if (uploadSource == null) {
                uploadSource = new VcsSource ();
                uploadSource.ProjectId = projectId;
                uploadSource.Type = "Upload";
                db.InsertObject (uploadSource);
            }

            SourceTag st = new SourceTag ();
            st.IsUpload = true;
            st.ProjectId = projectId;
            st.SourceId = uploadSource.Id;
            st.BuildDate = DateTime.Now;
            st.Name = "Upload";
            st.Platforms = string.Join (" ", platforms);
            st.TargetAppVersion = appVersion;
            st.Status = SourceTagStatus.Ready;
            db.InsertObject (st);

            string filePath = null;

            if (!Directory.Exists (st.PackagesPath))
                Directory.CreateDirectory (st.PackagesPath);

            if (platforms.Length == CurrentApplication.PlatformsList.Length) {
                filePath = Path.Combine (st.PackagesPath, "All.mpack");
                if (file != null)
                    file.SaveAs (filePath);
                else
                    File.WriteAllBytes (filePath, fileData);
            }
            else {
                foreach (string plat in platforms) {
                    filePath = Path.Combine (st.PackagesPath, plat + ".mpack");
                    if (file != null)
                        file.SaveAs (filePath);
                    else
                        File.WriteAllBytes (filePath, fileData);
                }
            }
            AddinInfo mpack = ReadAddinInfo (filePath);
            st.AddinId = Addin.GetIdName (mpack.Id);
            st.AddinVersion = mpack.Version;

            db.UpdateObject (st);
            return st;
        }
예제 #7
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;
        }
예제 #8
0
 public void MergeTo(SourceTag st)
 {
     st.Name = Name;
     st.LastRevision = LastRevision;
     st.Url = Url;
     st.Status = Status;
 }
예제 #9
0
 public SourceTagInfo(SourceTag st)
 {
     Id = st.Id;
     Name = st.Name;
     LastRevision = st.LastRevision;
     Url = st.Url;
     Status = st.Status;
     DevStatus = st.DevStatus;
 }
예제 #10
0
        public void SetSourceTagStatus(SourceTag stag, string status)
        {
            stag.Status = status;
            stag.BuildDate = DateTime.Now;
            db.UpdateObject (stag);

            Project p = GetProject (stag.ProjectId);

            if (status == SourceTagStatus.BuildError) {
                string subject = "Project build failed: " + p.Name + " (" + stag.Name + ")";
                StringBuilder msg = new StringBuilder ();
                msg.AppendLine ("The project **" + p.Name + "** failed to build.");
                msg.AppendLine ();
                msg.AppendLine ("Tag/Branch: " + stag.Name);
                msg.AppendLine ("Revision: " + stag.LastRevision);
                msg.AppendLine ();
                msg.AppendFormat ("[Go to Project Page]({0}).\n", GetProjectUrl (p.Id));
                msg.AppendFormat ("[View Build Log]({0}).\n", GetBuildLogUrl (stag.Id));
                SendMail (subject, msg.ToString (), p.Id, ProjectNotification.BuildError, ApplicationNotification.ProjectBuildError);
            }
            else if (status == SourceTagStatus.Built) {
                string subject = "Project built: " + p.Name + " (" + stag.Name + ")";
                StringBuilder msg = new StringBuilder ();
                msg.AppendLine ("The project **" + p.Name + "** has been successfuly built.");
                msg.AppendLine ();
                msg.AppendLine ("Tag/Branch: " + stag.Name);
                msg.AppendLine ("Revision: " + stag.LastRevision);
                msg.AppendLine ("Add-in version: " + stag.AddinVersion);
                msg.AppendLine ("App version: " + stag.TargetAppVersion);
                msg.AppendLine ();
                msg.AppendFormat ("[Go to Project Page]({0}).\n", GetProjectUrl (p.Id));
                msg.AppendFormat ("[View Build Log]({0}).\n", GetBuildLogUrl (stag.Id));
                SendMail (subject, msg.ToString (), p.Id, ProjectNotification.BuildSuccess, ApplicationNotification.ProjectBuildSuccess);
            }
            else if (status == SourceTagStatus.FetchError) {
                string subject = "Project fetch failed: " + p.Name + " (" + stag.Name + ")";
                StringBuilder msg = new StringBuilder ();
                msg.AppendLine ("The source code of the project **" + p.Name + "** could not be fetched.");
                msg.AppendLine ();
                msg.AppendLine ("Tag/Branch: " + stag.Name);
                msg.AppendLine ("Revision: " + stag.LastRevision);
                msg.AppendLine ();
                msg.AppendFormat ("[Go to Project Page]({0}).\n", GetProjectUrl (p.Id));
                SendMail (subject, msg.ToString (), p.Id, ProjectNotification.BuildError, ApplicationNotification.ProjectBuildError);
            }
        }
예제 #11
0
 public void DeleteSourceTag(SourceTag stag)
 {
     ValidateProject(stag.ProjectId);
     stag.CleanPackages();
     db.DeleteObject(stag);
 }
예제 #12
0
 public void UpdateSourceTag(SourceTag stag)
 {
     db.UpdateObject(stag);
 }
예제 #13
0
 public void CreateSourceTag(SourceTag stag)
 {
     db.InsertObject(stag);
 }
예제 #14
0
        SourceTag UploadRelease(int projectId, HttpPostedFileBase file, byte[] fileData, string appVersion, string[] platforms)
        {
            if (platforms.Length == 0)
            {
                throw new Exception("No platform selected");
            }

            VcsSource uploadSource = GetSources(projectId).Where(s => s.Type == "Upload").FirstOrDefault();

            if (uploadSource == null)
            {
                uploadSource           = new VcsSource();
                uploadSource.ProjectId = projectId;
                uploadSource.Type      = "Upload";
                db.InsertObject(uploadSource);
            }

            SourceTag st = new SourceTag();

            st.IsUpload         = true;
            st.ProjectId        = projectId;
            st.SourceId         = uploadSource.Id;
            st.BuildDate        = DateTime.Now;
            st.Name             = "Upload";
            st.Platforms        = string.Join(" ", platforms);
            st.TargetAppVersion = appVersion;
            st.Status           = SourceTagStatus.Ready;
            db.InsertObject(st);

            string filePath = null;

            if (!Directory.Exists(st.PackagesPath))
            {
                Directory.CreateDirectory(st.PackagesPath);
            }

            if (platforms.Length == CurrentApplication.PlatformsList.Length)
            {
                filePath = Path.Combine(st.PackagesPath, "All.mpack");
                if (file != null)
                {
                    file.SaveAs(filePath);
                }
                else
                {
                    File.WriteAllBytes(filePath, fileData);
                }
            }
            else
            {
                foreach (string plat in platforms)
                {
                    filePath = Path.Combine(st.PackagesPath, plat + ".mpack");
                    if (file != null)
                    {
                        file.SaveAs(filePath);
                    }
                    else
                    {
                        File.WriteAllBytes(filePath, fileData);
                    }
                }
            }
            AddinInfo mpack = ReadAddinInfo(filePath);

            st.AddinId      = Addin.GetIdName(mpack.Id);
            st.AddinVersion = mpack.Version;

            db.UpdateObject(st);
            return(st);
        }
예제 #15
0
 public void DeleteSourceTag(SourceTag stag)
 {
     ValidateProject (stag.ProjectId);
     stag.CleanPackages ();
     db.DeleteObject (stag);
 }
예제 #16
0
 public void UpdateSourceTags(int appId, int sourceId, DateTime fetchTime, SourceTagInfo[] sourceTags)
 {
     BuildService.CheckClient ();
     using (UserModel m = UserModel.GetAdmin (appId)) {
         VcsSource s = m.GetSource (sourceId);
         s.LastFetchTime = fetchTime;
         m.UpdateSource (s, false);
         IEnumerable<SourceTag> currentTags = m.GetVcsSourceTags (sourceId);
         foreach (SourceTagInfo stInfo in sourceTags) {
             SourceTag st = currentTags.FirstOrDefault (t => t.Url == stInfo.Url);
             if (st != null) {
                 stInfo.MergeTo (st);
                 m.UpdateSourceTag (st);
             }
             else {
                 st = new SourceTag ();
                 st.SourceId = s.Id;
                 st.ProjectId = s.ProjectId;
                 stInfo.MergeTo (st);
                 m.CreateSourceTag (st);
             }
         }
         foreach (SourceTag st in currentTags) {
             if (!sourceTags.Any (t => t.Url == st.Url))
                 m.DeleteSourceTag (st);
         }
     }
 }
예제 #17
0
 public Release GetPublishedRelease(SourceTag st)
 {
     return db.SelectObjectWhere<Release> ("SourceTagId = {0}", st.Id);
 }
예제 #18
0
 public SourceTagAddinInfo(SourceTag stag)
 {
     Id = stag.Id;
     AddinVersion = stag.AddinVersion;
     AddinId = stag.AddinId;
     AppVersion = stag.TargetAppVersion;
     Platforms = stag.Platforms;
     DevStatus = stag.DevStatus;
 }
예제 #19
0
 public void UpdateSourceTag(SourceTag stag)
 {
     db.UpdateObject (stag);
 }
예제 #20
0
 public Release GetPublishedRelease(SourceTag st)
 {
     return(db.SelectObjectWhere <Release> ("SourceTagId = {0}", st.Id));
 }