private void filterBtn_Click(object sender, EventArgs e)
        {
            ReviewsLV.Items.Clear();


            // for real
            if (Scm == null)
            {
                // shouldn't happen but...
                return;
            }
            SwarmApi.Options searchOptions = new SwarmApi.Options();
            string           s             = reviewsCB.Text;

            if (string.IsNullOrEmpty(s) == false)
            {
                string ids = string.Format("[{0}]", s);
                searchOptions["ids[]"] = new JSONParser.JSONArray(ids);
            }
            s = participantsCB.Text;
            if (string.IsNullOrEmpty(s) == false)
            {
                string participants = string.Format("[{0}]", s);
                searchOptions["participants[]"] = new JSONParser.JSONArray(participants);
            }
            s = changesCB.Text;
            if (string.IsNullOrEmpty(s) == false)
            {
                string changes = string.Format("[{0}]", s);
                searchOptions["change[]"] = new JSONParser.JSONArray(changes);
            }
            searchOptions["max"] = new JSONParser.JSONNumericalField(Preferences.LocalSettings.GetInt("Number_specs", 100));
            try
            {
                SwarmServer sw = new SwarmServer(Scm.Connection.Swarm.SwarmUrl, Scm.Connection.User, Scm.Connection.Swarm.SwarmPassword);

                SwarmServer.ReviewList reviews = sw.GetReviews(searchOptions);

                foreach (SwarmServer.Review review in reviews)
                {
                    TreeListViewItem it = new TreeListViewItem(null, review.id.ToString(), review.description);
                    it.Tag = review;
                    ReviewsLV.Items.Add(it);
                }
            }
            catch (Exception)
            { }
        }
Beispiel #2
0
        public bool IsChangelistAttachedToReview(IDictionary <int, SwarmApi.SwarmServer.Review> changes)
        {
            if (SwarmEnabled == false)
            {
                return(false);
            }
            SwarmApi.SwarmServer.ReviewList l = null;

            bool       success   = false;
            List <int> changeIds = null;

            SwarmApi.SwarmServer sw = new SwarmApi.SwarmServer(SwarmUrl, user, SwarmPassword);

            int[] allChangeIds = changes.Keys.ToArray();

            int idx = 0;

            while (idx < allChangeIds.Length)
            {
                changeIds = new List <int>();
                int cnt = 0;
                while ((idx < allChangeIds.Length) && (cnt < 50))
                {
                    changeIds.Add(allChangeIds[idx++]);
                    cnt++;
                }
                SwarmApi.Options ops = new SwarmApi.Options();
                ops["change[]"] = new JSONParser.JSONArray(changeIds.ToArray());

                l = sw.GetReviews(ops);
                if ((l != null) && (l.Count > 0) && (l[0] != null) && (l[0] is SwarmApi.SwarmServer.Review))
                {
                    foreach (SwarmApi.SwarmServer.Review r in l)
                    {
                        foreach (int c in r.changes)
                        {
                            if (changes.ContainsKey(c))
                            {
                                changes[c] = r;
                            }
                        }
                    }
                    success = true;
                }
            }
            return(success);
        }
Beispiel #3
0
        public SwarmApi.SwarmServer.Review IsChangelistAttachedToReview(int change)
        {
            if (SwarmEnabled == false)
            {
                return(null);
            }
            SwarmApi.SwarmServer.ReviewList l = null;

            SwarmApi.SwarmServer sw = new SwarmApi.SwarmServer(SwarmUrl, user, SwarmPassword);

            SwarmApi.Options ops = new SwarmApi.Options();
            ops["change[]"] = new JSONParser.JSONArray(new int[] { change });

            l = sw.GetReviews(ops);
            if ((l != null) && (l.Count > 0) && (l[0] != null) && (l[0] is SwarmApi.SwarmServer.Review))
            {
                return((SwarmApi.SwarmServer.Review)l[0]);
            }
            return(null);
        }