Exemplo n.º 1
0
        /// <summary>
        /// Creates a JIRA client with the given rest client implementation.
        /// </summary>
        /// <param name="jiraClient">Rest client to use.</param>
        /// <param name="credentials">Credentials to use.</param>
        /// <param name="cache">Cache to use.</param>
        public static Jira CreateRestClient(IJiraRestClient jiraClient, JiraCredentials credentials = null, JiraCache cache = null)
        {
            var services = new ServiceLocator();
            var jira     = new Jira(services, credentials, cache);

            ConfigureDefaultServices(services, jira, jiraClient);
            return(jira);
        }
Exemplo n.º 2
0
 public Jira(string url, string token, JiraCredentials credentials)
     : this(new JqlExpressionVisitor(),
            new JiraSoapServiceClientWrapper(url),
            new FileSystem(),
            credentials,
            token)
 {
 }
Exemplo n.º 3
0
        /// <summary>
        /// Create a client that connects with a JIRA server with specified dependencies.
        /// </summary>
        public Jira(ServiceLocator services, JiraCredentials credentials = null, JiraCache cache = null)
        {
            _services    = services;
            _credentials = credentials;
            _cache       = cache ?? new JiraCache();

            this.Debug = false;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Creates a JIRA client configured to use the SOAP API with specified access token.
 /// </summary>
 /// <param name="url">Url to the JIRA server.</param>
 /// <param name="token">JIRA access token to use.</param>
 /// <param name="credentials">Credentials used to re-generate token.</param>
 public static Jira CreateSoapClient(string url, string token, JiraCredentials credentials = null)
 {
     return(new Jira(new JqlExpressionVisitor(),
                     new JiraSoapServiceClientWrapper(url),
                     new FileSystem(),
                     credentials,
                     token));
 }
Exemplo n.º 5
0
 /// <summary>
 /// Creates a JIRA client with service dependency.
 /// </summary>
 public static Jira CreateRestClient(IJiraClient jiraClient, JiraCredentials credentials = null, JiraCache cache = null)
 {
     return(new Jira(
                new JqlExpressionVisitor(),
                jiraClient,
                new FileSystem(),
                credentials,
                null,
                cache));
 }
        /// <summary>
        /// Creates a new instance of IssueFields.
        /// </summary>
        /// <param name="remoteIssue">The remote issue that contains the fields.</param>
        /// <param name="jiraUrl">The JIRA server url.</param>
        /// <param name="credentials">The credentials used to access server resources.</param>
        public IssueFields(RemoteIssue remoteIssue, string jiraUrl = null, JiraCredentials credentials = null)
        {
            _map = remoteIssue.fieldsReadOnly ?? new Dictionary <string, JToken>();

            if (remoteIssue.remotePagedComments != null)
            {
                var pagedResults = remoteIssue.remotePagedComments;
                var comments     = pagedResults.remoteComments.Select(remoteComment => new Comment(remoteComment));
                this.Comments = new PagedQueryResult <Comment>(comments, pagedResults.startAt, pagedResults.maxResults, pagedResults.total);
            }

            if (remoteIssue.remotePagedWorklogs != null)
            {
                var pagedResults = remoteIssue.remotePagedWorklogs;
                var worklogs     = pagedResults.remoteWorklogs.Select(remoteWorklog => new Worklog(remoteWorklog));
                this.Worklogs = new PagedQueryResult <Worklog>(worklogs, pagedResults.startAt, pagedResults.maxResults, pagedResults.total);
            }

            if (remoteIssue.remoteAttachments != null)
            {
                this.Attachments = remoteIssue.remoteAttachments.Select(remoteAttachment => new Attachment(jiraUrl, new WebClientWrapper(credentials), remoteAttachment));
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Create a client that connects with a JIRA server with specified dependencies.
        /// </summary>
        public Jira(IJqlExpressionVisitor translator,
                    IJiraSoapClient jiraService,
                    IFileSystem fileSystem,
                    JiraCredentials credentials = null,
                    string accessToken          = null,
                    JiraCache cache             = null)
        {
            _provider    = new JiraQueryProvider(translator, this);
            _jiraService = jiraService;
            _fileSystem  = fileSystem;
            _token       = accessToken;
            _credentials = credentials;
            _restClient  = jiraService as IJiraRestClient;
            _cache       = cache ?? new JiraCache();

            this.MaxIssuesPerRequest = DEFAULT_MAX_ISSUES_PER_REQUEST;
            this.Debug = false;

            if (_restClient == null && !String.IsNullOrEmpty(jiraService.Url))
            {
                var options = new JiraRestClient.Options()
                {
                    Url = jiraService.Url,
                    RestClientSettings = new JiraRestClientSettings(),
                    GetCurrentJiraFunc = () => this
                };

                if (this._credentials != null)
                {
                    options.Username = _credentials.UserName;
                    options.Password = _credentials.Password;
                }

                this._restClient = new JiraRestClient(options);
            }
        }
 public WebClientWrapper(JiraCredentials credentials)
 {
     _credentials = credentials;
     _webClient   = new WebClient();
     _webClient.DownloadFileCompleted += _webClient_DownloadFileCompleted;
 }
Exemplo n.º 9
0
        static async Task <List <JiraIssue> > Integration(string username, string password, string project)
        {
            var services    = new ServiceLocator();
            var credentials = new Atlassian.Jira.JiraCredentials(username, password);
            var cache       = new JiraCache();

            var jira = new Jira(services, credentials, cache);

            jira.Issues.MaxIssuesPerRequest = 5000;

            /*
             * Status
             * 0 - Open
             * 1 - In Progress
             * 2 - Reopened
             * 3 - Resolved
             * 4 - Closed
             * 5 - Building
             * 6 - Build Broken
             * 7 - To Do
             * 8 - Done
             * 9 - Backlog
             * 10 - Selected for Development
             */

            IEnumerable <IssueStatus> listaStatus = await jira.Statuses.GetStatusesAsync();


            List <JiraIssue> list = new List <JiraIssue>();

            var issues   = jira.Issues;
            var projetos = jira.Projects;

            Console.WriteLine("===============================================");
            Console.WriteLine("Looking for Project Issues...");
            Console.WriteLine("===============================================");
            foreach (var item in issues.Queryable)
            {
                if (item.Project == project &&
                    (item.Status.Id == "0" || item.Status.Id == "1" || item.Status.Id == "2" || item.Status.Id == "7" || item.Status.Id == "9")
                    )
                {
                    DateTime?resolucao = item.ResolutionDate;
                    resolucao = resolucao == null?DateTime.Now.AddDays(1) : resolucao;

                    DateTime?criacao = item.Created == null?DateTime.Now.AddDays(1) : item.Created;

                    DateTime?duedate = item.DueDate == null?DateTime.Now.AddDays(1) : item.DueDate;

                    DateTime?updated = item.Updated == null?DateTime.Now.AddDays(1) : item.Updated;

                    Console.WriteLine("===============================================");
                    Console.WriteLine(item.Project);
                    Console.WriteLine(item.Summary);
                    Console.WriteLine(item.Priority);
                    Console.WriteLine(item.Assignee);
                    Console.WriteLine(item.Reporter);
                    Console.WriteLine(item.Status.Description);

                    list.Add(getIssue(item));
                }
            }
            Console.WriteLine("===============================================");

            return(list);
        }