예제 #1
0
파일: Swarm.cs 프로젝트: perforce/P4VS
        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);
        }
예제 #2
0
파일: Swarm.cs 프로젝트: perforce/P4VS
        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);
        }
예제 #3
0
파일: Swarm.cs 프로젝트: perforce/P4VS
        public void CheckForSwarm()
        {
            SwarmUrl = null;

            if ((repository == null) || (repository.Connection == null) ||
                repository.Connection.Status == ConnectionStatus.Disconnected || checkedForSwarm)
            {
                return;
            }
            P4.P4Command propertyCmd = repository.Connection.CreateCommand("property", true);
            P4.Options   opts        = new P4.Options();
            opts["-l"] = null;
            opts["-n"] = P4SwarmPropertyName;

            P4.P4CommandResult results = null;
            try
            {
                results = propertyCmd.Run(opts);
            }
            catch (P4Exception ex)
            {
                if (ex.ErrorCode == P4.P4ClientError.MsgServer_Login2Required)
                {
                    throw ex;
                }
                // error getting property, likely not logged in
                return;
            }
            catch
            {
                // error getting property, likely not logged in
                return;
            }
            //command ran, so if no property than not attached to swarm
            checkedForSwarm = true;

            if (results.TaggedOutput != null)
            {
                foreach (TaggedObject tag in results.TaggedOutput)
                {
                    if (tag.ContainsKey("name") && tag["name"].StartsWith(P4SwarmPropertyName) && tag.ContainsKey("value"))
                    {
                        SwarmUrl = tag["value"].TrimEnd('/');

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

                        if (certHandler == null)
                        {
                            certHandler = new ScmSSLCertificateHandler();
                            certHandler.Init(SwarmUrl);
                        }
                        SwarmVersion = sw.GetVersion;

                        if (SwarmVersion == null)
                        {
                            SwarmUrl = null;
                            return;
                        }

                        string msg = String.Format(Resources.P4ScmProvider_ConnectedToSwarmServer,
                                                   SwarmUrl, SwarmVersion.version);
                        P4VsOutputWindow.AppendMessage(msg);

                        FileLogger.LogMessage(3, "P4API.NET", msg);
                        return;
                    }
                }
            }
            return;
        }