/// <summary>
        /// Processes a record.
        /// </summary>
        protected override void ProcessRecord()
        {
            this.WriteVerbose("Starting a new server connection");
            var client = ClientHelpers.GenerateClient(this.Address, this);

            this.WriteVerbose("Retrieving server version");
            var version = client.GetServerVersion();

            if (!string.IsNullOrEmpty(this.UserName))
            {
                this.WriteVerbose("Logging in");
                var credentials = new List <NameValuePair>
                {
                    new NameValuePair(LoginRequest.UserNameCredential, this.UserName)
                };
                if (!string.IsNullOrEmpty(this.Password))
                {
                    credentials.Add(new NameValuePair(LoginRequest.PasswordCredential, this.Password));
                }

                client.Login(credentials);
            }

            var connection = new CCConnection(client, new Version(version));

            this.WriteObject(connection);
        }
Example #2
0
        /// <summary>
        /// Processes the project.
        /// </summary>
        /// <param name="action">The action to perform.</param>
        protected void ProcessProject(Action <CCProject> action)
        {
            if (this.Project != null)
            {
                action(this.Project);
            }
            else
            {
                var connection = this.Connection
                                 ?? new CCConnection(ClientHelpers.GenerateClient(this.Address, this), new Version());

                var project =
                    connection.GetProjects().FirstOrDefault(
                        p => p.Name.Equals(this.ProjectName, StringComparison.CurrentCultureIgnoreCase));
                if (project == null)
                {
                    var record = new ErrorRecord(
                        new Exception("Unable to find project '" + this.ProjectName + "'"),
                        "1",
                        ErrorCategory.ResourceUnavailable,
                        this);
                    this.WriteError(record);
                }
                else
                {
                    action(project);
                }
            }
        }
        /// <summary>
        /// Processes a record.
        /// </summary>
        protected override void ProcessRecord()
        {
            this.WriteVerbose("Getting project");
            var connection = this.Connection
                             ?? new CCConnection(ClientHelpers.GenerateClient(this.Address, this), new Version());

            var projects = connection.GetProjects();

            this.WriteObject(
                !string.IsNullOrEmpty(this.ProjectName) ? projects.Where(p => p.Name.IndexOf(this.ProjectName, StringComparison.CurrentCultureIgnoreCase) >= 0) : projects,
                true);
        }
        /// <summary>
        /// Processes a record.
        /// </summary>
        protected override void ProcessRecord()
        {
            this.WriteVerbose("Clearing queue");

            Action <CCQueue> action = q =>
            {
                var queue = q.Refresh();
                foreach (var request in queue.Requests)
                {
                    queue.CancelRequest(request);
                }

                this.WriteObject(queue.Refresh());
            };

            if (this.Queue != null)
            {
                action(this.Queue);
            }
            else
            {
                var connection = this.Connection
                                 ?? new CCConnection(ClientHelpers.GenerateClient(this.Address, this), new Version());

                var project = connection.GetQueues().FirstOrDefault(
                    p => p.Name.Equals(this.QueueName, StringComparison.CurrentCultureIgnoreCase));
                if (project == null)
                {
                    var record = new ErrorRecord(
                        new Exception("Unable to find queue '" + this.QueueName + "'"),
                        "1",
                        ErrorCategory.ResourceUnavailable,
                        this);
                    this.WriteError(record);
                }
                else
                {
                    action(project);
                }
            }
        }
Example #5
0
        /// <summary>
        /// Processes a record.
        /// </summary>
        protected override void ProcessRecord()
        {
            this.WriteVerbose("Getting log");

            if (this.Project != null)
            {
                this.WriteVerbose("Retrieving project log");
                this.WriteLog(this.Project.GetLog(), LogOutputMode.Values);
            }
            else if (this.Build != null)
            {
                this.WriteVerbose("Retrieving build log");
                this.WriteLog(this.Build.GetLog(), LogOutputMode.Lines);
            }
            else
            {
                this.WriteVerbose("Retrieving server log");
                var connection = this.Connection
                                 ?? new CCConnection(ClientHelpers.GenerateClient(this.Address, this), new Version());
                this.WriteLog(connection.GetLog(), LogOutputMode.Values);
            }
        }