Esempio n. 1
0
 private IEnumerable <String> GetListIssueTypes(JiraTypeMap map)
 {
     foreach (var item in map.Mappings)
     {
         string issueType = item.Key;
         if (issueType.Any(Char.IsWhiteSpace) || JQL_RESERVED.Contains(issueType.ToLower()))
         {
             issueType = String.Format("\"{0}\"", issueType);
         }
         yield return(issueType);
     }
 }
Esempio n. 2
0
        public IEnumerable <Ticket> Tickets(IAvailableTicketTypes availableTypes)
        {
            var map = new JiraTypeMap(this, availableTypes, false);
            ConcurrentBag <Ticket> tickets = new ConcurrentBag <Ticket>();
            var issueTypes = GetListIssueTypes(map);

            Parallel.ForEach(jira.EnumerateIssues(jiraProject, issueTypes),
                             new ParallelOptions {
                MaxDegreeOfParallelism = Environment.ProcessorCount
            },
                             jiraKey =>
            {
                Console.WriteLine("Thread {0} comming into get ticket", Thread.CurrentThread.ManagedThreadId);

                var issueRef = new IssueRef
                {
                    id  = jiraKey.id,
                    key = jiraKey.key
                };
                var jiraTicket = jira.LoadIssue(issueRef);

                onDetailedProcessing(jiraTicket.key + " - " + jiraTicket.fields.summary);

                var ticket        = new Ticket();
                ticket.TicketType = map[jiraTicket.fields.issuetype.name];
                ticket.ID         = jiraTicket.key;
                ticket.Summary    = JiraString.StripNonPrintable(jiraTicket.fields.summary);

                var status = jiraTicket.fields.status.statusCategory.key.ToUpper();
                switch (status)
                {
                case "NEW":
                    ticket.TicketState = Ticket.State.Todo;
                    break;

                case "DONE":
                    ticket.TicketState = Ticket.State.Done;
                    break;

                case "INDETERMINATE":
                    ticket.TicketState = Ticket.State.InProgress;
                    break;

                default:
                    ticket.TicketState = Ticket.State.Unknown;
                    break;
                }

                ticket.Parent = jiraTicket.fields.parent.key;

                ticket.Description = JiraString.StripNonPrintable(jiraTicket.fields.description);
                if (PreferHtml &&
                    string.IsNullOrWhiteSpace(jiraTicket.renderedFields.description) == false)
                {
                    ticket.Description = JiraString.StripNonPrintable(jiraTicket.renderedFields.description);
                }
                ticket.CreatedOn    = jiraTicket.fields.created;
                ticket.LastModified = jiraTicket.fields.updated;

                ticket.CreatedBy = new User(jiraTicket.fields.reporter.displayName,
                                            jiraTicket.fields.reporter.name,
                                            jiraTicket.fields.reporter.emailAddress);
                ticket.AssignedTo = new User(jiraTicket.fields.assignee.displayName,
                                             jiraTicket.fields.assignee.name,
                                             jiraTicket.fields.assignee.emailAddress);

                ticket.Epic = jiraTicket.fields.customfield_10800;
                ticket.ExternalReference = jiraTicket.key;
                ticket.Url = jiraServer + "/browse/" + jiraTicket.key;
                int.TryParse(jiraTicket.fields.customfield_10004, out ticket.StoryPoints);

                foreach (var link in jiraTicket.fields.issuelinks)
                {
                    if (string.Compare(link.inwardIssue.key, jiraTicket.key) != 0)
                    {
                        ticket.Links.Add(new Link(link.inwardIssue.key, link.type.name));
                    }
                    if (string.Compare(link.outwardIssue.key, jiraTicket.key) != 0)
                    {
                        ticket.Links.Add(new Link(link.outwardIssue.key, link.type.name));
                    }
                }

                foreach (var jiraComment in jiraTicket.fields.comments)
                {
                    var author = new User(jiraComment.author.displayName,
                                          jiraComment.author.name, jiraComment.author.emailAddress);
                    var comment = new Comment(author, jiraComment.body, jiraComment.created);
                    if (jiraComment.updated.Date > jiraComment.created.Date)
                    {
                        comment.Updated = jiraComment.updated;
                    }
                    ticket.Comments.Add(comment);
                }

                foreach (var attachment in jiraTicket.fields.attachment)
                {
                    ticket.Attachments.Add(new Attachment(attachment.filename, attachment.content));
                }

                ticket.Priority = jiraTicket.fields.priority.name;
                ticket.Project  = jiraTicket.fields.project.name;
                if (jiraTicket.fields.resolutiondate != null)
                {
                    ticket.ClosedOn = jiraTicket.fields.resolutiondate;
                }

                tickets.Add(ticket);
            });
            return(tickets);
        }
Esempio n. 3
0
        public IEnumerable<Ticket> Tickets(IAvailableTicketTypes availableTypes)
        {
            var map = new JiraTypeMap(this, availableTypes);
            foreach (var jiraKey in jira.EnumerateIssues(jiraProject))
            {
                var issueRef = new IssueRef
                {
                    id = jiraKey.id,
                    key = jiraKey.key
                };
                var jiraTicket = jira.LoadIssue(issueRef);

                onDetailedProcessing(jiraTicket.key + " - " + jiraTicket.fields.summary);

                var ticket = new Ticket();
                ticket.TicketType = map[jiraTicket.fields.issuetype.name];
                ticket.ID = jiraTicket.key;
                ticket.Summary = JiraString.StripNonPrintable(jiraTicket.fields.summary);

                var status = jiraTicket.fields.status.statusCategory.key.ToUpper();
                switch (status)
                {
                    case "NEW":
                        ticket.TicketState = Ticket.State.Todo;
                        break;
                    case "DONE":
                        ticket.TicketState = Ticket.State.Done;
                        break;
                    case "INDETERMINATE":
                        ticket.TicketState = Ticket.State.InProgress;
                        break;
                    default:
                        ticket.TicketState = Ticket.State.Unknown;
                        break;
                }

                ticket.Parent = jiraTicket.fields.parent.key;

                ticket.Description = JiraString.StripNonPrintable(jiraTicket.fields.description);
                if (PreferHtml &&
                    string.IsNullOrWhiteSpace(jiraTicket.renderedFields.description) == false)
                {
                    ticket.Description = JiraString.StripNonPrintable(jiraTicket.renderedFields.description);
                }
                ticket.CreatedOn = jiraTicket.fields.created;
                ticket.LastModified = jiraTicket.fields.updated;

                ticket.CreatedBy = new User(jiraTicket.fields.reporter.displayName,
                    jiraTicket.fields.reporter.name,
                    jiraTicket.fields.reporter.emailAddress);
                ticket.AssignedTo = new User(jiraTicket.fields.assignee.displayName,
                    jiraTicket.fields.assignee.name,
                    jiraTicket.fields.assignee.emailAddress);

                ticket.Epic = jiraTicket.fields.customfield_10800;
                ticket.ExternalReference = jiraTicket.key;
                ticket.Url = jiraServer + "/browse/" + jiraTicket.key;
                int.TryParse(jiraTicket.fields.customfield_10004, out ticket.StoryPoints);

                foreach (var link in jiraTicket.fields.issuelinks)
                {
                    if (string.Compare(link.inwardIssue.key, jiraTicket.key) != 0)
                    {
                        ticket.Links.Add(new Link(link.inwardIssue.key, link.type.name));
                    }
                    if (string.Compare(link.outwardIssue.key, jiraTicket.key) != 0)
                    {
                        ticket.Links.Add(new Link(link.outwardIssue.key, link.type.name));
                    }
                }

                foreach (var jiraComment in jiraTicket.fields.comments)
                {
                    var author = new User(jiraComment.author.displayName,
                        jiraComment.author.name, jiraComment.author.emailAddress);
                    var comment = new Comment(author, jiraComment.body, jiraComment.created);
                    if (jiraComment.updated.Date > jiraComment.created.Date)
                    {
                        comment.Updated = jiraComment.updated;
                    }
                    ticket.Comments.Add(comment);
                }

                foreach (var attachment in jiraTicket.fields.attachment)
                {
                    ticket.Attachments.Add(new Attachment(attachment.filename, attachment.content));
                }

                ticket.Priority = jiraTicket.fields.priority.name;
                ticket.Project = jiraTicket.fields.project.name;
                if (jiraTicket.fields.resolutiondate != null)
                {
                    ticket.ClosedOn = jiraTicket.fields.resolutiondate;
                }

                yield return (ticket);
            }
        }