예제 #1
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);
         }
     }
 }