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; }
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); } } }